/* The shell's stylesheet: a dark sidebar beside a light (or dark) page pane.
   It styles the markup the templates already render and adds none of its own,
   so a page without this file stays complete, only plain. */

:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #5b6b7b;
  --line: #dbe2e8;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #dff1ef;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --danger: #b42318;

  --side-bg: #13202b;
  --side-text: #d6dee6;
  --side-muted: #8798a8;
  --side-line: #243442;
  --side-hover: #1d2e3c;
  --side-active: #2dd4bf;
  --side-active-ink: #06302c;

  --radius: 8px;
  --side-width: 272px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e151b;
    --surface: #16212a;
    --text: #e5ebf0;
    --muted: #94a4b3;
    --line: #26343f;
    --accent: #2dd4bf;
    --accent-ink: #06302c;
    --accent-soft: #123530;
    --warn: #f0b457;
    --warn-soft: #33270f;
    --danger: #ff8a7a;
    --side-bg: #0a1117;
    --side-line: #1c2933;
    --side-hover: #15212a;
    color-scheme: dark;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
}

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- sidebar ---------------------------------------------------------- */

.shell-header {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px 14px;
  overflow-y: auto;
  background: var(--side-bg);
  color: var(--side-text);
}

.shell-header :focus-visible { outline-color: var(--side-active); }

.shell-home {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 4px 14px;
  padding: 4px 6px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: .01em;
  text-decoration: none;
}

.shell-home::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(255, 255, 255, .85) 46% 54%, transparent 54%) ,
    var(--side-active);
}

.shell-home:hover { background: var(--side-hover); }

.shell-nav {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shell-nav li { list-style: none; }

.nav-item { margin: 1px 0; }

.nav-group-key {
  display: block;
  margin: 14px 8px 4px;
  color: var(--side-muted);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--side-text);
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}

.nav-link:hover { background: var(--side-hover); color: #fff; }

.nav-link.active,
.nav-link[aria-current="page"] {
  background: var(--side-active);
  color: var(--side-active-ink);
  font-weight: 600;
}

.nav-branch > summary {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 2px;
  border-radius: 6px;
  cursor: pointer;
  list-style: none;
}

.nav-branch > summary::-webkit-details-marker { display: none; }

.nav-branch > summary::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background:
    linear-gradient(currentColor, currentColor) center / 9px 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2px 9px no-repeat;
  color: var(--side-muted);
  transition: background-size .15s ease, color .15s ease;
}

.nav-branch > summary:hover::before { color: #fff; }

.nav-branch[open] > summary::before {
  background-size: 9px 2px, 0 0;
  color: var(--side-active);
}

.nav-branch > summary > .nav-link { flex: 1 1 auto; min-width: 0; }

.nav-list {
  margin: 2px 0 6px 11px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--side-line);
  list-style: none;
}

/* ---- language switch and user ----------------------------------------- */

.shell-languages {
  display: flex;
  gap: 2px;
  margin: 10px 4px 0;
  padding: 3px;
  border: 1px solid var(--side-line);
  border-radius: 8px;
}

.language-form { flex: 1 1 0; margin: 0; }

.language {
  width: 100%;
  padding: 5px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--side-muted);
  font: inherit;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
}

.language:hover { color: #fff; }

.language.active {
  background: var(--side-hover);
  color: #fff;
  font-weight: 600;
  cursor: default;
}

.shell-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 4px 0;
  padding: 6px 8px;
  color: var(--side-muted);
  font-size: .85rem;
}

.shell-user::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--side-active);
}

/* ---- page pane --------------------------------------------------------- */

.shell-main {
  width: 100%;
  max-width: 980px;
  padding: 36px 40px 56px;
}

.page-title {
  margin: 0 0 22px;
  font-size: 1.65rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -.005em;
  text-wrap: balance;
}

.page-title::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 10px;
  border-radius: 2px;
  background: var(--accent);
}

.page-message { color: var(--muted); }

.stub,
.error {
  max-width: 640px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 30, 45, .04);
}

.stub p,
.error p { margin: 0; }

.stub-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .85rem;
  font-weight: 600;
}

.stub-notice::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.stub-round { margin-top: 12px !important; color: var(--muted); }

.stub-detail {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 14px;
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: .85rem;
}

.stub-detail dt { color: var(--muted); }
.stub-detail dd { margin: 0; overflow-wrap: anywhere; }

.error-label { color: var(--muted); font-size: .85rem; }
.error-id { margin-top: 4px !important; color: var(--danger); font: 600 1rem/1.4 var(--mono); }

/* ---- sign-in form ------------------------------------------------------ */

.login-form {
  display: grid;
  gap: 8px;
  max-width: 380px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 30, 45, .04);
}

.login-form label { font-size: .85rem; font-weight: 600; color: var(--muted); }

.login-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.login-form input:focus { border-color: var(--accent); }

.login-form button {
  margin-top: 6px;
  padding: 10px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s ease;
}

.login-form button:hover { filter: brightness(1.08); }

/* ---- narrow screens ----------------------------------------------------- */

.nav-toggle { display: none; }

@media (max-width: 860px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .shell-header {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 14px;
  }

  .shell-home { margin: 0; }
  .shell-nav { order: 5; flex: 1 0 100%; padding-top: 6px; }
  .shell-languages { order: 2; margin: 0 0 0 auto; width: 150px; }
  .shell-user { order: 3; margin: 0; padding: 0; }
  .shell-main { padding: 24px 18px 40px; }

  /* The toggle exists only when the script ran, so the menu is never hidden
     from a visitor whose script did not load. */
  .js .nav-toggle {
    order: 4;
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border: 1px solid var(--side-line);
    border-radius: 6px;
    background: transparent;
    color: var(--side-text);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
  }

  .js .shell-header:not([data-open]) .shell-nav { display: none; }
}

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