:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Noto Sans SC", sans-serif;
  background: #f4f1ea;
  color: #17221e;
  --ink: #17221e;
  --muted: #69736e;
  --line: #d9ded9;
  --paper: #fffef9;
  --green: #1b6e54;
  --blue: #245f9f;
  --orange: #b9582d;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: #f4f1ea; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 92% 2%, rgba(27, 110, 84, 0.12), transparent 28rem),
    #f4f1ea;
}

button { font: inherit; }

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(32px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-lockup { display: flex; min-width: 0; align-items: center; gap: 11px; }
.brand-mark { display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; border-radius: 12px; color: white; background: var(--green); font-size: 1.2rem; font-weight: 850; }
.brand-name { margin: 0; color: var(--green); font-size: 0.82rem; font-weight: 850; letter-spacing: 0.16em; }
.brand-descriptor { margin: 2px 0 0; color: var(--muted); font-size: 0.57rem; font-weight: 700; letter-spacing: 0.09em; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.25rem, 5.5vw, 1.7rem); letter-spacing: -0.035em; }

.text-button {
  border: 0;
  padding: 9px 2px;
  color: var(--muted);
  background: transparent;
  font-size: 0.88rem;
}

.status-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  align-items: center;
  padding: 13px 15px;
  border: 1px solid rgba(23, 34, 30, 0.12);
  border-radius: 16px;
  background: rgba(255, 254, 249, 0.82);
  box-shadow: 0 8px 30px rgba(23, 34, 30, 0.05);
}

