/* ─────────────────────────────────────────────────────────────────────────────
   Design System — Simply Size AI
   White background, pure-black cards, purple accent
───────────────────────────────────────────────────────────────────────────── */

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

:root {
  /* Colors */
  --bg-primary:     #ffffff;
  --bg-secondary:   #ffffff;
  --bg-tertiary:    #f2f2f7;
  --bg-elevated:    #e5e5ea;

  --text-primary:   #000000;
  --text-secondary: #1c1c1e;
  --text-tertiary:  #6e6e73;
  --text-quaternary:#8e8e93;

  /* iOS system purple (#BF5AF2) — matches Color.purple in the iOS app */
  --accent:         #bf5af2;
  --accent-hover:   #d07df5;
  --accent-dim:     rgba(191, 90, 242, 0.18);
  --accent-glow:    rgba(191, 90, 242, 0.35);

  --accent-green:   #30d158;
  --accent-red:     #ff453a;
  --accent-yellow:  #ffd60a;

  --separator:      rgba(0, 0, 0, 0.12);

  /* Radii */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.6);
  --shadow-btn:  0 2px 12px var(--accent-glow);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
          Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--separator);
}

/* ── Logo / Branding ── */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo img {
  height: 130px;
  width: auto;
  object-fit: contain;
}

.brand-logo-placeholder {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  text-align: center;
}

.brand-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: -4px;
}

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  letter-spacing: -0.1px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
}

.btn-outline:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}

.btn-ghost {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
}

.btn-danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--accent-red);
  border: 1.5px solid rgba(255, 69, 58, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 69, 58, 0.25);
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
  width: auto;
  border-radius: var(--radius-sm);
}

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: var(--separator);
}

.divider-text {
  font-size: 13px;
  color: var(--text-quaternary);
  white-space: nowrap;
}

/* ── Login page ── */
.login-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-quaternary);
  margin-top: 20px;
  line-height: 1.6;
}

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

.login-mission {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--separator);
}

.login-mission-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.login-mission-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.login-mission-link:hover {
  opacity: 0.8;
}

/* ── Landing page (login / about) ── */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow-y: auto;
}

.landing-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}

.landing-nav-logo {
  height: 52px;
  width: auto;
}

.landing-hero-logo {
  margin-bottom: 24px;
}

.landing-hero-logo img {
  width: 100%;
  max-width: 300px;
  height: auto;
  object-fit: contain;
}

.landing-hero {
  background: #000;
  color: #fff;
  padding: 72px 24px 64px;
  text-align: center;
}

.landing-hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.landing-hero h1 {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -1.2px;
  line-height: 1.15;
  margin-bottom: 20px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.landing-hero h1 span { color: var(--accent); }

.landing-hero-sub {
  font-size: 16px;
  color: rgba(255,255,255,0.65);
  max-width: 500px;
  margin: 0 auto 36px;
  line-height: 1.65;
}

.landing-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.18s;
}

.landing-hero-btn:hover { background: var(--accent-hover); }
.landing-hero-btn:active { transform: scale(0.97); }

.landing-body {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 64px;
  width: 100%;
}

.landing-section { margin-bottom: 48px; }

.landing-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 10px;
}

.landing-section h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.6px;
  margin-bottom: 14px;
}

.landing-section p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
}

.landing-section p:last-child { margin-bottom: 0; }

.landing-notice {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  margin-top: 16px;
}

.landing-notice p {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0;
}

.landing-divider {
  height: 1px;
  background: var(--separator);
  margin: 48px 0;
}

.landing-specialty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 500px) {
  .landing-specialty-grid { grid-template-columns: 1fr; }
  .landing-hero h1 { font-size: 28px; }
}

.landing-specialty-card {
  border: 1px solid var(--separator);
  border-radius: 12px;
  padding: 18px 20px;
  background: #fafafa;
}

.landing-specialty-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 12px;
}

.landing-specialty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.landing-specialty-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.landing-footer {
  border-top: 1px solid var(--separator);
  padding: 20px 24px;
}

.landing-footer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
}

.landing-footer-copy {
  font-size: 12px;
  color: var(--text-tertiary);
}

