/* ============================================================
   Pics Portal docs — typography + palette
   Serif: Source Serif 4 (headers)
   Sans:  Inter (body, UI)
   Mono:  JetBrains Mono (code)
   ============================================================ */

:root {
  /* Light palette — warm paper */
  --bg:           #faf9f6;
  --bg-elev:     #ffffff;
  --fg:          #1c1917;
  --fg-soft:     #44403c;
  --muted:       #78716c;
  --rule:        #e7e5e0;
  --rule-soft:   #efece6;
  --accent:      #4f46e5;
  --accent-soft: #eef2ff;

  --code-bg:     #f4f2ed;
  --code-fg:     #1c1917;

  --badge-bg:    #f4f2ed;
  --badge-fg:    #44403c;
  --badge-rule:  #d6d3cd;
  --badge-draft-bg:   #fef3c7;
  --badge-draft-fg:   #78350f;
  --badge-done-bg:    #dcfce7;
  --badge-done-fg:    #14532d;
  --badge-planned-bg: #e0e7ff;
  --badge-planned-fg: #3730a3;
  --badge-open-bg:    #fee2e2;
  --badge-open-fg:    #7f1d1d;

  --highlight-bg: rgba(250, 204, 21, 0.32);
  --highlight-bg-hover: rgba(250, 204, 21, 0.55);

  --font-serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style",
                "Apple Garamond", Baskerville, "Times New Roman", serif;
  --font-sans:  "Inter", ui-sans-serif, system-ui, -apple-system,
                "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo,
                Consolas, monospace;

  --measure: 38rem; /* body column */
  --gutter:  1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #18181b;
    --bg-elev:      #1f1f23;
    --fg:           #e7e5e4;
    --fg-soft:      #d4d4d4;
    --muted:        #a1a1aa;
    --rule:         #2a2a2e;
    --rule-soft:    #232327;
    --accent:       #818cf8;
    --accent-soft:  rgba(129, 140, 248, 0.12);

    --code-bg:      #1a1a1d;
    --code-fg:      #e7e5e4;

    --badge-bg:     #232327;
    --badge-fg:     #d4d4d4;
    --badge-rule:   #2f2f33;
    --badge-draft-bg:   rgba(251, 191, 36, 0.14);
    --badge-draft-fg:   #fbbf24;
    --badge-done-bg:    rgba(74, 222, 128, 0.14);
    --badge-done-fg:    #86efac;
    --badge-planned-bg: rgba(129, 140, 248, 0.16);
    --badge-planned-fg: #c7d2fe;
    --badge-open-bg:    rgba(248, 113, 113, 0.14);
    --badge-open-fg:    #fca5a5;

    --highlight-bg: rgba(250, 204, 21, 0.22);
    --highlight-bg-hover: rgba(250, 204, 21, 0.36);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  font-feature-settings: "ss01", "cv05";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Page frame
   ============================================================ */

.page {
  max-width: 62rem;
  margin: 0 auto;
  padding: 4rem 2rem 8rem;
}
@media (max-width: 720px) {
  .page { padding: 2.5rem 1.25rem 5rem; }
}

.page > * + * { /* keep things from hugging */ }

.crumbs {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 2.5rem;
}
.crumbs a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.crumbs a:hover {
  color: var(--accent);
  border-bottom-color: currentColor;
}
.crumbs .sep { opacity: 0.5; margin: 0 0.5em; }

.kicker {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.1rem, 1.6rem + 1.8vw, 2.8rem);
  line-height: 1.12;
  margin: 0 0 1rem;
  font-weight: 600;
}
h1 .badge { vertical-align: middle; margin-left: 0.5rem; }

h2 {
  font-size: 1.55rem;
  line-height: 1.25;
  margin: 3.5rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

h3 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 2.25rem 0 0.6rem;
}

h4 {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.5rem 0 0.4rem;
}

p, ul, ol {
  margin: 0 0 1.15rem;
  max-width: 38rem;
}
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.35rem; }
li > ul, li > ol { margin: 0.4rem 0 0.4rem; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color 120ms ease;
}
a:hover { border-bottom-color: currentColor; }

strong { font-weight: 600; color: var(--fg); }
em { font-style: italic; }

.lede {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  line-height: 1.55;
  font-style: italic;
  color: var(--fg-soft);
  max-width: 40rem;
  margin: 0 0 2.75rem;
}

/* ============================================================
   Code
   ============================================================ */

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.86em;
}
:not(pre) > code {
  background: var(--code-bg);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--rule-soft);
}
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.25rem 0 1.5rem;
  max-width: 100%;
}
pre code { background: transparent; padding: 0; border: 0; }

/* ============================================================
   Tables
   ============================================================ */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0 1.75rem;
  font-size: 0.95rem;
  font-feature-settings: "tnum";
}
th, td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
tbody tr:last-child td { border-bottom: 1px solid var(--rule); }

/* Status column — fit-content + alignment so badges sit naturally */
td:has(> .badge), th + th:nth-last-child(2) {
  white-space: nowrap;
}

/* ============================================================
   Definition list (kv)
   ============================================================ */

