/* ============================================================
   Mac mini console
   A panel, not a product. Graphite chassis, two voices:
   sand for you, lilac for the machine, one green LED for life.
   ============================================================ */

:root {
  --ink:        #0d0f12;
  --panel:      #14171b;
  --panel-2:    #191d22;
  --edge:       #262c34;
  --edge-soft:  #1c2128;
  --text:       #e6e9ec;
  --text-dim:   #b3bcc5;
  --muted:      #7c8792;
  --human:      #e3bd85;   /* your voice */
  --machine:    #a8a4ff;   /* the model's voice */
  --led:        #5fd3a0;
  --alert:      #ff8f6b;

  --serif: "Source Serif 4", Iowan Old Style, Georgia, serif;
  --sans:  "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --rail-h: 52px;
  --measure: 46rem;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* A faint vertical grain — the brushed face of the chassis. */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(168,164,255,.06), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.014) 0 1px, transparent 1px 3px);
  z-index: 0;
}

/* Author display rules (display:grid/flex below) outrank the UA's
   [hidden] rule, so state it once here and let `hidden` mean hidden. */
[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor;
      stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible {
  outline: 2px solid var(--machine);
  outline-offset: 2px;
  border-radius: 3px;
}

.label {
  font-size: 10.5px; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}

/* --------------------------------------------------------------- LED --- */

.led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 transparent;
  flex: none;
  transition: background .4s var(--ease), box-shadow .4s var(--ease);
}
.led-on   { background: var(--led);   box-shadow: 0 0 9px rgba(95,211,160,.65); }
.led-off  { background: var(--alert); box-shadow: 0 0 9px rgba(255,143,107,.5); }
.led-idle { animation: breathe 2.4s var(--ease) infinite; }
@keyframes breathe { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

/* -------------------------------------------------------------- gate --- */

.gate {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 24px;
  background: var(--ink);
}
.gate-card {
  position: relative;
  width: min(340px, 100%);
  display: flex; flex-direction: column;
  animation: rise .5s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) } }

.gate-mark {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  display: grid; place-items: center;
  margin-bottom: 22px;
}
.gate-title {
  font-family: var(--serif);
  font-size: 30px; font-weight: 600; letter-spacing: -.015em;
  margin: 0 0 6px;
}
.gate-sub {
  margin: 0 0 26px;
  font-size: 13.5px; line-height: 1.55; color: var(--muted);
  max-width: 30ch;
}

