/* HangON design system: one set of tokens, one grid, one card. Dark is the default theme. */

:root {
  --bg: #0b0f0e;
  --surface: #121816;
  --surface-2: #19211e;
  --border: #25312d;
  --text: #e9f0ed;
  --muted: #95a59f;
  --faint: #6b7a75;
  --accent: #34d399;
  --accent-strong: #10b981;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --accent-ink: #03140d;
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.25);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 72px;

  --radius: 14px;
  --radius-sm: 10px;
  --container: 1120px;
  --gutter: 24px;
  --header-h: 64px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #f0f4f2;
  --border: #dde6e2;
  --text: #0f1b17;
  --muted: #5a6a65;
  --faint: #83928d;
  --accent: #0b9468;
  --accent-strong: #087a56;
  --accent-soft: rgba(11, 148, 104, 0.1);
  --accent-ink: #ffffff;
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --shadow: 0 1px 2px rgba(15, 27, 23, 0.05), 0 12px 32px rgba(15, 27, 23, 0.06);
  color-scheme: light;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + var(--space-5)); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
h1, h2, h3, p, dl, dd, ol, ul, figure, blockquote { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

h1 { font-size: clamp(2.1rem, 4.4vw, 3.4rem); line-height: 1.08; letter-spacing: -0.03em; font-weight: 800; text-wrap: balance; }
h2 { font-size: clamp(1.4rem, 2.2vw, 1.75rem); line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; text-wrap: balance; }
h3 { font-size: 1.05rem; line-height: 1.3; font-weight: 700; }
.card-head h2 { font-size: 1.1rem; letter-spacing: -0.01em; }

.container { width: 100%; max-width: calc(var(--container) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }

.eyebrow, .label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.eyebrow { color: var(--accent); margin-bottom: var(--space-3); }
.lead { color: var(--muted); font-size: 1.15rem; max-width: 34rem; text-wrap: pretty; }
.caption { color: var(--faint); font-size: 0.85rem; }
.text-accent { color: var(--accent); }
.text-warn { color: var(--warn); }
.is-empty { color: var(--faint) !important; font-weight: 500 !important; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-row { height: var(--header-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-5); }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); justify-self: start; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; }
.brand-name { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.main-nav { display: flex; gap: var(--space-1); }
.main-nav a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--muted); font-size: 0.92rem; font-weight: 600; transition: color 0.15s, background 0.15s; }
.main-nav a:hover { color: var(--text); background: var(--surface-2); }
.main-nav a.active { color: var(--text); background: var(--surface-2); }
.header-actions { display: flex; align-items: center; gap: var(--space-3); justify-self: end; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
}
.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.button-lg { height: 48px; padding: 0 var(--space-5); font-size: 1rem; }
.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-primary:hover:not(:disabled) { background: var(--accent-strong); }
:root[data-theme="light"] .button-primary:hover:not(:disabled) { background: var(--accent-strong); }
.button-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.button-ghost:hover { background: var(--surface-2); }
.button-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.theme-toggle-btn {
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.theme-toggle-btn:hover { color: var(--text); background: var(--surface-2); }

/* Chips and badges */
.status-chip, .badge-tech {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.status-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-safe, .badge-safe { background: var(--accent-soft); color: var(--accent); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-neutral { background: var(--surface-2); color: var(--muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); min-height: 40px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-5); }
.field-grid > div { min-width: 0; }
.field-grid .span-2 { grid-column: span 2; }
.field-grid dt { color: var(--muted); font-size: 0.78rem; font-weight: 600; margin-bottom: 2px; }
.field-grid dd { font-weight: 700; overflow-wrap: anywhere; }

/* Home: hero */
.hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--space-7); align-items: center; padding-top: var(--space-8); padding-bottom: var(--space-8); }
.hero-copy h1 { margin-bottom: var(--space-4); }
.hero-copy .lead { margin-bottom: var(--space-6); }
.example-card { display: grid; gap: var(--space-4); }
.example-block { display: grid; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); }
.quote { font-size: 1rem; color: var(--text); text-wrap: pretty; }
.example-arrow { width: 2px; height: 20px; margin: calc(var(--space-2) * -1) auto; background: var(--border); position: relative; }
.example-arrow::after { content: ""; position: absolute; left: 50%; bottom: -2px; width: 8px; height: 8px; border-right: 2px solid var(--border); border-bottom: 2px solid var(--border); transform: translateX(-50%) rotate(45deg); }

/* Home: sections */
.section { padding-bottom: var(--space-8); }
.section-head { margin-bottom: var(--space-5); }
.section-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.step { display: grid; gap: var(--space-2); }
.step-num { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-bottom: var(--space-2); border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 0.9rem; }
.step p { color: var(--muted); }

