/* ============================================================
   TalkingLogs — Goblin-Powered Combat Log Shredder
   Theme: WoW high-fantasy carved wood + aged parchment + gold
   filigree, grimed up with goblin engineering (hazard tape,
   rivets, copper, goblin green).
   ============================================================ */

:root {
  /* Wood stain ramp (tweakable via --stain-* overrides) */
  --wood-900: #160c05;
  --wood-800: #22140a;
  --wood-700: #321f11;
  --wood-650: #3d2715;
  --wood-600: #4c2f18;
  --wood-500: #6a4322;
  --wood-400: #895a30;
  --grain:    #b07b41;

  /* Parchment */
  --parch:   #ecd9a8;
  --parch-2: #e2c98e;
  --parch-edge: #c9a866;
  --ink:     #38280f;
  --ink-soft:#6c542c;

  /* Metals */
  --gold:        #d8a73e;
  --gold-bright: #f4d480;
  --gold-deep:   #9c711f;
  --copper:      #b06a39;
  --iron:        #2a2723;
  --iron-light:  #423d36;

  /* Goblin accents */
  --green:       #93cf45;
  --green-deep:  #5a9230;
  --hazard:      #f2c33d;
  --ember:       #d8592c;
  --ember-bright:#f3833f;
  --blood:       #b0322a;

  /* Interactive accent (tweakable) */
  --accent:       var(--green);
  --accent-deep:  var(--green-deep);
  --accent-glow:  rgba(147, 207, 69, 0.55);

  --motion: 1; /* scaled by tweak */

  --font-carve: "Cinzel", "Times New Roman", serif;
  --font-read:  "Spectral", Georgia, serif;
  --font-gob:   "Oswald", "Arial Narrow", sans-serif;
  --font-mono:  "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-read);
  color: var(--parch);
  background: var(--wood-900);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Reusable wood-grain surface --------------------------------- */
.woodgrain {
  background-color: var(--wood-600);
  background-image:
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.00) 0px, rgba(0,0,0,0.06) 2px,
      rgba(255,255,255,0.025) 4px, rgba(0,0,0,0.00) 9px,
      rgba(0,0,0,0.10) 13px, rgba(0,0,0,0.00) 18px),
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.00) 0px, rgba(0,0,0,0.05) 40px,
      rgba(0,0,0,0.00) 90px, rgba(255,255,255,0.02) 130px,
      rgba(0,0,0,0.00) 180px),
    linear-gradient(180deg, var(--wood-500), var(--wood-700));
}
.woodgrain-v {
  background-color: var(--wood-650);
  background-image:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0.00) 0px, rgba(0,0,0,0.07) 2px,
      rgba(255,255,255,0.02) 4px, rgba(0,0,0,0.00) 10px,
      rgba(0,0,0,0.10) 15px, rgba(0,0,0,0.00) 21px),
    linear-gradient(90deg, var(--wood-700), var(--wood-600) 50%, var(--wood-800));
}

/* ---- App shell --------------------------------------------------- */
#app {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 100vh;
  width: 100vw;
}

/* Left: the tavern / workshop floor where Old Splinter holds court */
#chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background-color: var(--wood-700);
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(216,167,62,0.10), transparent 60%),
    repeating-linear-gradient(91deg,
      rgba(0,0,0,0) 0, rgba(0,0,0,0.05) 60px, rgba(0,0,0,0) 120px,
      rgba(255,255,255,0.012) 200px, rgba(0,0,0,0) 280px),
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0.18) 0, rgba(0,0,0,0) 3px, rgba(0,0,0,0) 158px, rgba(0,0,0,0.18) 162px),
    linear-gradient(180deg, var(--wood-650), var(--wood-800));
  box-shadow: inset 0 30px 60px -30px rgba(0,0,0,0.7);
}

