/* Site shell: sidebar on the left, content on the right. Colors live in the variables below. */
:root {
  --bg: #faf9f6;
  --panel: #f2f0ea;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e3dfd5;
  --accent: #d9531e;
  --accent-soft: rgba(217, 83, 30, .12);
  --shadow: 0 6px 20px rgba(31, 35, 40, .07);
  --sidebar-w: 264px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --panel: #1b1c21;
    --card: #1e2026;
    --ink: #e7e5df;
    --muted: #9b9992;
    --line: #2b2d34;
    --accent: #f08a5a;
    --accent-soft: rgba(240, 138, 90, .16);
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; top: -100px; left: 8px; z-index: 60; padding: 6px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.skip:focus { top: 8px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; }
.content { flex: 1 0 auto; width: 100%; max-width: 1080px; margin: 0 auto; padding: 44px 48px 72px; }

/* ---------- sidebar ---------- */
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 8px 20px; }
.site-name { font-size: 16px; font-weight: 600; letter-spacing: .01em; text-decoration: none; }
.nav { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 20px; }
.nav-link { display: block; padding: 6px 10px; border-radius: 7px; font-size: 14px; text-decoration: none; }
.nav-link:hover { background: var(--accent-soft); }
.nav-link[aria-current="page"] { background: var(--card); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-section { margin-top: 18px; }
.nav-section-head { display: flex; align-items: center; justify-content: space-between; padding-left: 4px; }
.nav-section-title { flex: 1; padding: 4px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); text-decoration: none; border-radius: 6px; }
.nav-section-title:hover { color: var(--ink); }
.nav-section-title[aria-current="page"] { color: var(--accent); }
.nav-pages .nav-link { padding-left: 22px; font-size: 13.5px; line-height: 1.35; }
.nav-link.page { display: flex; align-items: baseline; gap: 8px; }
.nav-date, .card-date { flex: none; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); }
.nav-text { min-width: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nav-empty { padding: 4px 10px 4px 22px; font-size: 13px; font-style: italic; color: var(--muted); }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.icon-btn:hover { background: var(--accent-soft); }
.chev { color: var(--muted); }
.chev svg { transition: transform .15s; }
.chev[aria-expanded="false"] svg { transform: rotate(-90deg); }

/* ---------- content: listings ---------- */
.site-intro { margin: 0 0 36px; max-width: 62ch; font-size: 17px; line-height: 1.6; color: var(--muted); }
.section + .section { margin-top: 52px; }
.section-head h1, .section-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-top: 18px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.card-title { display: flex; align-items: baseline; gap: 10px; font-weight: 600; font-size: 15.5px; line-height: 1.4; }
.card-desc { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-file { margin-top: auto; padding-top: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.empty { margin: 16px 0 0; color: var(--muted); font-style: italic; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); font-size: 13px; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- content: a page shown in an iframe ---------- */
.main.tool { overflow: hidden; }
.main.tool .content { display: flex; flex-direction: column; max-width: none; padding: 0; }
.main.tool #view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tool-bar { flex: none; display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tool-bar .crumb { font-size: 13.5px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tool-bar .crumb:hover { color: var(--accent); }
.tool-bar .tool-title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-frame { display: block; flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }

/* ---------- menu button: only while the sidebar is out of the way ---------- */
.menu-btn { display: none; }
.menu-btn.float { position: fixed; top: 12px; left: 12px; z-index: 20; width: 38px; height: 38px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.main.tool .menu-btn.float { display: none; } /* the tool bar carries its own menu button */
.backdrop { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); }

@media (min-width: 820px) {
  .sidebar-hidden .sidebar, .sidebar-hidden #hide-sidebar { display: none; }
  .sidebar-hidden .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar-hidden .menu-btn { display: inline-flex; }
}

/* ---------- mobile: the sidebar becomes a drawer ---------- */
@media (max-width: 819px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(84vw, 300px); box-shadow: 0 0 40px rgba(0, 0, 0, .18); transform: translateX(-102%); transition: transform .22s ease; }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .backdrop { display: block; }
  html:not(.sidebar-open) .menu-btn { display: inline-flex; }
  .content { padding: 68px 20px 56px; }
  .site-intro { margin-bottom: 28px; font-size: 16px; }
  .cards { grid-template-columns: 1fr; }
  .tool-bar { gap: 8px; }
  .tool-bar .tool-title, #hide-sidebar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
