/* Gleanscape styles.
   Every colour, radius, space and font is a token in :root, so the look can be
   retuned in one place. Sections: tokens · base · layout · chat · WinnowWhip ·
   ContextPunnet · popovers · settings · Ramblefield · Orchard Drill · mobile. */

/* ================================================================ tokens */

:root {
  /* Warm, crafted, BerryPicker colours with less ornament. Light theme. */
  --bg: #f4ead6;
  --surface: #fffaf0;
  --surface-2: #efe3c9;
  --surface-3: #e6d6b5;
  --ink: #1f160e;
  --ink-soft: #5e4b36;
  --ink-faint: #8f7a60;
  --line: rgba(110, 78, 40, .18);
  --line-strong: rgba(110, 78, 40, .34);
  --accent: #8c2f3a;          /* berry */
  --accent-ink: #fff6ea;
  --accent-soft: rgba(140, 47, 58, .12);
  --gold: #b8862f;
  --gold-soft: rgba(184, 134, 47, .18);
  --leaf: #4f6f3e;
  --danger: #a33a2c;
  --pick-tint: rgba(184, 134, 47, .13);
  --pick-hover: rgba(184, 134, 47, .30);
  --pick-line: rgba(140, 47, 58, .55);
  --code-bg: #282c34;

  --viz-front: #b8323f;
  --viz-other: #2a78d6;

  --font-text: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-text: 17px;
  --fs-ui: 14px;
  --fs-small: 12.5px;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --r-pill: 999px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  --shadow: 0 1px 2px rgba(60, 35, 10, .08), 0 6px 18px rgba(60, 35, 10, .10);
  --shadow-lg: 0 18px 50px rgba(40, 20, 5, .28);

  --sidebar-w: 272px;
  --ww-w: 440px;
  --sheet-h: 46dvh;
  --edge-w: 56px;
  --topbar-h: 52px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #17100a;
  --surface: #21170e;
  --surface-2: #1b130c;
  --surface-3: #2e2115;
  --ink: #f0e2c4;
  --ink-soft: #c2ab88;
  --ink-faint: #8d7a5f;
  --line: rgba(217, 174, 82, .14);
  --line-strong: rgba(217, 174, 82, .30);
  --accent: #d9606d;
  --accent-ink: #1b0d08;
  --accent-soft: rgba(217, 96, 109, .16);
  --gold: #d9ae52;
  --gold-soft: rgba(217, 174, 82, .16);
  --leaf: #8fae78;
  --danger: #ff8f7d;
  --pick-tint: rgba(217, 174, 82, .10);
  --pick-hover: rgba(217, 174, 82, .26);
  --pick-line: rgba(217, 96, 109, .6);
  --viz-front: #e0505f;
  --viz-other: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #17100a;
    --surface: #21170e;
    --surface-2: #1b130c;
    --surface-3: #2e2115;
    --ink: #f0e2c4;
    --ink-soft: #c2ab88;
    --ink-faint: #8d7a5f;
    --line: rgba(217, 174, 82, .14);
    --line-strong: rgba(217, 174, 82, .30);
    --accent: #d9606d;
    --accent-ink: #1b0d08;
    --accent-soft: rgba(217, 96, 109, .16);
    --gold: #d9ae52;
    --gold-soft: rgba(217, 174, 82, .16);
    --leaf: #8fae78;
    --danger: #ff8f7d;
    --pick-tint: rgba(217, 174, 82, .10);
    --pick-hover: rgba(217, 174, 82, .26);
    --pick-line: rgba(217, 96, 109, .6);
    --viz-front: #e0505f;
    --viz-other: #3987e5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* ================================================================== base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-ui)/1.45 var(--font-ui);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  outline: none;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
hr { border: none; border-top: 1px solid var(--line); margin: var(--s1) 0; }
.grow { flex: 1; }
.muted { color: var(--ink-faint); }
.mono { font-family: var(--font-mono); font-size: 11.5px; }
.icon { display: block; flex: 0 0 auto; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--ink-soft);
  transition: background .12s, color .12s, transform .06s;
}
.icon-btn:hover { background: var(--gold-soft); color: var(--ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.small { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-btn.small .icon { width: 16px; height: 16px; }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

.primary, .ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r); padding: 7px 14px; font-weight: 600;
  border: 1px solid transparent;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .5; }
.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.ghost:hover { background: var(--gold-soft); color: var(--ink); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg button { border: none; background: transparent; padding: 5px 10px; color: var(--ink-soft); display: inline-flex; align-items: center; }
.seg button.on { background: var(--gold-soft); color: var(--ink); }

.wordmark {
  font-family: var(--font-text); font-size: 20px; letter-spacing: .02em;
  color: var(--accent); font-weight: 600;
}

.shimmer {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ================================================================= login */

.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.login-card {
  display: flex; flex-direction: column; gap: var(--s3); width: min(320px, 86vw);
  padding: var(--s6) var(--s5); background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow); text-align: center;
}
.login-card .wordmark { font-size: 28px; margin-bottom: var(--s2); }
.login-card input { padding: 11px 14px; font-size: 16px; text-align: center; }
.login-card .primary { justify-content: center; padding: 10px; }
.login-error { color: var(--danger); min-height: 1.2em; font-size: var(--fs-small); }

/* ================================================================ layout */

.shell { display: flex; height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto;
  display: flex; flex-direction: column;
  background: var(--surface-2); border-right: 1px solid var(--line);
}
body.sidebar-collapsed .sidebar { display: none; }
.sidebar.away { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 4px 16px; height: var(--topbar-h); }
.side-actions { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2) 10px; }
.side-search { position: relative; display: block; }
.side-search input { width: 100%; padding-left: 32px; background: var(--surface); }
.side-search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }
.conv-nav { flex: 1; overflow-y: auto; padding: 4px 6px 12px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); padding: 12px 10px 4px; }
.side-empty { color: var(--ink-faint); padding: 10px; font-size: var(--fs-small); }
.side-foot { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); }
.month-cost { font-size: var(--fs-small); color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.conv-row { display: flex; align-items: center; border-radius: var(--r-sm); }
.conv-row:hover, .conv-row.active { background: var(--surface-3); }
.conv-row.active .conv-open { color: var(--ink); font-weight: 600; }
.conv-open {
  flex: 1; min-width: 0; text-align: left; border: none; background: none;
  padding: 7px 10px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-more { opacity: 0; }
.conv-row:hover .conv-more, .conv-row.active .conv-more { opacity: 1; }
@media (pointer: coarse) { .conv-more { opacity: 1; } }
.assistant { margin-top: 3px; border-radius: var(--r); }
.assistant.current { background: var(--surface-3); }
.assistant-head { display: flex; align-items: center; border-radius: var(--r-sm); padding: 2px 2px 2px 0; }
.assistant-head:hover { background: var(--surface-3); }
.assistant-name {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  border: none; background: none; padding: 4px 6px; color: var(--ink); font-weight: 600; text-align: left;
}
.assistant-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-convs { padding: 0 0 4px 18px; }
.assistant.current .conv-row:hover, .assistant.current .conv-row.active { background: var(--surface); }
.conv-new { display: flex; align-items: center; gap: 6px; width: 100%; border: none; background: none; padding: 7px 10px; color: var(--accent); font-weight: 600; border-radius: var(--r-sm); text-align: left; }
.conv-new:hover { background: var(--surface); }
.assistant-convs .side-empty { padding: 4px 10px 6px; }

/* The icon tile: a colour square with an emoji on it. */
.avatar {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  width: var(--size, 28px); height: var(--size, 28px); border-radius: 30%;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tile) 78%, white), var(--tile));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .18);
  font-size: calc(var(--size, 28px) * .56); line-height: 1; user-select: none;
  font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}
.assistant-chip {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  border: 1px solid transparent; background: none; border-radius: var(--r); padding: 3px 8px 3px 3px;
  color: var(--ink); font-weight: 600;
}
.assistant-chip:hover { background: var(--surface-3); }
.assistant-chip[hidden] { display: none; }
.thread-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.thread-empty-name { font-weight: 700; color: var(--ink-soft); font-size: 18px; }

/* ----- assistant editor */
.asst-panel {
  width: min(880px, 100%); max-height: 100%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.asst-top { display: flex; align-items: center; gap: 14px; padding: 16px 16px 8px 20px; }
.asst-name { flex: 1; min-width: 0; font-size: 22px; font-weight: 700; border: none; background: none; padding: 4px 0; border-bottom: 2px solid var(--line); border-radius: 0; }
.asst-name:focus { outline: none; border-bottom-color: var(--accent); }
.asst-section { display: flex; align-items: center; gap: 10px; padding: 4px 20px 8px; flex-wrap: wrap; }
.asst-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.asst-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--bg); border-radius: var(--r-pill); padding: 3px 12px 3px 4px; color: var(--ink); }
.chip:hover { border-color: var(--gold); background: var(--gold-soft); }
.asst-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 8px 20px 12px; overflow: auto; min-height: 0; }
.asst-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.asst-search { width: 100%; }
.emoji-grid { height: 230px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); padding: 4px 8px 8px; }
.emoji-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); padding: 8px 2px 4px; position: sticky; top: -4px; background: var(--bg); }
.emoji-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; }
.emoji-btn { font-size: 22px; line-height: 1; padding: 6px 0; border: 2px solid transparent; background: none; border-radius: var(--r-sm); font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.emoji-btn:hover { background: var(--gold-soft); }
.emoji-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row .swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--tile); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); padding: 0; }
.color-row .swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.asst-col .field.row input[type="range"] { min-width: 0; width: 0; }
.asst-prompt { min-height: 170px; resize: vertical; }
.asst-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.rename-input { width: 100%; padding: 5px 8px; }