.landing-footer-links {
  display: flex;
  gap: 16px;
}

.landing-footer-links a {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.landing-footer-links a:hover { opacity: 0.8; }

.landing-phi-note {
  width: 100%;
  font-size: 12px;
  color: var(--text-quaternary);
  text-align: center;
  margin: 0;
}

/* ── Welcome / Authenticated page ── */
.welcome-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 900px;
  padding: 20px 0 32px;
}

.welcome-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome-header-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.welcome-header-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.welcome-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-bottom: 80px;
}

.welcome-greeting {
  font-size: 42px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1.5px;
  text-align: center;
}

.welcome-name {
  color: var(--accent);
}

.welcome-tagline {
  font-size: 17px;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 4px;
}

.welcome-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  margin-bottom: 12px;
  object-fit: cover;
}

.welcome-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}

/* ── Loading state ── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* ── Responsive ── */
@media (max-width: 480px) {
  .card {
    padding: 32px 24px;
    border-radius: var(--radius-lg);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCESS DENIED VIEW
═══════════════════════════════════════════════════════════════════════════ */

.access-denied-icon {
  display: flex;
  justify-content: center;
  color: var(--accent-red);
  margin-bottom: 16px;
}

.access-denied-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 12px;
}

.access-denied-body {
  font-size: 14px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 8px;
}

.access-denied-email {
  color: var(--text-secondary);
  font-weight: 600;
}

.access-denied-body a {
  color: var(--accent);
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════════════════════ */

#app-view {
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── App Header Logo Image ── */
.app-header-logo img {
  height: 44px;
  width: auto;
  object-fit: contain;
}

/* ── App Header ── */
.app-header {
  flex-shrink: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--separator);
  z-index: 10;
}

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

.app-header-logo {
  display: flex;
  align-items: center;
}

.app-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-user-name {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ── Tab Bar ── */
.tab-bar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--separator);
  z-index: 10;
  gap: 2px;
}

.tab-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 0 14px;
  height: 44px;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.tab-btn svg {
  stroke: currentColor;
  flex-shrink: 0;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* ── Tab Content ── */
.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}


/* ═══════════════════════════════════════════════════════════════════════════
   PREDICT FORM
═══════════════════════════════════════════════════════════════════════════ */

.predict-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.predict-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* ── Location Row ── */
.location-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.location-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.location-select {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.location-select:focus {
  outline: none;
  border-color: var(--accent);
}

.aneurysm-type-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  padding-left: 2px;
}

/* ── Measurement Sections ── */
.measure-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--separator);
}

.measure-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.measure-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.measure-hint {
  font-size: 11px;
  color: var(--text-quaternary);
  background: var(--bg-tertiary);
  border: 1px solid var(--separator);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: default;
}

/* ── Input Row ── */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.input-row:last-child {
  margin-bottom: 0;
}

.input-row-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  width: 56px;
  flex-shrink: 0;
}

.measure-input {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 16px;
  transition: border-color 0.15s;
}

.measure-input:focus {
  outline: none;
  border-color: var(--accent);
}

.measure-input::placeholder {
  color: var(--text-quaternary);
}

.input-unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  width: 28px;
  flex-shrink: 0;
}

/* ── Action Buttons ── */
.predict-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.predict-actions .btn {
  flex: 1;
}

.btn-predict {
  background: #000000;
  color: #fff;
  border: none;
  box-shadow: 0 0 12px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.2);
}

.btn-predict:hover {
  box-shadow: 0 0 18px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.2);
  background: #1c1c1e;
}

.btn-predict.loading {
  opacity: 0.6;
  pointer-events: none;
}

.btn-report-case {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}

.btn-report-case:hover {
  background: var(--accent-dim);
}

/* ── New Case button ── */
.predict-nav-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

/* ── Placeholder tabs ── */
.placeholder-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: 12px;
  color: var(--text-quaternary);
}

.placeholder-tab svg {
  opacity: 0.3;
}