/* ---- Top plaque -------------------------------------------------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background:
    linear-gradient(180deg, var(--wood-500), var(--wood-700));
  border-bottom: 3px solid var(--wood-900);
  box-shadow: 0 6px 14px -4px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-plaque {
  display: flex; flex-direction: column; line-height: 1;
}
.brand-plaque h1 {
  margin: 0;
  font-family: var(--font-carve);
  font-weight: 800;
  font-size: 27px;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  text-shadow: 0 1px 0 var(--gold-deep), 0 2px 3px rgba(0,0,0,0.6), 0 0 18px rgba(216,167,62,0.18);
}
.brand-plaque .tagline {
  font-family: var(--font-gob);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10.5px;
  color: var(--green);
  margin-top: 4px;
}
.brand-badge {
  width: 58px; height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5));
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Per-session model picker */
.model-select {
  font-family: var(--font-gob);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 3px;
  color: var(--gold-bright);
  background: var(--wood-800);
  border: 2px solid var(--gold-deep);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.model-select:hover { filter: brightness(1.12); }
.model-select:focus { outline: none; border-color: var(--gold-bright); }
.model-select option { color: #2a1606; background: #e8c45a; }

/* Status chip (keys) */
.chip {
  font-family: var(--font-gob);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 11px;
  padding: 6px 13px;
  border-radius: 3px;
  color: #2a1606;
  background: repeating-linear-gradient(-45deg, var(--hazard), var(--hazard) 9px, #1c130b 9px, #1c130b 18px);
  border: 2px solid #1c130b;
  display: inline-flex; align-items: center; gap: 7px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  white-space: nowrap;
}
.chip .chip-label {
  background: var(--hazard);
  padding: 1px 6px;
  border-radius: 2px;
}
.chip.ok {
  background: var(--wood-800);
  border-color: var(--green-deep);
  color: var(--green);
}
.chip.ok .chip-label { background: transparent; padding: 0; }

/* Brass cog settings button */
.cog-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid var(--gold-deep);
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold) 45%, var(--gold-deep));
  color: var(--wood-900);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.5);
  transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
  flex-shrink: 0;
}
.cog-btn:hover { transform: rotate(90deg); }
.cog-btn svg { width: 24px; height: 24px; }

/* ---- Transcript / scroll area ------------------------------------ */
#transcript:empty { flex: 0; }
#transcript {
  flex: 1;
  overflow-y: auto;
  padding: 26px 30px 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: var(--wood-500) transparent;
}
#transcript::-webkit-scrollbar { width: 11px; }
#transcript::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--wood-400), var(--wood-600));
  border-radius: 6px; border: 2px solid var(--wood-700);
}

/* ---- Messages ---------------------------------------------------- */
.row { display: flex; gap: 14px; align-items: flex-start; max-width: 880px; }
.row.user { align-self: flex-end; flex-direction: row-reverse; }
.row.assistant { align-self: flex-start; width: 100%; }

/* User message = a branded shipping crate / carved request token */
.bubble-user {
  background: linear-gradient(180deg, var(--wood-500), var(--wood-650));
  border: 2px solid var(--wood-800);
  border-radius: 4px;
  padding: 12px 16px;
  color: var(--parch);
  font-size: 16px;
  max-width: 560px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.07);
  position: relative;
}
.bubble-user::before {
  content: "▸ ASK";
  position: absolute; top: -9px; right: 12px;
  font-family: var(--font-gob); font-size: 9px; letter-spacing: 0.15em;
  color: var(--wood-900); background: var(--gold);
  padding: 1px 7px; border-radius: 2px;
}

.avatar-mini {
  width: 46px; height: 46px; flex-shrink: 0;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

/* Assistant = parchment scroll spoken by Old Splinter */
.scroll-wrap { flex: 1; min-width: 0; }
.speaker-name {
  font-family: var(--font-carve);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  margin: 2px 0 6px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.speaker-name .knots {
  font-family: var(--font-gob); font-weight: 500; font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--green); opacity: 0.85;
}

.parchment {
  position: relative;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(0,0,0,0.05), transparent 40%),
    radial-gradient(140% 120% at 100% 100%, rgba(120,80,30,0.18), transparent 45%),
    linear-gradient(160deg, var(--parch), var(--parch-2));
  color: var(--ink);
  border-radius: 5px;
  padding: 18px 22px;
  font-size: 16px;
  line-height: 1.62;
  box-shadow:
    0 8px 20px -6px rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(0,0,0,0.07),
    inset 0 0 40px rgba(150,110,50,0.12);
  border-top: 1px solid rgba(255,255,255,0.35);
}
/* torn / rolled top & bottom edges */
.parchment::before, .parchment::after {
  content: ""; position: absolute; left: 0; right: 0; height: 10px;
  background-size: 18px 10px;
}
.parchment::before {
  top: -6px;
  background-image: radial-gradient(circle at 9px 10px, var(--parch) 7px, transparent 7px);
}
.parchment::after {
  bottom: -6px;
  background-image: radial-gradient(circle at 9px 0px, var(--parch-2) 7px, transparent 7px);
}
.parchment > :first-child { margin-top: 0; }
.parchment > :last-child { margin-bottom: 0; }

