/* Crossing Live — warm & human. One upright screen: language pair up top, a
   running conversation log in the middle, two hold-to-talk buttons at the bottom. */
:root {
  --bg: #fbf6ef;
  --surface: #ffffff;
  --surface-2: #f4ebe0;
  --line: #ece0d2;
  --ink: #2a211c;
  --ink-dim: #7a6c62;
  --ink-faint: #a99a8d;
  --coral: #f2603f;
  --coral-strong: #e14b28;
  --coral-soft: #ffe4da;
  --amber: #ff9a4d;
  --grad: linear-gradient(135deg, #ff9a4d 0%, #f2603f 100%);
  --shadow-sm: 0 1px 2px rgba(80,40,15,.06), 0 2px 8px rgba(80,40,15,.05);
  --shadow-glow: 0 10px 30px -8px rgba(242,96,63,.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
  -webkit-user-select: none; user-select: none;
}
#app {
  max-width: 520px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column;
  background: radial-gradient(120% 40% at 50% -8%, #ffe7d3 0%, rgba(255,231,211,0) 55%), var(--bg);
}

/* Top bar */
.topbar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,250,.82); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.brand {
  font-weight: 800; letter-spacing: -0.02em; font-size: 20px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.iconbtn {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-dim);
  border-radius: 999px; height: 32px; min-width: 40px; font-size: 15px; cursor: pointer;
}
#spkBtn { margin-left: auto; }
.clear {
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-dim); border-radius: 999px; padding: 6px 12px; font: inherit;
  font-size: 12px; font-weight: 700; cursor: pointer;
}

/* Language pair setup */
.setup {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.pick { display: flex; align-items: center; gap: 8px; }
.lang {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-sm); text-align: center;
}
.gender {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--coral); font-size: 17px; cursor: pointer; box-shadow: var(--shadow-sm);
}
.swap { color: var(--ink-faint); font-size: 18px; flex: none; }

/* Conversation log */
.log { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.log-empty {
  margin: auto; text-align: center; color: var(--ink-faint); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.log-empty .spark { font-size: 38px; }
.log-empty strong { color: var(--ink); font-size: 15px; font-weight: 700; }
.log-empty span { font-size: 13px; max-width: 22em; }

.turn { display: flex; max-width: 86%; }
.turn.side-A { align-self: flex-start; }
.turn.side-B { align-self: flex-end; }
.bubble { width: 100%; background: var(--surface); border-radius: 18px; padding: 10px 13px; box-shadow: var(--shadow-sm); }
.turn.side-B .bubble { background: var(--grad); color: #fff; box-shadow: var(--shadow-glow); }
.turn-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.lang-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--coral-strong); background: var(--coral-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.turn.side-B .lang-tag { color: #fff; background: rgba(255,255,255,.22); }
.turn-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.replay, .flip {
  width: 30px; height: 30px; border-radius: 50%; flex: none; cursor: pointer; border: none;
  display: grid; place-items: center;
}
.replay { background: var(--coral); color: #fff; font-size: 12px; }
.flip { background: var(--surface-2); color: var(--coral-strong); font-size: 15px; }
.turn.side-B .replay { background: #fff; color: var(--coral); }
.turn.side-B .flip { background: rgba(255,255,255,.22); color: #fff; }
.replay:disabled, .flip:disabled { opacity: .35; cursor: default; }
.flip:active { transform: scale(0.9); }
.del {
  width: 30px; height: 30px; border-radius: 50%; flex: none; cursor: pointer; border: none;
  background: var(--surface-2); color: var(--ink-faint); font-size: 17px; line-height: 1;
  display: grid; place-items: center;
}
.del:active { transform: scale(0.9); }
.turn.side-B .del { background: rgba(255,255,255,.22); color: #fff; }
.del.confirm { background: var(--coral); color: #fff; box-shadow: 0 0 0 3px var(--coral-soft); }
.turn.side-B .del.confirm { background: #fff; color: var(--coral); box-shadow: 0 0 0 3px rgba(255,255,255,.4); }
.target { font-size: 17px; line-height: 1.35; font-weight: 600; }
.source { margin-top: 5px; font-size: 12.5px; line-height: 1.3; color: var(--ink-faint); }
.turn.side-B .source { color: rgba(255,255,255,.82); }
.turn-time { display: block; margin-top: 5px; font-size: 10px; color: var(--ink-faint); }
.turn.side-B .turn-time { color: rgba(255,255,255,.7); }

/* Status line */
.status { flex: none; text-align: center; padding: 6px 16px; font-size: 12.5px; color: var(--ink-dim); min-height: 1.4em; }
.status.live { color: var(--coral); font-weight: 700; }
.status.err { color: var(--coral-strong); font-weight: 700; }

/* Controls */
.controls {
  flex: none; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255,253,250,.9); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.mode { display: flex; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.mode button {
  flex: 1; border: none; background: none; border-radius: 999px; padding: 8px 10px;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink-dim); cursor: pointer;
}
.mode button.active { background: var(--surface); color: var(--coral-strong); box-shadow: var(--shadow-sm); }
.talk {
  flex: 1; min-height: 128px; padding: 16px 12px; border: 2px solid var(--coral-soft);
  border-radius: 22px; cursor: pointer;
  background: var(--surface); color: var(--coral); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em; position: relative;
  touch-action: none; transition: transform .1s ease, background .2s ease, color .2s ease;
}
.talk .talk-emoji { font-size: 40px; line-height: 1; }
.talk:active { transform: scale(0.98); }
.talk.recording, .talk.listening { background: var(--grad); color: #fff; border-color: transparent; }
.talk.recording::before, .talk.listening::before {
  content: ""; position: absolute; inset: -2px; border-radius: 22px; z-index: -1;
  background: var(--grad); opacity: .35; transform: scale(calc(1 + var(--lvl,0) * 0.22));
}
.talk:disabled { opacity: .45; }

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