/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --border: #E2E8F0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input { font-family: inherit; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  font-size: 24px;
  line-height: 1;
}
.app-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.app-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.header-right {
  display: flex;
  gap: 4px;
}

/* ─── Icon Button ────────────────────────────────────────────────────────── */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}
.icon-btn svg { display: block; }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
}
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.view.hidden { display: none; }

/* ─── Idle View ──────────────────────────────────────────────────────────── */
.greeting {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}
.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  margin: 16px 0;
}
.record-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.15);
}
.record-btn:active { transform: scale(0.97); }
.record-icon-inner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
}
.record-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.hint {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
}

/* ─── Recording View ─────────────────────────────────────────────────────── */
.recording-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
}
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.rec-label { flex: 1; }
.rec-timer {
  font-variant-numeric: tabular-nums;
  color: var(--danger);
}
.transcript-box {
  width: 100%;
  flex: 1;
  min-height: 200px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  box-shadow: var(--shadow);
}
.transcript-box::-webkit-scrollbar { width: 4px; }
.transcript-box::-webkit-scrollbar-track { background: transparent; }
.transcript-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.interim { color: var(--text-tertiary); }
.cursor-blink {
  color: var(--primary);
  animation: blink 1s step-end infinite;
  font-weight: 300;
}
.recording-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── Processing View ────────────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 60px;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-text {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ─── Results View ───────────────────────────────────────────────────────── */
#results-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.result-greeting {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  padding: 4px 0 8px;
}
.result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: #FAFAFA;
}
.result-section-body {
  padding: 4px 0;
}

/* Priority items */
.priority-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.priority-item:last-child { border-bottom: none; }
.urgency-chip {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 7px;
  border-radius: 20px;
  margin-top: 2px;
}
.urgency-high { background: #FEE2E2; color: #DC2626; }
.urgency-medium { background: #FEF3C7; color: #D97706; }
.urgency-low { background: #D1FAE5; color: #059669; }
.priority-text strong { font-size: 14px; font-weight: 600; color: var(--text); display: block; }
.priority-text p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }

/* Delegate / Help items */
.list-item {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 3px;
}
.list-item:last-child { border-bottom: none; }
.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.list-item-sub {
  font-size: 13px;
  color: var(--text-secondary);
}
.list-item-to {
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
}

/* Can wait */
.wait-list {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wait-item {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.wait-item:last-child { border-bottom: none; }
.wait-item::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}

/* Insight */
.insight-card {
  background: linear-gradient(135deg, #EFF6FF, #F0FDF4);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  color: #1E40AF;
  line-height: 1.5;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.insight-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.results-actions {
  width: 100%;
  display: flex;
  gap: 10px;
  padding-top: 8px;
}

/* ─── Follow-up View ─────────────────────────────────────────────────────── */
.followup-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.primary-btn {
  flex: 1;
  padding: 12px 20px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background 0.15s, transform 0.1s;
}
.primary-btn:hover { background: var(--primary-dark); }
.primary-btn:active { transform: scale(0.98); }

.secondary-btn {
  flex: 1;
  padding: 12px 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.secondary-btn:hover { background: var(--bg); }
.secondary-btn:active { transform: scale(0.98); }

.stop-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--danger);
  color: white;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background 0.15s, transform 0.1s;
}
.stop-btn:hover { background: #DC2626; }
.stop-btn:active { transform: scale(0.98); }

.ghost-btn {
  padding: 12px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.ghost-btn:hover { background: var(--bg); }

.danger-btn {
  padding: 10px 16px;
  background: #FEF2F2;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid #FECACA;
  transition: background 0.15s;
}
.danger-btn:hover { background: #FEE2E2; }

/* ─── Side Panel (Memory) ────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 92vw);
  height: 100%;
  background: var(--surface);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(0);
}
.side-panel.hidden { display: none; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 {
  font-size: 17px;
  font-weight: 700;
}
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Session card in memory panel */
.session-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.session-card:hover { border-color: var(--primary); }
.session-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.session-priorities {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.session-priority-item {
  font-size: 13px;
  color: var(--text);
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.session-priority-item::before {
  content: '•';
  color: var(--primary);
  flex-shrink: 0;
}
.session-insight {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
}
.memory-empty {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 40px 20px;
  line-height: 1.6;
}

/* Known context section */
.context-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.context-section-title {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: #FAFAFA;
  border-bottom: 1px solid var(--border);
}
.context-tag-list {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.context-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text);
}

/* ─── Settings Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.setting-section { display: flex; flex-direction: column; gap: 10px; }
.setting-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.help-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── Error Toast ────────────────────────────────────────────────────────── */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1E293B;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  max-width: 340px;
  text-align: center;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal {
    border-radius: var(--radius);
    max-height: 80vh;
    margin: 0 20px;
  }
}