.field { display: block; }
.field-label {
  display: block; margin-bottom: 8px;
  font-size: 10.5px; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.field input {
  width: 100%;
  padding: 11px 13px;
  font-family: var(--mono); font-size: 14px; letter-spacing: .08em;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 8px;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.field input:focus { outline: none; border-color: var(--machine); background: var(--panel-2); }

.gate-error {
  margin: 12px 0 0;
  font-size: 12.5px; color: var(--alert);
  animation: nudge .3s var(--ease);
}
@keyframes nudge { 0%,100% { transform: none } 25% { transform: translateX(-4px) } 75% { transform: translateX(4px) } }

.btn-primary {
  margin-top: 18px;
  padding: 11px 16px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 13px; font-weight: 500; letter-spacing: .02em;
  cursor: pointer;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.btn-primary:hover:not(:disabled) { background: #212630; border-color: #333b45; }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: default; }

/* --------------------------------------------------------------- app --- */

.app {
  position: relative; z-index: 1;
  height: 100%;
  display: grid;
  grid-template-rows: var(--rail-h) 1fr auto;
}

/* ------- status rail: the signature. Real telemetry, nothing decorative. */

.rail {
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--edge-soft);
  background: rgba(13,15,18,.86);
  backdrop-filter: blur(12px);
}
.host { display: flex; align-items: center; gap: 8px; }
.host-name {
  font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  white-space: nowrap;
}
.rail-mid {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  padding-left: 14px;
  border-left: 1px solid var(--edge-soft);
  margin-left: 2px;
}
.select-wrap { position: relative; display: flex; align-items: center; }
.select-wrap select {
  appearance: none;
  padding: 4px 22px 4px 8px;
  max-width: 46vw;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-overflow: ellipsis;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.select-wrap select:hover { border-color: var(--edge); background: var(--panel); }
.select-wrap select option { background: var(--panel); color: var(--text); }
.chev { position: absolute; right: 7px; width: 10px; height: 10px; color: var(--muted); pointer-events: none; }

.tele {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted); letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tele b { color: var(--machine); font-weight: 500; }
.beat {
  display: inline-block; width: 4px; height: 10px;
  margin-right: 5px; vertical-align: -1px;
  background: var(--machine);
  animation: blink 1s steps(2, start) infinite;
}

.icon-btn {
  width: 30px; height: 30px; padding: 7px;
  flex: none;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--muted); cursor: pointer;
  transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--panel); border-color: var(--edge); }

/* ---------------------------------------------------------- transcript -- */

.transcript {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.transcript::-webkit-scrollbar { width: 10px; }
.transcript::-webkit-scrollbar-thumb { background: var(--edge); border: 3px solid var(--ink); border-radius: 6px; }

.turns { max-width: var(--measure); margin: 0 auto; padding: 26px 22px 40px; }

.empty {
  max-width: var(--measure); margin: 0 auto;
  padding: 16vh 22px 0;
  animation: rise .6s var(--ease) both;
}
.empty-line { margin: 0 0 8px; font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.empty-sub { margin: 0 0 22px; font-size: 14px; line-height: 1.6; color: var(--muted); max-width: 42ch; }
.caps { display: flex; flex-wrap: wrap; gap: 6px; }
.cap {
  padding: 3px 9px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--edge-soft); border-radius: 20px;
}
.cap-on { color: var(--machine); border-color: rgba(168,164,255,.3); }

/* ------- a turn: gutter mark + block. No bubbles. */

.turn { padding: 20px 0; border-top: 1px solid var(--edge-soft); }
.turn:first-child { border-top: 0; padding-top: 4px; }

.turn-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.who {
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
}
.turn-user .who { color: var(--human); }
.turn-assistant .who { color: var(--machine); }
.turn-head .rule { flex: 1; height: 1px; background: var(--edge-soft); }
.turn-head .stat {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap;
}
.turn-head .copy { opacity: 0; transition: opacity .18s var(--ease); }
.turn:hover .copy, .copy:focus-visible { opacity: 1; }

.prose {
  font-family: var(--serif);
  font-size: 16.5px; line-height: 1.68;
  color: var(--text);
  overflow-wrap: anywhere;
}
.turn-user .prose { color: var(--text-dim); }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .85em; }
.prose h1, .prose h2, .prose h3 {
  font-family: var(--sans); font-weight: 500; letter-spacing: -.005em;
  margin: 1.4em 0 .5em; line-height: 1.3;
}
.prose h1 { font-size: 1.28em; }
.prose h2 { font-size: 1.15em; }
.prose h3 { font-size: 1.02em; color: var(--text-dim); }
.prose ul, .prose ol { margin: 0 0 .9em; padding-left: 1.25em; }
.prose li { margin: .25em 0; }
.prose li::marker { color: var(--muted); }
.prose a { color: var(--machine); text-decoration-color: rgba(168,164,255,.4); text-underline-offset: 2px; }
.prose blockquote {
  margin: 0 0 .9em; padding: .1em 0 .1em 1em;
  border-left: 2px solid var(--edge); color: var(--muted); font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--edge-soft); margin: 1.4em 0; }
.prose code {
  font-family: var(--mono); font-size: .82em;
  padding: .12em .4em; border-radius: 4px;
  background: var(--panel-2); color: #d8c9a8;
}
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-family: var(--sans); font-size: .88em; }
.prose th, .prose td { border: 1px solid var(--edge-soft); padding: 6px 9px; text-align: left; }
.prose th { color: var(--muted); font-weight: 500; }

.code-block {
  position: relative;
  margin: 0 0 1em;
  border: 1px solid var(--edge-soft); border-radius: 9px;
  background: #0f1216;
  overflow: hidden;
}
.code-block header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--edge-soft);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code-block code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; color: #cdd6e0; }

/* ------- thinking: folded away, but never hidden. */

.think {
  margin: 0 0 12px;
  border-left: 2px solid rgba(168,164,255,.22);
  padding-left: 12px;
}
.think summary {
  list-style: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  color: var(--muted);
  display: flex; align-items: center; gap: 7px;
}
.think summary::-webkit-details-marker { display: none; }
/* Drawn, not typed: the disclosure arrow must not depend on a font glyph. */
.think summary::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 4.5px solid var(--machine);
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform .18s var(--ease);
}
.think[open] summary::before { transform: rotate(90deg); }
.think summary:hover { color: var(--text-dim); }
.think-body {
  margin-top: 8px;
  font-family: var(--serif); font-size: 14px; line-height: 1.6;
  color: var(--muted); white-space: pre-wrap;
  max-height: 300px; overflow-y: auto;
}

/* ------- images */

.shots { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.shots img {
  height: 132px; width: auto; max-width: 100%;
  border-radius: 8px; border: 1px solid var(--edge);
  display: block; object-fit: cover;
}

/* ------- the caret: proof something is still arriving */

.caret {
  display: inline-block;
  width: .5em; height: 1.02em;
  margin-left: 2px;
  vertical-align: -.16em;
  background: var(--machine);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0 } }

.turn-error {
  font-family: var(--sans); font-size: 13.5px;
  color: var(--alert);
  border-left: 2px solid var(--alert); padding-left: 12px;
}

/* ---------------------------------------------------------- composer --- */