.placeholder-tab-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.placeholder-tab-sub {
  font-size: 14px;
  color: var(--text-quaternary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   PREDICTION SHEET
═══════════════════════════════════════════════════════════════════════════ */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sheet-overlay.visible {
  opacity: 1;
}

.prediction-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 92vh;
  background: var(--bg-primary);
  border-radius: 20px 20px 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  border-top: 1px solid var(--separator);
}

.prediction-sheet.visible {
  transform: translateY(0);
}

.sheet-grip-wrap {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 12px 0 6px;
  cursor: pointer;
}

.sheet-grip {
  width: 36px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 40px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   ANEURYSM CARD (in sheet)
═══════════════════════════════════════════════════════════════════════════ */

.aneurysm-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  margin: 12px 16px;
  border: 1px solid var(--separator);
  overflow: hidden;
}

.aneurysm-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--separator);
}

.triangular-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 69, 58, 0.12);
  color: var(--accent-red);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 69, 58, 0.2);
  line-height: 1.4;
}

.aneurysm-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.aneurysm-stat {
  padding: 12px 16px;
  border-right: 1px solid var(--separator);
  border-bottom: 1px solid var(--separator);
}

.aneurysm-stat:nth-child(even) {
  border-right: none;
}

.aneurysm-stat:nth-child(3),
.aneurysm-stat:nth-child(4) {
  border-bottom: none;
}

.aneurysm-stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}

.aneurysm-stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Sheet title row ── */
.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sheet-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.btn-export-pdf {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-export-pdf:hover {
  background: var(--accent-dim);
}

/* ── No suggestions message ── */
.no-suggestions {
  padding: 24px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-align: center;
}


/* ═══════════════════════════════════════════════════════════════════════════
   DEVICE CARDS (horizontal scroll)
═══════════════════════════════════════════════════════════════════════════ */

.device-cards-wrap {
  padding: 4px 16px 8px;
}

.device-cards-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}

.device-cards-scroll::-webkit-scrollbar { display: none; }

.device-card {
  flex-shrink: 0;
  width: 280px;
  /* Scoped dark-mode variables — every child inherits these */
  --bg-tertiary:    #1c1c1e;
  --bg-elevated:    #2c2c2e;
  --text-primary:   #ffffff;
  --text-secondary: rgba(235, 235, 245, 0.8);
  --text-tertiary:  rgba(235, 235, 245, 0.6);
  --text-quaternary:rgba(235, 235, 245, 0.3);
  --separator:      rgba(84, 84, 88, 0.65);

  background: #000000;
  border-radius: var(--radius-lg);
  border: 1px solid #2c2c2e;
  overflow: hidden;
  scroll-snap-align: start;
  box-shadow: 0 0 20px rgba(191, 90, 242, 0.18);
}

/* ── Card Header ── */
.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--separator);
}

.device-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.device-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.device-type-arc  { background: rgba(191, 90, 242, 0.2); color: var(--accent); }
.device-type-base { background: rgba(48, 209, 88, 0.15); color: var(--accent-green); }

/* ── Device type image (arc / base) in card header — mirrors iOS 60×30 frame ── */
.device-type-img {
  width: 60px;
  height: 30px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── MC catheter image in MC ID row — mirrors iOS 30×30 frame ── */
.device-mc-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Card Rows ── */
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(84, 84, 88, 0.3);
  gap: 8px;
}

.device-row:last-child {
  border-bottom: none;
}