.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px; padding: 0 10px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
body:not(.sidebar-collapsed) #sideOpen { display: none; }
.conv-title {
  border: 1px solid transparent; background: transparent; font-weight: 600;
  width: min(280px, 30vw); padding: 6px 8px; text-overflow: ellipsis;
}
.conv-title:hover { border-color: var(--line); }
.model-picker {
  display: inline-flex; align-items: center; gap: 5px; max-width: 260px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-pill);
  padding: 5px 10px 5px 12px; color: var(--ink-soft); font-size: var(--fs-small);
}
.model-picker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker:hover { border-color: var(--gold); color: var(--ink); }
.modes { display: flex; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--surface-2); }
.mode-btn.on { background: var(--accent); color: var(--accent-ink); }
.mode-btn.on:hover { background: var(--accent); color: var(--accent-ink); }

.workspace { flex: 1; min-height: 0; display: flex; }

.edgebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--edge-w); z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: max(10px, env(safe-area-inset-top)) 0 10px;
  background: rgba(10, 8, 6, .72); backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.edgebar .icon-btn { color: rgba(255, 240, 220, .7); }
.edgebar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.edgebar .mode-btn.on { background: rgba(255, 240, 220, .9); color: #1a120b; }
.edge-back {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255, 240, 220, .35);
  background: rgba(255, 240, 220, .1); color: #fff; display: grid; place-items: center; margin-bottom: 10px;
}
.edge-back:hover { background: rgba(255, 240, 220, .24); }

/* ================================================================== chat */

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread {
  flex: 1; overflow-y: auto;
  padding: var(--s5) max(var(--s4), calc((100% - 780px) / 2)) var(--s4);
  scroll-behavior: auto;
}
.thread-empty {
  height: 100%; justify-content: center;
  font-family: var(--font-text); font-size: 22px; color: var(--ink-faint);
}
.msg { margin: 0 0 var(--s5); }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .msg-body {
  max-width: 85%; background: var(--surface-3); border-radius: var(--r-lg) var(--r-lg) var(--s1) var(--r-lg);
  padding: 10px 14px;
}
.user-text { white-space: pre-wrap; font-size: var(--fs-text); line-height: 1.55; font-family: var(--font-text); }
.msg-assistant .msg-body, .markdown {
  font-family: var(--font-text); font-size: var(--fs-text); line-height: 1.68; overflow-wrap: anywhere;
}
.msg-body > :first-child, .markdown > :first-child { margin-top: 0; }
.msg-body > :last-child, .markdown > :last-child { margin-bottom: 0; }
.msg-body p, .markdown p { margin: 0 0 .85em; }
.msg-body h1, .msg-body h2, .msg-body h3, .markdown h1, .markdown h2, .markdown h3 { line-height: 1.3; margin: 1.1em 0 .45em; }
.msg-body h1, .markdown h1 { font-size: 1.35em; }
.msg-body h2, .markdown h2 { font-size: 1.2em; }
.msg-body h3, .markdown h3 { font-size: 1.05em; }
.msg-body ul, .msg-body ol, .markdown ul, .markdown ol { padding-left: 1.4em; margin: 0 0 .85em; }
.msg-body li, .markdown li { margin: .2em 0; }
.msg-body blockquote, .markdown blockquote { margin: 0 0 .85em; padding-left: 1em; border-left: 3px solid var(--gold-soft); color: var(--ink-soft); }
.msg-body code, .markdown code { font-family: var(--font-mono); font-size: .86em; background: var(--surface-3); padding: .1em .35em; border-radius: 4px; }
.msg-body pre, .markdown pre { background: var(--code-bg); color: #e6e1d6; border-radius: var(--r); padding: 12px 14px; overflow-x: auto; margin: 0 0 .9em; }
.msg-body pre code, .markdown pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; color: inherit; }
.msg-body table, .markdown table { border-collapse: collapse; margin: 0 0 .9em; display: block; overflow-x: auto; }
.msg-body th, .msg-body td, .markdown th, .markdown td { border: 1px solid var(--line-strong); padding: 5px 9px; }
.msg-body a, .markdown a { color: var(--accent); }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-images img { max-width: min(100%, 420px); max-height: 420px; border-radius: var(--r); display: block; }
.msg-user .msg-images img { max-width: 180px; max-height: 180px; }
.msg-error-text { color: var(--danger); font-family: var(--font-ui); font-size: var(--fs-small); margin-top: 6px; }
.msg-tools { display: flex; align-items: center; gap: 2px; margin-top: 4px; opacity: .55; transition: opacity .12s; min-height: 28px; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (pointer: coarse) { .msg-tools { opacity: .9; } }
.branch-nav { display: inline-flex; align-items: center; gap: 0; margin-right: 4px; }
.branch-count { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; min-width: 26px; text-align: center; }
.msg-meta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--ink-faint); margin-left: 6px; font-variant-numeric: tabular-nums; }
.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: blink 1.1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }
.edit-area { width: 100%; font-family: var(--font-text); font-size: var(--fs-text); resize: vertical; }
.edit-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 4px; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); padding: 0; }

.composer {
  flex: 0 0 auto; margin: 0 max(var(--s3), calc((100% - 800px) / 2)) var(--s3);
  padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--gold); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea {
  flex: 1; border: none; box-shadow: none; resize: none; background: transparent;
  font-family: var(--font-text); font-size: var(--fs-text); line-height: 1.45; padding: 7px 6px; max-height: 40vh;
}
.send-btn {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
}
.send-btn.stop { background: var(--ink); color: var(--bg); }
.attach-list { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 4px; }
.attach-list:empty { display: none; }
.attach { position: relative; margin: 4px 0; }
.attach img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); display: block; }
.attach .icon-btn { position: absolute; top: -8px; right: -8px; background: var(--surface); border: 1px solid var(--line-strong); width: 22px; height: 22px; border-radius: 50%; }

/* ============================================================ WinnowWhip */

.winnowwhip {
  width: var(--ww-w); flex: 0 0 auto; min-width: 300px;
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line); position: relative;
}
.ww-divider { width: 6px; margin-right: -6px; cursor: col-resize; z-index: 5; position: relative; }
.ww-divider:hover, .ww-divider.dragging { background: var(--gold-soft); }
.ww-grab { display: none; }
.ww-head { display: flex; align-items: center; gap: 2px; padding: 8px 8px 4px 10px; height: var(--topbar-h); }
.punnet-picker {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 60%;
  border: none; background: none; font-weight: 700; font-size: 15px; color: var(--ink); padding: 6px 6px;
  border-radius: var(--r-sm);
}
.punnet-picker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.punnet-picker:hover { background: var(--gold-soft); }
.view-btn.on { color: var(--accent); background: var(--accent-soft); }
.ww-sources { display: flex; gap: 6px; padding: 2px 10px 8px; overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.src-chip {
  display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; max-width: 180px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-pill);
  padding: 3px 9px; font-size: var(--fs-small); color: var(--ink-soft);
}
span.src-chip { padding: 0 2px 0 0; }
.src-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.src-name { border: none; background: none; padding: 3px 2px 3px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.src-x { border: none; background: none; padding: 3px; color: var(--ink-faint); display: grid; place-items: center; border-radius: 50%; }
.src-x:hover { color: var(--danger); }
.src-add { border-radius: 50%; }
.ww-source {
  flex: 1 1 50%; min-height: 80px; overflow-y: auto; padding: 14px 18px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg);
}
.ww-punnet { flex: 1 1 50%; min-height: 0; display: flex; flex-direction: column; position: relative; }
.contextpunnet-editor {
  flex: 1; width: 100%; resize: none; border: none; border-radius: 0; box-shadow: none !important;
  background: var(--surface); padding: 14px 18px 30px;
  font-family: var(--font-text); font-size: 16.5px; line-height: 1.65;
}
.punnet-view { flex: 1; overflow-y: auto; padding: 0 0 20px; }
.view-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; position: sticky; top: 0;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 2;
}
.view-title { font-weight: 600; }
.view-empty { color: var(--ink-faint); padding: 18px; text-align: center; list-style: none; }

.ww-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 0;
  padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface-2);
}
.ww-status { display: inline-flex; align-items: center; gap: 7px; padding: 0 6px; }
.pick-count {
  min-width: 26px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  background: var(--gold-soft); color: var(--ink); font-weight: 700; font-size: 12px;
  display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
}
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); transition: background .2s; }
.save-dot[data-state="dirty"], .save-dot[data-state="saving"] { background: var(--gold); }
.save-dot[data-state="error"] { background: var(--danger); }
.harvest-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 4px;
  border: none; border-radius: var(--r); padding: 7px 12px 7px 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.harvest-btn:hover { filter: brightness(1.08); }
.harvest-btn.pulse { animation: pulse .5s var(--ease); }
@keyframes pulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.coin-btn.ready { color: var(--accent); background: var(--accent-soft); }

/* Pickable chunks: only styled while WinnowWhip is open. Five close tints of the
   page colour, cycled by chunk (data-t), so each chunk differs slightly from the
   one before it while the text keeps its full contrast. No underlines. */
