:root {
  --bg: #191918;
  --fg: #e7e5de;
  --dim: #8f8d86;
  --faint: #4a4945;
  --accent: #d77757;  /* Claude Code's orange, same in both themes */
  --shine: #eb9f7f;
  --sel: #b1b9f9;
  --ok: #4eba65;
  --err: #ff6b80;
  --user-bg: #2b2b29;
  --link: var(--sel);  /* links share the command highlight color */
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #faf9f5;
  --fg: #1f1e1c;
  --dim: #6f6d66;
  --faint: #c9c6bc;
  --accent: #d77757;
  --shine: #f59575;
  --sel: #4a5ae0;  /* a bit darker than Claude Code's #5769f7, for readability */
  --ok: #2c7a39;
  --err: #ab2b3f;
  --user-bg: #ecebe4;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

@media (max-width: 600px) {
  body { font-size: 12.5px; }
}

::selection { background: var(--accent); color: var(--bg); }

.term {
  display: flex;
  flex-direction: column;
  max-width: 110ch;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px 0;
}

p { margin: 0; }
b, .bold { font-weight: 700; }
.dim { color: var(--dim); }
.accent { color: var(--accent); }
.ok { color: var(--ok); }
.err { color: var(--err); }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

kbd { font: inherit; color: var(--fg); }

button.cmd, button.hint, button.copy {
  all: unset;
  cursor: pointer;
}
button.cmd { color: var(--sel); }
button.cmd:hover, button.copy:hover, button.hint:hover { text-decoration: underline; }
button.cmd:focus-visible, button.copy:focus-visible, button.hint:focus-visible {
  outline: 1px solid var(--sel);
  outline-offset: 1px;
}
button.copy { color: var(--dim); }
/* [bracketed] links: the brackets already say "clickable", so no underline until hover */
a.bracket { text-decoration: none; }
a.bracket:hover { text-decoration: underline; }
.file { margin-right: 2ch; }

/* ── welcome box (pinned to the top) ─────────────────────── */

#welcome {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -16px -16px 12px;
  padding: 12px 16px 0;
  background: var(--bg);
}
#welcome::after {
  /* soft fade so the transcript scrolls under the header */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  height: 12px;
  background: linear-gradient(var(--bg), transparent);
  pointer-events: none;
}
.welcome {
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin: 0;
  padding: 2px 2ch 8px;
  min-width: 0;
}
.welcome legend {
  color: var(--accent);
  padding: 0 1ch;
  margin-left: 1ch;
}
.wl {
  display: flex;
  align-items: center;
  gap: 2ch;
}
.wl-id {
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.wl-right {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 2ch;
  align-content: center;
  padding-left: 2ch;
  border-left: 1px solid var(--accent);
}
.wl-sub { display: inline-block; }  /* fixed-width sub-label inside a header row */
.wl-right > span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
@media (max-width: 760px) {
  .wl-right { display: none; }
}

.mascot {
  --px: 4px;
  display: grid;
  grid-auto-rows: var(--px);
  flex: 0 0 auto;
  cursor: pointer;
  user-select: none;
}
.mascot i { display: block; width: var(--px); height: var(--px); }
@media (max-width: 600px) {
  .mascot { --px: 3px; }
}
.mascot.hop { animation: hop 0.45s ease; }
.mascot.shake { animation: shake 0.4s ease; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}
/* Murphy is mostly white: give her a faint outline on the light theme */
:root[data-theme="light"] .mascot {
  filter: drop-shadow(1px 0 0 #0004) drop-shadow(-1px 0 0 #0004) drop-shadow(0 1px 0 #0004) drop-shadow(0 -1px 0 #0004);
}

/* ── transcript ──────────────────────────────────────────── */

#log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  display: flex;
  gap: 1ch;
  min-width: 0;
}
.msg > .dot { flex: 0 0 1ch; }
.msg .body, .msg .call {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.msg .body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg.user {
  background: var(--user-bg);
  padding: 2px 1ch;
  margin: 4px 0 0;
  border-radius: 3px;
}
.msg.user .caret { color: var(--dim); }

.dot.pending { color: var(--dim); animation: blink 0.8s steps(2, start) infinite; }
.dot.ok { color: var(--ok); }
.dot.err { color: var(--err); }
@keyframes blink { to { visibility: hidden; } }

.result { color: var(--dim); }

.spin { display: inline-block; width: 1ch; color: var(--accent); }
.verb {
  background: linear-gradient(90deg, var(--accent) 35%, var(--shine) 50%, var(--accent) 65%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

.pending { display: none !important; }

.table {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 3ch;
  row-gap: 2px;
}
.row { display: contents; }

.card { display: flex; flex-direction: column; }
.indent { padding-left: 2ch; }

ul.list { margin: 0; padding: 0; list-style: none; }
ul.list li { padding-left: 2ch; text-indent: -2ch; }
ul.list li::before { content: '- '; color: var(--dim); }

/* ── prompt (pinned to the bottom) ───────────────────────── */

.dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin: 12px -16px 0;
  padding: 8px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
}
.dock::before {
  /* soft fade so the transcript scrolls under the prompt */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}

.prompt {
  display: flex;
  align-items: center;
  gap: 1ch;
  padding: 6px 1ch;
  border: 1px solid var(--faint);
  border-radius: 6px;
}
.prompt:focus-within { border-color: var(--dim); }
.prompt button.caret {
  all: unset;
  color: var(--fg);
  cursor: pointer;
}
.prompt button.caret:hover { color: var(--accent); }
.prompt button.caret:focus-visible { outline: 1px solid var(--sel); outline-offset: 1px; }
.prompt input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  caret-color: var(--fg);
  caret-shape: block;
}
.prompt input::placeholder { color: var(--dim); opacity: 1; }
@media (pointer: coarse) {
  /* stops iOS from zooming the page when the input is focused */
  .prompt input { font-size: 16px; }
}

.menu {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 1ch;
}
.menu li {
  display: grid;
  grid-template-columns: 16ch 1fr;
  gap: 2ch;
  color: var(--dim);
  cursor: pointer;
}
.menu li[aria-selected="true"] { color: var(--sel); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 2ch;
  padding: 4px 1ch;
  white-space: nowrap;
  color: var(--dim);
}
.status::before { content: '● '; color: var(--ok); }
.status[data-mood="hissing"]::before { color: var(--err); }
.status[data-mood="sleepy"]::before { color: var(--dim); }
.status:empty { display: none; }

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22ch, 1fr));
  gap: 2px 2ch;
  padding: 0 1ch;
  color: var(--dim);
}
.shortcuts[hidden], .menu[hidden] { display: none; }

