/* Toonlight — an illustrated paper notebook turned into a macOS-style app.
   Thick black ink, warm paper, cut-out offset shadows, a few muted accents.
   Components: .btn (tactile button), .ink (outlined paper card), .hand (handwriting),
   .doodle (inline SVG sketches). The accent colour follows the selected character. */

@property --tint { syntax: '<color>'; inherits: true; initial-value: #EDB95E; }

:root {
  /* paper */
  --desk: #E9DFCC;
  --paper: #FBF6EC;
  --cream: #F4ECDD;
  --beige: #E6D8BF;
  --rule: #E3D6BE;
  --margin: #E9A69C;
  /* ink */
  --ink: #000;
  --shade: #000;          /* offset shadows */
  --on-tint: #111;        /* text on the pastel accent */
  --ink-soft: #3B3530;
  --muted: #6B6158;
  /* the character's muted accent (set from JS) */
  --tint-soft: color-mix(in srgb, var(--tint) 35%, var(--paper));
  /* macOS lights */
  --red: #FF5F57; --yellow: #FEBC2E; --green: #28C840;

  --line: 2.5px;
  --line-bold: 3px;
  --shadow: 4px 4px 0 var(--shade);
  --shadow-lift: 6px 6px 0 var(--shade);
  --shadow-big: 9px 10px 0 var(--shade);
  /* slightly uneven corners: looks drawn, not machined */
  --wobble: 14px 18px 13px 17px / 17px 13px 18px 14px;
  --wobble-sm: 10px 12px 9px 13px / 12px 9px 13px 10px;

  --display: 'Bricolage Grotesque', 'Arial Black', system-ui, sans-serif;
  --text: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --hand: 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.28 0 0 0 0 0.2 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  transition: --tint 0.7s ease;
  color-scheme: light;
}

/* Black theme: a dark desk and charcoal paper, drawn with warm white chalk-like ink */
:root[data-theme='dark'] {
  --desk: #0F0F11;
  --paper: #1A1A1D;
  --cream: #222226;
  --beige: #3A3A40;
  --rule: #2A2A2F;
  --margin: #6E3A35;
  --ink: #F2EDE3;
  --ink-soft: #CFC8BB;
  --muted: #A1998D;
  --shade: #000;
  --tint-soft: color-mix(in srgb, var(--tint) 22%, var(--paper));
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.95 0 0 0 0 0.9 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}
/* in the dark, cut-out shadows are a soft lift of the ink colour so they stay visible */
:root[data-theme='dark'] { --shadow: 4px 4px 0 #4A4740; --shadow-lift: 6px 6px 0 #4A4740; --shadow-big: 9px 10px 0 #3B3934; --shade: #4A4740; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--text); font-size: 16px; line-height: 1.5; color: var(--ink);
  background: var(--grain), var(--desk);
  display: flex; flex-direction: column; min-height: 100dvh; overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.hand { font-family: var(--hand); font-weight: 700; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.doodle { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; position: absolute; pointer-events: none; }

/* ---------- tactile button ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: var(--line) solid var(--ink); border-radius: var(--wobble-sm);
  box-shadow: var(--shadow); font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s ease;
}
.btn:hover { transform: translate(-1px, -2px); box-shadow: var(--shadow-lift); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shade); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; box-shadow: var(--shadow); }
.btn-accent { background: var(--tint); color: var(--on-tint); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; box-shadow: 3px 3px 0 var(--shade); }
.btn-small:hover { box-shadow: 4px 5px 0 var(--shade); }
.btn-small:active { box-shadow: 0 0 0 var(--shade); transform: translate(3px, 3px); }
.btn-icon { width: 46px; padding: 0; }
.btn[aria-pressed='true'] { background: var(--ink); color: var(--paper); }

/* ---------- menu bar ---------- */

.menubar {
  display: flex; align-items: center; gap: 22px; height: 46px; padding: 0 18px; flex: none;
  background: var(--paper); border-bottom: var(--line-bold) solid var(--ink); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.brand-mark svg { width: 26px; height: 26px; display: block; fill: var(--tint); stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.brand-mark svg circle { fill: var(--ink); stroke: none; }
.brand-mark svg path { fill: none; }
.menu { display: flex; gap: 4px; }
.menu-item {
  background: none; border: var(--line) solid transparent; border-radius: 9px; padding: 3px 10px; cursor: pointer; font-weight: 700;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.menu-item:hover { border-color: var(--ink); background: var(--cream); }
.menu-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn { width: 36px; height: 30px; display: grid; place-items: center; background: none; border: var(--line) solid transparent; border-radius: 9px; cursor: pointer; }
.icon-btn:hover { border-color: var(--ink); background: var(--cream); }
.icon-btn .ico-moon { display: block; } .icon-btn .ico-sun { display: none; }
:root[data-theme='dark'] .icon-btn .ico-moon { display: none; } :root[data-theme='dark'] .icon-btn .ico-sun { display: block; }
.clock { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- the desk & app window ---------- */

.desk { flex: 1; min-height: 0; display: flex; padding: 22px 26px 28px; }
.window {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column;
  max-width: 1480px; margin: 0 auto; width: 100%;
  background: var(--paper); border: var(--line-bold) solid var(--ink); border-radius: 20px 22px 19px 23px / 22px 19px 23px 20px;
  box-shadow: var(--shadow-big); overflow: hidden;
  animation: window-in 0.55s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes window-in { from { transform: translateY(18px) rotate(-0.6deg); } }
.titlebar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 54px; padding: 0 14px 0 18px; flex: none;
  background: var(--grain), var(--cream); border-bottom: var(--line-bold) solid var(--ink);
}
.lights { display: flex; gap: 9px; }
.lights span { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--ink); }
.l-red { background: var(--red); } .l-yellow { background: var(--yellow); } .l-green { background: var(--green); }
.window-title { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar .btn { justify-self: end; }

.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 236px minmax(0, 1fr) minmax(340px, 410px); }

/* ---------- sidebar: the cast ---------- */

.sidebar { border-right: var(--line-bold) solid var(--ink); background: var(--grain), var(--cream); padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }
.side-label { margin: 0 4px; font-size: 1.3rem; line-height: 1.1; }
.cast { display: flex; flex-direction: column; gap: 10px; }
.cast-group { margin: 6px 4px 0; font-family: var(--hand); font-weight: 700; font-size: 1.05rem; color: var(--muted); }
.card {
  display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; text-align: left; width: 100%;
  padding: 8px 10px; cursor: pointer; background: var(--paper);
  border: var(--line) solid var(--shade); border-radius: var(--wobble-sm); box-shadow: 3px 3px 0 var(--shade);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.25s ease;
}
.card:hover { transform: translate(-1px, -2px) rotate(-0.4deg); box-shadow: 5px 5px 0 var(--shade); }
.card:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shade); }
.card[aria-pressed='true'] { background: var(--tint-soft); transform: rotate(-1deg); box-shadow: 5px 5px 0 var(--shade); }
.card .face { width: 52px; height: 52px; border-radius: 50%; border: var(--line) solid var(--ink); background: var(--cream) center / cover no-repeat; }
.card .who { font-family: var(--display); font-weight: 800; font-size: 1rem; line-height: 1.1; }
.card .what { font-size: 0.82rem; color: var(--muted); line-height: 1.25; display: block; margin-top: 2px; }
.side-foot { margin-top: auto; position: relative; padding: 10px 6px 0 38px; }
.side-foot p { margin: 0; font-size: 1.1rem; line-height: 1.15; color: var(--ink-soft); }
.d-heart { width: 30px; height: 30px; left: 2px; top: 10px; fill: var(--tint); }

/* ---------- stage ---------- */

.stage-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 18px 18px; gap: 12px; background: var(--paper); }
.modes { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.mode {
  border: var(--line) solid var(--ink); background: var(--paper); border-radius: 999px; padding: 5px 14px; cursor: pointer; font-weight: 700; font-size: 0.92rem;
  box-shadow: 2px 2px 0 var(--shade); transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s ease;
}
.mode:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shade); }
.mode:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shade); }
.mode[aria-selected='true'] { background: var(--ink); color: var(--paper); }

