/* Accent Coach: a black page with the coach's eye in the middle. */
:root {
  --bg: #0b0b0f; --ink: #ecebf2; --soft: #9a99a8; --faint: #5f5e6b; --line: #24232c; --card: #131219;
  --eye: #ffc21a; --live: #ff6b5e; --size: 120px; --level: 0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--eye); }
[hidden] { display: none !important; }

main { width: min(640px, 100% - 32px); flex: 1; display: flex; flex-direction: column; align-items: center; padding: 48px 0 24px; }

/* The eye */
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; transition: margin .6s ease; }
.eye {
  width: var(--size); aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background-color: transparent;
  background-image: radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--eye) 25%, #fff) 0 7%,
    var(--eye) 15% 36%,
    color-mix(in srgb, var(--eye) 55%, transparent) 50%,
    color-mix(in srgb, var(--eye) 18%, transparent) 62%,
    transparent 71%);
  filter: drop-shadow(0 0 calc(8px + var(--level) * 18px) color-mix(in srgb, var(--eye) 70%, transparent));
  transition: width .7s cubic-bezier(.2,.8,.2,1), filter .3s ease, transform .1s ease;
}
.eye:focus-visible { outline: 2px solid var(--eye); outline-offset: 6px; }
body[data-screen="start"] .eye { cursor: default; }
body[data-screen="practice"] { --size: min(17vh, 40vw, 170px); height: 100dvh; overflow: hidden; }
body[data-screen="practice"] main { min-height: 0; height: 100%; }
body[data-screen="practice"] .stage { flex: none; gap: 8px; }
body[data-screen="practice"] main { padding: max(14px, 2vh) 0 10px; }

/* Resting (before the eye is clicked, or after stopping): dim, so the bright eye clearly means the coach is on. */
body[data-state="idle"] .eye { filter: brightness(.42) saturate(.75) drop-shadow(0 0 4px color-mix(in srgb, var(--eye) 30%, transparent)); }
body[data-state="idle"][data-screen="practice"] .eye { animation: glow 3.4s ease-in-out infinite; }
body[data-state="idle"][data-screen="practice"] .eye:hover { animation: none; filter: brightness(.7) drop-shadow(0 0 12px color-mix(in srgb, var(--eye) 50%, transparent)); }
body[data-state="processing"] .eye, body[data-state="connecting"] .eye, body[data-state="thinking"] .eye { animation: pulse 1.1s ease-in-out infinite; }
body[data-state="listening"] .eye { animation: breathe 3.2s ease-in-out infinite; }
body[data-state="paused"] .eye { filter: brightness(.6); }
body[data-state="intro"] .eye, body[data-state="speaking"] .eye {
  transition: width .7s ease, filter .05s linear, transform .05s linear;
  filter: brightness(calc(.85 + var(--level) * .6)) drop-shadow(0 0 calc(10px + var(--level) * 30px) color-mix(in srgb, var(--eye) 80%, transparent));
  transform: scale(calc(1 + var(--level) * .05));
}
@keyframes glow { 0%,100% { filter: brightness(.38) saturate(.75) drop-shadow(0 0 3px color-mix(in srgb, var(--eye) 25%, transparent)); } 50% { filter: brightness(.55) saturate(.85) drop-shadow(0 0 10px color-mix(in srgb, var(--eye) 40%, transparent)); } }
@keyframes breathe { 0%,100% { filter: brightness(1) drop-shadow(0 0 10px color-mix(in srgb, var(--eye) 65%, transparent)); } 50% { filter: brightness(1.2) drop-shadow(0 0 24px var(--eye)); } }
@keyframes pulse { 0%,100% { transform: scale(1); filter: brightness(.75); } 50% { transform: scale(.93); filter: brightness(1.1); } }

.status { margin: 0; min-height: 1.5em; font: 500 .8rem/1.5 ui-monospace, "IBM Plex Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); text-align: center; }
body[data-state="listening"] .status { color: var(--live); }
.ai-note { margin: 10px 0 0; color: var(--faint); font-size: .8rem; text-align: center; }

/* Start screen */
.start { width: 100%; text-align: center; margin-top: 18px; }
h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); font-weight: 650; letter-spacing: -.02em; margin: 6px 0 6px; }
.tagline { color: var(--soft); margin: 0 auto 26px; max-width: 34em; }
.form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.field {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid #2e2d38; background: var(--card); color: var(--ink); font: inherit;
}
.field:focus { outline: none; border-color: var(--eye); }
.key-box { margin-top: 8px; }
.key-box label, .settings h3 { display: block; font-weight: 600; margin: 0 0 6px; font-size: 1rem; }
em { font-style: normal; color: var(--soft); font-weight: 400; }
.help { color: var(--soft); font-size: .84rem; margin: 8px 2px 0; }
button { font: inherit; cursor: pointer; }
.primary {
  margin-top: 6px; padding: 14px 18px; border-radius: 12px; border: 0; background: var(--eye); color: #14120a;
  font-weight: 700; font-size: 1.02rem; transition: transform .1s, filter .2s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(.99); }