/* ── resume popup ─────────────────────────────────────────── */

.viewer {
  --viewer-speed: 0.18s;  /* keep in sync with VIEWER_MS in app.js */
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(2px);
  /* open/close transition: the backdrop fades, the window lifts in (see .open below) */
  opacity: 0;
  transition: opacity var(--viewer-speed) ease-out;
}
.viewer[hidden] { display: none; }
.viewer.open { opacity: 1; }
html.viewer-open { overflow: hidden; }

.viewer-window {
  /* the same orange-bordered box as the header */
  display: flex;
  flex-direction: column;
  width: min(100%, 92ch);
  max-height: calc(100dvh - 48px);
  min-width: 0;
  margin: 0;
  padding: 2px 2ch 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 12px 48px #0009;
  outline: none;  /* it takes focus on open; no ring needed */
  transform: translateY(10px) scale(0.98);
  transition: transform var(--viewer-speed) ease-out;
}
.viewer.open .viewer-window { transform: none; }
.viewer-window legend {
  color: var(--accent);
  font-weight: 700;
  padding: 0 1ch;
  margin-left: 1ch;
}
/* the regular orange is faint as title text on the light theme; use a deeper shade (text only) */
:root[data-theme="light"] .viewer-window legend { color: #b9552f; }
.viewer-bar {
  text-align: right;
  padding: 0 0 8px;
}
.viewer-close {
  all: unset;
  margin-left: 1ch;
  color: var(--dim);
  cursor: pointer;
}
.viewer-close:hover { color: var(--fg); }
.viewer-close:focus-visible { outline: 1px solid var(--sel); outline-offset: 1px; }
.viewer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--faint);
  border-radius: 4px;
  background: #fff;
}
.viewer-body img { display: block; width: 100%; height: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
