:root {
  --bg: #f4efe7;
  --panel: #fffaf2;
  --panel-strong: #f6ede0;
  --ink: #102027;
  --muted: #6f7d82;
  --accent: #e35c42;
  --accent-soft: #ffd9cd;
  --line: rgba(16, 32, 39, 0.08);
  --shadow: 0 18px 40px rgba(16, 32, 39, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(227, 92, 66, 0.12), transparent 35%),
    linear-gradient(180deg, #fbf6ef 0%, #f3ecdf 100%);
}

body {
  font-family: "Avenir Next", "SF Pro Display", "Helvetica Neue", sans-serif;
  color: var(--ink);
}

button {
  font: inherit;
  touch-action: manipulation;
}

.lite-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.lite-card {
  width: min(100%, 430px);
  min-height: min(88vh, 860px);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 18px;
  padding: 18px;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(249, 241, 229, 0.98));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.control-row,
.bottombar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

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

.chip,
.action-btn {
  border: 0;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 12px 16px;
  min-height: 46px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.chip:active,
.action-btn:active {
  transform: scale(0.98);
}

.chip.is-model-0 {
  background: #eef6f3;
  color: #19463b;
  box-shadow: inset 0 0 0 1px rgba(25, 70, 59, 0.12);
}

.chip.is-model-1 {
  background: #fff0e8;
  color: #8c3c27;
  box-shadow: inset 0 0 0 1px rgba(140, 60, 39, 0.12);
}

.chip.is-mode-raw {
  background: #f2efe9;
  color: #5d605f;
}

.chip.is-mode-refine {
  background: #e8f4ff;
  color: #21577d;
  box-shadow: inset 0 0 0 1px rgba(33, 87, 125, 0.12);
}

.chip.is-mode-written {
  background: #f5ebff;
  color: #69429c;
  box-shadow: inset 0 0 0 1px rgba(105, 66, 156, 0.12);
}

.level-strip {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  align-items: center;
  height: 14px;
}

.level-strip span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: rgba(111, 125, 130, 0.16);
  transition:
    background 90ms linear,
    opacity 90ms linear,
    transform 90ms linear;
  opacity: 0.36;
  transform: scaleY(0.82);
}

.level-strip span.active {
  opacity: 1;
  transform: scaleY(1);
}

.level-strip span.low {
  background: #7dc7a0;
}

.level-strip span.mid {
  background: #f1c35c;
}

.level-strip span.high {
  background: #ea6a4b;
}

.record-button {
  position: relative;
  width: min(24vw, 96px);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}

.record-ring,
.record-core {
  position: absolute;
  border-radius: 50%;
}

.record-ring {
  inset: 0;
  background: linear-gradient(180deg, #fff7f1, #f7e8db);
  box-shadow:
    inset 0 0 0 1px rgba(16, 32, 39, 0.05),
    0 20px 40px rgba(227, 92, 66, 0.16);
}

.record-core {
  inset: 22%;
  background: var(--accent);
  box-shadow:
    inset 0 -8px 18px rgba(0, 0, 0, 0.12),
    0 10px 20px rgba(227, 92, 66, 0.28);
}

.record-button.is-recording .record-ring::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(227, 92, 66, 0.22);
  animation: pulse 1.6s infinite;
}

.record-button.is-recording .record-core {
  inset: 28%;
  border-radius: 28px;
}

.timer {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.message-panel {
  min-height: 240px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 18px;
  overflow: auto;
}

#messageOutput {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "PingFang TC", "Hiragino Sans GB", "Noto Sans CJK TC", sans-serif;
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--ink);
}

.action-btn {
  min-width: 84px;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c9d2d4;
  transition: background 160ms ease, transform 160ms ease;
}

.status-dot.ready {
  background: #76b39d;
}

.status-dot.busy {
  background: var(--accent);
  transform: scale(1.1);
}

.status-dot.error {
  background: #cc3f3f;
}

.meta-line {
  min-height: 18px;
  text-align: center;
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: var(--muted);
  line-height: 1.5;
}

.meta-line div + div {
  margin-top: 2px;
}

@keyframes pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.16);
    opacity: 0;
  }
}

@media (max-width: 420px) {
  .lite-card {
    min-height: calc(100vh - 24px);
    border-radius: 28px;
    padding: 16px;
  }

  .control-row {
    gap: 10px;
  }

  #messageOutput {
    font-size: 1.02rem;
  }
}