/* Home: schedule */
.schedule-card { padding: 0; overflow: hidden; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--border); }
.stat { display: grid; gap: var(--space-1); padding: var(--space-4) var(--space-5); min-width: 0; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat strong { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appointments-feed { display: grid; }
.appointment-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto;
  gap: var(--space-5);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.appointment-row:last-child { border-bottom: 0; }
.apt-primary-col, .apt-secondary-col { display: grid; gap: 2px; min-width: 0; }
.apt-primary-col strong, .apt-secondary-col strong { font-weight: 700; }
.apt-primary-col span, .apt-secondary-col span { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apt-status-col { display: flex; gap: var(--space-2); justify-content: flex-end; }
.empty-row { padding: var(--space-6) var(--space-5); color: var(--muted); text-align: center; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-top: var(--space-5); padding-bottom: var(--space-5); color: var(--muted); font-size: 0.9rem; }
.footer-links { display: flex; gap: var(--space-5); }
.footer-links a:hover { color: var(--text); }

/* Live call page */
.call-page { padding-top: var(--space-6); padding-bottom: var(--space-8); display: grid; gap: var(--space-5); align-content: start; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: var(--space-3); }
.page-title h1 { font-size: clamp(1.6rem, 3vw, 2rem); }
.voice-setting { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.voice-setting select {
  height: 40px;
  padding: 0 var(--space-6) 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%2395a59f' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.sample-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

.call-grid, .results-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: var(--space-5); align-items: start; }
.results-grid:not(:has(> :not([hidden]))) { display: none; }
.call-panel, .details-panel { min-height: 100%; }

.voice-stage { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-5) 0; margin-bottom: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); }
.hint { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 0 var(--space-4); }

.voice-orb { position: relative; width: 72px; height: 72px; display: grid; place-items: center; }
.orb-core { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 24px var(--accent-soft); transition: transform 0.3s; }
.orb-ring-1, .orb-ring-2 { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
.orb-listening .orb-ring-1 { animation: ring 1.8s ease-out infinite; }
.orb-listening .orb-ring-2 { animation: ring 1.8s ease-out 0.9s infinite; }
.orb-speaking .orb-core { animation: pulse 0.8s ease-in-out infinite alternate; }
@keyframes ring { from { transform: scale(0.5); opacity: 0.6; } to { transform: scale(1.3); opacity: 0; } }
@keyframes pulse { from { transform: scale(0.9); } to { transform: scale(1.15); } }

.voice-wave { display: flex; align-items: center; gap: 4px; height: 20px; }
.voice-wave .bar { width: 3px; height: 4px; border-radius: 2px; background: var(--faint); transition: background 0.2s; }
.wave-active .bar { background: var(--accent); animation: wave 0.9s ease-in-out infinite; }
.wave-active .bar:nth-child(2n) { animation-delay: 0.15s; }
.wave-active .bar:nth-child(3n) { animation-delay: 0.3s; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 18px; } }

.conversation { display: grid; gap: var(--space-3); max-height: 380px; overflow-y: auto; align-content: start; }
.conversation-empty { color: var(--faint); font-size: 0.9rem; text-align: center; padding: var(--space-5) 0; }
.message { display: grid; gap: 2px; max-width: 85%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); }
.message span { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.message p { font-size: 0.95rem; }
.message-caller { justify-self: start; background: var(--surface-2); }
.message-agent { justify-self: end; background: var(--accent-soft); }
.message-agent span { color: var(--accent); }

.details-panel { display: grid; gap: var(--space-5); align-content: start; }
.details-panel .card-head { margin-bottom: 0; }
.heard { display: grid; gap: var(--space-2); padding: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); }
.heard-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-1); }
.heard-raw { color: var(--muted); font-size: 0.9rem; font-style: italic; }
.heard-clean { font-weight: 600; }
.slot-line { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

.result-card { display: grid; gap: var(--space-4); align-content: start; }
.result-card .card-head { margin-bottom: 0; }
.receipt-details { display: grid; }
.receipt-row { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.receipt-row:last-child { border-bottom: 0; }
.receipt-row span { color: var(--muted); }
.receipt-row strong { text-align: right; overflow-wrap: anywhere; }
.sms-preview { display: grid; gap: var(--space-2); padding: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); }
.sms-preview p { font-size: 0.9rem; font-family: ui-monospace, "SF Mono", Consolas, monospace; overflow-wrap: anywhere; }
.brief { text-wrap: pretty; }
.brief-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.brief-meta strong { text-transform: capitalize; }
.checklist { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.checklist li { position: relative; padding-left: var(--space-5); font-size: 0.92rem; }
.checklist li::before { content: ""; position: absolute; left: 0; top: 0.35em; width: 12px; height: 12px; border-radius: 4px; border: 2px solid var(--accent); }

/* Operator sign in dialog (built by auth-ui.js) */
.operator-auth-shell { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: var(--space-5); background: rgba(5, 10, 8, 0.6); backdrop-filter: blur(8px); }
.operator-auth-card { width: min(100%, 26rem); padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); display: grid; gap: var(--space-3); }
.operator-auth-card h2 { font-size: 1.4rem; }
.operator-auth-card p { color: var(--muted); }
.operator-auth-card label { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.operator-auth-card input { height: 44px; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.operator-auth-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.operator-auth-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); color: var(--muted); font-size: 0.85rem; }
.operator-auth-submit { height: 40px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.operator-auth-submit:disabled { opacity: 0.6; cursor: wait; }
.operator-auth-status { min-height: 1.3rem; color: var(--warn); font-size: 0.85rem; }

/* Responsive */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: var(--space-6); padding-top: var(--space-7); padding-bottom: var(--space-7); }
  .call-grid, .results-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--border); }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .header-row { grid-template-columns: 1fr auto; }
  .main-nav { display: none; }
  .steps { grid-template-columns: 1fr; }
  .section-head-row { align-items: flex-start; flex-direction: column; }
  .appointment-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .apt-status-col { justify-content: flex-start; }
  .card { padding: var(--space-4); }
  .card-head { flex-wrap: wrap; }
  .footer-row { flex-direction: column; align-items: flex-start; }
  .message { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.checklist li::first-letter { text-transform: uppercase; }