.device-row-label {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.device-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.device-row-value {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: right;
}

/* ── Quality Badges ── */
.quality-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.quality-acceptable {
  background: rgba(48, 209, 88, 0.15);
  color: var(--accent-green);
}

.quality-uncertain {
  background: rgba(255, 214, 10, 0.15);
  color: var(--accent-yellow);
}

/* ── Metallic Volume subrows ── */
.metal-volume-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.metal-volume-stack span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.metal-volume-total {
  font-weight: 600;
  color: var(--text-secondary) !important;
  border-top: 1px solid var(--separator);
  padding-top: 3px;
  margin-top: 2px;
}

/* ── Insertion Difficulty ── */
.difficulty-section {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(84, 84, 88, 0.3);
}

.difficulty-section-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.difficulty-cell {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  border: 1px solid var(--bg-elevated);
}

.difficulty-cell.diff-low {
  background: rgba(48, 209, 88, 0.08);
  border-color: rgba(48, 209, 88, 0.25);
}

.difficulty-cell.diff-high {
  background: rgba(255, 69, 58, 0.08);
  border-color: rgba(255, 69, 58, 0.25);
}

.difficulty-angle {
  font-size: 10px;
  color: var(--text-quaternary);
  margin-bottom: 4px;
}

.difficulty-value {
  font-size: 11px;
  font-weight: 600;
}

.diff-low  .difficulty-value { color: var(--accent-green); }
.diff-high .difficulty-value { color: var(--accent-red);   }

.difficulty-conf {
  font-size: 9px;
  color: var(--text-quaternary);
  margin-top: 2px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   ADD SUGGESTION SECTION
═══════════════════════════════════════════════════════════════════════════ */

.add-suggestion-section {
  padding: 16px 16px 0;
}

.add-suggestion-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.add-suggestion-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.add-suggestion-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.add-suggestion-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(191, 90, 242, 0.3);
}

.chip:hover { background: var(--accent-hover); }
.chip:active { transform: scale(0.95); }


/* ═══════════════════════════════════════════════════════════════════════════
   SHEET DISCLAIMER
═══════════════════════════════════════════════════════════════════════════ */

.sheet-disclaimer {
  font-size: 12px;
  color: var(--text-quaternary);
  padding: 20px 16px 8px;
  line-height: 1.6;
  border-top: 1px solid var(--separator);
  margin-top: 16px;
}




/* ═══════════════════════════════════════════════════════════════════════════
   REPORT CASE FORM
═══════════════════════════════════════════════════════════════════════════ */

.report-form { padding: 0 0 48px; }

.report-form-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--separator);
}

.report-section {
  margin: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.report-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--separator);
}

.report-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--separator);
}
.report-field:last-child { border-bottom: none; }

.report-field-col {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.report-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  width: 120px;
  flex-shrink: 0;
}
.report-field-col .report-label { width: auto; }

.report-input,
.report-select {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 15px;
  transition: border-color 0.15s;
}
.report-input:focus, .report-select:focus { outline: none; border-color: var(--accent); }
.report-input::placeholder { color: var(--text-quaternary); }

.report-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.report-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 15px;
  resize: vertical;
  min-height: 72px;
  transition: border-color 0.15s;
}
.report-textarea:focus { outline: none; border-color: var(--accent); }
.report-textarea::placeholder { color: var(--text-quaternary); }

.report-save-wrap {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.report-save-msg {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  min-height: 20px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   CASES TAB
═══════════════════════════════════════════════════════════════════════════ */

.cases-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Stats Bar ── */
.cases-stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--separator);
  padding: 0 4px;
  flex-shrink: 0;
}

.cases-stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-right: 1px solid var(--separator);
}

.cases-stat-item:last-of-type {
  border-right: none;
}

.cases-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  line-height: 1;
}

.cases-stat-label {
  font-size: 10px;
  color: var(--text-quaternary);
  font-weight: 500;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cases-export-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.cases-export-btn:hover {
  background: var(--accent-dim);
}

/* ── Charts Strip ── */
.charts-strip-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 4px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.charts-strip-wrap::-webkit-scrollbar { display: none; }

.charts-strip {
  display: flex;
  gap: 10px;
  width: max-content;
}

.chart-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px 14px 10px;
  width: 240px;
  flex-shrink: 0;
  position: relative;
}

.chart-card-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.chart-canvas-wrap {
  position: relative;
  height: 160px;
  width: 100%;
}

.chart-no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  font-size: 13px;
  color: var(--text-quaternary);
}

/* ── Search + Status Toggle ── */
.cases-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 0;
  flex-shrink: 0;
}

.cases-search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.cases-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-quaternary);
  pointer-events: none;
}

.cases-search-input {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-md);
  padding: 9px 12px 9px 34px;
  font-family: var(--font);
  font-size: 15px;
  transition: border-color 0.15s;
}

.cases-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.cases-search-input::placeholder {
  color: var(--text-quaternary);
}

/* ── Status Toggle ── */
.cases-status-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.cases-toggle-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.cases-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Filter Row ── */
.cases-filters-row {
  display: flex;
  gap: 8px;
  padding: 8px 14px 10px;
  overflow-x: auto;
  flex-shrink: 0;
}