.stage {
  position: relative; flex: 1; min-height: 260px; overflow: hidden;
  border: var(--line-bold) solid var(--ink); border-radius: var(--wobble);
  background:
    radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--tint) 30%, transparent), transparent 55%),
    radial-gradient(var(--beige) 1.3px, transparent 1.6px) 0 0 / 22px 22px,
    var(--grain), var(--cream);
  box-shadow: inset 0 -10px 0 color-mix(in srgb, var(--shade) 4%, transparent);
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage.dropping::after {
  content: 'Drop the model to try it'; position: absolute; inset: 12px; display: grid; place-items: center;
  border: 3px dashed var(--ink); border-radius: var(--wobble); background: color-mix(in srgb, var(--paper) 75%, transparent);
  font-family: var(--hand); font-size: 2rem; pointer-events: none;
}

/* the name: a sticky note held on with tape */
.sticky {
  position: absolute; top: 18px; left: 18px; max-width: 270px; padding: 16px 16px 14px;
  background: var(--tint-soft); border: var(--line) solid var(--ink); border-radius: 4px 6px 5px 3px;
  box-shadow: var(--shadow); transform: rotate(-2deg); z-index: 2;
}
.tape { position: absolute; top: -12px; left: 50%; width: 74px; height: 22px; transform: translateX(-50%) rotate(3deg); background: color-mix(in srgb, #fff 55%, var(--beige)); border: 2px solid var(--ink); opacity: 0.92; }
.sticky-kind { margin: 0; font-size: 1.15rem; line-height: 1; }
.sticky h1 { font-size: 1.55rem; line-height: 1.05; margin: 3px 0 5px; }
.sticky-tag { margin: 0; font-size: 0.9rem; line-height: 1.35; color: var(--ink-soft); }

.score {
  position: absolute; top: 18px; right: 18px; z-index: 2; display: grid; place-items: center; width: 88px; height: 88px;
  background: var(--paper); border: var(--line-bold) solid var(--ink); border-radius: 50% 46% 52% 48% / 48% 53% 47% 52%;
  box-shadow: var(--shadow); transform: rotate(6deg); line-height: 1;
}
.score .hand { font-size: 1.1rem; }
.score strong { font-family: var(--display); font-size: 1.5rem; }
.score.bump { animation: bump 0.45s ease; }
@keyframes bump { 40% { transform: rotate(-4deg) scale(1.15); } }

.thought {
  position: absolute; left: 56%; top: 16%; display: flex; gap: 6px; padding: 11px 15px; z-index: 2;
  background: var(--paper); border: var(--line) solid var(--shade); border-radius: 999px; box-shadow: 3px 3px 0 var(--shade);
}
.thought span, .typing .bubble span { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); animation: dot 1s infinite ease-in-out; }
.thought span:nth-child(2), .typing .bubble span:nth-child(2) { animation-delay: 0.15s; }
.thought span:nth-child(3), .typing .bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.d-star { width: 42px; height: 42px; right: 26px; bottom: 30px; fill: var(--tint); transform: rotate(12deg); }
.d-squiggle { width: 110px; height: 22px; left: 24px; bottom: 26px; }
.d-spiral { width: 38px; height: 38px; right: 120px; top: 22px; opacity: 0.8; }
.d-burst { width: 34px; height: 34px; left: 44%; top: 20px; opacity: 0.7; }
.stage .doodle { transition: transform 0.4s ease; }
.stage:hover .d-star { transform: rotate(32deg) scale(1.08); }
.stage:hover .d-spiral { transform: rotate(-25deg); }

.mode-setup {
  display: flex; align-items: center; gap: 10px; flex: none; padding: 10px 12px;
  background: var(--tint-soft); border: var(--line) solid var(--shade); border-radius: var(--wobble-sm); box-shadow: 3px 3px 0 var(--shade);
}
.mode-setup label { font-family: var(--hand); font-weight: 700; font-size: 1.25rem; white-space: nowrap; }
.mode-setup input, .mode-setup select { flex: 1; min-width: 0; height: 40px; padding: 0 12px; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 10px; }

/* ---------- chat: a ruled notebook page ---------- */

.chat {
  display: flex; flex-direction: column; min-height: 0; border-left: var(--line-bold) solid var(--ink);
  background: linear-gradient(90deg, transparent 38px, var(--margin) 38px, var(--margin) 40px, transparent 40px), var(--grain), var(--paper);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 10px 54px; border-bottom: var(--line) solid var(--ink); background: var(--grain), var(--cream); }
.chat-head h2 { font-size: 1.2rem; line-height: 1.1; }
.chat-head-text { min-width: 0; }
.chat-head .chat-mode { font-size: 1.1rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.chat-mode { margin: 0; font-size: 1.25rem; white-space: nowrap; }

/* Chat only / Voice switch */
.seg { display: inline-flex; border: var(--line) solid var(--ink); border-radius: 999px; overflow: hidden; box-shadow: 2px 2px 0 var(--shade); flex: none; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--paper); padding: 4px 12px; cursor: pointer; font-weight: 700; font-size: 0.86rem; transition: background-color 0.15s ease; }
.seg button + button { border-left: var(--line) solid var(--ink); }
.seg button .ico { width: 16px; height: 16px; }
.seg button:hover { background: var(--cream); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }

/* Listen button under a reply */
.listen {
  display: inline-flex; align-items: center; gap: 5px; margin: 6px 0 0 2px; padding: 2px 10px 2px 7px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; cursor: pointer;
  font-size: 0.8rem; font-weight: 700; box-shadow: 2px 2px 0 var(--shade);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.listen .ico { width: 14px; height: 14px; }
.listen:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shade); }
.listen:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--shade); }
.listen[aria-pressed='true'] { background: var(--tint); color: var(--on-tint); }
.notice { margin: 12px 16px 0 54px; padding: 9px 12px; background: var(--tint-soft); border: 2px solid var(--ink); border-radius: var(--wobble-sm); font-size: 0.92rem; }

