/* Parley: warm ink, cream paper, one hot vermilion. The spoken line is set in a
   serif like a line of dialogue in a script; everything else stays quiet. */

:root {
  --bg: #14110f;
  --surface: #1c1815;
  --surface-2: #26201c;
  --line: #342b25;
  --text: #f3ebe0;
  --muted: #9d9087;
  --faint: #6b5f57;
  --accent: #ff5a36;
  --accent-ink: #1a0d08;
  --accent-soft: rgba(255, 90, 54, 0.13);
  --them: #8fd1b6;
  --them-soft: rgba(143, 209, 182, 0.12);
  --good: #8fd1b6;
  --bad: #ff6f61;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Space Grotesk", "Segoe UI Variable", system-ui, -apple-system, sans-serif;
  font-family: var(--sans);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

/* A faint glow behind the top, so the page isn't a flat slab. */
body {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
  background:
    radial-gradient(120% 50% at 0% 0%, rgba(255, 90, 54, 0.09), transparent 60%),
    var(--bg);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* --- Header: brand, mode, clear, all on one line --------------------------------- */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 6px;
}

.brand { display: flex; align-items: baseline; gap: 3px; margin-right: auto; }
.name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.5px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.modes { display: flex; gap: 2px; }
.modes button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
}
.modes button:hover { color: var(--text); }
.modes button.on { color: var(--text); }
.modes button.on::after {
  content: "";
  position: absolute;
  left: 9px; right: 9px; bottom: 1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.clear {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 17px;
  padding: 4px 6px;
  border-radius: 8px;
}
.clear:hover { color: var(--text); background: var(--surface-2); }

/* --- Setup: the settings as one sentence ---------------------------------------- */

.setup { padding: 2px 0 10px; border-bottom: 1px solid var(--line); }

.sentence {
  margin: 0;
  font-size: 15px;
  line-height: 2;
  color: var(--muted);
}

.word {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  padding: 0 1px;
  text-decoration: underline dotted var(--faint);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  white-space: nowrap;
}
.word:hover { text-decoration-color: var(--text); }
.word.open { color: var(--accent); text-decoration: underline solid var(--accent); text-decoration-thickness: 2px; }
.word .icon { margin-right: 5px; display: inline-block; text-decoration: none; }

.drawer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 2px;
  animation: drop 0.14s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.12s, background 0.12s;
}
.chip:hover { border-color: var(--faint); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.chip .icon { font-size: 15px; }
.chip .sub { color: var(--muted); font-size: 12px; }

.code {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.chip.on .code { color: var(--accent); }

.chip-input {
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 16px;  /* 16px+ stops iOS zooming in */
  width: 220px;
  outline: none;
}

/* --- Feed: a transcript, not a stack of boxes ----------------------------------- */

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.empty { margin: auto; text-align: center; }
.empty-big {
  font-family: var(--serif);
  font-style: italic;
  font-size: 40px;
  margin: 0 0 6px;
  color: var(--text);
}
.muted { color: var(--muted); font-size: 14px; margin: 0; }

.card {
  position: relative;
  padding: 2px 30px 2px 14px;
  border-left: 2px solid var(--accent);
  animation: rise 0.18s ease-out;
}
.card.them { border-left-color: var(--them); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.you { color: var(--muted); font-size: 13.5px; margin-bottom: 3px; }
.you b { color: var(--text); font-weight: 500; }
.meta { color: var(--faint); font-size: 12px; margin-left: 6px; }
.card.them .meta { color: var(--them); opacity: 0.8; }

.said { display: flex; gap: 10px; align-items: baseline; }
.said .who { font-size: 18px; }
.line {
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.22;
  letter-spacing: -0.2px;
}

/* One font per script, so Windows doesn't mix fonts inside a line (it was
   pulling some kanji from one font and the rest from another). */
.line:lang(ja) { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Yu Gothic UI", serif; font-size: 23px; }
.line:lang(zh-Hant) { font-family: "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif; font-size: 23px; }

.means { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.original { color: var(--muted); font-size: 13.5px; margin-bottom: 2px; }
.original b { color: var(--text); font-weight: 500; }

.status { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error { color: var(--bad); font-size: 14px; }

.warn {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 111, 97, 0.1);
  color: var(--bad);
  font-size: 13.5px;
  line-height: 1.4;
}
.warn q { color: var(--text); }

.actions { display: flex; gap: 2px; margin: 4px 0 0 -8px; }
.actions button {
  border: 0;
  background: transparent;
  color: var(--faint);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
}
.actions button:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.actions button:disabled { opacity: 0.4; cursor: default; }

.dismiss {
  position: absolute;
  top: 0; right: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.6;
}
.dismiss:hover { opacity: 1; color: var(--text); background: var(--surface-2); }

.menu { display: flex; gap: 6px; margin-top: 6px; }

/* --- Banner + composer --------------------------------------------------------- */

.banner {
  text-align: center;
  font-size: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0 16px;
}

#say-form {
  flex: 1;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 4px 4px 14px;
}
#say-form:focus-within { border-color: var(--faint); }

#say-input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  min-width: 0;
}
#say-input::placeholder { color: var(--faint); }

#speaker {
  background: var(--surface-2);
  color: var(--text);
  border: 0;
  border-radius: 8px;
  padding: 0 8px;
  margin-right: 8px;
  font: inherit;
  font-size: 13px;
}

.send {
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 9px;
  font-size: 17px;
  font-weight: 600;
}
.send:hover { background: var(--accent); color: var(--accent-ink); }

.mic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.1s, background 0.15s;
}
.mic:active { transform: scale(0.98); }

/* Five little level bars: still at rest, dancing while it listens. */
.mic-bars { display: inline-flex; align-items: center; gap: 2.5px; height: 18px; }
.mic-bars i {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
}
.mic-bars i:nth-child(2), .mic-bars i:nth-child(4) { height: 11px; }
.mic-bars i:nth-child(3) { height: 16px; }

.mic.live { background: var(--text); color: var(--bg); }
.mic.live .mic-bars i { animation: level 0.7s ease-in-out infinite alternate; }
.mic.live .mic-bars i:nth-child(2) { animation-delay: -0.2s; }
.mic.live .mic-bars i:nth-child(3) { animation-delay: -0.45s; }
.mic.live .mic-bars i:nth-child(4) { animation-delay: -0.1s; }
.mic.live .mic-bars i:nth-child(5) { animation-delay: -0.3s; }
@keyframes level { from { height: 4px; } to { height: 18px; } }

/* Phones: the mic is a big thumb-sized bar above the iPhone's home bar. */
@media (max-width: 560px) {
  body { padding: 0 14px; }
  .top { padding-top: 10px; gap: 4px; }
  .name { font-size: 27px; }
  .modes button { padding: 6px 7px; font-size: 13px; }
  .modes button.on::after { left: 7px; right: 7px; }
  .sentence { font-size: 14.5px; line-height: 1.95; }
  .line { font-size: 25px; }
  .composer { flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .mic { height: 56px; font-size: 16px; }
}
