:root{
  --bg: #0b0f16;
  --panel: #0f1624;
  --panel-2: #111b2d;
  --fg: #e6edf7;
  --muted: #a9b7d0;
  --border: rgba(255,255,255,.10);
  --accent: #6ea8fe;
  --accent-2: #9b7bff;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

@media (prefers-color-scheme: light){
  :root{
    --bg:#f6f8fc;
    --panel:#ffffff;
    --panel-2:#f6f8fc;
    --fg:#0b1220;
    --muted:#4e5b73;
    --border: rgba(12,18,32,.12);
    --accent:#2457ff;
    --accent-2:#6b3cff;
    --shadow: 0 10px 30px rgba(16,24,40,.12);
  }
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family:var(--sans);
}

a{color:inherit}

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

.sidebar{
  border-right:1px solid var(--border);
  background:linear-gradient(180deg, var(--panel), var(--panel-2));
  padding:18px 14px;
  overflow:auto;
}

.brand{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow: var(--shadow);
  background: rgba(255,255,255,.02);
}

.brand h1{
  margin:0;
  font-size:1.05rem;
  letter-spacing:.2px;
}

.brand .sub{
  display:block;
  margin-top:2px;
  color:var(--muted);
  font-size:.86rem;
}

.controls{margin-top:14px; display:grid; gap:10px;}

.search{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--fg);
  outline:none;
}

.search::placeholder{color: var(--muted); opacity: .78}

.nav{margin-top:12px; display:grid; gap:8px;}

.nav a{
  display:flex;
  flex-direction:column;
  gap:2px;
  text-decoration:none;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid transparent;
}

/* Sites list: one-line items (match Time API sidebar feel) */
.nav.nav-sites a{
  flex-direction:row;
  align-items:center;
  gap:10px;
}

.nav.nav-sites .item-title{
  flex:1;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.nav a:hover{border-color: var(--border); background: rgba(255,255,255,.03)}

.nav a.active{
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(110,168,254,.18), rgba(155,123,255,.10));
}

.item-title{font-weight:650}
.item-meta{color:var(--muted); font-size:.86rem}

.sections{
  margin-top:16px;
  padding-top:14px;
  border-top:1px solid var(--border);
}

.sections-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
  margin:0 6px 10px;
}

.sections-title{font-weight:650; font-size:.8rem; color:var(--muted); letter-spacing:.02em; text-transform:uppercase}
.sections-hint{color:var(--muted); font-size:.86rem}

.sections-nav{display:grid; gap:6px;}

.sections-nav a{
  display:block;
  text-decoration:none;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid transparent;
  color:inherit;
}

.sections-nav a:hover{border-color: var(--border); background: rgba(255,255,255,.03)}

.sections-nav a.active{
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(110,168,254,.14), rgba(155,123,255,.08));
}

.sections-nav .sec{
  display:flex;
  gap:10px;
  align-items:baseline;
}

.sections-nav .sec-title{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}

.sections-nav .lvl-h1{padding-left:10px}
.sections-nav .lvl-h2{padding-left:14px}
.sections-nav .lvl-h3{padding-left:22px}
.sections-nav .lvl-h4{padding-left:30px}

.main{
  display:grid;
  grid-template-rows: auto 1fr;
  height:100vh;
}

.topbar{
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background: rgba(255,255,255,.02);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.iconBtn{
  display:none;
  align-items:center;
  justify-content:center;
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--fg);
  font-size:1.2rem;
  line-height:1;
}

.iconBtn:active{transform: translateY(1px)}

.overlay{
  display:none;
}

.topbar .title{font-weight:650}
.topbar .hint{color:var(--muted); font-size:.92rem}

.viewer{
  width:100%;
  height:100%;
  border:0;
  background:white;
}

@media (max-width: 900px){
  .app{
    grid-template-columns: 1fr;
    height:100dvh;
  }

  .main{
    height:100dvh;
  }

  .iconBtn{
    display:inline-flex;
  }

  /* Off-canvas sidebar drawer */
  .sidebar{
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    width:min(88vw, 340px);
    border-right:1px solid var(--border);
    border-bottom:0;
    z-index:50;
    transform: translateX(-110%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow);
  }

  .overlay{
    position:fixed;
    inset:0;
    background: rgba(0,0,0,.45);
    z-index:40;
  }

  .app.nav-open .sidebar{
    transform: translateX(0);
  }

  .app.nav-open .overlay{
    display:block;
  }
}
