:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --surface-2: #232d39;
  --text: #e8eef2;
  --muted: #8b9aab;
  --accent: #3d9a8c;
  --accent-2: #2f7a70;
  --danger: #c45c5c;
  --warn: #d4a24c;
  --line: #2c3846;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body {
  padding-top: var(--safe-top);
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + var(--safe-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 1.35rem;
  font-weight: 650;
  margin: 0;
}

h2 {
  font-size: 1rem;
  margin: 0 0 10px;
  font-weight: 650;
}

.status {
  margin: 14px 0 10px;
  color: var(--muted);
  min-height: 1.4em;
}

.wave {
  display: block;
  width: 100%;
  height: 88px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.note-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.note {
  display: block;
  width: 100%;
  min-height: 7.5em;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.5;
}

.talk {
  display: block;
  width: 100%;
  margin: 16px 0 20px;
  min-height: 72px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #f4fffc;
  font-size: 1.05rem;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
}

.talk,
.talk * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none;
}

.talk-label {
  pointer-events: none;
}

.talk-label::after {
  content: attr(data-label);
  pointer-events: none;
}

.talk:disabled {
  opacity: 0.55;
}

.talk.recording {
  background: var(--danger);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    filter: brightness(1.18);
    transform: scale(1.015);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.result-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
  user-select: text;
  min-height: 3em;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

.link-btn,
button.primary,
button.ghost,
button.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.link-btn,
button.primary {
  background: var(--accent-2);
  border-color: transparent;
  color: #f4fffc;
}

.link-btn.secondary {
  background: var(--surface-2);
  color: var(--text);
}

button.ghost {
  background: transparent;
}

button.small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.warn {
  color: var(--warn);
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history li {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.history li:first-child {
  border-top: 0;
  padding-top: 0;
}

.history li.latest {
  background: var(--surface-2);
  margin: 0 -8px;
  padding: 12px 8px;
  border-radius: 10px;
}

.history .meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.history .excerpt {
  margin: 0 0 8px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  color: var(--muted);
}

.ios-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 8px 0;
}

.foot {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 8px 0 0;
}

.settings {
  width: min(92vw, 440px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  padding: 0;
}

.settings::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.settings form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.settings label {
  font-weight: 650;
  margin-top: 8px;
}

.settings input,
.settings textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

audio {
  width: 100%;
  margin: 10px 0 0;
}

.default-prompt {
  margin: 0;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