.messages {
  flex: 1; overflow-y: auto; margin: 0; padding: 18px 18px 10px 54px; list-style: none; display: flex; flex-direction: column; gap: 14px;
  background-image: repeating-linear-gradient(transparent 0 27px, var(--rule) 27px 28px); background-attachment: local;
}
.msg { max-width: 92%; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .who { font-family: var(--hand); font-weight: 700; font-size: 1.2rem; line-height: 1; margin: 0 0 3px 4px; }
.msg.bot .bubble { background: var(--paper); border: var(--line) solid var(--shade); border-radius: 4px 16px 14px 15px / 4px 14px 16px 13px; padding: 10px 14px; box-shadow: 3px 3px 0 var(--shade); }
.msg.user { align-self: flex-end; }
.msg.user .bubble { color: var(--on-tint); background: var(--tint); border: var(--line) solid var(--shade); border-radius: 16px 4px 15px 14px / 14px 4px 13px 16px; padding: 10px 14px; box-shadow: 3px 3px 0 var(--shade); }
.msg.system { align-self: center; max-width: 96%; text-align: center; }
.msg.system p { font-family: var(--hand); font-size: 1.15rem; line-height: 1.2; color: var(--ink-soft); }
.msg.new .bubble { animation: pop-in 0.28s cubic-bezier(.2,.9,.3,1.3); }
@keyframes pop-in { from { transform: translateY(6px) scale(0.97); } }
.typing .bubble { display: flex; gap: 5px; width: fit-content; padding: 14px 16px !important; }
.memo { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; font-family: var(--hand); font-weight: 700; font-size: 1.05rem; color: var(--ink-soft); }
.memo::before { content: ''; width: 14px; height: 14px; border: 2px solid var(--ink); border-radius: 3px; background: var(--tint); transform: rotate(-8deg); }
.sources { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.82rem; }
.sources a { color: var(--ink); background: var(--cream); border: 2px solid var(--ink); border-radius: 999px; padding: 0 9px; text-decoration: none; }

.suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 16px 10px 54px; }
.suggest button {
  border: 2px dashed var(--ink); background: var(--paper); border-radius: 12px; padding: 5px 11px; cursor: pointer; text-align: left; font-size: 0.9rem;
  transition: transform 0.12s ease, background-color 0.2s ease, border-style 0s;
}
.suggest button:hover { background: var(--tint-soft); border-style: solid; transform: translate(-1px, -1px); }