:root {   /* light theme (the base) */
  --chunk-0: #ecdfbf; --chunk-1: #f0d9cb; --chunk-2: #e1e5c4; --chunk-3: #d3e2d8; --chunk-4: #e4d9e8;
  --chunk-hover: #f2cf94; --chunk-focus: #efc27a;
}
:root[data-theme="dark"] {
  --chunk-0: #3b2b1c; --chunk-1: #3a2724; --chunk-2: #31331f; --chunk-3: #263330; --chunk-4: #332a3a;
  --chunk-hover: #55391f; --chunk-focus: #5e4222;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --chunk-0: #3b2b1c; --chunk-1: #3a2724; --chunk-2: #31331f; --chunk-3: #263330; --chunk-4: #332a3a;
    --chunk-hover: #55391f; --chunk-focus: #5e4222;
  }
}
body.winnow-on [data-ww] .sent {
  cursor: pointer; border-radius: 4px; padding: 1px 0;
  background: var(--chunk-0);
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  transition: background-color .1s, opacity .1s;
  -webkit-touch-callout: none;
}
body.winnow-on [data-ww] .sent[data-t="1"] { background: var(--chunk-1); }
body.winnow-on [data-ww] .sent[data-t="2"] { background: var(--chunk-2); }
body.winnow-on [data-ww] .sent[data-t="3"] { background: var(--chunk-3); }
body.winnow-on [data-ww] .sent[data-t="4"] { background: var(--chunk-4); }
body.winnow-on [data-ww] .sent:hover, body.winnow-on [data-ww] .sent.hover { background: var(--chunk-hover); }
/* taken: faded back, marked by a gold bar rather than an underline */
body.winnow-on [data-ww] .sent.taken {
  opacity: .55; background: transparent; box-shadow: inset 3px 0 0 var(--gold);
  text-decoration: none;
}
body.winnow-on [data-ww] .sent.has-frag:not(.taken) { box-shadow: inset 0 0 0 1px var(--gold); }
body.winnow-on [data-ww] .sent.focus { background: var(--chunk-focus); box-shadow: inset 0 0 0 1px var(--gold); }
body.winnow-on [data-ww] pre.sent.focus { outline: 2px solid var(--gold); outline-offset: 2px; }
body.winnow-on [data-ww] pre.sent { cursor: pointer; }
body.winnow-on [data-ww] pre.sent.taken { opacity: .45; }
body.winnow-on [data-ww] .sent + .sent { margin-left: 1px; }

.ww-popup {
  position: fixed; z-index: 70; display: flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow);
}
.ww-plus {
  position: fixed; z-index: 70; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.undo-chip {
  position: fixed; z-index: 75; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sheet-h) + 14px);
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--r-pill); border: none; background: var(--ink); color: var(--bg); font-weight: 600;
  box-shadow: var(--shadow);
}
body:not(.winnow-on) .undo-chip { display: none; }

.ww-options { display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.swatches { display: flex; gap: 6px; }
.swatch { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); padding: 4px 6px; color: var(--ink-soft); }
.color-row .swatch.on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.opt-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.opt-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.opt-list { display: flex; flex-direction: column; gap: 14px; }

.add-source { display: flex; flex-direction: column; gap: 8px; width: min(360px, 86vw); }
.paste-area { width: 100%; font-family: var(--font-text); }
.add-source-row { display: flex; align-items: center; gap: 6px; }

/* ========================================================= ContextPunnet */

.pick-list { display: flex; flex-direction: column; }
.pick-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.pick-row.on { background: var(--accent-soft); }
.pick-row input { margin-top: 4px; accent-color: var(--accent); }
.pick-text { flex: 1; min-width: 0; font-family: var(--font-text); font-size: 15px; line-height: 1.45; }
.pick-text > div:first-child { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pick-meta { font-family: var(--font-ui); font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.learn-btn.on { color: var(--leaf); background: rgba(79, 111, 62, .15); }

.harvest-timeline { list-style: none; margin: 0; padding: 10px 12px 10px 26px; position: relative; }
.harvest-timeline::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: var(--line-strong); }
.harvest { position: relative; display: flex; gap: 10px; padding: 6px 0 12px; }
.harvest-dot { position: absolute; left: -14px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface); }
.harvest-main { flex: 1; min-width: 0; }
.harvest-row { display: flex; align-items: center; gap: 6px; }
.harvest-name { font-weight: 700; }
.harvest-date { color: var(--ink-faint); font-size: var(--fs-small); }
.harvest-note { width: 100%; resize: none; margin-top: 4px; font-size: 13.5px; padding: 5px 8px; background: var(--bg); border-color: var(--line); overflow: hidden; }
.harvest-doc { padding: 14px 18px; }
.diff { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; padding: 6px 0; }
.diff-line { display: flex; gap: 8px; padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-mark { flex: 0 0 auto; width: 1ch; color: var(--ink-faint); }
.diff-add { background: rgba(79, 111, 62, .16); }
.diff-add .diff-mark { color: var(--leaf); }
.diff-del { background: rgba(163, 58, 44, .13); text-decoration: line-through; text-decoration-color: rgba(163, 58, 44, .45); }
.diff-del .diff-mark { color: var(--danger); }
.diff-fold { color: var(--ink-faint); padding: 2px 30px; }

.coin-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line-strong); box-shadow: 0 -10px 30px rgba(40, 20, 5, .15);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 14px; animation: rise .18s var(--ease);
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }
.coin-form { display: flex; flex-direction: column; gap: 8px; }
.coin-passage { font-family: var(--font-text); color: var(--ink-soft); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.coin-proposals { display: flex; gap: 6px; flex-wrap: wrap; }
.coin-chip {
  min-width: 90px; height: 34px; border-radius: var(--r-pill); border: 1px solid var(--line-strong);
  background: var(--surface); padding: 0 14px; font-weight: 700; color: var(--accent); font-family: var(--font-text); font-size: 15px;
}
.coin-chip.on { background: var(--accent); color: var(--accent-ink); }
.coin-name { font-family: var(--font-text); font-size: 18px; font-weight: 700; }
.coin-def { resize: none; }
.coin-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* ============================================================== popovers */

.popover {
  position: fixed; z-index: 80; min-width: 200px; max-width: min(420px, 94vw);
  max-height: min(70vh, 560px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 6px;
  animation: pop .12s var(--ease);
}
.popover.wide { width: min(420px, 94vw); }
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.menu { display: flex; flex-direction: column; min-width: 200px; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  border: none; background: none; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink);
}
.menu-item:hover { background: var(--gold-soft); }
.menu-item.on { font-weight: 700; color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item select { flex: 1; }
.menu-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px 2px; }
.picker { display: flex; flex-direction: column; gap: 6px; width: min(380px, 90vw); }
.picker-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.model-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  border: none; background: none; text-align: left; padding: 7px 9px; border-radius: var(--r-sm); color: var(--ink);
}
.model-row:hover, .model-row.on { background: var(--gold-soft); }
.model-row-name { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-row-name .icon { color: var(--gold); }
.model-row-meta { font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }
.conv-settings { display: flex; flex-direction: column; gap: 12px; padding: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-small); color: var(--ink-soft); }
.field > span { display: inline-flex; align-items: center; gap: 5px; }
.field.row { flex-direction: row; align-items: center; gap: 8px; }
.field.row input[type="range"] { flex: 1; accent-color: var(--accent); }
.sys-prompt { font-family: var(--font-text); font-size: 14.5px; resize: vertical; }
.temp-value { width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(16px);
  z-index: 100; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: var(--r); background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s var(--ease); max-width: min(560px, 92vw);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-undo { border: none; background: none; color: var(--gold); font-weight: 700; padding: 0; }

/* ============================================================== settings */

.settings-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(20, 12, 5, .45);
  display: grid; place-items: center; padding: 3vh 3vw;
}
.settings-panel {
  width: min(1100px, 100%); height: min(820px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.settings-head { display: flex; align-items: center; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.settings-title { font-weight: 700; font-size: 16px; }
.settings-main { flex: 1; min-height: 0; display: flex; }
.settings-tabs { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; width: 190px; flex: 0 0 auto; border-right: 1px solid var(--line); background: var(--surface-2); }
.settings-tab { display: flex; align-items: center; gap: 8px; border: none; background: none; text-align: left; padding: 9px 12px; border-radius: var(--r-sm); color: var(--ink-soft); }
.settings-tab:hover { background: var(--gold-soft); }
.settings-tab.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.settings-body { flex: 1; min-width: 0; overflow: auto; padding: 18px 22px 30px; }
.settings-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin: 22px 0 8px; }

.provider-list { display: flex; flex-direction: column; gap: 12px; }
.provider-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--bg); }
.provider-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.provider-status { color: var(--ink-faint); }
.provider-status.ok { color: var(--leaf); }
.provider-fields { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 8px; }
.provider-add { display: grid; grid-template-columns: auto 1fr 1.4fr 1fr auto; gap: 8px; align-items: center; margin-top: 18px; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--surface-3); transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(16px); }

