:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #252722;
  background: #eeece5;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #eeece5; }

body {
  min-height: 100dvh;
  margin: 0;
  background: #f7f5ef;
  transition: background-color 240ms ease;
}

body[data-turn="partner"] { background: #f2f5f3; }

button, select, textarea { font: inherit; }
button, select { touch-action: manipulation; }
button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(72, 95, 82, .28);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar { position: relative; text-align: center; }
.brand { font-size: 28px; line-height: 1; font-weight: 720; letter-spacing: -.04em; }
.end-conversation-button {
  position: absolute;
  top: -4px;
  right: 0;
  width: auto;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(53,69,60,.18);
  border-radius: 12px;
  color: #5c665f;
  background: rgba(255,255,255,.48);
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}
.end-conversation-button:disabled { opacity: .45; cursor: default; }

.language-row {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.language-select select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  color: #34372f;
  background: rgba(255,255,255,.68);
  border: 1px solid rgba(37,39,34,.12);
  border-radius: 14px;
  text-align: center;
  font-size: 16px;
  font-weight: 640;
}

.swap-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  color: #4b5f54;
  background: #e3e8e2;
  font-size: 26px;
}

.history {
  margin: 20px 0 -4px;
  max-height: 178px;
  overflow: auto;
  border-top: 1px solid rgba(37,39,34,.09);
  scrollbar-width: thin;
}

.history-item {
  padding: 14px 2px;
  border-bottom: 1px solid rgba(37,39,34,.09);
}