.primary:disabled { filter: grayscale(.6) brightness(.7); cursor: progress; }
.ghost { background: transparent; color: var(--ink); border: 1px solid #34333f; border-radius: 10px; padding: 9px 14px; }
.disclaimer { color: var(--faint); font-size: .78rem; line-height: 1.5; margin: 18px auto 0; max-width: 40em; }

/* Practice screen */
.practice { width: 100%; display: none; flex-direction: column; align-items: center; margin-top: 6px; flex: 1; min-height: 0; }
.practice > * { flex: none; }
body[data-screen="practice"] .practice { display: flex; }
body[data-screen="practice"] .start { display: none; }
.gate { display: none; }
body[data-screen="password"] .gate { display: block; }
body[data-screen="password"] #start { display: none; }
body[data-screen="password"] .eye { cursor: default; }
.gate-msg { color: #ff8a80; min-height: 1.2em; margin: 0; font-size: .92rem; }
.gate-msg:empty { display: none; }
.transcript {
  width: 100%; flex: 1 1 0 !important; min-height: 70px; overflow-y: auto; scroll-behavior: smooth; padding: 28px 4px 8px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 56px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 56px);
  scrollbar-width: none;
}
.transcript::-webkit-scrollbar { display: none; }
.transcript:empty { display: block; }
.line { margin: 0; max-width: 86%; padding: 9px 14px; border-radius: 16px; line-height: 1.45; animation: rise .25s ease; }
.line.me { align-self: flex-start; color: #fff; background: #17161e; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.line.you { align-self: flex-end; color: var(--soft); background: transparent; border: 1px solid var(--line); border-bottom-right-radius: 5px; }
.line:first-child { margin-top: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Settings button and panel */
.settings-btn {
  position: fixed; top: 16px; right: 16px; z-index: 10; display: none; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid #3a3946; background: #16151d; color: var(--ink); font-weight: 600;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
}
.settings-btn:hover { border-color: var(--eye); }
.settings-btn svg { width: 20px; height: 20px; fill: var(--eye); }
body[data-screen="practice"] .settings-btn { display: inline-flex; }
.settings {
  width: min(480px, 100% - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 0 22px 18px;
  border: 1px solid #2e2d38; border-radius: 18px; background: #111017; color: var(--ink);
}
.settings::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.settings-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #111017; padding: 16px 0 6px; }
.settings-head h2 { margin: 0; font-size: 1.25rem; }
.close { padding: 6px 11px; }
.settings section { border-top: 1px solid var(--line); padding: 16px 0 6px; }
.current { color: var(--soft); font-size: .88rem; margin: 0 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .primary { margin-top: 10px; }
.row .ghost { margin-top: 10px; }
.settings-msg { color: var(--soft); min-height: 1.2em; font-size: .9rem; margin: 10px 0 0; }

/* Messages */
.message {
  position: fixed; left: 0; right: 0; margin: 0 auto; bottom: 64px; z-index: 20; width: min(520px, 100% - 24px);
  background: #1a1820; border: 1px solid #3a3946; border-left: 3px solid var(--eye); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 10px 34px rgba(0,0,0,.5); animation: rise .25s ease;
}
.message p { margin: 0 0 10px; }
.message-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.message-actions button:not(.ghost) { background: var(--eye); color: #14120a; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; }

@media (max-width: 560px) {
  main { padding-top: 32px; }
  body[data-screen="practice"] main { padding-top: 70px; }
  .settings-btn { top: 12px; right: 12px; padding: 9px 13px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Start form */
.form label { font-weight: 600; margin: 4px 0 -6px; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--soft) 50%), linear-gradient(135deg, var(--soft) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

/* The sentence being practised */
.counter { color: var(--faint); font: 500 .78rem/1.5 ui-monospace, "IBM Plex Mono", monospace; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 8px; }
.sentence-card { width: 100%; text-align: center; padding: 18px 20px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.sentence { margin: 0; font-size: clamp(1.3rem, 4.2vw, 1.85rem); line-height: 1.35; font-weight: 600; letter-spacing: -.01em; }
.sentence mark { background: color-mix(in srgb, var(--eye) 22%, transparent); color: var(--eye); border-radius: 6px; padding: 0 4px;
  box-shadow: inset 0 -2px 0 var(--eye); animation: rise .25s ease; }
.sound { margin: 8px 0 0; color: var(--faint); font-size: .82rem; }
.all-done { text-align: center; }
.all-done p { font-size: 1.3rem; font-weight: 650; margin: 8px 0; }

/* Recordings */
.attempts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 0; min-height: 40px; }
.attempts .label { width: 100%; text-align: center; color: var(--soft); font-size: .82rem; margin: 0; }
.clip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; border: 1px solid #34333f;
  background: #16151d; color: var(--ink); font-weight: 600; font-size: .9rem; }
.clip::before { content: ""; width: 0; height: 0; border-left: 9px solid currentColor; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.clip.gemini { border-color: color-mix(in srgb, var(--eye) 60%, transparent); color: var(--eye); }
.clip.playing { background: color-mix(in srgb, var(--eye) 18%, #16151d); }
.clip:hover { border-color: var(--eye); }

.focus { margin: -4px 0 8px; color: var(--eye); font-size: .85rem; font-weight: 600; text-align: center; }
.focus:empty { display: none; }
.sentence-card.reading .sentence { font-size: clamp(1rem, 2.6vw, 1.2rem); font-weight: 500; line-height: 1.5; text-align: left; }
.line-of-text { display: block; }
.sentence-card.reading { max-height: 34vh; overflow-y: auto; }
.clip:disabled { opacity: .55; cursor: progress; }
.review { text-align: center; margin: 10px 0 0; }
.review p { margin: 0 0 2px; color: var(--soft); font-size: .88rem; }
.review .row { justify-content: center; }
.review .primary, .review .ghost { margin-top: 6px; padding: 10px 22px; }
.status { min-height: 1.2em; }
@media (max-height: 640px) { body[data-screen="practice"] { --size: 90px; } .sentence { font-size: 1.2rem; } }
.clip .heard { font-weight: 400; color: var(--soft); font-size: .8rem; }
.welcome { width: 100%; text-align: center; padding: 18px 20px; border: 1px dashed #3a3946; border-radius: 18px; color: var(--soft); }
.welcome p { margin: 0; font-size: 1.05rem; }
.clip.playing::before { border: 0; width: 9px; height: 9px; background: currentColor; border-radius: 2px; }