.composer-wrap {
  padding: 0 22px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--ink) 26%);
}

.banner {
  max-width: var(--measure); margin: 0 auto 10px;
  padding: 9px 12px;
  font-size: 12.5px; color: var(--alert);
  border: 1px solid rgba(255,143,107,.28); border-radius: 8px;
  background: rgba(255,143,107,.06);
}

.attachments {
  max-width: var(--measure); margin: 0 auto 10px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.thumb { position: relative; animation: rise .25s var(--ease) both; }
.thumb img { height: 62px; width: 62px; object-fit: cover; border-radius: 8px; border: 1px solid var(--edge); display: block; }
.thumb button {
  position: absolute; top: -6px; right: -6px;
  width: 19px; height: 19px; padding: 4px;
  border-radius: 50%; border: 1px solid var(--edge);
  background: var(--panel-2); color: var(--text-dim);
  cursor: pointer;
}
.thumb button:hover { color: var(--alert); }

.composer {
  max-width: var(--measure); margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 7px 7px 7px 9px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  transition: border-color .2s var(--ease);
}
.composer:focus-within { border-color: #3a4250; }
.composer .attach { margin-bottom: 2px; }

#input {
  flex: 1;
  min-height: 30px; max-height: 220px;
  padding: 5px 2px;
  font-family: var(--serif); font-size: 16px; line-height: 1.5;
  background: transparent; border: 0; resize: none;
  outline: none;
  scrollbar-width: thin;
}
#input::placeholder { color: var(--muted); }

.chip {
  margin-bottom: 3px;
  padding: 4px 10px;
  font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--edge-soft); border-radius: 20px;
  cursor: pointer; white-space: nowrap;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.chip:hover { color: var(--text-dim); border-color: var(--edge); }
.chip[aria-pressed="true"] {
  color: var(--machine); border-color: rgba(168,164,255,.4); background: rgba(168,164,255,.08);
}

.send {
  width: 34px; height: 34px; padding: 8px; flex: none;
  border: 1px solid var(--edge); border-radius: 9px;
  background: var(--panel-2); color: var(--text-dim);
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.send:hover:not(:disabled) { background: #232935; color: var(--text); }
.send:active:not(:disabled) { transform: translateY(1px); }
.send:disabled { opacity: .38; cursor: default; }
.send.stop { color: var(--alert); border-color: rgba(255,143,107,.3); }
.send.stop svg { fill: currentColor; stroke: none; }

.hint {
  max-width: var(--measure); margin: 9px auto 0;
  font-size: 10.5px; letter-spacing: .04em; color: #5c6670; text-align: center;
}
.hint kbd { font-family: var(--mono); font-size: 10px; color: #6d7883; }

/* ------- drop target */

.drop {
  position: fixed; inset: var(--rail-h) 0 0;
  z-index: 20;
  display: grid; place-items: center;
  background: rgba(13,15,18,.82);
  backdrop-filter: blur(3px);
}
.drop span {
  padding: 16px 26px;
  border: 1px dashed rgba(168,164,255,.5); border-radius: 12px;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--machine);
}

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

.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(8,9,11,.6); animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0 } }
.drawer-panel {
  position: absolute; inset: 0 auto 0 0;
  width: min(292px, 84vw);
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--edge);
  animation: slide .26s var(--ease);
}
@keyframes slide { from { transform: translateX(-100%) } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--rail-h); padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--edge-soft);
}
.conv-list { flex: 1; overflow-y: auto; margin: 0; padding: 8px; list-style: none; }
.conv-list li { position: relative; }
.conv-list button.open {
  display: block; width: 100%; text-align: left;
  padding: 9px 34px 9px 11px;
  background: transparent; border: 0; border-radius: 8px;
  font-size: 13px; color: var(--text-dim); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.conv-list button.open:hover { background: var(--panel-2); color: var(--text); }
.conv-list li.active button.open { color: var(--machine); background: rgba(168,164,255,.07); }
.conv-list .del {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 22px; height: 22px; padding: 5px;
  background: transparent; border: 0; border-radius: 5px;
  color: var(--muted); cursor: pointer; opacity: 0;
  transition: opacity .16s var(--ease), color .16s var(--ease);
}
.conv-list li:hover .del, .del:focus-visible { opacity: 1; }
.conv-list .del:hover { color: var(--alert); }
.conv-empty { padding: 14px 11px; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------- responsive - */

@media (max-width: 720px) {
  .turns { padding: 20px 16px 32px; }
  .composer-wrap { padding: 0 12px calc(10px + env(safe-area-inset-bottom)); }
  .empty { padding-top: 12vh; padding-inline: 16px; }
  .tele { display: none; }
  .hint { display: none; }
  .prose { font-size: 16px; }
  .select-wrap select { max-width: 38vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .caret { animation: none; opacity: .85; }
}