/* Markdown inside parchment */
.parchment p { margin: 0 0 10px; }
.parchment strong { color: #5a3c12; }
.parchment em { color: var(--ink-soft); }
.parchment h1, .parchment h2, .parchment h3, .parchment h4 {
  font-family: var(--font-carve); font-weight: 700;
  margin: 16px 0 8px; color: #4a3210;
  border-bottom: 1px solid rgba(120,90,40,0.3); padding-bottom: 3px;
}
.parchment h1 { font-size: 21px; }
.parchment h2 { font-size: 18px; }
.parchment h3 { font-size: 16px; }
.parchment ul, .parchment ol { margin: 6px 0 10px; padding-left: 22px; }
.parchment li { margin: 3px 0; }
.parchment code {
  font-family: var(--font-mono); font-size: 13px;
  background: rgba(90,60,20,0.14); padding: 1px 6px; border-radius: 3px;
  border: 1px solid rgba(90,60,20,0.2);
}
.parchment pre {
  background: var(--wood-900); color: var(--parch);
  padding: 12px 14px; border-radius: 5px; overflow-x: auto;
  border: 1px solid var(--wood-600); font-size: 13px;
}
.parchment pre code { background: none; border: 0; padding: 0; color: inherit; }
.parchment a {
  color: var(--blood); font-weight: 600; text-decoration: none;
  border-bottom: 1.5px dotted var(--blood);
}
.parchment a:hover { color: var(--ember); border-bottom-style: solid; }

/* Tables = ledger rows */
.parchment table {
  border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 14.5px;
  box-shadow: 0 2px 6px rgba(80,50,20,0.2);
}
.parchment th {
  font-family: var(--font-gob); font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; font-size: 12px;
  background: linear-gradient(180deg, #5a3c12, #432c0c);
  color: var(--gold-bright); padding: 7px 12px; text-align: left;
  border: 1px solid #2e1d08;
}
.parchment td {
  padding: 6px 12px; border: 1px solid rgba(110,80,35,0.35);
  background: rgba(255,255,255,0.16);
}
.parchment tbody tr:nth-child(even) td { background: rgba(150,110,50,0.12); }
.parchment td:first-child { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Follow-up chips = "More to chew on" splinter tags */
.followups-label {
  font-family: var(--font-gob); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; font-size: 11px; color: var(--green-deep);
  margin: 14px 0 7px; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.followups { display: flex; flex-wrap: wrap; gap: 8px; }
.followup {
  font-family: var(--font-read); font-size: 13.5px; font-weight: 500;
  background: linear-gradient(180deg, #5d3e16, #422c0e);
  color: var(--parch);
  border: 1.5px solid var(--gold-deep);
  border-radius: 3px;
  padding: 6px 13px 6px 11px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.followup::before {
  content: "⛏"; font-size: 12px; color: var(--accent);
  transition: transform 0.2s;
}
.followup:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 10px rgba(0,0,0,0.45), 0 0 12px var(--accent-glow);
}
.followup:hover::before { transform: rotate(-25deg); }

/* ---- Composer ---------------------------------------------------- */
#composer {
  display: flex; gap: 12px; align-items: stretch;
  padding: 16px 24px 20px;
  background: linear-gradient(0deg, var(--wood-800), transparent);
  position: relative; z-index: 4;
}
.composer-field {
  flex: 1; position: relative; display: flex; align-items: center;
  background: linear-gradient(180deg, var(--wood-900), var(--wood-700));
  border: 2px solid var(--wood-500);
  border-radius: 5px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
  overflow: hidden;
}
.composer-field:focus-within {
  border-color: var(--accent);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), 0 0 0 1px var(--accent), 0 0 16px var(--accent-glow);
}
#question {
  flex: 1; padding: 14px 16px; border: 0; background: transparent;
  color: var(--parch); font-family: var(--font-read); font-size: 16px;
  outline: none;
}
#question::placeholder { color: rgba(236,217,168,0.4); font-style: italic; }
#question:disabled { cursor: not-allowed; }

/* Big goblin "Shred it!" button */
.ask-btn {
  font-family: var(--font-gob); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 16px;
  padding: 0 26px;
  border: 2px solid #6e1d12;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--ember-bright), var(--ember) 55%, var(--blood));
  color: #fff5ec;
  cursor: pointer;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
  box-shadow: 0 4px 0 #6e1d12, 0 6px 10px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
  display: flex; align-items: center; gap: 9px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.ask-btn:hover:not(:disabled) { filter: brightness(1.08); }
.ask-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 #6e1d12, 0 2px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
}
.ask-btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.ask-btn svg { width: 20px; height: 20px; }

/* ============================================================
   SETTINGS — "Workshop Credentials"
   ============================================================ */
.settings-scrim {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(10,6,2,0.62);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: grid; place-items: center;
  animation: fade 0.2s ease;
}
.settings-scrim[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.settings {
  width: 440px; max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px); overflow-y: auto;
  border-radius: 7px;
  border: 3px solid var(--wood-900);
  background:
    linear-gradient(160deg, var(--parch), var(--parch-2));
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  animation: pop 0.28s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes pop { from { transform: scale(0.92) translateY(8px); } to { transform: none; } }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(180deg, #5a3c12, #3c2709);
  border-bottom: 2px solid var(--gold-deep);
}
.settings-head h2 {
  margin: 0; font-family: var(--font-carve); font-weight: 700; font-size: 19px;
  color: var(--gold-bright); letter-spacing: 0.03em; border: 0;
  display: flex; align-items: center; gap: 10px;
}
.settings-close {
  border: 0; background: rgba(0,0,0,0.25); color: var(--parch);
  width: 30px; height: 30px; border-radius: 4px; cursor: pointer; font-size: 16px;
}
.settings-close:hover { background: var(--blood); }
.settings-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.settings-intro {
  font-size: 14px; font-style: italic; color: var(--ink-soft);
  margin: 0; line-height: 1.5;
}
.field label {
  display: block; font-family: var(--font-gob); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; font-size: 12px;
  color: #5a3c12; margin-bottom: 5px;
}
.field input {
  width: 100%; padding: 10px 12px; border-radius: 4px;
  border: 2px solid var(--parch-edge); background: rgba(255,255,255,0.55);
  color: var(--ink); font-family: var(--font-mono); font-size: 14px;
  box-shadow: inset 0 1px 3px rgba(120,90,40,0.25);
}
.field input:focus { outline: none; border-color: var(--green-deep); background: #fff; }
.field .help {
  font-size: 12px; color: var(--blood); text-decoration: none; font-weight: 600;
  display: inline-block; margin-top: 5px;
}
.field .help:hover { text-decoration: underline; }
.settings-note {
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; margin: 0;
  background: rgba(147,207,69,0.16); border-left: 3px solid var(--green-deep);
  padding: 9px 12px; border-radius: 3px;
}
.settings-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn-save {
  flex: 1; font-family: var(--font-gob); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 14px; padding: 11px; cursor: pointer;
  border: 2px solid var(--green-deep); border-radius: 4px;
  background: linear-gradient(180deg, var(--green), var(--green-deep)); color: #16240a;
  box-shadow: 0 3px 0 #3f6a1f;
}
.btn-save:active { transform: translateY(3px); box-shadow: 0 0 0 #3f6a1f; }
.btn-clear {
  font-family: var(--font-gob); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; font-size: 14px; padding: 11px 18px; cursor: pointer;
  border: 2px solid var(--wood-600); border-radius: 4px;
  background: var(--wood-600); color: var(--parch);
}
.btn-clear:hover { background: var(--blood); border-color: var(--blood); }

/* ============================================================
   EMPTY / WELCOME STATE
   ============================================================ */
.welcome {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
  justify-content: safe center; gap: 4px; text-align: center; padding: 20px 30px;
}
.welcome-mascot { margin-bottom: 10px; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45)); }
.welcome-mascot img { width: clamp(80px, 14vh, 160px); height: auto; }
.welcome h2 {
  font-family: var(--font-carve); font-weight: 800; font-size: 30px;
  color: var(--gold-bright); margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6); border: 0;
}
.welcome .sub {
  font-size: 17px; color: var(--parch); font-style: italic;
  max-width: 560px; margin: 8px 0 2px; line-height: 1.5;
}
.welcome .quip {
  font-family: var(--font-gob); text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 12px; color: var(--green); margin-bottom: 18px;
}
.welcome-disclaimer {
  max-width: 540px; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px;
}
.welcome-disclaimer p {
  margin: 0; font-size: 13px; line-height: 1.5; color: var(--parch);
  background: rgba(147,207,69,0.16); border-left: 3px solid var(--green-deep);
  padding: 9px 12px; border-radius: 3px; text-align: left;
}
.welcome-disclaimer strong { color: var(--gold-bright); }

/* Easter egg: "the house always wins" tag under any answer naming Ozzyoxbourne */
.house-wins {
  margin-top: 14px; font-family: var(--font-gob); font-size: 12px;
  letter-spacing: 0.05em; color: var(--gold-deep); font-style: italic; opacity: 0.85;
}

/* ============================================================
   RIGHT RAIL — THE SHREDDER (Fizzwick's workshop)
   ============================================================ */
#shredder {
  position: relative;
  display: flex; flex-direction: column;
  border-left: 4px solid var(--wood-900);
  background-color: var(--wood-650);
  background-image:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,0) 13px, rgba(0,0,0,0.22) 15px),
    linear-gradient(180deg, var(--wood-600), var(--wood-800));
  box-shadow: inset 6px 0 20px -8px rgba(0,0,0,0.8);
  overflow: hidden;
}
.shredder-head {
  padding: 14px 18px 12px;
  background: linear-gradient(180deg, var(--iron-light), var(--iron));
  border-bottom: 3px solid #11100e;
  position: relative;
}
.shredder-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--hazard) 0 12px, #11100e 12px 24px);
}
.shredder-title {
  font-family: var(--font-carve); font-weight: 700; font-size: 17px;
  color: var(--gold-bright); margin: 0; letter-spacing: 0.03em;
  display: flex; align-items: center; gap: 9px;
}
.shredder-sub {
  font-family: var(--font-gob); text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 10px; color: var(--green); margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
}
.status-led {
  width: 8px; height: 8px; border-radius: 50%;
  background: #5a6b3a; box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.status-led.live {
  background: var(--ember-bright);
  box-shadow: 0 0 8px var(--ember-bright), 0 0 0 1px rgba(0,0,0,0.4);
  animation: led-pulse 0.7s steps(2) infinite;
}
@keyframes led-pulse { 50% { opacity: 0.4; } }
.status-led.armed {
  background: var(--green);
  box-shadow: 0 0 7px var(--accent-glow), 0 0 0 1px rgba(0,0,0,0.4);
}

