:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --fg: #0b1220;
  --muted: #2b3954;
  --btn: #0a4fa3;
  --btn-fg: #ffffff;
  --btn2: #ffffff;
  --btn2-fg: #0b1220;
  --border: #0b1220;
  --end: #a3122a;
  --focus: #005fcc;
  --surface: #ffffff;
  --line: #c5d2e4;
  --soft: #eaf2fc;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1220;
    --fg: #f4f7fb;
    --muted: #c9d3e6;
    --btn: #8dbbff;
    --btn-fg: #0b1220;
    --btn2: #16213a;
    --btn2-fg: #f4f7fb;
    --border: #f4f7fb;
    --end: #ff9aa9;
    --focus: #ffbf00;
    --surface: #111c30;
    --line: #465a77;
    --soft: #162943;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-wrap: anywhere; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.25rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

main {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

main > *, footer > * { min-width: 0; }

h1 { font-size: 2rem; line-height: 1.2; margin: 0.5rem 0; }

button {
  font: inherit;
  cursor: pointer;
  min-height: 3rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  touch-action: manipulation;
  padding: 0.75rem 1.25rem;
  border: 3px solid var(--border);
  border-radius: 1rem;
  background: var(--btn2);
  color: var(--btn2-fg);
}

.talk {
  width: min(15rem, 80vw);
  min-height: min(15rem, 80vw);
  border-radius: 50%;
  border-width: 4px;
  background: var(--btn);
  color: var(--btn-fg);
  font-size: 1.6rem;
  font-weight: 700;
}

.talk[data-active="true"] { background: var(--end); }

body[data-state="speaking"] .talk,
body[data-state="listening"] .talk { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--btn); }
  50% { box-shadow: 0 0 0 1rem transparent; }
}

button:focus-visible, a:focus-visible, #micPermission:focus {
  outline: 5px solid var(--focus);
  outline-offset: 4px;
}

#langs { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
#langs[hidden], [hidden] { display: none !important; }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  padding: 0 1rem 2rem;
  font-size: 1rem;
}

.help { color: var(--muted); max-width: 32rem; margin: 0; }
.help .privacy { display: block; margin-top: 0.5rem; }
a { color: inherit; }

.history { align-items: stretch; text-align: left; }
.history h2 { font-size: 1.4rem; margin: 1.5rem 0 0.25rem; }
.history p { margin: 0; }

