:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #111827;
  --accent-soft: #eef2ff;
  --blue: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 14px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}

.dot.live {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.18);
  animation: pulse 1.4s infinite;
}

.dot.ready {
  background: var(--ok);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.75; }
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.toolbar {
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lang-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.toggle-chip input {
  accent-color: var(--blue);
  margin: 0;
}

select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
}

select:disabled {
  opacity: 0.45;
}

.arrow {
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.pane {
  display: none;
}

.pane.active {
  display: block;
}

.empty-state {
  margin: 36px auto;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
  padding: 24px 18px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-title {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
}

.empty-desc {
  margin: 0;
  font-size: 13px;
}

.transcript-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.utterance {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.utterance.interim {
  border-color: #93c5fd;
  background: #f8fbff;
}

.utterance-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.utterance-src {
  font-size: 15px;
  color: var(--text);
  word-break: break-word;
}

.utterance-tr {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
  color: var(--blue);
  word-break: break-word;
}

.summary-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.summary-exports {
  display: flex;
  gap: 6px;
}

.summary-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.7;
}

.summary-output h1,
.summary-output h2,
.summary-output h3 {
  margin: 12px 0 6px;
  font-size: 16px;
}

.summary-output ul,
.summary-output ol {
  padding-left: 20px;
  margin: 6px 0;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.dock {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  min-width: 44px;
}

.meter-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  transition: width 80ms linear;
}

.dock-actions {
  display: flex;
  gap: 10px;
}

.btn-record {
  flex: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.btn-record.recording {
  background: var(--danger);
}

.rec-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

.btn-record.recording .rec-indicator {
  background: #fff;
  border-radius: 2px;
}

.btn-primary {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 14px;
  font-weight: 600;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}

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

.btn-primary.full {
  width: 100%;
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12.5px;
  cursor: pointer;
}

.btn-ghost.small {
  padding: 4px 10px;
  font-size: 12px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
  }
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 640px) {
  .modal-card {
    border-radius: 18px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
}

.close-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="password"],
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.history-item-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.history-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.history-del {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
}

.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.hidden {
  display: none;
}
