:root {
  --bg: #0d1117;
  --bg-half-el: #0f141c;
  --bg-half-en: #0d1117;
  --line: #222a35;
  --text: #f2f4f7;
  --muted: #8b95a5;
  --mine: #9aa6b8;
  --accent: #5fb3ff;
  --ok: #3ecf8e;
  --speak: #ffb547;
  --bad: #ff6b6b;
  --big: clamp(26px, 7.4vw, 48px);
  --small: clamp(16px, 4.2vw, 24px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.table {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr 1fr;
}

.half {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 16px 12px;
}
.half-el { background: var(--bg-half-el); transform: rotate(180deg); border-top: 1px solid var(--line); }
.half-en { background: var(--bg-half-en); border-top: 1px solid var(--line); }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(17px, 2.2vw, 24px);
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.who { font-weight: 600; letter-spacing: .02em; }
.status { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status[data-state="listening"] .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(62, 207, 142, .15); }
.status[data-state="speaking"] .dot { background: var(--speak); box-shadow: 0 0 0 4px rgba(255, 181, 71, .18); }
.status[data-state="speaking"] .status-text { color: var(--speak); }
.status[data-state="connecting"] .dot { background: var(--accent); }
.status[data-state="error"] .dot { background: var(--bad); }
.status[data-state="error"] .status-text { color: var(--bad); }

.voice-toggle {
  margin-left: auto;
  font: inherit;
  font-size: clamp(15px, 1.9vw, 20px);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.voice-toggle[aria-pressed="false"] { color: var(--bad); border-color: rgba(255, 107, 107, .4); }
.voice-toggle.layout-next { margin-left: 0; }
.bar { flex-wrap: wrap; row-gap: 8px; }
.stop-btn { margin-left: 0; color: var(--bad); border-color: rgba(255, 107, 107, .4); }
.stop-btn[hidden] { display: none; }

.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.feed > :first-child { margin-top: auto; } /* newest at the bottom, short feeds sit low */

.hint { color: var(--muted); font-size: var(--small); margin: 0; line-height: 1.35; }

.line { margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
/* The other person's words, translated into this half's language: the thing to read. */
.line.theirs { font-size: var(--big); font-weight: 500; color: var(--text); }
/* This person's own words, so they can see they were heard. */
.line.mine {
  font-size: var(--small);
  color: var(--mine);
  text-align: right;
  padding-left: 18%;
}
.line .partial { opacity: .45; }
.line:empty { display: none; }

/* Start overlay */
.start {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: 1fr 1fr;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.start[hidden] { display: none; }
.start-half {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
}
.start-el { transform: rotate(180deg); border-bottom: 1px solid var(--line); }
.start-big {
  font-size: clamp(34px, 11vw, 72px);
  font-weight: 700;
  border: 2px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: .25em 1.1em;
}
.start-small { font-size: var(--small); color: var(--muted); max-width: 26ch; line-height: 1.35; }
.start:disabled { cursor: default; }
.start:disabled .start-big { border-color: var(--line); color: var(--muted); }
.start.problem .start-small { color: var(--bad); }

/* LAYOUT "side": both halves upright, for a laptop or two people sitting side by side.
   Wide screen = two columns (Greek left, English right). Narrow phone = stacked, both upright. */
body[data-layout="side"] .half-el,
body[data-layout="side"] .start-el { transform: none; }
body[data-layout="side"] .half-el { order: 0; }
@media (min-width: 640px), (orientation: landscape) {
  body[data-layout="side"] .table,
  body[data-layout="side"] .start { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  body[data-layout="side"] .half-en { border-top: 0; border-left: 1px solid var(--line); }
  body[data-layout="side"] .start-el { border-bottom: 0; border-right: 1px solid var(--line); }
  body[data-layout="side"] { --big: clamp(22px, 3.4vw, 40px); --small: clamp(15px, 2vw, 20px); }
}

@media (min-width: 900px) {
  .half { padding: 14px 32px 16px; }
  .feed { max-width: 1100px; width: 100%; margin: 0 auto; }
  .bar { max-width: 1100px; width: 100%; margin: 0 auto; }
}
