:root{
  --bg:#0b1020;
  --panel:#111735;
  --text:#eee;
  --muted:rgba(255,255,255,0.75);
  --accent:#4aa3ff;
}

html, body{
  margin:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
  overflow:hidden;
}

.layout{
  display:grid;
  grid-template-columns:360px 1fr;
  height:100vh;
}

.sidebar{
  padding:16px;
  background:var(--panel);
  overflow:auto;
  position: relative; /* allows the login overlay to cover ONLY the sidebar */
}

h1{
  font-size:18px;
  margin:0 0 10px;
}

label{
  font-size:12px;
  color:var(--muted);
  display:block;
  margin-top:10px;
}

input, select{
  width:100%;
  box-sizing:border-box;
  padding:9px 10px;
  margin-top:6px;
  border-radius:10px;
  border:0;
  background:rgba(255,255,255,0.08);
  color:var(--text);
  outline:none;
}

input:focus, select:focus{
  box-shadow:0 0 0 3px rgba(74,163,255,0.22);
}

.btnrow{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:12px;
}

.btnrow2{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  margin-top:10px;
}

button{
  padding:10px 12px;
  border-radius:10px;
  border:0;
  cursor:pointer;
  font-weight:800;
}

#addBtn{ background:var(--accent); color:#06101e; }
#resetBtn{ background:rgba(255,255,255,0.12); color:var(--text); }
#testBtn{ background:rgba(255,255,255,0.18); color:var(--text); }
#clearSaveBtn{ background:rgba(255,120,120,0.25); color:var(--text); }

.small{
  font-size:12px;
  color:var(--muted);
  margin-top:10px;
  line-height:1.35;
}

.pill{
  display:inline-block;
  padding:3px 8px;
  border-radius:999px;
  background:rgba(255,255,255,0.10);
  font-size:11px;
  color:var(--muted);
}

.entry{
  font-size:12px;
  background:rgba(255,255,255,0.07);
  padding:8px;
  border-radius:10px;
  margin-top:8px;
}

/* -------------------- List pager -------------------- */
.pager{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:10px;
  align-items:center;
}

.pagerBtn{
  padding:8px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(255,255,255,0.08);
  color:var(--text);
  cursor:pointer;
  font-weight:800;
}

.pagerBtn:disabled{
  opacity:0.45;
  cursor:not-allowed;
}

.pagerBtn.isActive{
  background:rgba(74,163,255,0.25);
  border-color:rgba(74,163,255,0.55);
}

.pagerEllipsis{
  color:var(--muted);
  padding:0 2px;
  user-select:none;
}


#stage{
  position:relative;
}

#canvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
}

.overlay{
  position:absolute;
  left:14px;
  top:14px;
  background:rgba(0,0,0,0.28);
  border:1px solid rgba(255,255,255,0.14);
  border-radius:12px;
  padding:10px 12px;
  font-size:12px;
  color:var(--muted);
  white-space:pre-wrap;
  pointer-events:none;
  max-width:680px;
  backdrop-filter: blur(8px);
}

.overlay b{
  color:var(--text);
}

code{
  font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
}


/* --- Utility spacing classes (replaces inline margin-top styles) --- */
.mt12{ margin-top:12px; }
.mt14{ margin-top:14px; }

/* --- Pills row spacing (replaces inline margin-left on pills) --- */
.pills{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:12px; /* this replaces <div style="margin-top:12px;"> */
}

/* --- Entry (branch list item) structure (replaces JS inline styles) --- */
.entryTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.entryName{
  font-weight:900;
}

.colorPill{
  /* per-item color comes from CSS var set inline: style="--pillColor:#aabbcc" */
  color: var(--pillColor, var(--muted));
  border:1px solid rgba(255,255,255,0.18);
  background:rgba(255,255,255,0.08);
}

.entryMeta{
  margin-top:6px;
  color:var(--muted);
}

/* -------------------- Mobile / small screens -------------------- */
/* Goal: give the canvas a big, usable viewport and move controls below it. */
@media (max-width: 900px){
  html, body{
    /* allow the page to scroll (sidebar below the canvas) */
    overflow:auto;
    height:auto;
  }

  .layout{
    grid-template-columns: 1fr;
    /* Canvas first, controls second */
    grid-template-rows: minmax(52dvh, 62dvh) auto;
    grid-template-areas:
      "stage"
      "sidebar";
    height: auto;
    min-height: 100dvh;
  }

  #stage{
    grid-area: stage;
    /* ensure the stage has a real height so ResizeObserver sizes the renderer correctly */
    min-height: 52dvh;
    height: 62dvh;
  }

  .sidebar{
    grid-area: sidebar;
    padding: 12px;
    /* prevent the sidebar from stealing space from the canvas */
    overflow: visible;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  /* Comfortable but not “giant” controls */
  input{
    padding: 8px 10px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  button{
    padding: 10px 12px;
    font-size: 14px;
  }

  .btnrow{
    grid-template-columns: 1fr;
  }

  .overlay{
    max-width: calc(100% - 28px);
  }
}

/* Even smaller phones */
@media (max-width: 420px){
  .sidebar{ padding: 10px; }
  h1{ font-size: 16px; }
  .small{ font-size: 11px; }
  .pill{ font-size: 10px; }
}

/* -------------------- Sidebar Lock (Login Gate) -------------------- */
.loginOverlay{
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(8px);
}

/* Make it obvious the panel is locked */
.sidebar.isLocked{
  /* subtle dim only; overlay does the real blocking */
  filter: saturate(0.9);
}

.loginCard{
  width: min(440px, 100%);
  border-radius: 16px;
  padding: 18px;
  background: rgba(20, 24, 44, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 18px 60px rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.92);
}

.loginTitle{
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.loginSub{
  margin-top: 6px;
  color: rgba(255,255,255,0.72);
  font-size: 13px;
}

.loginLabel{
  display:block;
  margin-top: 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.78);
}

.loginInput{
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  outline: none;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
}

.loginInput:focus{
  border-color: rgba(255,255,255,0.28);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

.loginRow{
  margin-top: 14px;
  display:flex;
  justify-content: flex-end;
  gap: 10px;
}

.loginBtn{
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
  font-weight: 800;
  cursor: pointer;
}

.loginBtn:hover{
  background: rgba(255,255,255,0.14);
}

.loginError{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 70, 70, 0.12);
  border: 1px solid rgba(255, 70, 70, 0.24);
  color: rgba(255,255,255,0.92);
  font-size: 12px;
}


/* -------- Sidebar toggle (safe) -------- */
.layout.sidebarHidden{
  grid-template-columns: 1fr; /* only the stage column */
}

.layout.sidebarHidden .sidebar{
  display: none;
}

.layout.sidebarHidden #stage{
  grid-column: 1 / -1;
}

/* Button is always visible */
.toggleSidebarBtn{
  position: fixed;
  top: 14px;
  left: 300px;
  z-index: 10000;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.45);
  color: white;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.toggleSidebarBtn:hover{
  background: rgba(0,0,0,0.65);
}

select{
  color: var(--text);        /* bright white text */
  background: rgba(255,255,255,0.08);
}

select option{
  color: #000;               /* readable inside dropdown list */
  background: #fff;
}
