/* Pea app shell: tokens, base type, and the permanent sidebar.
   Shared by every page on app.pea.dev. Page-specific styles stay in the page. */

/* Inter (the typeface the Cloudflare dashboard uses) and JetBrains Mono, served from
   app.pea.dev/fonts so no page calls Google. Latin, Latin Extended (Lithuanian etc.)
   and Cyrillic load only when a page needs them. SIL Open Font License. */
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/inter-cyrillic.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/inter-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/inter-latin.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/jetbrains-mono-cyrillic.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/jetbrains-mono-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(/fonts/jetbrains-mono-latin.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* Page to page without a flash: the new page cross-fades in while the sidebar
   stays put (Chrome and Edge; others just navigate). */
@view-transition { navigation: auto; }
.side { view-transition-name: pea-side; }
::view-transition-group(pea-side) { animation: none; }
::view-transition-old(pea-side) { display: none; }
::view-transition-new(pea-side) { animation: none; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 120ms; }

:root {
  --bg: #FAFAF5;
  --bg-soft: #F2F1EA;
  --bg-tint: #ECF3DC;
  --ink: #0F1F0F;
  --ink-soft: #2A3A2A;
  --ink-mute: #5A6A5A;
  --line: #E0DFD5;
  --line-soft: #EBEAE0;
  --pea: #A3D62F;
  --pea-deep: #6B9216;
  --forest: #1F3A1F;
  --err: #B91C1C;
  --err-bg: #FEF2F2;
  --err-line: #F5B5B5;
  --r: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --side-w: 236px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); }
[hidden] { display: none !important; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.011em;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
::selection { background: var(--pea); color: var(--ink); }
:focus-visible { outline: 2px solid var(--pea-deep); outline-offset: 2px; }

/* ---------- layout ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}
.shell-main {
  min-width: 0;
  padding: 40px 48px 72px;
}
.shell-inner { max-width: 920px; }

/* ---------- sidebar ---------- */
.side {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 18px 12px 12px;
  overflow-y: auto;
}
.side-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 8px 18px;
  font-weight: 600; font-size: 17px; letter-spacing: -0.03em;
}
.side-logo svg { width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0; }
.side-logo .dot { color: var(--pea-deep); }