/* The machine itself */
.machine-stage {
  position: relative; height: 220px; flex-shrink: 0;
  background:
    radial-gradient(80% 60% at 50% 120%, rgba(216,167,62,0.12), transparent 70%),
    linear-gradient(180deg, var(--wood-700), var(--wood-900));
  border-bottom: 3px solid #11100e;
  overflow: hidden;
}
#chip-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

/* Steps log */
.steps-head {
  font-family: var(--font-gob); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.12em; font-size: 11px; color: var(--gold);
  padding: 12px 18px 6px; display: flex; justify-content: space-between; align-items: center; white-space: nowrap;
}
.steps-head .clear { color: var(--ink-soft); cursor: pointer; font-size: 10px; }
#steps {
  list-style: none; margin: 0; padding: 0 14px 18px; overflow-y: auto; flex: 1;
  scrollbar-width: thin; scrollbar-color: var(--wood-500) transparent;
}
#steps::-webkit-scrollbar { width: 8px; }
#steps::-webkit-scrollbar-thumb { background: var(--wood-500); border-radius: 4px; }
.step {
  font-family: var(--font-mono); font-size: 12px; color: var(--parch);
  padding: 8px 10px 8px 12px; margin-bottom: 6px;
  background: linear-gradient(90deg, rgba(0,0,0,0.28), rgba(0,0,0,0.1));
  border-left: 3px solid var(--accent); border-radius: 3px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  animation: step-in 0.3s ease both;
}
@keyframes step-in { from { transform: translateX(16px); } to { transform: none; } }
.step .s-txt { flex: 1; min-width: 0; }
.step .elapsed { color: var(--green); font-size: 11px; flex-shrink: 0; }
.step.error { border-left-color: var(--ember); color: var(--ember-bright); }
.step.error .elapsed { color: var(--ember-bright); }
.step.done { border-left-color: var(--gold); opacity: 0.78; }
.step .tick { color: var(--green); margin-right: 5px; }
.step .pending { color: var(--gold); margin-right: 5px; animation: led-pulse 0.6s steps(2) infinite; }