.history-speaker { margin: 0 0 5px; color: #667067; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.history-source, .history-translation { margin: 0; font-size: 14px; line-height: 1.45; }
.history-translation { margin-top: 4px; color: #667067; }

.turn-card {
  flex: 1;
  min-height: 450px;
  padding: clamp(42px, 8vh, 84px) 0 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
}

.eyebrow { margin: 0 0 12px; color: #657168; font-size: 14px; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(31px, 9vw, 45px); line-height: 1.04; letter-spacing: -.045em; }
.hint { min-height: 25px; margin: 14px 0 0; color: #6e716b; font-size: 17px; line-height: 1.45; }

.panel { width: 100%; margin-top: auto; padding-top: 34px; }
.primary-button, .secondary-button {
  width: 100%;
  min-height: 62px;
  border-radius: 19px;
  border: 0;
  font-weight: 720;
  cursor: pointer;
}

.primary-button { color: #fff; background: #43584c; box-shadow: 0 10px 28px rgba(45,65,54,.16); font-size: 18px; }
body[data-turn="partner"] .primary-button { background: #4e6265; }
.handoff-button, body[data-turn="partner"] .handoff-button { background: #76664f; box-shadow: 0 10px 28px rgba(84,70,49,.15); }
.primary-button:disabled, .secondary-button:disabled { opacity: .48; cursor: default; }
.secondary-button { margin-top: 10px; color: #435047; background: transparent; border: 1px solid rgba(53,69,60,.2); font-size: 16px; }

.talk-button { min-height: 84px; display: flex; align-items: center; justify-content: center; gap: 13px; font-size: 21px; }
.mic-dot { width: 19px; height: 25px; border: 3px solid currentColor; border-radius: 12px; position: relative; }
.mic-dot::after { content: ""; position: absolute; width: 25px; height: 14px; left: -6px; bottom: -9px; border: 3px solid currentColor; border-top: 0; border-radius: 0 0 14px 14px; }

.recording-status { display: flex; flex-direction: column; align-items: center; gap: 22px; margin-bottom: 30px; }
.timer { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 680; }
.audio-meter { height: 46px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.audio-meter i { display: block; width: 7px; min-height: 7px; height: 7px; border-radius: 10px; background: #708378; transition: height 70ms linear; }
.stop-button { background: #70554f; }

.processing { margin: auto 0; padding: 42px 0; color: #5d665e; }
.processing p { margin: 18px 0 0; font-size: 18px; }
.spinner { width: 38px; height: 38px; margin: auto; border: 3px solid rgba(67,88,76,.15); border-top-color: #43584c; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.review-panel, .result-panel, .error-panel { margin-top: 26px; padding-top: 0; }
.field-label { display: block; margin: 0 0 12px; color: #5c665f; font-size: 15px; font-weight: 720; text-align: left; }
textarea {
  width: 100%;
  min-height: 174px;
  resize: vertical;
  padding: 18px;
  color: #252722;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(37,39,34,.14);
  border-radius: 18px;
  font-size: 21px;
  line-height: 1.42;
}
.review-panel .primary-button { margin-top: 16px; }
.translated-text { padding: 7px 0 28px; text-align: left; font-size: clamp(27px, 7vw, 38px); line-height: 1.19; font-weight: 650; letter-spacing: -.025em; overflow-wrap: anywhere; }
.repeat-button { margin: 0 0 12px; }
.turn-actions { display: grid; gap: 10px; }
.error-panel p { margin: 0 0 22px; color: #704b47; font-size: 19px; line-height: 1.45; }
.privacy-note { margin: 12px auto 0; max-width: 370px; color: #8b8b85; font-size: 11px; line-height: 1.4; text-align: center; }
.transcript-screen { width: 100%; padding: clamp(42px, 8vh, 76px) 0 20px; }
.transcript-header { text-align: center; }
.full-transcript { margin-top: 38px; }
.transcript-entry { position: relative; padding: 24px 0 30px 14px; border-top: 1px solid rgba(37,39,34,.11); }
.transcript-entry::before { content: ""; position: absolute; top: 27px; bottom: 32px; left: 0; width: 3px; border-radius: 4px; background: #708378; }
.transcript-entry[data-turn="partner"]::before { background: #75888b; }
.transcript-speaker { margin: 0 0 18px; color: #59665e; font-size: 13px; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.transcript-language { margin: 18px 0 6px; color: #6b716b; font-size: 13px; font-weight: 720; }
.transcript-text { margin: 0; font-size: 20px; line-height: 1.5; overflow-wrap: anywhere; }
.transcript-translation { color: #536059; }
.transcript-actions { margin-top: 14px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.transcript-return-button { min-height: 48px; border: 0; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 599px) {
  .topbar {
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  .end-conversation-button {
    position: static;
    align-self: center;
    min-height: 44px;
    padding: 10px 16px;
    border-color: #8f3030;
    color: #fff;
    background: #a63d3d;
    box-shadow: 0 8px 20px rgba(118, 35, 35, .18);
    font-size: 14px;
  }
  .end-conversation-button:active { background: #8f3030; }
  #finish-conversation {
    color: #fff;
    background: #a63d3d;
    box-shadow: 0 10px 28px rgba(118, 35, 35, .2);
  }
  #finish-conversation:active { background: #8f3030; }
  textarea { overflow-y: hidden; resize: none; }
  .translated-text {
    width: 100%;
    min-height: 174px;
    margin-bottom: 16px;
    padding: 18px;
    color: #252722;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(37,39,34,.14);
    border-radius: 18px;
    font-size: 23px;
    line-height: 1.42;
    font-weight: 600;
    letter-spacing: -.015em;
  }
  .repeat-button { margin-top: 0; }
  .transcript-screen { padding-top: 46px; }
}

@media (min-width: 600px) {
  body { background: #e9e7e0; }
  body[data-turn="partner"] { background: #e6ebe8; }
  .app-shell { background: #f7f5ef; box-shadow: 0 0 50px rgba(25,32,27,.08); }
  body[data-turn="partner"] .app-shell { background: #f2f5f3; }
}

@media (max-height: 680px) {
  .app-shell { padding-top: calc(14px + env(safe-area-inset-top)); }
  .language-row { margin-top: 14px; }
  .turn-card { min-height: 390px; padding-top: 28px; }
  .panel { padding-top: 24px; }
  textarea { min-height: 130px; }
  .privacy-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