.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-group + .side-group { margin-top: 18px; }
.side-label {
  padding: 0 10px 6px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-mute);
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  font-size: 14px; color: var(--ink-soft);
  border: 1px solid transparent;
  transition: background 120ms ease, color 120ms ease;
}
.side-link:hover { background: #fff; color: var(--ink); }
.side-link[aria-current="page"] {
  background: #fff; border-color: var(--line);
  color: var(--ink); font-weight: 600;
}
.side-link svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--ink-mute); }
.side-link[aria-current="page"] svg { color: var(--pea-deep); }
.side-link .ext { width: 12px; height: 12px; margin-left: auto; opacity: 0.55; }
.side-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A page's own navigation under its sidebar link (PeaShell.subnav) */
.side-sub {
  display: flex; flex-direction: column; gap: 1px;
  margin: 2px 0 8px 17px; padding-left: 9px;
  border-left: 1px solid var(--line);
}
.side-sub .sub-link {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border-radius: 6px; border: 1px solid transparent;
  background: none; font-size: 13.5px; line-height: 1.35; color: var(--ink-soft);
  text-align: left; cursor: pointer; min-width: 0;
}
.side-sub .sub-link > span:not(.sub-count):not(.sub-dot):not(.bookglyph):not(.tagdot) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-sub .sub-link:hover { background: #fff; color: var(--ink); }
.side-sub .sub-link[aria-current="true"] { background: #fff; border-color: var(--line); color: var(--ink); font-weight: 600; }
.side-sub .sub-link svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-mute); }
.side-sub .sub-count { margin-left: auto; font-size: 11.5px; color: var(--ink-mute); font-variant-numeric: tabular-nums; font-weight: 500; flex-shrink: 0; }
.side-sub .sub-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 3px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-mute);
}
.side-sub .sub-mini {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; border-radius: 5px; color: var(--ink-mute); cursor: pointer; padding: 0;
}
.side-sub .sub-mini:hover { background: #fff; color: var(--ink); }
.side-sub .sub-mini svg { width: 14px; height: 14px; }
.side-sub .sub-new {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 2px 0 6px; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.side-sub .sub-new:hover { background: var(--forest); border-color: var(--forest); }
.side-sub .sub-new svg { width: 15px; height: 15px; }
.side-sub .sub-row { position: relative; }
.side-sub .sub-edit {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; display: none; align-items: center; justify-content: center;
  border: none; border-radius: 5px; background: var(--bg-soft); color: var(--ink-mute); cursor: pointer; padding: 0;
}
.side-sub .sub-row:hover .sub-edit, .side-sub .sub-edit:focus-visible { display: inline-flex; }
.side-sub .sub-row:hover .sub-count { visibility: hidden; }
.side-sub .sub-edit svg { width: 13px; height: 13px; }
.side-sub .sub-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--line); }
.side-sub .sub-dot.blue { background: #2f63c4; }
.side-sub .sub-dot.green { background: var(--pea-deep); }
.side-sub .sub-dot.red { background: var(--err); }
.side-sub .sub-meta { margin-left: auto; font-size: 11.5px; color: var(--ink-mute); flex-shrink: 0; }
.side-sub .sub-foot { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.side-sub .sub-empty { padding: 4px 8px; font-size: 12.5px; color: var(--ink-mute); }

.side-spacer { flex: 1; min-height: 24px; }

.side-user {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; padding: 12px 6px 2px 8px;
  border-top: 1px solid var(--line);
}
.side-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--forest); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; text-transform: uppercase;
}
.side-who { min-width: 0; flex: 1; line-height: 1.3; }
.side-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-email { font-size: 12px; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-out {
  width: 30px; height: 30px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 7px;
  color: var(--ink-mute); cursor: pointer;
}
.side-out:hover { background: var(--err-bg); color: var(--err); }
.side-out svg { width: 16px; height: 16px; }

/* Narrow screens: the sidebar stays, as a rail of icons. */
@media (max-width: 780px) {
  :root { --side-w: 60px; }
  .side { padding: 14px 8px 10px; align-items: center; }
  .side-logo { padding: 2px 0 16px; }
  .side-logo span, .side-label, .side-text, .side-link .ext, .side-who, .side-sub { display: none !important; }
  .side-group { width: 100%; align-items: center; }
  .side-group + .side-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
  .side-link { width: 42px; height: 42px; padding: 0; justify-content: center; }
  .side-link svg { width: 19px; height: 19px; }
  .side-user { flex-direction: column; gap: 6px; padding: 10px 0 0; width: 100%; }
  .shell-main { padding: 24px 16px 56px; }
}

/* ---------- shared page bits ---------- */
.page-head { margin-bottom: 28px; }
.page-title { font-size: 30px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; }
.page-sub { margin-top: 6px; color: var(--ink-mute); }
@media (max-width: 780px) { .page-title { font-size: 25px; } }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
}
@media (max-width: 780px) { .card { padding: 18px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; font-size: 14px; font-weight: 500; white-space: nowrap;
  background: #fff; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; transition: background 140ms ease, border-color 140ms ease;
}
.btn:hover { background: var(--bg-soft); color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-ink { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.btn-ink:hover:not(:disabled) { background: var(--forest); border-color: var(--forest); color: #fff; }

/* ---------- loading ----------
   Covers the page area only, never the sidebar, and says "Loading…" only if
   it takes long enough to notice. */
.boot {
  position: fixed; inset: 0 0 0 var(--side-w); z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--ink-mute); font-size: 14px;
}
.boot:not(:has(a)) { animation: boot-late 1ms 450ms both; }
@keyframes boot-late { from { color: transparent; } to { color: var(--ink-mute); } }
.boot:not(:has(a)) .boot-spin { animation: boot-spin 0.7s linear infinite, boot-late-spin 1ms 450ms both; }
@keyframes boot-late-spin { from { opacity: 0; } to { opacity: 1; } }
.boot-spin {
  width: 16px; height: 16px;
  border: 2px solid var(--line); border-top-color: var(--ink);
  border-radius: 50%; animation: boot-spin 0.7s linear infinite;
}
.boot a { color: var(--pea-deep); margin-left: 6px; }
@keyframes boot-spin { to { transform: rotate(360deg); } }
body.ready .boot { display: none; }

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