:root {
  color-scheme: light;
  --ink: #13233f;
  --muted: #65728a;
  --line: #dfe5ee;
  --canvas: #f4f7fb;
  --surface: #ffffff;
  --accent: #2563eb;
  --accent-dark: #194cb8;
  --success: #16845b;
  --danger: #c63c47;
  --shadow: 0 18px 50px rgba(38, 55, 86, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid rgba(210, 220, 234, 0.8);
  background: rgba(244, 247, 251, 0.88);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: var(--ink);
  font-size: 20px;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: -0.02em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: clamp(38px, 6vw, 78px) 0 80px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 36px; margin-bottom: 76px; }
.intro h1 { max-width: 720px; margin: 10px 0 20px; font-size: clamp(40px, 6vw, 72px); line-height: 0.98; letter-spacing: -0.055em; }
.lede { max-width: 660px; margin: 0; color: var(--muted); font-size: clamp(16px, 2vw, 19px); line-height: 1.65; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.14em; }
.section-heading, .surface-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading { margin-bottom: 22px; }
h2 { margin: 5px 0 0; font-size: clamp(23px, 3vw, 30px); letter-spacing: -0.035em; }
h3 { margin: 0; font-size: 20px; }

.primary-button, .secondary-button, .icon-button, .microphone-setup {
  min-height: 48px;
  border-radius: 14px;
  padding: 12px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 750;
}
.primary-button { color: white; background: var(--accent); box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22); }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled, .secondary-button:disabled { opacity: 0.48; cursor: not-allowed; }
.secondary-button, .microphone-setup, .icon-button { border-color: var(--line); background: white; }
.secondary-button:hover, .microphone-setup:hover { border-color: var(--accent); color: var(--accent); }
.count-badge, .secure-pill, .save-status {
  border-radius: 999px;
  padding: 7px 11px;
  background: #e8eef8;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.app-card {
  position: relative;
  display: grid;
  min-height: 255px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.app-card:hover { transform: translateY(-3px); box-shadow: 0 24px 65px rgba(38, 55, 86, 0.14); }
.app-card::after {
  position: absolute;
  right: -55px;
  bottom: -70px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-color) 11%, transparent);
  content: "";
}
.application-logo {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 17px;
  color: white;
  background: var(--card-color, var(--accent));
  font-size: 20px;
  font-weight: 850;
  object-fit: cover;
}
.application-logo.large { width: 78px; height: 78px; border-radius: 24px; font-size: 30px; }
.app-card h3 { align-self: end; margin: 24px 0 5px; }
.app-card p { margin: 0; color: var(--muted); }
.app-card footer { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; font-size: 12px; font-weight: 700; }
.presence { display: inline-flex; align-items: center; gap: 7px; color: var(--success); }
.presence::before, .availability-pill span { width: 8px; height: 8px; border-radius: 50%; background: currentColor; content: ""; }

.empty-state {
  display: grid;
  min-height: 330px;
  place-items: center;
  align-content: center;
  gap: 11px;
  border: 1px dashed #bdc8d8;
  border-radius: 26px;
  color: var(--muted);
  text-align: center;
}
.empty-state h3 { color: var(--ink); }
.empty-state p { max-width: 420px; margin: 0 0 10px; }
.empty-icon { display: grid; width: 60px; height: 60px; place-items: center; border-radius: 20px; background: white; color: var(--accent); font-size: 30px; }

