:root {
  --bg: #f5f1e8;
  --bg-subtle: #efe9dc;
  --paper: #fffdf8;
  --paper-soft: #faf6ee;
  --ink: #232a22;
  --muted: #6a7068;
  --faint: #9aa09a;
  --line: rgba(40, 50, 40, 0.1);
  --line-strong: rgba(40, 50, 40, 0.18);
  --green: #2a7a5e;
  --green-soft: rgba(42, 122, 94, 0.12);
  --gold: #9a7435;
  --gold-soft: rgba(154, 116, 53, 0.12);
  --coral: #c05040;
  --coral-soft: rgba(192, 80, 64, 0.12);
  --amber: #b87a20;
  --shadow-card: 0 1px 3px rgba(40, 36, 28, 0.06), 0 4px 12px rgba(40, 36, 28, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

button,
select,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(720px, calc(100% - 28px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(22px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  color: var(--green);
  font-size: 15px;
  line-height: 1.2;
}

.status-pill {
  min-width: 94px;
  height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready {
  color: var(--green);
  background: var(--green-soft);
}

.status-pill.error {
  color: var(--coral);
  background: var(--coral-soft);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

.control-panel,
.transcript-card,
.pin-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
}

.control-panel {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.field-row label,
.pin-panel label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper-soft);
  color: var(--ink);
  padding: 0 12px;
}

.mic-button {
  width: 100%;
  height: clamp(148px, 30dvh, 240px);
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(35, 42, 34, 0.18);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.mic-button:active,
.mic-button.listening {
  background: var(--green);
  transform: translateY(1px);
}

.mic-button.busy {
  background: var(--amber);
}

.mic-button svg {
  width: 58px;
  height: 58px;
  padding: 12px;
  border: 1px solid rgba(255, 253, 248, 0.28);
  border-radius: 999px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.secondary-actions button,
.pin-panel button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink);
  font-weight: 700;
}

.transcript-grid {
  display: grid;
  gap: 14px;
}

.transcript-card {
  min-height: 150px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.transcript-card.translation {
  min-height: 190px;
}

.transcript-text {
  color: var(--muted);
  font-size: clamp(21px, 7vw, 36px);
  font-weight: 800;
  line-height: 1.34;
  letter-spacing: 0;
  user-select: text;
  -webkit-user-select: text;
  overflow-wrap: anywhere;
}

.translation .transcript-text {
  color: var(--ink);
}

.pin-panel {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.pin-panel div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.hidden {
  display: none;
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 22px, 720px);
    gap: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .status-pill {
    min-width: 78px;
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .control-panel {
    padding: 14px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