.cases-filters-row::-webkit-scrollbar { display: none; }

.cases-filter-select {
  flex-shrink: 0;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm);
  padding: 7px 28px 7px 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238e8e93' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.cases-filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── List Wrap ── */
.cases-list-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cases-loading,
.cases-empty,
.cases-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text-quaternary);
  font-size: 14px;
  text-align: center;
}

.cases-error {
  color: var(--accent-red);
}

/* ── Case Row ── */
.case-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--separator);
  cursor: pointer;
  transition: background 0.12s;
  background: var(--bg-primary);
}

.case-row:hover {
  background: var(--bg-tertiary);
}

.case-row:active {
  background: var(--bg-elevated);
}

/* ── Initials Circle ── */
.case-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.case-initials-bifurcation {
  background: var(--accent-dim);
  color: var(--accent);
}

.case-initials-sidewall {
  background: rgba(48, 209, 88, 0.15);
  color: var(--accent-green);
}

/* ── Case Row Body ── */
.case-row-body {
  flex: 1;
  min-width: 0;
}

.case-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.case-row-device {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-row-date {
  font-size: 12px;
  color: var(--text-quaternary);
  white-space: nowrap;
  flex-shrink: 0;
}

.case-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}

.case-row-comment {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-row-chevron {
  color: var(--text-quaternary);
  flex-shrink: 0;
}

/* ── Case Badges ── */
.case-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.2px;
}

.case-badge-open {
  background: rgba(48, 209, 88, 0.14);
  color: var(--accent-green);
}

.case-badge-closed {
  background: var(--bg-elevated);
  color: var(--text-quaternary);
}

.case-badge-status {
  background: var(--accent-dim);
  color: var(--accent);
}

.case-badge-location {
  background: rgba(255, 159, 10, 0.12);
  color: #ff9f0a;
}

.case-badge-reports {
  background: rgba(100, 210, 255, 0.12);
  color: #64d2ff;
}


/* ═══════════════════════════════════════════════════════════════════════════
   CASE DETAIL SHEET
═══════════════════════════════════════════════════════════════════════════ */

.case-detail {
  padding-bottom: 48px;
}

.case-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--separator);
}

.case-detail-subject {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.case-detail-meta {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.case-detail-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Detail Sections ── */
.detail-section {
  margin: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--separator);
}

/* ── 4-column stats grid ── */
.detail-grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.detail-stat {
  padding: 10px 10px;
  border-right: 1px solid var(--separator);
  border-bottom: 1px solid var(--separator);
}

.detail-stat:nth-child(4n) {
  border-right: none;
}

.detail-stat:nth-last-child(-n+4) {
  border-bottom: none;
}

.detail-stat-label {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-bottom: 3px;
  white-space: nowrap;
}

.detail-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Detail Rows ── */
.detail-subrows {
  border-top: 1px solid var(--separator);
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--separator);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row-label {
  font-size: 13px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.detail-row-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.detail-comment {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Status Reports ── */
.detail-reports-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-empty-reports {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-quaternary);
  text-align: center;
}

.detail-report-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--separator);
}

.detail-report-row:last-child {
  border-bottom: none;
}

.detail-report-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.detail-report-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-report-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 1px 0;
}

.detail-report-field-label {
  color: var(--text-tertiary);
}

/* ── Report image strip (in detail view) ── */
.report-images-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 2px;
  -webkit-overflow-scrolling: touch;
}

.report-images-strip::-webkit-scrollbar { display: none; }

.report-img-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--separator);
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}

.report-img-thumb:hover {
  opacity: 0.85;
}

.report-img-broken {
  background: var(--bg-tertiary);
  border: 1px dashed var(--separator);
  opacity: 0.5;
}

/* ── Image picker in add-report form ── */
.sr-image-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-tertiary);
  color: var(--accent);
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  justify-content: center;
}

.sr-image-add-btn:hover {
  background: var(--accent-dim);
}

.sr-image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.sr-image-thumb-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sr-image-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--separator);
}