.shredder-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 24px; gap: 10px;
  color: var(--ink-soft);
}
.shredder-empty .big { font-family: var(--font-gob); text-transform: uppercase;
  letter-spacing: 0.12em; font-size: 12px; color: var(--gold); }
.shredder-empty .small { font-size: 13px; font-style: italic; line-height: 1.5; max-width: 230px; }

/* typing dots in mascot speech */
.thinking { display: inline-flex; gap: 5px; align-items: center; padding: 4px 0; }
.thinking i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft);
  animation: chew 0.9s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chew { 0%,100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(-5px); opacity: 1; } }

/* shake utility when shredder kicks */
@keyframes rattle {
  0%,100% { transform: translate(0,0) rotate(0); }
  20% { transform: translate(-1px,1px) rotate(-0.3deg); }
  40% { transform: translate(1px,-1px) rotate(0.3deg); }
  60% { transform: translate(-1px,0) rotate(-0.2deg); }
  80% { transform: translate(1px,1px) rotate(0.2deg); }
}
.rattling { animation: rattle 0.18s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}


/* ============================================================
   SHREDDER MACHINE ANIMATIONS
   State classes are toggled on #app by shredder.js:
     #app.armed   → blade idle-spins
     #app.working → fast blade + smoke + lever + feed-log
   ============================================================ */