.models-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.models-bar input[type="search"] { width: 240px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.table-wrap { overflow-x: auto; }
.model-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.model-table th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 6px 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.model-table th.sortable { cursor: pointer; }
.model-table th.on { color: var(--accent); }
.model-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.model-table tr.dim td { opacity: .55; }
.model-table tr.pareto td:nth-child(2) { box-shadow: inset 3px 0 0 var(--viz-front); }
.model-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.model-name { min-width: 200px; }
.mods { display: flex; gap: 4px; color: var(--ink-faint); }
.star.on { color: var(--gold); }
.star.on svg { fill: currentColor; }
.quality-input { width: 64px; padding: 3px 6px; text-align: right; }

.scatter-wrap { position: relative; }
.scatter-plot svg { width: 100%; height: auto; max-height: 60vh; }
.scatter .grid { stroke: var(--line); stroke-width: 1; }
.scatter .tick { fill: var(--ink-faint); font-size: 11px; font-family: var(--font-ui); }
.scatter .axis-label { fill: var(--ink-soft); font-size: 12px; font-family: var(--font-ui); }
.scatter .frontier { fill: none; stroke: var(--viz-front); stroke-width: 2; stroke-linejoin: round; opacity: .7; }
.scatter .dot { stroke: var(--surface); stroke-width: 2; }
.scatter .dot.front { fill: var(--viz-front); }
.scatter .dot.other { fill: var(--viz-other); opacity: .75; }
.scatter .dot-label { fill: var(--ink); font-size: 11.5px; font-family: var(--font-ui); }
.scatter .hit { fill: transparent; cursor: pointer; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key::before { content: ""; width: 10px; height: 10px; border-radius: 50%; }
.legend .key.front::before { background: var(--viz-front); }
.legend .key.other::before { background: var(--viz-other); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; padding: 8px 10px; min-width: 160px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow); font-size: 12.5px; color: var(--ink-soft);
}
.chart-tip strong { color: var(--ink); }

.role-grid { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.role-row { display: grid; grid-template-columns: 220px 1fr; align-items: center; gap: 12px; }
.role-row select { width: 100%; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { padding: 14px 18px; border-radius: var(--r); background: var(--bg); border: 1px solid var(--line); min-width: 140px; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-faint); font-size: var(--fs-small); }
.cost-table { border-collapse: collapse; min-width: 360px; }
.cost-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); }
.cost-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.theme-row { display: flex; gap: 14px; }
.rf-settings { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.rf-set-row { display: grid; grid-template-columns: 110px auto 1fr auto 3.5ch; align-items: center; gap: 10px; }
.rf-set-row .swatches { grid-column: 2 / -1; }
.rf-set-row input[type="range"] { accent-color: var(--accent); }
.rf-set-label { font-weight: 600; }
.rf-end { font-size: 12px; color: var(--ink-faint); }
.rf-set-value { font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-soft); }
.rf-template { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; resize: vertical; }
.rf-settings .ghost { align-self: flex-start; }
.theme-swatch {
  width: 96px; height: 64px; border-radius: var(--r); border: 2px solid var(--line-strong);
  padding: 0; display: flex; overflow: hidden; background: none;
}
.theme-swatch span { flex: 1; }
.theme-swatch.light span { background: #f4ead6; }
.theme-swatch.light span + span { background: #8c2f3a; flex: .35; }
.theme-swatch.dark span { background: #17100a; }
.theme-swatch.dark span + span { background: #d9606d; flex: .35; }
.theme-swatch.auto span:first-child { background: #f4ead6; }
.theme-swatch.auto span + span { background: #17100a; }
.theme-swatch.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* =========================================================== Ramblefield */

.ramblefield {
  --rf-ink: rgba(232, 238, 245, .62);
  --rf-ink-strong: #eef3f8;
  --rf-chrome: rgba(255, 255, 255, .06);
  --rf-chrome-line: rgba(255, 255, 255, .10);
  --rf-glow: rgba(255, 196, 120, .16);
  --rf-fruit: #f2a33a;
  position: fixed; inset: 0 0 0 var(--edge-w); z-index: 30; overflow: hidden;
  background: #040506; color: var(--rf-ink); font-family: var(--font-ui);
}
.rf-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 30%, rgba(40, 60, 80, .22), transparent 70%),
    radial-gradient(ellipse 50% 40% at 75% 70%, rgba(70, 40, 30, .18), transparent 70%),
    radial-gradient(ellipse at 50% 45%, #10151c 0%, #07090c 55%, #020203 100%);
  animation: fog 30s ease-in-out infinite alternate;
}
@keyframes fog { to { background-position: 4% 3%, -3% -2%, 0 0; } }
.rf-stage { position: absolute; inset: 64px 28px 76px; perspective: 1400px; container-type: size; }
.rf-grid {
  --px: 0; --py: 0;
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .4s cubic-bezier(.2, .8, .2, 1), opacity .4s;
}
.rf-grid.rising { transform: translateZ(-700px) scale(.5); opacity: 0; transition: none; }
.rf-grid.from-above { transform: scale(1.9); opacity: 0; transition: none; }
/* The grid's own plane must not catch clicks meant for tiles set back in depth. */
.rf-grid { pointer-events: none; }
.rf-tile { pointer-events: auto; }
.rf-grid.flying .rf-tile, .rf-grid.sinking .rf-tile { pointer-events: none; }
.rf-grid.flying { z-index: 2; transition: transform .3s cubic-bezier(.55, 0, .25, 1); }
.rf-grid.sinking { transform: translateZ(-600px) scale(.5); opacity: 0; transition: transform .25s ease-in, opacity .25s; }
.rf-tile {
  /* Fill the screen, overlapping a little; never stretch past 1.6:1. */
  --w: calc(100cqw / var(--cols) * 1.06);
  --h: calc(100cqh / var(--rows) * 1.06);
  position: absolute; width: min(var(--w), var(--h) * 1.6); height: min(var(--h), var(--w) * 1.25);
  cursor: pointer; outline: none;
  transform: translate(-50%, -50%)
    translate3d(calc(var(--px) * var(--d) * -30px), calc(var(--py) * var(--d) * -30px), calc(var(--d) * 70px))
    rotate(var(--rot));
  transition: transform .3s ease-out, opacity .3s;
}
.rf-grid.flying .rf-tile:not(.chosen) {
  opacity: 0; transition: transform .3s ease-in, opacity .26s;
  transform: translate(-50%, -50%) translate3d(var(--fx, 0), var(--fy, 0), 260px);
}
.rf-tile-inner {
  position: relative; width: 100%; height: 100%; border-radius: 14px; overflow: hidden; background: #0c1015;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 24px 60px rgba(0, 0, 0, .7);
  animation: tile-drift 11s ease-in-out infinite; animation-delay: calc(var(--delay) * -6);
  transition: transform .18s ease-out, box-shadow .18s;
}
@keyframes tile-drift { 50% { transform: translate(4px, -6px); } }
.rf-tile.ready .rf-tile-inner { box-shadow: 0 0 0 1px rgba(255, 255, 255, .12), 0 24px 70px rgba(0, 0, 0, .75), 0 0 46px var(--rf-glow); }
.rf-tile:hover, .rf-tile:focus-visible { z-index: 5; }
.rf-tile:hover .rf-tile-inner, .rf-tile:focus-visible .rf-tile-inner {
  transform: scale(1.05); box-shadow: 0 0 0 2px rgba(255, 255, 255, .5), 0 30px 80px rgba(0, 0, 0, .8), 0 0 70px var(--rf-glow);
}
.rf-tile.failed .rf-tile-inner { opacity: .3; }
.rf-visual { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; object-fit: cover; pointer-events: none; }
.rf-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(110deg, #111821 25%, #27323f 50%, #111821 75%); background-size: 250% 100%;
  animation: shimmer 1.5s linear infinite;
}
.rf-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px; pointer-events: none;
  font: 650 clamp(11px, 1.15vw, 14px)/1.25 var(--font-ui); letter-spacing: .02em; color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .9); background: linear-gradient(transparent, rgba(0, 0, 0, .7));
}
.rf-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0; transition: opacity .15s; }
.rf-tile:hover .rf-actions, .rf-tile:focus-within .rf-actions, .rf-tile.kept .rf-actions { opacity: 1; }
@media (pointer: coarse) { .rf-actions { opacity: 1; } }
.rf-actions .icon-btn { width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px); }
.rf-actions .icon-btn:hover { background: rgba(0, 0, 0, .8); color: #fff; }
.rf-tile.kept .rf-keep { background: var(--rf-fruit); color: #1d1000; }

.rf-seed {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); z-index: 3;
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; width: min(560px, 86%);
}
.rf-seed-input {
  font: 300 clamp(24px, 3.4vw, 36px) var(--font-text); color: var(--rf-ink-strong);
  background: transparent; border: none; border-bottom: 1px solid var(--rf-chrome-line); border-radius: 0; padding: 10px 4px;
}
.rf-seed-input:focus { box-shadow: none; border-bottom-color: rgba(255, 220, 170, .6); }
.rf-go {
  width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--rf-chrome-line);
  background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center;
}
.rf-go:hover { background: rgba(255, 255, 255, .16); }
.rf-estimate { grid-column: 1 / -1; font-size: 13px; color: var(--rf-ink); min-height: 1.2em; font-variant-numeric: tabular-nums; }
.rf-back { position: absolute; top: 14px; left: 18px; z-index: 4; color: var(--rf-ink); }
.rf-back:hover, .rf-corner .icon-btn:hover { background: var(--rf-chrome); color: #fff; }
.rf-corner { position: absolute; top: 14px; right: 18px; z-index: 4; display: flex; align-items: center; gap: 4px; }
.rf-corner .icon-btn { color: var(--rf-ink); }
.rf-cost {
  display: inline-flex; gap: 8px; padding: 5px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--rf-chrome); border: 1px solid var(--rf-chrome-line); font-variant-numeric: tabular-nums;
}
.rf-cost:empty { display: none; }
.rf-cost span:first-child { color: var(--rf-ink-strong); }
.rf-cost-session { opacity: .6; }
.rf-crumbs {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; height: 60px;
  display: flex; align-items: center; gap: 6px; padding: 0 18px max(0px, env(safe-area-inset-bottom));
  overflow-x: auto; scrollbar-width: none;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.rf-crumb {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--rf-chrome-line); background: var(--rf-chrome); color: var(--rf-ink); font-size: 13px;
}
.rf-crumb + .rf-crumb::before { content: ""; }
.rf-crumb:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.rf-crumb.on { color: #10151c; background: var(--rf-ink-strong); border-color: transparent; font-weight: 650; }

/* ========================================================= Orchard Drill */

.orchard-drill {
  --od-ink: #3b2a1a;
  --od-wood: #c48a4f;
  --od-wood-dark: #8a5a3b;
  --od-paper: #fff6dc;
  --od-green: #5fb34a;
  --od-green-dark: #3d8c36;
  --od-red: #ef6a5b;
  --od-sky-top: #8fd3f4;
  --od-sky-bottom: #e6f7ff;
  --od-hill-far: #9fdc7c;
  --od-hill-near: #78c45a;
  --od-ground: #6db84f;
  --od-font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Trebuchet MS", system-ui, sans-serif;
  position: fixed; inset: 0 0 0 var(--edge-w); overflow: hidden; z-index: 30;
  color: var(--od-ink); font-family: var(--od-font);
  display: grid; grid-template-rows: auto 1fr 38%;
}
.orchard-drill[data-season="autumn"] { --od-sky-top: #f7c27e; --od-sky-bottom: #fff0d8; --od-hill-far: #e2b356; --od-hill-near: #cf9a3a; --od-ground: #b89a48; }
.orchard-drill[data-season="snow"] { --od-sky-top: #bfd3e6; --od-sky-bottom: #f3f8fc; --od-hill-far: #eef4f9; --od-hill-near: #e2ecf4; --od-ground: #f6f9fc; }
.orchard-drill.rain { --od-sky-top: #93a9ba; --od-sky-bottom: #d9e4ea; }

.od-scene { position: absolute; inset: 0; z-index: 0; }
.od-scene svg { width: 100%; height: 100%; display: block; }
.od-scene .sky-top { stop-color: var(--od-sky-top); }
.od-scene .sky-bottom { stop-color: var(--od-sky-bottom); }
.od-scene .hill.far { fill: var(--od-hill-far); }
.od-scene .hill.near { fill: var(--od-hill-near); }
.od-scene .ground { fill: var(--od-ground); }
.od-scene .od-fence rect { fill: #e9c999; stroke: #b98b52; stroke-width: 2; }
.od-sun circle { fill: #ffd84d; }
.od-sun .halo { fill: #fff6c4; opacity: .5; animation: halo 4s ease-in-out infinite; transform-origin: 1320px 150px; }
.orchard-drill.rain .od-sun, .orchard-drill[data-season="snow"] .od-sun { opacity: .25; }
.od-clouds ellipse { fill: #fff; opacity: .92; }
.cloud { animation: drift 40s linear infinite alternate; }
.cloud.c2 { animation-duration: 55s; }
@keyframes drift { to { transform: translateX(120px); } }
@keyframes halo { 50% { transform: scale(1.12); } }

.od-top { position: relative; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 14px 18px; }
.od-streak {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px 6px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .85); font-weight: 800; font-size: 18px; box-shadow: 0 3px 0 rgba(0, 0, 0, .08);
}
.od-streak.big { font-size: 26px; padding: 8px 18px 8px 12px; }
.od-tray-btn, .od-exit {
  position: relative; width: 48px; height: 48px; border-radius: 16px; border: 3px solid var(--od-wood-dark);
  background: var(--od-paper); color: var(--od-ink); display: grid; place-items: center;
  box-shadow: 0 4px 0 var(--od-wood-dark); transition: transform .08s;
}
.od-tray-btn:active, .od-exit:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--od-wood-dark); }
.od-badge {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--od-red); color: #fff; font-size: 13px; font-weight: 800; display: grid; place-items: center;
  border: 2px solid #fff;
}

.od-stage { position: relative; z-index: 3; display: grid; place-items: center; padding: 0 16px; min-height: 0; }
.od-sign {
  position: relative; padding: 26px 34px 30px; border-radius: 20px; text-align: center;
  background: repeating-linear-gradient(0deg, #d29a5c 0 34px, #c48a4f 34px 36px);
  border: 4px solid var(--od-wood-dark); box-shadow: 0 8px 0 var(--od-wood-dark), 0 16px 30px rgba(60, 30, 5, .25);
  color: #3b1f0b; animation: settle .4s cubic-bezier(.2, 1.4, .4, 1);
}
.od-sign::before, .od-sign::after {
  content: ""; position: absolute; bottom: -60px; width: 12px; height: 60px; background: var(--od-wood-dark); z-index: -1;
}
.od-sign::before { left: 40px; } .od-sign::after { right: 40px; }
.od-sign.quiet { padding: 20px 30px; }
.od-order { font-size: clamp(22px, 3.2vw, 34px); font-weight: 900; letter-spacing: .01em; text-shadow: 0 2px 0 rgba(255, 230, 180, .5); }
.od-start {
  margin-top: 18px; padding: 14px 46px; border-radius: 999px; border: 4px solid var(--od-green-dark);
  background: var(--od-green); color: #fff; font: 900 24px var(--od-font); letter-spacing: .02em;
  box-shadow: 0 6px 0 var(--od-green-dark); transition: transform .08s;
}
.od-start:hover { filter: brightness(1.06); }
.od-start:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--od-green-dark); }
@keyframes settle { from { transform: translateY(-30px) rotate(-3deg); opacity: 0; } }

.od-card {
  width: min(720px, 100%); max-height: 100%; overflow: auto;
  background: var(--od-paper); border: 5px solid var(--od-wood); border-radius: 26px;
  box-shadow: 0 8px 0 var(--od-wood-dark), 0 20px 40px rgba(60, 30, 5, .22);
  padding: 18px 22px 22px; animation: dealt .25s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes dealt { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.od-card.right { border-color: var(--od-green); box-shadow: 0 8px 0 var(--od-green-dark), 0 0 0 8px rgba(95, 179, 74, .25); }
.od-card.wrong { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.od-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.od-time { flex: 1; height: 10px; border-radius: 999px; background: #f0dfb8; position: relative; overflow: hidden; }
.od-time::after {
  content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--left, 1));
  background: linear-gradient(90deg, #ffb627, #5fb34a); border-radius: 999px; transition: transform .25s linear;
}
.od-count { font-weight: 800; font-variant-numeric: tabular-nums; color: #8a6a44; }
.od-card-body { display: grid; place-items: center; min-height: 110px; padding: 8px 4px 16px; }
.od-prompt { margin: 0; font-size: clamp(19px, 2.4vw, 25px); font-weight: 700; line-height: 1.4; text-align: center; }
.od-blank { display: inline-block; min-width: 4.5em; border-bottom: 4px dashed var(--od-wood); margin: 0 4px; }
.od-tile { border: none; background: #0d1014; border-radius: 16px; display: block; pointer-events: none; }
.od-tile.big { width: min(260px, 60vw); aspect-ratio: 1; box-shadow: 0 4px 0 var(--od-wood-dark); }
.od-tile.thumb { width: 72px; height: 72px; border-radius: 12px; flex: 0 0 auto; }
.od-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.od-choice {
  position: relative; min-height: 64px; padding: 12px 16px; border-radius: 18px; text-align: center;
  border: 3px solid #e2c48f; background: #fffdf5; color: var(--od-ink);
  font: 700 17px/1.3 var(--od-font); box-shadow: 0 5px 0 #d1aa6a; transition: transform .08s, background .12s;
}
.od-choice::before {
  content: attr(data-key); position: absolute; left: 10px; top: 8px; font-size: 12px; color: #c1a073; font-weight: 800;
}
.od-choice:hover { transform: translateY(-2px); }
.od-choice:active { transform: translateY(3px); box-shadow: 0 2px 0 #d1aa6a; }
.od-choice.right { background: var(--od-green); border-color: var(--od-green-dark); color: #fff; animation: pop .3s; }
.od-choice.wrong { background: var(--od-red); border-color: #c4483b; color: #fff; }
.od-choice.answer { border-color: var(--od-green); box-shadow: 0 5px 0 var(--od-green-dark), 0 0 0 4px rgba(95, 179, 74, .35); }
@keyframes pop { 50% { transform: scale(1.06); } }
.od-tile-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.od-tile-choice { position: relative; border-radius: 16px; border: 3px solid #e2c48f; overflow: hidden; aspect-ratio: 1; box-shadow: 0 5px 0 #d1aa6a; }
.od-tile-choice .od-tile { width: 100%; height: 100%; border-radius: 0; }
.od-tile-hit { position: absolute; inset: 0; border: none; background: transparent; }
.od-tile-choice.right { border-color: var(--od-green); }
.od-tile-choice.wrong { border-color: var(--od-red); }
.od-tile-choice.answer { border-color: var(--od-green); box-shadow: 0 0 0 4px rgba(95, 179, 74, .45); }
.od-type-form { display: flex; gap: 10px; }
.od-typed {
  flex: 1; font: 700 20px var(--od-font); padding: 12px 16px; border-radius: 16px;
  border: 3px solid #e2c48f; background: #fffdf5; color: var(--od-ink);
}
.od-go { width: 56px; border-radius: 16px; border: 3px solid var(--od-green-dark); background: var(--od-green); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 var(--od-green-dark); }
.od-why { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: #ffeedd; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; animation: dealt .2s; }
.od-right-answer { font-weight: 900; color: var(--od-green-dark); font-size: 18px; flex-basis: 100%; }
.od-explain { flex: 1; color: #6b4a2b; }
.od-next {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px; padding: 10px 18px; border-radius: 999px;
  border: 3px solid var(--od-wood-dark); background: var(--od-wood); color: #fff; font: 800 16px var(--od-font);
  box-shadow: 0 4px 0 var(--od-wood-dark);
}

.od-burst { position: fixed; z-index: 120; width: 0; height: 0; pointer-events: none; }
.od-burst span {
  position: absolute; width: 10px; height: 10px; border-radius: 50% 50% 50% 0; left: -5px; top: -5px;
  animation: fly .8s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }

.od-done { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.od-score { font-size: 30px; font-weight: 800; background: var(--od-paper); padding: 10px 26px; border-radius: 20px; border: 4px solid var(--od-wood); box-shadow: 0 6px 0 var(--od-wood-dark); }
.od-score span { font-size: 54px; color: var(--od-green-dark); }
.od-unlock {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px 12px 12px; border-radius: 20px;
  background: #fff; border: 4px solid #ffd166; box-shadow: 0 6px 0 #e0a92e, 0 0 40px rgba(255, 209, 102, .7);
  animation: reveal .7s cubic-bezier(.2, 1.5, .4, 1) both;
}
.od-unlock-art { width: 72px; height: 72px; }
.od-unlock-art svg { width: 100%; height: 100%; }
.od-unlock-label { font-size: 22px; font-weight: 900; }
@keyframes reveal { from { transform: scale(.3) rotate(-12deg); opacity: 0; } }

.od-field {
  position: relative; z-index: 2; grid-row: 3;
  background: repeating-linear-gradient(180deg, transparent 0 30px, rgba(40, 90, 30, .16) 30px 36px) 0 18% / 100% 82% no-repeat;
}
.orchard-drill[data-season="snow"] .od-field { background-image: repeating-linear-gradient(180deg, transparent 0 30px, rgba(150, 170, 190, .18) 30px 36px); }
.od-plots {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%); width: min(1100px, 94%);
  display: flex; flex-wrap: wrap-reverse; justify-content: center; align-items: flex-end; gap: 0 4px;
  max-height: 92%; overflow: hidden;
}
.od-plot { width: clamp(64px, 9vw, 124px); aspect-ratio: 100 / 120; margin: 0 -6px; }
.od-plot svg { width: 100%; height: 100%; transform-origin: 50% 92%; animation: sway 5s ease-in-out infinite; }
.od-plot:nth-child(2n) svg { animation-delay: -1.3s; }
.od-plot:nth-child(3n) svg { animation-delay: -2.6s; }
.od-plot svg.ghost { opacity: .35; }
.od-plot .sparkle { animation: twinkle 1.6s ease-in-out infinite; transform-origin: 78px 37px; }
@keyframes sway { 50% { transform: rotate(1.6deg); } }
@keyframes twinkle { 50% { transform: scale(.4); opacity: .4; } }
.od-extra { position: absolute; pointer-events: none; }
.od-extra svg { width: 100%; height: 100%; display: block; }
.od-extra.scarecrow { left: 3%; bottom: 10%; width: clamp(60px, 7vw, 100px); aspect-ratio: 80 / 110; }
.od-extra.beehive { right: 3%; bottom: 8%; width: clamp(50px, 6vw, 84px); aspect-ratio: 80 / 90; }
.od-extra.beehive .bee { animation: buzz 1.8s ease-in-out infinite; }
.od-extra.lanterns { left: 4%; width: 92%; top: -8%; aspect-ratio: 800 / 70; }
.od-extra.lanterns .lamp { animation: glow 2.4s ease-in-out infinite; }
.od-extra.bluebird { right: 16%; top: 4%; width: 54px; aspect-ratio: 60 / 50; animation: bob 2.2s ease-in-out infinite; }
.od-extra.hedgehog { bottom: 2%; width: 74px; aspect-ratio: 90 / 56; animation: amble 38s linear infinite; }
.od-extra.fox { right: -10px; bottom: 30%; width: 90px; aspect-ratio: 100 / 80; animation: peek 9s ease-in-out infinite; }
@keyframes buzz { 50% { transform: translate(-6px, -4px); } }
@keyframes glow { 50% { filter: brightness(1.35); } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes amble { from { left: -80px; } to { left: 100%; } }
@keyframes peek { 0%, 60%, 100% { transform: translateX(70px); } 70%, 90% { transform: translateX(0); } }
.od-weather { position: fixed; inset: 0 0 0 var(--edge-w); pointer-events: none; z-index: 4; }
.od-weather.rain {
  background-image: repeating-linear-gradient(105deg, transparent 0 22px, rgba(74, 144, 217, .35) 22px 23px);
  background-size: 120px 120px; animation: rainfall .5s linear infinite; opacity: .6;
}
@keyframes rainfall { to { background-position: -30px 120px; } }
.od-weather.snow {
  background-image: radial-gradient(circle, #fff 1.6px, transparent 2.2px), radial-gradient(circle, #fff 1.2px, transparent 1.8px);
  background-size: 90px 90px, 60px 60px; background-position: 0 0, 30px 20px; animation: snowfall 8s linear infinite;
}
@keyframes snowfall { to { background-position: 40px 360px, 70px 260px; } }

.od-tray-wrap {
  width: min(760px, 100%); max-height: 100%; display: flex; flex-direction: column;
  background: var(--od-paper); border: 5px solid var(--od-wood); border-radius: 24px; box-shadow: 0 8px 0 var(--od-wood-dark);
  overflow: hidden;
}
.od-tray-head { display: flex; align-items: center; padding: 12px 14px 8px 18px; }
.od-tray-title { display: inline-flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 900; }
.od-tray { overflow-y: auto; padding: 4px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.od-empty { padding: 18px; text-align: center; color: #8a6a44; font-weight: 700; }
.od-packet {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: #fffdf5; border: 3px dashed #e2c48f; transition: transform .35s, opacity .35s;
}
.od-packet.planted { transform: translateY(40px) scale(.6); opacity: 0; }
.od-packet-origin { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e9f6df; color: var(--od-green-dark); flex: 0 0 auto; }
.od-packet-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.od-packet-fields textarea, .od-packet-fields input {
  font: 600 15px var(--od-font); color: var(--od-ink); background: #fff; border: 2px solid #eedcb6; border-radius: 10px; resize: vertical;
}
.od-packet-fields input { font-weight: 800; }
.od-packet-actions { display: flex; flex-direction: column; gap: 6px; }
.od-approve, .od-discard { width: 44px; height: 44px; border-radius: 14px; }
.od-approve { background: var(--od-green); color: #fff; box-shadow: 0 3px 0 var(--od-green-dark); }
.od-approve:hover { background: var(--od-green); color: #fff; filter: brightness(1.08); }
.od-discard { background: #f6e3cf; color: #8a5a3b; }

/* ================================================================ mobile */

@media (max-width: 820px) {
  .asst-body { grid-template-columns: 1fr; }
  .asst-chip-name, .assistant-chip .chip-name { display: none; }
  .asst-panel { border-radius: 0; height: 100%; }
  .asst-overlay { padding: 0; }
  :root { --fs-text: 16.5px; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .22s var(--ease);
    padding-top: env(safe-area-inset-top);
  }
  body.sidebar-open .sidebar { box-shadow: var(--shadow-lg); }
  body.sidebar-collapsed .sidebar { display: flex; }
  body.sidebar-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(20, 12, 5, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  body:not(.sidebar-collapsed) #sideOpen { display: inline-flex; }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); gap: 2px; }
  .conv-title { display: none; }
  .model-picker { max-width: 34vw; }
  #convSettings { display: none; }
  .modes { padding: 2px; }
  .modes .icon-btn { width: 34px; height: 34px; }

  /* WinnowWhip becomes a bottom sheet over the chat. */
  .winnowwhip {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; width: auto; min-width: 0;
    height: var(--sheet-h); border-left: none; border-top: 1px solid var(--line-strong);
    border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -12px 34px rgba(40, 20, 5, .22);
  }
  .ww-grab { display: block; height: 18px; flex: 0 0 auto; cursor: ns-resize; touch-action: none; position: relative; }
  .ww-grab::after { content: ""; position: absolute; left: 50%; top: 7px; width: 42px; height: 4px; margin-left: -21px; border-radius: 2px; background: var(--line-strong); }
  .ww-head { height: 40px; padding-top: 0; }
  body.winnow-on .thread { padding-bottom: calc(var(--sheet-h) + 12px); }
  body.winnow-on .composer { display: none; }
  .winnowwhip.with-source .ww-source { flex-basis: 45%; }
  .ww-bar .icon-btn { width: 34px; height: 34px; }
  .harvest-btn span { display: none; }

  .edgebar {
    top: 0; bottom: auto; right: 0; width: auto; height: calc(48px + env(safe-area-inset-top));
    flex-direction: row; justify-content: center; padding: env(safe-area-inset-top) 8px 0;
    border-right: none; border-bottom: 1px solid rgba(255, 255, 255, .06);
  }
  .edge-back { margin: 0 auto 0 0; width: 36px; height: 36px; }

  .orchard-drill { inset: calc(48px + env(safe-area-inset-top)) 0 0 0; grid-template-rows: auto 1fr 30%; }
  .ramblefield { inset: calc(48px + env(safe-area-inset-top)) 0 0 0; }
  .rf-stage { inset: 54px 8px 66px; }
  .rf-tile-inner { border-radius: 10px; }
  .rf-label { padding: 18px 7px 6px; font-size: 10.5px; }
  .rf-actions .icon-btn { width: 28px; height: 28px; }
  .od-weather { inset: 0; }
  .orchard-drill[data-view="drill"], .orchard-drill[data-view="seedtray"] { grid-template-rows: auto 1fr 9%; }
  .od-choices { grid-template-columns: 1fr; gap: 9px; }
  .od-choice { min-height: 52px; font-size: 16px; }
  .od-tile-choices { grid-template-columns: 1fr 1fr; }
  .od-card { padding: 14px 14px 18px; border-radius: 20px; }
  .od-sign { padding: 20px 22px 24px; }

  .settings-overlay { padding: 0; }
  .settings-panel { height: 100%; border-radius: 0; }
  .settings-main { flex-direction: column; }
  .settings-tabs { flex-direction: row; width: auto; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); padding: 6px; }
  .settings-tab { white-space: nowrap; }
  .settings-body { padding: 14px; }
  .provider-fields, .provider-add { grid-template-columns: 1fr; }
  .role-row { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ===================================================== character avatars */
/* Each assistant reply carries its character's icon, inline to the left. */
.msg-assistant { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: start; }
.msg-assistant > .msg-who { grid-column: 1; grid-row: 1; padding-top: 2px; }
.msg-assistant > .msg-body { grid-column: 2; grid-row: 1; }
.msg-assistant > .msg-tools { grid-column: 2; grid-row: 2; }
/* A chat with no assistant keeps the old single-column look. */
.msg-assistant:not(:has(> .msg-who)) { grid-template-columns: minmax(0, 1fr); }
.msg-assistant:not(:has(> .msg-who)) > .msg-body,
.msg-assistant:not(:has(> .msg-who)) > .msg-tools { grid-column: 1; }
.msg.flash > .msg-body { animation: flash 1.4s var(--ease); border-radius: var(--r); }
@keyframes flash { 0%, 35% { background: var(--gold-soft); box-shadow: 0 0 0 6px var(--gold-soft); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }

/* ============================================================ copy on select */
.copied-tag {
  position: fixed; z-index: 85; pointer-events: none; opacity: 0;
  padding: 2px 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
  transform: translateY(4px); transition: opacity .15s, transform .15s var(--ease);
}
.copied-tag.show { opacity: .92; transform: none; }

/* ================================================================ branch map */
#branchBtn.has-forks { color: var(--accent); }
.bmap {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column; opacity: 0; transition: opacity .16s;
}
.bmap.in { opacity: 1; }
.bmap-head { display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex: 0 0 auto; }
.bmap-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-family: var(--font-text); font-size: 17px; color: var(--accent); }
.bmap-stats { color: var(--ink-faint); font-size: var(--fs-small); }
.bmap-viewport {
  position: relative; flex: 1; overflow: hidden; touch-action: none; outline: none; cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1px); background-size: 22px 22px;
}
.bmap-viewport:active { cursor: grabbing; }
.bmap-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.bmap-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.bmap-edge { fill: none; stroke: var(--line-strong); stroke-width: 1.6; }
.bmap-edge.active { stroke: var(--leaf); stroke-width: 2.4; stroke-dasharray: 5 5; animation: march 1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -10; } }
.bmap-node {
  position: absolute; display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 9px 11px; border-radius: var(--r); border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink); opacity: .72; overflow: hidden;
  transition: opacity .12s, transform .12s var(--ease), box-shadow .12s;
}
.bmap-node.user { background: color-mix(in srgb, var(--leaf) 14%, var(--surface)); border-color: color-mix(in srgb, var(--leaf) 45%, transparent); }
.bmap-node.assistant { background: color-mix(in srgb, var(--tile, var(--viz-other)) 13%, var(--surface)); border-color: color-mix(in srgb, var(--tile, var(--viz-other)) 45%, transparent); }
.bmap-node.on-path { opacity: 1; box-shadow: var(--shadow); }
.bmap-node:hover { opacity: 1; transform: translateY(-2px); }
.bmap-node.err { border-color: var(--danger); }
.bmap-node-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bmap-role { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; min-width: 0; }
.bmap-role span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bmap-emoji { font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif; font-size: 14px; line-height: 1; }
.bmap-model { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
.bmap-preview { font-size: 12.5px; line-height: 1.38; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bmap-legend { position: absolute; top: calc(var(--topbar-h) + 12px); right: 16px; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: flex-end;
  max-width: 60%; font-size: var(--fs-small); color: var(--ink-soft); pointer-events: none; }
.bmap-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bmap-legend .sw { width: 16px; height: 10px; border-radius: 3px; border: 1.5px solid; }
.bmap-legend .sw.user { background: color-mix(in srgb, var(--leaf) 20%, var(--surface)); border-color: var(--leaf); }
.bmap-legend .sw.asst { background: color-mix(in srgb, var(--viz-other) 20%, var(--surface)); border-color: var(--viz-other); }
.bmap-legend .ln { width: 20px; border-top: 2.4px dashed var(--line-strong); }
.bmap-legend .ln.active { border-color: var(--leaf); }
.bmap-mini { position: absolute; right: 16px; bottom: 16px; width: 150px; height: 100px; border-radius: var(--r); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); cursor: pointer; }
.bmap-mini svg { display: block; }
.bmap-mini .mn { fill: var(--line-strong); }
.bmap-mini .mn.user.path { fill: var(--leaf); }
.bmap-mini .mn.assistant.path { fill: var(--viz-other); }
.bmap-mini .mv { fill: var(--gold-soft); stroke: var(--gold); stroke-width: 1.2; }
.bmap-controls { position: absolute; left: 16px; bottom: 16px; display: flex; flex-direction: column; border-radius: var(--r); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.bmap-controls .icon-btn { border-radius: 0; }
.bmap-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: var(--fs-small); color: var(--ink-faint); pointer-events: none; white-space: nowrap; }
@media (max-width: 720px) { .bmap-mini, .bmap-hint { display: none; } .bmap-legend { max-width: 70%; } }

/* =================================================== Ramblefield: history */
.rf-recent { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.rf-recent:empty { display: none; }
.rf-recent-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--rf-chrome-line); background: var(--rf-chrome); color: var(--rf-ink);
}
.rf-recent-chip:hover { color: #fff; background: rgba(255, 255, 255, .13); }
.rf-corner .rf-star.on, .rf-ex-star.on { color: var(--rf-fruit); }
.rf-corner .rf-star.on .icon, .rf-ex-star.on .icon { fill: currentColor; }
.rf-corner .icon-btn.on { background: var(--rf-chrome); color: #fff; }
.rf-history {
  position: absolute; z-index: 6; top: 58px; right: 14px; bottom: 74px; width: min(380px, calc(100% - 28px));
  display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
  background: rgba(14, 18, 24, .86); backdrop-filter: blur(16px);
  border: 1px solid var(--rf-chrome-line); box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  animation: pop .16s var(--ease);
}
.rf-history-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--rf-chrome-line); }
.rf-history-title { flex: 1; font: 600 16px var(--font-text); color: var(--rf-ink-strong); }
.rf-history .seg { border-color: var(--rf-chrome-line); }
.rf-history .seg button { color: var(--rf-ink); font-size: 12.5px; }
.rf-history .seg button.on { background: rgba(255, 255, 255, .14); color: #fff; }
.rf-history .icon-btn { color: var(--rf-ink); }
.rf-history .icon-btn:hover { background: var(--rf-chrome); color: #fff; }
.rf-history-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.rf-history-empty { color: var(--rf-ink); padding: 22px 12px; font-size: 13.5px; text-align: center; }
.rf-ex { border: 1px solid var(--rf-chrome-line); background: var(--rf-chrome); border-radius: 16px; padding: 8px 8px 10px 12px; }
.rf-ex.current { border-color: rgba(255, 210, 150, .5); }
.rf-ex-top { display: flex; align-items: center; gap: 2px; }
.rf-ex-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; border: none; background: none; padding: 4px 0; color: var(--rf-ink-strong); }
.rf-ex-seed { font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-ex-meta { font-size: 12px; color: var(--rf-ink); font-variant-numeric: tabular-nums; }
.rf-ex-more.open .icon { transform: rotate(180deg); }
.rf-ex-labels { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; padding-right: 4px; }
.rf-ex-labels span { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: rgba(255, 255, 255, .07); color: var(--rf-ink); }
.rf-outline { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--rf-chrome-line); display: flex; flex-direction: column; }
.rf-node {
  display: flex; align-items: center; gap: 8px; border: none; background: none; text-align: left; border-radius: 10px;
  padding: 5px 8px 5px calc(6px + var(--depth, 0) * 16px); color: var(--rf-ink); font-size: 13px;
}
.rf-node:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.rf-node-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--rf-fruit); flex: 0 0 auto; opacity: .8; }
.rf-tile.explored .rf-label::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: var(--rf-fruit); box-shadow: 0 0 8px var(--rf-fruit); vertical-align: 1px; }
@media (max-width: 820px) { .rf-history { top: 54px; bottom: 66px; } }

/* ======================================================== read aloud + explainer */
.speak-btn.busy .icon { animation: xp-pulse .9s ease-in-out infinite; }
.speak-btn.playing, .explain-btn.on { color: var(--accent); background: var(--accent-soft); }
@keyframes xp-pulse { 50% { opacity: .3; } }

.portrait-box { display: flex; align-items: center; gap: 14px; }
.portrait-img { width: 96px; height: 96px; object-fit: cover; border-radius: 28px; box-shadow: var(--shadow); }
.portrait-empty { width: 96px; height: 96px; border-radius: 28px; display: grid; place-items: center; border: 1.5px dashed var(--line-strong); color: var(--ink-faint); font-size: var(--fs-small); }
.portrait-actions { display: flex; flex-direction: column; gap: 6px; }
.portrait-help { font-size: var(--fs-small); margin: -2px 0 8px; }
.voice-settings { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.voice-settings p { margin: 0; font-size: var(--fs-small); }
.explainer-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.explainer-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.explainer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.explainer-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explainer-cost { font-variant-numeric: tabular-nums; color: var(--ink-soft); }

.xp { position: fixed; inset: 0; z-index: 75; display: flex; flex-direction: column; background: #0c0907; color: #f3e8d2; animation: pop .16s var(--ease); }
.xp-head { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 10px 0 18px; flex: 0 0 auto; }
.xp-title { display: inline-flex; align-items: center; gap: 9px; font: 600 17px var(--font-text); }
.xp-head .icon-btn { color: rgba(243, 232, 210, .75); }
.xp-head .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.xp-cost { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16); color: rgba(243, 232, 210, .8); font-variant-numeric: tabular-nums; }
.xp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 14px 14px; gap: 10px; }
.xp-stage { position: relative; flex: 1; min-height: 0; border-radius: 26px; overflow: hidden; background: #130f0b; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); aspect-ratio: auto; }
.xp-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .5s ease; background: #130f0b; }
.xp-frame.on { opacity: 1; }
.xp-fallback { position: absolute; inset: 0; display: none; place-items: center; padding: 10% 12%; text-align: center; font: 22px/1.5 var(--font-text); background: radial-gradient(ellipse at 50% 40%, #3a2a1b, #17100a); }
.xp-fallback.on { display: grid; }
.xp-label { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); padding: 6px 16px; border-radius: 999px; background: rgba(12, 9, 7, .55); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, .14); font: italic 600 15px var(--font-text); }
.xp-caption { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(820px, calc(100% - 200px)); padding: 12px 20px; border-radius: 20px; text-align: center;
  background: rgba(12, 9, 7, .62); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, .12); font: 17px/1.5 var(--font-text); max-height: 38%; overflow: hidden; }
.xp-caption span { color: rgba(243, 232, 210, .55); transition: color .15s; }
.xp-caption .said { color: rgba(243, 232, 210, .9); }
.xp-caption .now { color: #ffd58a; }
.xp-char { position: absolute; left: 18px; bottom: 18px; width: 92px; height: 92px; display: grid; place-items: center; --lvl: 0;
  transform: translateY(calc(var(--lvl) * -6px)) scale(calc(1 + var(--lvl) * .1)) rotate(calc((var(--lvl) - .3) * 3deg)); transition: transform .05s linear; }
.xp-char .avatar { --size: 84px; }
.xp-portrait { width: 84px; height: 84px; object-fit: cover; border-radius: 28px; box-shadow: 0 8px 24px rgba(0, 0, 0, .55); position: relative; }
.xp-char-glow { position: absolute; inset: -8px; border-radius: 34px; background: radial-gradient(circle, rgba(255, 200, 120, .55), transparent 70%); opacity: 0; transition: opacity .2s; }
.xp-char.speaking .xp-char-glow { opacity: calc(.25 + var(--lvl) * .75); }
.xp-controls { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-radius: 22px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); flex: 0 0 auto; }
.xp-controls .icon-btn { color: #f3e8d2; }
.xp-controls .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.xp-play { width: 44px; height: 44px; border-radius: 50%; background: #f3e8d2; color: #1b120a !important; }
.xp-play:hover { background: #fff !important; }
.xp-track { position: relative; flex: 1; min-width: 80px; margin: 0 10px; height: 28px; display: flex; align-items: center; }
.xp-scrub { width: 100%; accent-color: #ffd58a; background: transparent; border: none; padding: 0; box-shadow: none; position: relative; z-index: 1; }
.xp-marks { position: absolute; inset: 0; pointer-events: none; }
.xp-marks i { position: absolute; top: 50%; width: 2px; height: 12px; margin-top: -6px; background: rgba(255, 255, 255, .45); border-radius: 1px; }
.xp-time { font-size: 12.5px; font-variant-numeric: tabular-nums; color: rgba(243, 232, 210, .75); min-width: 84px; text-align: right; }
.xp-speed { color: #f3e8d2; border-color: rgba(255, 255, 255, .2); padding: 4px 10px; }
.xp-confirm, .xp-making { margin: auto; max-width: 520px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.xp-confirm p { margin: 0; line-height: 1.55; }
.xp-est { font: 600 18px var(--font-text) !important; color: #ffd58a; }
.xp-confirm .muted { color: rgba(243, 232, 210, .6); font-size: 13px; }
.xp-confirm-actions { display: flex; gap: 10px; margin-top: 6px; }
.xp-spin { animation: spin 1.6s linear infinite; color: #ffd58a; }
.xp-spin.stopped { animation: none; opacity: .4; }
@keyframes spin { to { transform: rotate(360deg); } }
.xp-stage-text { font: 18px var(--font-text); }
.xp-dots { display: flex; gap: 8px; }
.xp-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, .2); transition: background .3s; }
.xp-dots i.done { background: #ffd58a; }
.xp-dots i.error { background: #e0705f; }
@media (max-width: 820px) {
  .xp-caption { width: calc(100% - 24px); bottom: 118px; font-size: 15px; }
  .xp-char { bottom: 14px; left: 14px; }
  .xp-time { display: none; }
  .xp-body { padding: 0 8px 8px; }
}
.xp:fullscreen { background: #000; }
@media (prefers-reduced-motion: reduce) { .xp-frame { transition: none; } .xp-char { transition: none; } }

/* ======================================================== read-aloud player */
.speak-wrap { display: inline-flex; align-items: center; min-width: 0; border-radius: var(--r-pill); }
.speak-wrap.open { background: var(--accent-soft); }
.speak-btn.paused { color: var(--accent); }
.sp-player {
  display: inline-flex; align-items: center; gap: 8px; overflow: hidden;
  max-width: 0; opacity: 0; padding: 0; transition: max-width .28s ease, opacity .2s ease, padding .28s ease;
}
.speak-wrap.open .sp-player { max-width: 320px; opacity: 1; padding: 0 6px 0 2px; }
.sp-track {
  position: relative; width: clamp(80px, 22vw, 190px); height: 18px; cursor: pointer; touch-action: none;
  display: flex; align-items: center;
}
.sp-track::before { content: ""; position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--line-strong); }
.sp-fill { position: relative; height: 4px; border-radius: 2px; background: var(--accent); width: 0; }
.sp-fill::after { content: ""; position: absolute; right: -5px; top: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.sp-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sp-time { font-size: var(--fs-small); color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-close { border: none; background: none; color: var(--ink-faint); padding: 2px; border-radius: 50%; display: grid; place-items: center; }
.sp-close:hover { color: var(--ink); }
.sp-close .icon { width: 14px; height: 14px; }
@media (prefers-reduced-motion: reduce) { .sp-player { transition: none; } }

/* ======================================================== Artifact panel */
.artifact-panel { min-width: 300px; }
.art-head { gap: 2px; }
.art-title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }
.art-count { font-size: var(--fs-small); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.art-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.art-frame { flex: 1; width: 100%; min-height: 0; border: none; background: var(--bg); }
.art-foot { padding: 4px 12px; font-size: var(--fs-small); color: var(--ink-faint); border-top: 1px solid var(--line); }
.art-empty { margin: auto; max-width: 340px; padding: 24px 20px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.art-lead { margin: 0; font-size: 17px; font-weight: 700; }
.art-note { margin: 0; color: var(--ink-soft); line-height: 1.5; font-size: 14px; }
.art-note.muted { color: var(--ink-faint); font-size: var(--fs-small); }
.art-note.art-error { color: var(--danger, #b5543a); }
.art-focus { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); padding: 9px 11px; font: inherit; }
.art-stale { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; background: var(--gold-soft); font-size: var(--fs-small); }
.art-pulse { width: 46px; height: 46px; margin: 0 auto; border-radius: 50%; background: var(--accent); animation: xp-pulse 1.1s ease-in-out infinite; }
.art-full { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; background: var(--bg); }
.art-full-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
@media (max-width: 820px) {
  body.artifact-on .thread { padding-bottom: calc(var(--sheet-h) + 12px); }
  body.artifact-on .composer { display: none; }
}

/* ======================================================== WinnowWhip box drag */
.ww-marquee { position: fixed; z-index: 70; pointer-events: none; border: 1.5px dashed var(--accent); background: var(--accent-soft); border-radius: 6px; }
body.ww-sweeping { user-select: none; -webkit-user-select: none; cursor: crosshair; }
body.ww-sweeping * { cursor: crosshair !important; }
body.winnow-on [data-ww] .sent.sweep { background: var(--chunk-hover); box-shadow: 0 0 0 1px var(--accent) inset; }
.box-btn.on { color: var(--accent); background: var(--accent-soft); }
.voice-row select { flex: 1; min-width: 0; }