.status-panel strong { display: block; font-size: 0.92rem; }
.status-panel p { margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: #9ca39f; box-shadow: 0 0 0 4px rgba(156, 163, 159, 0.16); }
.status-dot[data-state="ready"] { background: #29a878; box-shadow: 0 0 0 4px rgba(41, 168, 120, 0.16); }
.status-dot[data-state="busy"] { background: #d88a31; box-shadow: 0 0 0 4px rgba(216, 138, 49, 0.18); animation: pulse 1s ease-in-out infinite; }
.status-dot[data-state="error"] { background: #c94444; box-shadow: 0 0 0 4px rgba(201, 68, 68, 0.15); }

.setup-panel {
  margin-top: 18px;
  padding: 26px 22px 22px;
  border-radius: 24px;
  color: #f8fff9;
  text-align: center;
  background: linear-gradient(145deg, #174b3c, #1b6e54);
  box-shadow: 0 16px 50px rgba(23, 75, 60, 0.18);
}

.setup-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%; background: rgba(255,255,255,0.12); font-size: 1.7rem; }
.setup-panel h2 { margin-bottom: 7px; font-size: 1.35rem; }
.setup-panel p { margin-bottom: 20px; color: rgba(248,255,249,0.76); font-size: 0.9rem; line-height: 1.55; }
.setup-button { width: 100%; min-height: 54px; border: 0; border-radius: 15px; color: #174b3c; background: #f8fff9; font-weight: 750; }
.setup-button:disabled, .replay-button:disabled { opacity: 0.5; }

.quality-note {
  display: grid;
  gap: 3px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(23, 34, 30, 0.1);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 254, 249, 0.65);
  font-size: 0.76rem;
  line-height: 1.45;
}
.quality-note strong { color: var(--ink); font-size: 0.8rem; }

.auto-panel { margin-top: 18px; }
.listening-card { min-height: 158px; padding: 22px; border: 1px solid rgba(27, 110, 84, 0.18); border-radius: 24px; background: linear-gradient(145deg, rgba(255,255,255,0.94), rgba(237,248,242,0.92)); box-shadow: 0 14px 38px rgba(23, 75, 60, 0.09); }
.listening-card__label { display: block; color: var(--green); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.08em; }
.listening-card p { margin: 22px 0 13px; font-size: clamp(1.35rem, 7vw, 2rem); font-weight: 760; letter-spacing: -0.025em; }
.listening-card[data-speaking="true"] { border-color: rgba(27, 110, 84, 0.5); box-shadow: 0 14px 42px rgba(27, 110, 84, 0.16); }
.listening-card__note { display: block; color: var(--muted); font-size: 0.7rem; line-height: 1.45; }
.direction-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.direction-option { min-height: 46px; border: 1px solid #ccd5cf; border-radius: 14px; color: var(--muted); background: rgba(255,254,249,0.82); font-size: 0.76rem; font-weight: 760; }
.direction-option[aria-pressed="true"] { border-color: var(--green); color: white; background: var(--green); }
.direction-option:disabled { opacity: 0.5; }
.auto-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.secondary-button { min-height: 42px; border: 1px solid #ccd5cf; border-radius: 999px; padding: 0 16px; color: var(--ink); background: var(--paper); font-size: 0.8rem; font-weight: 740; }

.controls { margin-top: 18px; }
.controls__auto-return { width: 100%; margin-bottom: 10px; }
.talk-button {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 132px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  padding: 22px;
  color: white;
  text-align: left;
  box-shadow: 0 14px 36px rgba(23, 34, 30, 0.12);
  touch-action: manipulation;
  transition: transform 120ms ease, filter 120ms ease;
}

.talk-button::after { content: ""; position: absolute; right: -28px; top: -52px; width: 160px; height: 160px; border: 24px solid rgba(255,255,255,0.09); border-radius: 50%; }
.talk-button:active { transform: scale(0.985); }
.talk-button:disabled { filter: grayscale(0.65); opacity: 0.56; }
.talk-button--zh { background: linear-gradient(145deg, #1b4f84, var(--blue)); }
.talk-button--en { background: linear-gradient(145deg, #93431f, var(--orange)); }
.talk-button[data-recording="true"] { background: linear-gradient(145deg, #b92323, #d63d3d); animation: recording 1.1s ease-in-out infinite; }
.talk-button__prompt { position: relative; z-index: 1; font-size: 1.55rem; font-weight: 780; letter-spacing: -0.025em; }
.talk-button__action { position: relative; z-index: 1; margin-top: 5px; color: rgba(255,255,255,0.76); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; }

.turn-hint { display: flex; align-items: center; gap: 10px; margin: 12px 4px; color: var(--muted); font-size: 0.74rem; font-weight: 650; text-align: center; }
.turn-hint span { height: 1px; flex: 1; background: var(--line); }

.conversation { margin-top: 28px; }
.conversation__heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.conversation__heading h2 { margin: 0; font-size: 1.02rem; }
.conversation__heading span { color: var(--muted); font-size: 0.76rem; }
.empty-state { padding: 30px 20px; border: 1px dashed #c6cdc8; border-radius: 20px; text-align: center; }
.empty-state p { margin-bottom: 4px; font-weight: 700; }
.empty-state span { color: var(--muted); font-size: 0.8rem; }

.transcript-list { display: grid; gap: 14px; }
.transcript-card { padding: 17px; border: 1px solid rgba(23,34,30,0.10); border-radius: 20px; background: var(--paper); box-shadow: 0 10px 30px rgba(23,34,30,0.05); }
.transcript-card[data-direction="zh-en"] { border-left: 4px solid var(--blue); }
.transcript-card[data-direction="en-zh"] { border-left: 4px solid var(--orange); }
.transcript-card__speaker { margin-bottom: 15px; color: var(--muted); font-size: 0.72rem; font-weight: 740; letter-spacing: 0.08em; }
.transcript-block span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 0.7rem; font-weight: 700; }
.transcript-block p { margin-bottom: 0; font-size: 1.05rem; line-height: 1.48; }
.transcript-block--translation p { font-size: 1.28rem; font-weight: 720; letter-spacing: -0.015em; }
.translation-divider { display: flex; align-items: center; gap: 8px; margin: 13px 0; color: var(--muted); font-size: 0.66rem; }
.translation-divider::before, .translation-divider::after { content: ""; height: 1px; flex: 1; background: #e2e5e1; }
.replay-button { margin-top: 16px; border: 1px solid #d7dcd8; border-radius: 999px; padding: 8px 13px; color: var(--ink); background: #f8f7f2; font-size: 0.78rem; font-weight: 700; }

@keyframes pulse { 50% { opacity: 0.48; } }
@keyframes recording { 50% { box-shadow: 0 14px 44px rgba(185,35,35,0.30); } }

@media (min-width: 680px) {
  .app-shell { padding-left: 28px; padding-right: 28px; }
  .controls { display: grid; grid-template-columns: 1fr 36px 1fr; align-items: stretch; }
  .controls__auto-return { grid-column: 1 / -1; }
  .turn-hint { flex-direction: column; justify-content: center; margin: 6px 11px; }
  .turn-hint span { width: 1px; height: auto; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