/* Home: one tactile voice control, stable source order and no extra reading. */
.voice-page {
  --bg: #e5f1f8; --fg: #102f45; --muted: #294b62;
  --btn: #0b4d73; --btn-fg: #ffffff; --btn2: transparent;
  --btn2-fg: #102f45; --border: #102f45; --end: #8b2147; --focus: #865000;
  min-height: 100svh; display: flex; flex-direction: column;
  font-family: "Avenir Next", system-ui, -apple-system, "Segoe UI", sans-serif;
}
.voice-panel {
  width: 100%; max-width: 70rem; margin: 0 auto;
  padding: clamp(2rem, 6vh, 4rem) clamp(1.25rem, 5vw, 4rem) 2rem;
  gap: 0; background: transparent; border: 0; border-radius: 0;
}
.voice-panel h1 {
  max-width: 19ch; margin: 0 0 2rem;
  font-size: clamp(2.35rem, 5.5vw, 4.6rem); font-weight: 650;
  line-height: 1.06; letter-spacing: -0.045em; text-wrap: balance;
}
.voice-panel .talk {
  display: block; position: relative; width: min(26rem, 100%);
  min-height: 15rem; margin: 0 0 1.8rem; padding: 2rem 1.5rem;
  border: 3px solid var(--btn); border-radius: 4rem;
  box-shadow: 0 8px 0 #062e48; font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 650; line-height: 1.3; transition: background-color 120ms, box-shadow 120ms;
}
.voice-panel .talk::before {
  content: ""; display: block; width: 3.25rem; height: 3.25rem; margin: 0 auto 1.1rem;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='11' y='3' width='10' height='17' rx='5'/%3E%3Cpath d='M7 15v2a9 9 0 0 0 18 0v-2M16 26v4M11 30h10'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='11' y='3' width='10' height='17' rx='5'/%3E%3Cpath d='M7 15v2a9 9 0 0 0 18 0v-2M16 26v4M11 30h10'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
.voice-panel .talk:hover { box-shadow: 0 10px 0 #062e48; }
.voice-panel .talk:active { box-shadow: 0 3px 0 #062e48; }
.voice-panel .talk[data-active="true"] { background: var(--end); border-color: var(--end); }
.voice-panel #endConv { margin-bottom: 1.25rem; border-color: var(--end); }
.voice-panel #lang { border: 2px solid currentColor; border-radius: 2rem; padding: 0.65rem 1.25rem; font-size: 1.05rem; }
.voice-panel #langs:not([hidden]) { margin-top: 1rem; }
.voice-panel .help { max-width: 41rem; margin-top: 1.75rem; font-size: 1.1rem; line-height: 1.6; }
.voice-panel .privacy { font-size: 1rem; margin-top: 0.75rem; }
.voice-panel #micPermission:not(:empty), .voice-panel #alert:not(:empty) { margin-top: 1.25rem; max-width: 38rem; }
.voice-page footer { margin-top: auto; gap: 0.5rem 1.75rem; padding: 1.5rem 1.25rem; }
footer a { padding: 0.5rem 0; text-underline-offset: 0.2em; }
@media (prefers-color-scheme: dark) {
  .voice-page { --bg: #102632; --fg: #f5faff; --muted: #c9dce6; --btn: #b7e4f7; --btn-fg: #102632; --btn2-fg: #f5faff; --border: #f5faff; --end: #efa4b7; --focus: #ffd082; }
  .voice-panel .talk, .voice-panel .talk:hover, .voice-panel .talk:active { box-shadow: 0 8px 0 #07161f; }
}
@media (forced-colors: active) {
  .voice-panel .talk { border: 3px solid ButtonText; box-shadow: none; }
  .voice-panel .talk::before { background: ButtonText; }
}

/* A separate, readable project page without adding to the voice interface. */
.about {
  max-width: 50rem;
  align-items: stretch;
  text-align: left;
  gap: 0;
  padding: 1.5rem 2rem 2.5rem;
}
.about-back { align-self: flex-start; padding: 0.5rem 0; }
.about-profile { display: flex; align-items: center; gap: 1.75rem; margin: 2rem 0; }
.about-profile > div { min-width: 0; }
.profile-photo { width: 130px; height: 130px; flex: 0 0 130px; border-radius: 1rem; border: 1px solid var(--line); }
.about-label { color: var(--muted); font-size: 1rem; margin: 0 0 0.5rem; }
.about h1 { margin: 0 0 0.75rem; letter-spacing: -0.025em; }
.profile-intro { color: var(--muted); margin: 0; }
.about-section { border-top: 1px solid var(--line); padding: 1.75rem 0; }
.about h2 { font-size: 1.4rem; line-height: 1.3; margin: 0 0 0.75rem; }
.about-section p { margin: 0; max-width: 65ch; }
.about-section p + p { margin-top: 1rem; }
.pilot-section { background: var(--soft); border: 0; border-left: 4px solid var(--btn); padding: 1.5rem; margin-bottom: 1.75rem; }
.contact-section { padding-bottom: 0; }
.contact-links { display: flex; flex-wrap: wrap; gap: 1rem 2rem; font-style: normal; margin-top: 1.25rem; }
.contact-links a { display: block; min-width: 0; padding: 0.5rem 0; text-underline-offset: 0.2em; }
.contact-links span { display: block; color: var(--muted); font-size: 1rem; margin-bottom: 0.25rem; }

@media (max-width: 36rem) {
  .voice-panel { padding: 2rem 1.25rem 1.5rem; }
  .voice-panel h1 { margin-bottom: 1.75rem; }
  .voice-panel .talk { border-radius: 3rem; min-height: 14rem; }
  .about { padding-inline: 1rem; }
  .about-profile { align-items: flex-start; flex-direction: column; gap: 1.25rem; }
  .pilot-section { padding: 1.25rem; }
  footer { gap: 0.5rem 1.5rem; }
}

.stats table { border-collapse: collapse; width: 100%; }
.stats caption { text-align: left; padding-bottom: 0.5rem; color: var(--muted); }
.stats input { font: inherit; padding: 0.4rem; border: 3px solid var(--border); border-radius: 0.5rem; width: 8rem; margin-left: 0.5rem; }
.stats th, .stats td { border: 1px solid var(--border); padding: 0.4rem 0.75rem; text-align: left; }

/* Windows High Contrast / forced colours: keep borders and focus visible. */
@media (forced-colors: active) {
  button { border: 3px solid ButtonText; }
  .talk[data-active="true"] { border-style: double; border-width: 6px; }
  button:focus-visible, a:focus-visible, #micPermission:focus { outline: 5px solid Highlight; }
}

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

