:root {
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --surface-subtle: #F2F0EC;
  --text: #1C1B18;
  --text-muted: #5F5C55;
  --border: #E5E2DA;
  --border-strong: #D0CBC0;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --recording: #DC2626;
  --recording-hover: #B91C1C;
  --recording-ring: rgba(220, 38, 38, 0.22);
  --success: #16A34A;
  --success-bg: #ECFDF3;
  --warning-bg: #FEF3C7;
  --warning-border: #F59E0B;
  --warning-text: #92400E;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(28, 27, 24, 0.06), 0 1px 3px rgba(28, 27, 24, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.page-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 44px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--text);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9CA3AF;
}

.status-listening {
  color: var(--recording);
  border-color: rgba(220, 38, 38, 0.35);
  background: #FEF2F2;
}

.status-listening .status-dot {
  background: var(--recording);
  animation: dot-pulse 1.3s ease-in-out infinite;
}

.status-stopped {
  color: var(--text);
}

.status-stopped .status-dot {
  background: var(--primary);
}

.status-unsupported {
  color: var(--warning-text);
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.status-unsupported .status-dot {
  background: var(--warning-border);
}

.alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 0.92rem;
  font-weight: 500;
}

.alert-icon {
  flex-shrink: 0;
}

.workspace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #FCFBFA;
  flex-wrap: wrap;
}

.toolbar-primary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible,
.toggle-control input:focus-visible + .toggle-track,
.transcript-editor:focus-visible,
.btn-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary.is-recording {
  background: var(--recording);
  animation: record-ring 1.7s ease-out infinite;
}

.btn-primary.is-recording:hover:not(:disabled) {
  background: var(--recording-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.btn-secondary.is-copied {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(22, 163, 74, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-subtle);
  color: var(--text);
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #D1CEC5;
  position: relative;
  transition: background-color 0.16s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s ease;
}

.toggle-control input:checked + .toggle-track {
  background: var(--primary);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.interim-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
  font-size: 0.87rem;
}

.interim-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.interim-text {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.interim-bar.is-listening .interim-text {
  color: var(--text);
}

.waveform {
  display: none;
  align-items: center;
  gap: 3px;
  height: 16px;
  flex-shrink: 0;
}

.interim-bar.is-listening .waveform {
  display: inline-flex;
}

.waveform span {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--recording);
  animation: wave 0.9s ease-in-out infinite;
}

.waveform span:nth-child(2) {
  animation-delay: 0.15s;
}

.waveform span:nth-child(3) {
  animation-delay: 0.3s;
}

.command-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: #E0E7FF;
  color: #1E40AF;
  font-size: 0.78rem;
  font-weight: 600;
}

.undo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: #EFF6FF;
  border-bottom: 1px solid #BFDBFE;
  color: #1E3A8A;
  font-size: 0.88rem;
}

.btn-link {
  background: none;
  border: none;
  padding: 2px 6px;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.editor-wrap {
  padding: 0;
}

.transcript-editor {
  display: block;
  width: 100%;
  min-height: 310px;
  padding: 20px 22px;
  border: 0;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1.08rem;
  line-height: 1.7;
}

.transcript-editor::placeholder {
  color: #9A958B;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: #FCFBFA;
  color: var(--text-muted);
  font-size: 0.82rem;
  flex-wrap: wrap;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text);
}

.commands-section {
  margin-top: 22px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.commands-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.commands-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.commands-tip {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.commands-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.command-group h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

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

.command-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.chip-phrase {
  font-weight: 600;
  color: var(--text);
}

.chip-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

.chip-stop .chip-symbol {
  color: var(--recording);
}

@keyframes dot-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

@keyframes record-ring {
  0% {
    box-shadow: 0 0 0 0 var(--recording-ring);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
  }
}

@keyframes wave {
  0%, 100% {
    height: 5px;
  }
  50% {
    height: 15px;
  }
}

@media (max-width: 600px) {
  .page-shell {
    padding: 18px 12px 32px;
  }

  .toolbar {
    padding: 12px;
  }

  .btn {
    padding: 9px 13px;
    font-size: 0.9rem;
  }

  .transcript-editor {
    padding: 16px;
    min-height: 260px;
    font-size: 1rem;
  }
}

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