.sr-image-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-red);
  color: #fff;
  border: none;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sr-image-name {
  font-size: 10px;
  color: var(--text-quaternary);
  max-width: 72px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ─────────────────────────────────────────────────────────────────────────────
   Chat Tab — ECORE AI
───────────────────────────────────────────────────────────────────────────── */

/* Page layout */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
}

.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px 0;
  flex-shrink: 0;
}

/* Scrollable message area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* ── Welcome state ──────────────────────────────────────────────────────────── */

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  gap: 12px;
}

.chat-welcome-icon {
  width: 72px;
  height: 72px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 4px;
  box-shadow: 0 0 0 8px rgba(191,90,242,0.07);
}

.chat-welcome-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.chat-welcome-sub {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  line-height: 1.5;
  max-width: 320px;
}

/* Suggestion chips */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
  max-width: 400px;
}

.chat-suggestion-chip {
  background: var(--bg-primary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.chat-suggestion-chip:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.chat-suggestion-chip:active {
  transform: translateY(0);
}

/* ── Message bubbles ──────────────────────────────────────────────────────── */

.chat-msg {
  display: flex;
  flex-direction: column;
}

.chat-bubble {
  max-width: 82%;
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

/* User bubble — right-aligned, accent background */
.chat-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
  padding: 7px 12px;
}

/* Assistant bubble — left-aligned */
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  max-width: 92%;
  border: 1px solid var(--separator);
}

.chat-bubble-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  opacity: 0.8;
}

/* Status / progress line */
.chat-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  font-style: italic;
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: chat-pulse 1.2s ease-in-out infinite;
}

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

/* Markdown rendered content */
.chat-bubble-content p {
  margin-bottom: 8px;
}
.chat-bubble-content p:last-child {
  margin-bottom: 0;
}
.chat-bubble-content ul {
  padding-left: 18px;
  margin-bottom: 8px;
}
.chat-bubble-content li {
  margin-bottom: 3px;
}
.chat-bubble-content strong {
  font-weight: 600;
}
.chat-bubble-content em {
  font-style: italic;
}
.chat-code-block {
  background: rgba(0,0,0,0.07);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
  margin: 8px 0;
}
.chat-inline-code {
  background: rgba(0,0,0,0.07);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* ── Plot images ─────────────────────────────────────────────────────────── */

.chat-plot-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
  max-width: 280px;
  margin-bottom: 4px;
}

.chat-plot {
  display: block;
  width: 280px;
  max-width: 100%;
  border-radius: var(--radius-md);
  cursor: zoom-in;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.chat-plot:hover {
  opacity: 0.92;
  transform: scale(1.02);
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */

.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lightbox-in 0.18s ease;
}

@keyframes lightbox-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.chat-lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* ── Input area ──────────────────────────────────────────────────────────── */

.chat-input-area {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--separator);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--separator);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text-primary);
  line-height: 1.4;
  max-height: 160px;
  overflow-y: auto;
}

.chat-input::placeholder {
  color: var(--text-quaternary);
}

.chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn--loading {
  background: var(--accent);
  animation: chat-send-spin 0.9s linear infinite;
}

@keyframes chat-send-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.chat-disclaimer {
  font-size: 0.7rem;
  color: var(--text-quaternary);
  text-align: center;
  margin-top: 6px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   DEVICE SECTION HEADER (SEAL / WEB dividers)
═══════════════════════════════════════════════════════════════════════════ */

.device-section-header {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 4px 16px 8px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.device-section-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   WEB META ROW
═══════════════════════════════════════════════════════════════════════════ */

.web-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 0 16px 12px;
  align-items: center;
}

.web-meta-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.web-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
}

.web-meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   WEB SHAPE BADGE
═══════════════════════════════════════════════════════════════════════════ */

.web-shape-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(191, 90, 242, 0.15);
  color: var(--accent);
  border: 1px solid rgba(191, 90, 242, 0.3);
  letter-spacing: 0.5px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   SEGMENT PICKER — device selector (SEAL / WEB / Both)
═══════════════════════════════════════════════════════════════════════════ */

.seg-picker {
  display: flex;
  margin: 4px 16px 16px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: 7px 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}

.seg-btn:hover:not(.seg-btn--active) {
  color: var(--text-primary);
}

.seg-btn--active {
  background: #ffffff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
