:root {
  --accent: #E8590C;
  --accent-strong: #CC4D0A;   /* 白字壓橘底用這個，對比度才過 WCAG AA */
  --bg: #ffffff;
  --surface: #f6f6f4;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --line: #e2e2de;
  --danger: #c92a2a;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

.primary {
  background: var(--accent-strong);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 600;
}

.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  min-width: 76px;
}
.ghost:disabled { opacity: .4; cursor: default; }
.ghost.done { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* ---------------------------------------------------------------- 登入 */

.login {
  max-width: 360px;
  margin: 0 auto;
  padding: 18vh 16px 0;
  text-align: center;
}
.login h1 { font-size: 24px; margin: 0 0 24px; }
.login form { display: flex; gap: 8px; }
.login input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.msg { color: var(--danger); min-height: 1.6em; }

/* ---------------------------------------------------------------- 主畫面 */

.app {
  max-width: 680px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.result { flex: 1; display: flex; flex-direction: column; min-height: 0; }

#text {
  flex: 1;
  width: 100%;
  min-height: 160px;
  resize: none;
  font: inherit;
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
#text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

details { margin-top: 8px; color: var(--muted); font-size: 14px; }
details p { margin: 6px 0 0; white-space: pre-wrap; }

.controls { padding-top: 12px; text-align: center; }

.status { min-height: 1.6em; margin: 0 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status.err { color: var(--danger); }

.row { display: flex; align-items: center; justify-content: center; gap: 28px; }

.rec {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 0;
  background: var(--accent-strong);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgb(232 89 12 / .35);
  transition: transform .1s;
}
.rec:active { transform: scale(.95); }
.rec svg { width: 38px; height: 38px; fill: #fff; }
.rec .stop { display: none; }
.rec.on { background: var(--danger); animation: pulse 1.4s ease-in-out infinite; }
.rec.on .mic { display: none; }
.rec.on .stop { display: block; }
.rec:disabled { opacity: .5; cursor: default; animation: none; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgb(201 42 42 / .45); }
  50%      { box-shadow: 0 0 0 14px rgb(201 42 42 / 0); }
}

.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
@media (pointer: coarse) { .hint { display: none; } }