.back-button { margin-bottom: 24px; padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.application-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
  padding: 28px;
  border-radius: 26px;
  background: var(--ink);
  color: white;
}
.application-hero .eyebrow { color: #91b4ff; }
.application-hero h1 { margin: 4px 0; font-size: clamp(30px, 4vw, 44px); letter-spacing: -0.045em; }
.application-hero p:not(.eyebrow) { margin: 0; color: #b9c7de; }
.availability-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 13px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: #6fe0b2; font-size: 12px; font-weight: 750; white-space: nowrap; }
.availability-pill.offline { color: #ffd47b; }

.detail-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; }
.surface { padding: clamp(22px, 3vw, 30px); border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: var(--shadow); }
.surface-copy { margin: 14px 0 24px; color: var(--muted); line-height: 1.6; }
.call-button {
  display: flex;
  width: 100%;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 11px;
  border: 0;
  border-radius: 18px;
  color: white;
  background: var(--success);
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}
.call-button:disabled { opacity: 0.48; cursor: not-allowed; }
.call-icon { display: inline-grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.2); font-size: 11px; }
.microphone-setup { width: 100%; margin-top: 12px; }
.microphone-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.secure-pill { color: var(--success); background: #e8f7f1; }
.save-status { color: var(--success); background: transparent; padding-right: 0; }

.profile-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 22px; }
.profile-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.profile-form label:first-child, .profile-form button { grid-column: 1 / -1; }
.profile-form label span { color: var(--danger); }
input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: white;
}
input:disabled { color: var(--muted); background: #f4f6f9; }

.metrics-card { grid-column: 1 / -1; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.metric { padding: 16px; border-radius: 17px; background: #f4f7fb; }
.metric strong, .metric small { display: block; }
.metric strong { font-size: 25px; letter-spacing: -0.04em; }
.metric small { margin-top: 3px; color: var(--muted); }
.history-list { display: grid; gap: 9px; }
.history-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; padding: 14px 0; border-top: 1px solid var(--line); }
.history-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 13px; background: #e8f7f1; color: var(--success); }
.history-item.failed .history-icon { color: var(--danger); background: #fff0f0; }
.history-item strong, .history-item small { display: block; }
.history-item small { margin-top: 3px; color: var(--muted); }
.history-duration { color: var(--muted); font-size: 12px; }
.privacy-card { grid-column: 1 / -1; box-shadow: none; }
.privacy-card p:not(.eyebrow) { max-width: 760px; color: var(--muted); line-height: 1.6; }
.text-danger { padding: 8px 0; border: 0; color: var(--danger); background: transparent; cursor: pointer; font-weight: 750; }

.enroll-dialog { width: min(520px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 26px; box-shadow: 0 35px 90px rgba(15, 30, 55, 0.28); }
.enroll-dialog::backdrop { background: rgba(15, 30, 55, 0.6); backdrop-filter: blur(5px); }
.dialog-shell { padding: 26px; }
.close-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: white; cursor: pointer; font-size: 24px; }
.enroll-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 24px 0 20px; padding: 5px; border-radius: 14px; background: #edf1f7; }
.enroll-tabs button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 750; }
.enroll-tabs button[aria-selected="true"] { background: white; box-shadow: 0 3px 12px rgba(27, 42, 68, 0.08); }
.enroll-panel { display: grid; gap: 12px; }
.enroll-panel label { color: var(--muted); font-size: 12px; font-weight: 750; }
.enroll-panel p { margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.scanner-frame { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 18px; background: #111a2b; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-guide { position: absolute; inset: 18%; border: 2px solid rgba(255, 255, 255, 0.92); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28); }
.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.file-button { display: grid; place-items: center; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.call-screen { position: fixed; z-index: 100; inset: 0; overflow: auto; color: white; background: #0c1729; }
.call-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, #294a73 0, #142541 35%, #09111f 82%); }
.call-content { position: relative; display: flex; width: min(600px, 100%); min-height: 100dvh; margin: auto; padding: max(38px, env(safe-area-inset-top)) 24px max(30px, env(safe-area-inset-bottom)); flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.call-kicker { position: absolute; top: max(30px, env(safe-area-inset-top)); margin: 0; color: #9db1cd; font-size: 11px; font-weight: 800; letter-spacing: 0.16em; }
.call-avatar { display: grid; width: 126px; height: 126px; place-items: center; border: 2px solid rgba(255, 255, 255, 0.45); border-radius: 40px; background: var(--accent); box-shadow: 0 0 0 16px rgba(255, 255, 255, 0.04), 0 24px 70px rgba(0, 0, 0, 0.34); font-size: 44px; font-weight: 850; animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.035); box-shadow: 0 0 0 24px rgba(255, 255, 255, 0.03), 0 28px 80px rgba(0, 0, 0, 0.42); } }
.call-content h2 { margin-top: 30px; font-size: clamp(30px, 7vw, 42px); }
.call-state { margin: 10px 0 6px; color: #b4c2d6; }
#callTimer { font-variant-numeric: tabular-nums; color: #dbe5f5; }
.call-actions { display: flex; gap: 34px; margin-top: 56px; }
.call-actions button { display: grid; gap: 8px; justify-items: center; border: 0; color: white; background: transparent; cursor: pointer; }
.call-actions span { display: grid; width: 66px; height: 66px; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.14); font-size: 24px; }
.call-actions .end-call span { background: #e84b56; transform: rotate(135deg); }
.call-actions small { font-size: 12px; }
.call-details { width: 100%; margin-top: 44px; color: #91a4bf; font-size: 11px; }
.call-details summary { cursor: pointer; }
#callLog { max-height: 120px; margin-top: 10px; overflow: auto; text-align: left; }
.call-screen audio { display: none; }

.toast { position: fixed; z-index: 200; right: 20px; bottom: 20px; max-width: min(400px, calc(100% - 40px)); padding: 14px 17px; border-radius: 14px; color: white; background: var(--ink); box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .metrics-card, .privacy-card { grid-column: auto; }
  .application-hero { grid-template-columns: auto 1fr; }
  .availability-pill { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 620px) {
  .topbar { min-height: 66px; padding-inline: 16px; }
  main { width: min(100% - 28px, 1180px); padding-top: 30px; }
  .intro { align-items: stretch; flex-direction: column; margin-bottom: 48px; }
  .intro .primary-button { width: 100%; }
  .app-grid { grid-template-columns: 1fr; }
  .app-card { min-height: 220px; }
  .application-hero { grid-template-columns: 1fr; text-align: center; }
  .application-logo.large, .availability-pill { justify-self: center; }
  .profile-form, .metric-row { grid-template-columns: 1fr 1fr; }
  .profile-form label { grid-column: 1 / -1; }
  .surface-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .save-status { padding-left: 0; }
  .scan-actions { grid-template-columns: 1fr; }
}

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