:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #2dd4bf;
  --accent-dim: #14b8a6;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #4ade80;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.app-header .back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 8px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.health-dot.ok { background: var(--ok); }
.health-dot.warn { background: var(--warn); }
.health-dot.err { background: var(--danger); }

main {
  flex: 1;
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.view-title {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.view-sub {
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.mode-cards {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  text-align: left;
  color: inherit;
  width: 100%;
}

.mode-card:hover, .mode-card:focus {
  border-color: var(--accent);
  transform: translateY(-1px);
  outline: none;
}

.mode-card .icon { font-size: 2rem; margin-bottom: 12px; }
.mode-card h2 { font-size: 1.15rem; margin-bottom: 6px; }
.mode-card p { color: var(--muted); font-size: 0.9rem; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
}

input:focus, textarea:focus {
  outline: 2px solid var(--accent-dim);
  border-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-dim); color: #042f2e; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #7f1d1d; color: #fecaca; }
.btn-block { width: 100%; }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-active { background: #064e3b; color: var(--ok); }
.badge-awaiting { background: #422006; color: var(--warn); }
.badge-completed { background: #1e293b; color: var(--muted); }
.badge-recording { background: #7f1d1d; color: #fecaca; animation: pulse 1.5s infinite; }
.badge-failed { background: #450a0a; color: #fca5a5; }
.badge-analysis { background: #1e3a5f; color: #93c5fd; text-transform: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.transcript-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 280px;
  max-height: 50dvh;
  overflow-y: auto;
  padding: 16px;
}

.transcript-empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 16px;
  font-size: 0.9rem;
}

.seg {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.seg:last-child { border-bottom: none; }
.seg-speaker {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 2px;
}
.seg-text { font-size: 0.95rem; }
.seg-pending { opacity: 0.65; }

.meeting-list { display: grid; gap: 10px; }

.meeting-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.meeting-item:hover { border-color: var(--accent); }

.meeting-item h3 {
  font-size: 0.95rem;
  margin-bottom: 4px;
  flex: 1;
  min-width: 0;
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.fail-reason {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #fca5a5;
  line-height: 1.4;
}

.fail-hint { color: var(--warn); }

.summary-panel { margin-top: 12px; }

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

.summary-box h4 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.summary-text {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}

.meeting-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 0.9rem;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 100;
  max-width: 90%;
  animation: fadein 0.2s;
}
@keyframes fadein { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

.nav-bottom {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px;
  gap: 4px;
}

.nav-bottom button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 8px;
}
.nav-bottom button.active {
  color: var(--accent);
  background: var(--surface2);
}

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-info { background: #0c4a6e; color: #bae6fd; }
.alert-warn { background: #422006; color: #fde68a; }

.mic-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  margin: 12px 0;
}
.mic-bar {
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  height: 8px;
  transition: height 0.1s;
}

.install-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #134e4a 0%, #1a2332 100%);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  animation: fadein 0.3s;
}
.install-banner .install-icon { font-size: 1.5rem; flex-shrink: 0; }
.install-banner .install-body { flex: 1; min-width: 0; }
.install-banner h3 { font-size: 0.95rem; margin-bottom: 4px; }
.install-banner p { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.install-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.install-actions .btn { padding: 8px 14px; font-size: 0.85rem; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(45, 212, 191, 0.06);
}
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.upload-zone p { color: var(--muted); font-size: 0.9rem; }
.upload-zone .file-name {
  margin-top: 10px;
  color: var(--accent);
  font-size: 0.85rem;
  word-break: break-all;
}
.upload-progress {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}
.upload-progress .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-wrap { margin: 8px 0 12px; }
.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}
.progress-wrap small { color: var(--muted); font-size: 0.78rem; }

.view-toggle { display: inline-flex; gap: 4px; margin-left: auto; }
.view-toggle .btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
}
.view-toggle .btn-sm.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(45, 212, 191, 0.1);
}

.badge-analysis { background: #1e3a5f; color: #93c5fd; }
.fail-reason { font-size: 0.85rem; color: var(--warn); margin-top: 8px; }
.fail-hint { color: var(--warn); font-size: 0.8rem; }