.kv {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.5rem 1.5rem;
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
}
.kv dt {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.18rem;
}
.kv dd { margin: 0; }
@media (max-width: 540px) {
  .kv { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .kv dt { padding-top: 0.5rem; }
}

/* ============================================================
   Block elements: callouts, blockquotes, figures
   ============================================================ */

blockquote {
  margin: 1.5rem 0;
  padding: 0.4rem 0 0.4rem 1.1rem;
  border-left: 2px solid var(--accent);
  color: var(--fg-soft);
  font-family: var(--font-serif);
  font-style: italic;
}

.callout {
  margin: 1.5rem 0;
  padding: 0.95rem 1.15rem 1rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-elev);
}
.callout.warn  { border-left-color: #d97706; }
.callout.note  { border-left-color: var(--muted); }
.callout h4 {
  margin: 0 0 0.4rem;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.72rem;
}
.callout > :last-child { margin-bottom: 0; }

figure {
  margin: 1.75rem 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elev);
}
figure img { display: block; max-width: 100%; height: auto; }
figcaption {
  padding: 0.55rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  line-height: 1.5;
}

details {
  margin: 1rem 0 1.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-elev);
}
details > summary {
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--fg-soft);
  padding: 0.3rem 0;
}
details[open] > summary { color: var(--fg); margin-bottom: 0.5rem; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--badge-bg);
  color: var(--badge-fg);
  border: 1px solid var(--badge-rule);
}
.badge.draft    { background: var(--badge-draft-bg);   color: var(--badge-draft-fg);   border-color: transparent; }
.badge.done     { background: var(--badge-done-bg);    color: var(--badge-done-fg);    border-color: transparent; }
.badge.planned  { background: var(--badge-planned-bg); color: var(--badge-planned-fg); border-color: transparent; }
.badge.open     { background: var(--badge-open-bg);    color: var(--badge-open-fg);    border-color: transparent; }

/* ============================================================
   Footer
   ============================================================ */

footer.docs-footer {
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.83rem;
}

/* ============================================================
   Annotations
   ============================================================ */

mark.annot {
  background: var(--highlight-bg);
  color: inherit;
  padding: 0.02em 0;
  border-radius: 2px;
  cursor: pointer;
  transition: background 120ms ease;
}
mark.annot:hover, mark.annot.active {
  background: var(--highlight-bg-hover);
}

.annot-launcher {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.annot-launcher .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.72rem;
  font-weight: 600;
  font-feature-settings: "tnum";
}
.annot-launcher[hidden] { display: none; }

.annot-toolbar {
  position: absolute;
  z-index: 50;
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transform: translate(-50%, calc(-100% - 0.5rem));
}
.annot-toolbar button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}
.annot-toolbar button:hover { background: var(--accent-soft); color: var(--accent); }
.annot-toolbar[hidden] { display: none; }

.annot-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100dvh;
  background: var(--bg-elev);
  border-left: 1px solid var(--rule);
  box-shadow: -8px 0 24px rgba(0,0,0,0.08);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  z-index: 60;
}
.annot-panel.open { transform: translateX(0); }
.annot-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--rule);
}
.annot-panel header h2 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin: 0;
  padding: 0;
  border: 0;
  line-height: 1.2;
}
.annot-panel header .meta {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.annot-panel header button.close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.annot-panel header button.close:hover { background: var(--rule-soft); color: var(--fg); }

.annot-panel .threads {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 1.25rem 2rem;
}
.annot-panel .empty {
  padding: 2rem 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  border: 1px dashed var(--rule);
  border-radius: 6px;
  margin: 1rem 1.25rem;
}

.annot-thread {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}
.annot-thread:last-child { border-bottom: 0; }
.annot-thread blockquote {
  margin: 0 0 0.6rem;
  padding: 0 0 0 0.75rem;
  font-size: 0.85rem;
  font-style: normal;
  font-family: var(--font-sans);
  color: var(--muted);
  border-left: 2px solid var(--rule);
  cursor: pointer;
}
.annot-thread blockquote:hover { color: var(--fg); border-left-color: var(--accent); }
.annot-thread .author {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}
.annot-thread .author .name { font-weight: 600; color: var(--fg); }
.annot-thread .author .when { color: var(--muted); font-size: 0.78rem; }
.annot-thread .body {
  font-size: 0.92rem;
  color: var(--fg-soft);
  white-space: pre-wrap;
  margin: 0.15rem 0 0;
}

.annot-form {
  border-top: 1px solid var(--rule);
  padding: 0.85rem 1.25rem 1rem;
  background: var(--bg-elev);
  display: none;
}
.annot-form[data-open="true"] { display: block; }
.annot-form blockquote.preview {
  margin: 0 0 0.6rem;
  padding: 0 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  font-family: var(--font-sans);
  font-style: normal;
}
.annot-form textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
}
.annot-form textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.annot-form .row {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.annot-form button {
  appearance: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.95rem;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.annot-form button.primary {
  background: var(--accent);
  color: white;
  border-color: transparent;
}
.annot-form button:hover:not(.primary) { background: var(--rule-soft); }

.identity-bar {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}
.identity-bar .who { color: var(--fg); font-weight: 500; }
.identity-bar[hidden] { display: none; }