/* SVG element transform origins (SVG coordinate space) */
#blade-group   { transform-origin: 150px 134px; }
#feed-log-grp  { transform-origin: 170px 30px; }
#lever         { transform-origin: 300px 150px; }
#goblin        { transform-origin: 262px 130px; }
.smoke-puff    { opacity: 0; transform-origin: 284px 30px; }

/* Goblin idle sway (always on) */
#goblin { animation: gob-idle 3s ease-in-out infinite; }

/* Armed: blade idles, green LED */
#app.armed  #blade-group { animation: blade-spin 2.4s linear infinite; }

/* Working: everything fires */
#app.working #blade-group  { animation: blade-spin 0.18s linear infinite; }
#app.working #feed-log-grp { animation: feed-log  0.9s ease-in infinite; }
#app.working #lever        { animation: lever     0.4s ease-in-out infinite; }
#app.working #goblin       { animation: gob-work  0.4s ease-in-out infinite; }
#app.working .smoke-puff   { animation: puff 1.1s ease-out infinite; opacity: 1; }
#app.working .smoke-puff:nth-child(2) { animation-delay: 0.35s; }
#app.working .smoke-puff:nth-child(3) { animation-delay: 0.7s; }
#app.working .machine-stage { animation: rattle 0.18s linear infinite; }

@keyframes blade-spin { to { transform: rotate(360deg); } }
@keyframes puff       { 0%{transform:translateY(0) scale(0.5);opacity:.7} 100%{transform:translateY(-30px) scale(1.6);opacity:0} }
@keyframes feed-log   { 0%{transform:translateY(-6px)} 60%{transform:translateY(8px)} 100%{transform:translateY(-6px)} }
@keyframes lever      { 0%,100%{transform:rotate(0deg)} 50%{transform:rotate(20deg)} }
@keyframes gob-work   { 0%,100%{transform:translateY(0)} 50%{transform:translateY(2px)} }
@keyframes gob-idle   { 0%,100%{transform:translateY(0) rotate(0)} 50%{transform:translateY(-1px) rotate(2deg)} }

/* ============================================================
   RESPONSIVE — phones (≤768px)
   The two-column grid (1fr + 380px shredder rail) collapses the chat
   on narrow screens. Drop to a single full-height chat column and hide
   the decorative shredder rail; streaming tokens + the in-bubble
   thinking dots remain the working indicator. Tighten the topbar and
   composer so nothing crowds at ~375px.
   ============================================================ */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    height: 100dvh;
  }
  #shredder { display: none; }

  /* Topbar controls (model + status + cog) don't fit beside the brand at
     ~375px and were clipped off-screen by #chat's overflow:hidden — taking
     the settings cog (needed to enter keys) with them. Let the bar wrap so
     the controls drop to their own full-width row, right-aligned. */
  #topbar { padding: 10px 14px; flex-wrap: wrap; row-gap: 10px; }
  .brand { gap: 10px; }
  .brand-badge { width: 42px; }
  .brand-plaque h1 { font-size: 21px; }
  .brand-plaque .tagline { display: none; }
  .topbar-right { gap: 8px; flex: 1 0 100%; justify-content: flex-end; }
  /* Lock/armed status is conveyed by the disabled composer + its placeholder
     (and settings auto-opens when keys are missing), so drop the wide status
     chip on mobile to keep the model picker + cog on one tidy row. */
  #keys-status { display: none; }

  .welcome { padding: 16px 18px; }
  .welcome h2 { font-size: 23px; }
  .welcome .sub { font-size: 15px; }

  #composer { padding: 12px 14px 16px; gap: 8px; }
  .ask-btn { padding: 0 16px; font-size: 14px; }

  /* Tip menu wraps; Discord drops below the tip buttons. */
  .tip-toggle { margin: 6px 0 7px 14px; }
  .tip-panel { padding-left: 14px; padding-right: 14px; }
  #tip-bar.open .tip-panel { padding-left: 14px; padding-right: 14px; }
  .discord-btn { margin-left: 0; }
  .tip-btn { font-size: 12px; padding: 6px 11px; }
  .tip-fine { font-size: 10px; }
}