.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px 14px; border-top: var(--line) solid var(--ink); background: var(--grain), var(--cream); }
.composer textarea {
  flex: 1; resize: none; min-height: 46px; max-height: 150px; padding: 11px 13px; line-height: 1.4;
  background: var(--paper); border: var(--line) solid var(--shade); border-radius: var(--wobble-sm); box-shadow: inset 2px 2px 0 color-mix(in srgb, var(--shade) 8%, transparent);
}
.composer textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--tint); }
#mic[aria-pressed='true'] { background: var(--red); color: var(--shade); animation: listening 1.1s infinite; }
@keyframes listening { 50% { box-shadow: 4px 4px 0 var(--shade), 0 0 0 7px color-mix(in srgb, var(--red) 35%, transparent); } }

/* ---------- notebook drawer ---------- */

.scrim { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink) 25%, transparent); z-index: 20; }
.notebook {
  position: fixed; top: 64px; right: 20px; bottom: 20px; width: min(440px, calc(100vw - 24px)); z-index: 21;
  display: flex; transform: translateX(calc(100% + 40px)) rotate(2deg); transition: transform 0.35s cubic-bezier(.2,.9,.3,1.1);
}
.notebook.open { transform: none; }
.nb-rings { width: 26px; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; margin-right: -13px; z-index: 1; }
.nb-rings span { width: 26px; height: 12px; border: var(--line) solid var(--ink); border-radius: 999px; background: var(--paper); }
.nb-page {
  flex: 1; overflow-y: auto; padding: 18px 22px 22px 30px;
  background: repeating-linear-gradient(transparent 0 29px, var(--rule) 29px 30px), var(--grain), var(--paper);
  border: var(--line-bold) solid var(--shade); border-radius: 6px 18px 16px 6px; box-shadow: var(--shadow-big);
}
.nb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.nb-head h2 { font-size: 1.6rem; }
.nb-section { padding: 14px 0; border-bottom: 2px dashed var(--ink); }
.nb-section:last-child { border-bottom: 0; }
.nb-section h3 { font-size: 1.05rem; margin-bottom: 4px; }
.nb-help { margin: 0 0 10px; font-size: 0.9rem; color: var(--ink-soft); }
.nb-empty { margin: 0 0 10px; font-size: 1.15rem; color: var(--muted); }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field span { font-family: var(--hand); font-weight: 700; font-size: 1.15rem; line-height: 1; }
.field input, .field textarea { padding: 9px 11px; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 10px; resize: vertical; }
.facts { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 7px; }
.facts li { display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px 7px 11px; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; font-size: 0.92rem; }
.facts li span { flex: 1; }
.facts button { flex: none; width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 7px; background: var(--cream); cursor: pointer; line-height: 1; font-weight: 700; }
.facts button:hover { background: var(--red); color: var(--on-tint); }
.toggle-row { display: flex; align-items: flex-start; gap: 12px; }
.toggle-row .nb-help { margin: 0; }
.model-row { display: flex; flex-wrap: wrap; gap: 10px; }
.file-btn { cursor: pointer; }
code { font-size: 0.85em; background: var(--cream); border: 1.5px solid var(--ink); border-radius: 5px; padding: 0 4px; }

