:root {
  --bg: #f6f5f2;
  --pane: #ffffff;
  --ink: #1d1d1f;
  --muted: #8a8a8e;
  --draft: #a8a8ad;
  --accent: #2f6fde;
  --line: #e4e2dc;
  --danger: #c4372b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --pane: #1a1a1d;
    --ink: #ececee;
    --muted: #8d8d93;
    --draft: #5f5f66;
    --accent: #7aa5ff;
    --line: #2a2a2f;
    --danger: #ff7a6b;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

#app {
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}

.pane {
  position: relative;
  overflow-y: auto;
  padding: 20px clamp(16px, 5vw, 64px);
  background: var(--pane);
  scrollbar-width: thin;
}

#app.flipped #pane-top { transform: rotate(180deg); }

.lines { display: flex; flex-direction: column; gap: 14px; min-height: 100%; justify-content: flex-end; }

.line {
  margin: 0;
  font-size: clamp(18px, 2.4vw, 24px);
  line-height: 1.45;
  color: var(--muted);
  transition: color .2s;
}

/* The newest utterance is the one people are reading right now. */
.line:last-child { font-size: clamp(22px, 3.4vw, 34px); color: var(--ink); }
.line.translated:last-child { color: var(--accent); }
.line.draft { color: var(--draft) !important; }

.empty {
  position: absolute;
  inset: 0;
  margin: auto;
  height: fit-content;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}
.pane:has(.line) .empty { display: none; }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  border-block: 1px solid var(--line);
  background: var(--bg);
}

button, select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--pane);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 72px; }
button.primary.on { background: var(--danger); border-color: var(--danger); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.status { margin-left: auto; font-size: 13px; color: var(--muted); }
.bar .credit { font-size: 12px; color: var(--muted); text-decoration: none; }
.bar .credit:hover { color: var(--accent); }
.status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--line);
}
.status[data-state="live"]::before { background: #34c759; animation: pulse 1.4s infinite; }
.status[data-state="busy"]::before { background: #ff9f0a; }
.status[data-state="error"] { color: var(--danger); }
.status[data-state="error"]::before { background: var(--danger); }

@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 640px) {
  .bar { gap: 6px 8px; padding: 8px 12px; }
  .status { flex: 1; margin-left: 0; }
}

dialog#login {
  width: min(360px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--pane);
  color: var(--ink);
}
dialog#login::backdrop { background: rgb(0 0 0 / .35); backdrop-filter: blur(4px); }
#login-form { display: flex; flex-direction: column; gap: 14px; }
#login-form h1 { margin: 0; font-size: 20px; }
#login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
#login-form label[hidden] { display: none; }
#login-form input {
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
#login-form .msg { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--muted); }
#login-form button { padding: 9px 12px; }
#login-form .credit { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
#login-form .credit a { color: inherit; }