/* ============================================================
   TIP JAR + CONTACT — slim footer strip under the composer
   ============================================================ */
#tip-bar {
  flex: 0 0 auto;
  background: linear-gradient(0deg, var(--wood-900), var(--wood-800));
  border-top: 1px solid var(--wood-600);
  display: flex; flex-direction: column;
  position: relative; z-index: 4;
}
/* Collapsed-by-default toggle — keeps the tip menu from being forced on. */
.tip-toggle {
  align-self: flex-start;
  margin: 7px 0 8px 24px;
  font-family: var(--font-gob); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; font-size: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 5px;
  border: 1.5px solid var(--gold-deep);
  background: linear-gradient(180deg, var(--wood-700), var(--wood-800));
  color: var(--gold); cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  transition: color .12s, border-color .12s, box-shadow .12s;
}
.tip-toggle:hover {
  color: var(--gold-bright); border-color: var(--gold);
  box-shadow: 0 0 14px rgba(216,167,62,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}
.tip-toggle .caret { font-size: 9px; transition: transform .22s ease; }
#tip-bar.open .tip-toggle .caret { transform: rotate(180deg); }
/* Expandable menu — height/opacity animate open from the toggle. */
.tip-panel {
  max-height: 0; overflow: hidden; opacity: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 24px;
  transition: max-height .26s ease, opacity .2s ease, padding .26s ease;
}
#tip-bar.open .tip-panel { max-height: 240px; opacity: 1; padding: 11px 24px 3px; }
.tip-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tip-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.tip-btn {
  font-family: var(--font-gob); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; font-size: 13px;
  padding: 7px 13px; border-radius: 4px;
  border: 2px solid var(--gold-deep);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  color: var(--wood-900); text-decoration: none; white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 3px 0 var(--gold-deep), 0 4px 7px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
}
.tip-btn span { font-weight: 800; }
.tip-btn:hover { filter: brightness(1.07); }
.tip-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--gold-deep), 0 1px 4px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.4);
}
.discord-btn {
  margin-left: auto;
  font-family: var(--font-gob); font-weight: 500; letter-spacing: 0.03em; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 4px;
  border: 2px solid #2a2e52;
  background: linear-gradient(180deg, #5865f2, #4450c8);
  color: #f2f3ff; cursor: pointer; white-space: nowrap;
  box-shadow: 0 3px 0 #2a2e52, 0 4px 7px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
}
.discord-btn:hover { filter: brightness(1.1); }
.discord-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #2a2e52, inset 0 1px 0 rgba(255,255,255,0.18);
}
.discord-btn svg { width: 18px; height: 18px; fill: #fff; }
.tip-fine {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
  font-family: var(--font-read); font-size: 10.5px; line-height: 1.4;
  color: rgba(236,217,168,0.42);
}
.tip-fine .dot { opacity: 0.55; }

/* Goblin toast — Discord-handle copy confirmation */
.tl-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 18px);
  z-index: 60; pointer-events: none; max-width: 90vw;
  font-family: var(--font-gob); font-size: 14px; letter-spacing: 0.02em;
  padding: 10px 18px; border-radius: 6px;
  background: linear-gradient(180deg, var(--wood-700), var(--wood-900));
  border: 2px solid var(--gold-deep); color: var(--gold-bright);
  box-shadow: 0 6px 20px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.08);
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
}
.tl-toast.show { opacity: 1; transform: translate(-50%, 0); }