/* ---------- help card ---------- */

.pop {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) rotate(-1deg); width: min(420px, calc(100vw - 32px)); z-index: 22;
  padding: 22px 22px 18px; background: var(--grain), var(--paper); border: var(--line-bold) solid var(--shade); border-radius: var(--wobble); box-shadow: var(--shadow-big);
}
.pop h2 { font-size: 1.35rem; margin-bottom: 8px; }
.pop ol { margin: 0 0 14px; padding-left: 22px; display: grid; gap: 6px; }

/* ---------- tablet ---------- */

@media (max-height: 940px) { .side-foot { display: none; } }

@media (max-width: 1180px) {
  .panes { grid-template-columns: 92px minmax(0, 1fr) minmax(310px, 360px); }
  .sidebar { padding: 14px 10px; align-items: center; }
  .side-label, .side-foot, .cast-group { display: none; }
  .card { grid-template-columns: 52px; padding: 6px; justify-items: center; }
  .card .txt { display: none; }
}

/* ---------- phone ---------- */

@media (max-width: 820px) {
  body { overflow: auto; }
  .menubar { gap: 10px; height: 44px; padding: 0 12px; }
  .menu { display: none; }
  .desk { padding: 10px 10px 14px; }
  .window { border-radius: 16px 18px 15px 17px / 17px 15px 18px 16px; box-shadow: 5px 6px 0 var(--shade); }
  .titlebar { height: 46px; padding: 0 10px 0 12px; grid-template-columns: auto 1fr auto; gap: 10px; }
  .titlebar .btn span { display: none; }
  .titlebar .btn { width: 40px; padding: 0; }
  .lights span { width: 12px; height: 12px; }
  .window-title { font-size: 0.92rem; text-align: center; }
  .panes { display: flex; flex-direction: column; overflow-y: auto; }
  .panes > * { flex: none; }
  .sidebar { order: 2; border-right: 0; border-top: var(--line-bold) solid var(--ink); border-bottom: var(--line-bold) solid var(--ink); padding: 10px; overflow: visible; align-items: stretch; }
  .cast { flex-direction: row; overflow-x: auto; padding: 4px 4px 8px; scrollbar-width: none; gap: 10px; }
  .card { flex: none; width: auto; grid-template-columns: 44px; padding: 5px; }
  .card .face { width: 44px; height: 44px; }
  .stage-pane { order: 1; padding: 10px; gap: 10px; }
  .stage { min-height: 0; height: min(46dvh, 420px); flex: none; }
  .modes { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; }
  .mode { flex: none; }
  .sticky { top: auto; bottom: 12px; left: 12px; max-width: 170px; padding: 11px 11px 8px; transform: rotate(-2.5deg); }
  .sticky h1 { font-size: 1.05rem; }
  .sticky-kind { font-size: 1rem; }
  .d-squiggle { display: none; }
  .sticky-tag { display: none; }
  .score { width: 66px; height: 66px; top: 12px; right: 12px; }
  .score strong { font-size: 1.15rem; }
  .d-spiral, .d-burst { display: none; }
  .chat { order: 3; border-left: 0; min-height: 70dvh; background: linear-gradient(90deg, transparent 22px, var(--margin) 22px, var(--margin) 24px, transparent 24px), var(--grain), var(--paper); }
  .chat-head, .messages, .suggest, .notice { padding-left: 34px; margin-left: 0; }
  .notice { margin: 10px 12px 0 34px; }
  .suggest { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .suggest button { flex: none; }
  .composer { position: sticky; bottom: 0; }
  .notebook { top: 54px; right: 8px; bottom: 8px; }
  .mode-setup { flex-wrap: wrap; }
  .mode-setup label { width: 100%; }
}

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