/* ======================================================
   MBA IS AI Checker Pro — Design System  (v4.3)
   Modern · minimal · premium · classic
   Light theme: MBA KKU orange (#e0633b) + white + warm cream/gray
   Orange is reserved for ACTION + STATUS, never large fills.
   Variable names are kept stable because inline styles in the
   JS modules reference them via var(--…); only their VALUES change.
   ====================================================== */

/* ── Design Tokens ── */
:root {
  /* Brand — MBA KKU orange */
  --brand:        #e0633b;
  --brand-hover:  #d94e25;
  --brand-deep:   #c8552f;
  --brand-tint:   #f4d4c1;
  --brand-wash:   #fff5f0;

  /* Accent aliases (referenced widely incl. inline JS) */
  --accent:        #e0633b;   /* fills / borders / icons (non-text or large) */
  --accent-dark:   #b04a26;   /* contrast-safe orange for TEXT on light */
  --accent-light:  #f07a52;
  --accent-tint:        rgba(224, 99, 59, 0.08);
  --accent-tint-strong: rgba(224, 99, 59, 0.15);

  /* Ink — premium charcoal used for number medallions (kept under
     the legacy --navy* names so other rules/files don't break) */
  --navy:       #2a2f3a;
  --navy-mid:   #363c48;
  --navy-light: #454c5a;

  /* Surfaces — warm "paper" feel */
  --bg-primary:   #f7f5f0;   /* page + insets inside white cards */
  --bg-secondary: #ffffff;   /* panels / cards */
  --bg-elevated:  #ffffff;
  --paper:        #f6f4ee;
  --paper-2:      #f1ede4;

  /* Text — charcoal / slate */
  --text-main:      #1a1d24;
  --text-strong:    #15171c;
  --text-secondary: #4b5563;
  --text-muted:     #5f6672;
  --text-subtle:    #8a8f9b;

  /* Lines — warm hairlines */
  --border:        #e7e3d8;
  --border-strong: #d8d3c5;
  --border-cool:   #e2e8f0;
  --border-glow:   rgba(224, 99, 59, 0.30);

  /* Interaction surfaces */
  --hover-bg:   rgba(26, 29, 36, 0.04);
  --subtle-bg:  rgba(26, 29, 36, 0.025);
  --overlay-bg: rgba(26, 29, 36, 0.45);

  /* Semantic */
  --success: #1f8a5b;
  --error:   #dc2626;
  --danger:  #dc2626;
  --warning: #f59e0b;
  --info:    #2563eb;

  /* Fixed-contrast text on dark/accent fills (never themed) */
  --text-on-accent: #ffffff;

  /* Radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   18px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Elevation — warm-tinted, soft (not heavy) */
  --shadow-sm: 0 1px 2px rgba(26,29,36,0.05), 0 1px 3px rgba(26,29,36,0.04);
  --shadow-md: 0 4px 12px rgba(26,29,36,0.07), 0 2px 6px rgba(26,29,36,0.04);
  --shadow-lg: 0 14px 30px rgba(26,29,36,0.10), 0 6px 14px rgba(26,29,36,0.06);
  --shadow-xl: 0 28px 56px rgba(26,29,36,0.16), 0 12px 24px rgba(26,29,36,0.08);
  --shadow-focus: 0 0 0 3px rgba(224, 99, 59, 0.28);
  --shadow-glow: 0 0 18px rgba(224, 99, 59, 0.14);

  --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
  --brand-tint:  rgba(224, 99, 59, 0.22);
  --brand-wash:  rgba(224, 99, 59, 0.12);

  --accent-dark:  #f3865f;   /* lighter orange reads better on dark text */
  --accent-tint:        rgba(224, 99, 59, 0.16);
  --accent-tint-strong: rgba(224, 99, 59, 0.26);

  --navy:       #2a3140;
  --navy-mid:   #354056;
  --navy-light: #3f4c66;

  --bg-primary:   #15171c;
  --bg-secondary: #1b1f26;
  --bg-elevated:  #20252e;
  --paper:        #1f242c;
  --paper-2:      #252b34;

  --text-main:      #e8e6df;
  --text-strong:    #f4f1ea;
  --text-secondary: #b4b9c2;
  --text-muted:     #8c92a0;
  --text-subtle:    #6b7180;

  --border:        #2c313b;
  --border-strong: #3a4150;
  --border-cool:   #2c313b;

  --hover-bg:   rgba(255, 255, 255, 0.05);
  --subtle-bg:  rgba(255, 255, 255, 0.03);
  --overlay-bg: rgba(0, 0, 0, 0.68);

  --success: #34d399;
  --error:   #f87171;
  --danger:  #f87171;
  --warning: #fbbf24;
  --info:    #60a5fa;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.40);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg: 0 14px 30px rgba(0,0,0,0.50);
  --shadow-xl: 0 28px 56px rgba(0,0,0,0.62);
}

/* Smooth theme switching */
body, .panel, .header, .btn-scan, .slot-item, .sub-slot, .upload-area,
.insight-card, .modal-box, .summary-modal {
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Kanit', 'Inter', system-ui, sans-serif;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.6;
  background: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Kanit', 'Inter', sans-serif;
  color: var(--text-strong);
  letter-spacing: -0.015em;
  line-height: 1.3;
}

p { line-height: 1.6; }

/* Generic visibility utility used by history.js (#history-table /
   #history-empty) and other toggles. Scoped overlay `.hidden` rules
   already match this; this just makes the bare utility reliable. */
.hidden { display: none !important; }

a {
  color: var(--accent-dark);
  text-decoration: none;
  transition: color 0.18s ease-in-out;
}
a:hover { color: var(--brand-hover); }

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════════════
   Header — slim, sticky, premium light bar
   ════════════════════════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(26,29,36,0.02), var(--shadow-sm);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
body.dark-mode .header {
  background: rgba(21, 23, 28, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-logo {
  height: 42px;
  width: auto;
  border-radius: 10px;
  display: block;
}
.header-home-link {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.header-home-link:hover { opacity: 0.85; }
.header-home-link:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.header h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}
.header h1 span {
  color: var(--accent-dark);
  font-weight: 700;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  font-weight: 400;
  letter-spacing: 0.01em;
}

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

.header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-badge {
  background: var(--brand-wash);
  border: 1px solid var(--brand-tint);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ── Header pill buttons (lang, theme, history, AI settings, auth) ── */
.theme-toggle-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Kanit', sans-serif;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
  min-height: 36px;
}
.theme-toggle-btn:hover {
  background: var(--paper);
  border-color: var(--border-strong);
  color: var(--text-strong);
}
.theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
body.dark-mode .theme-toggle-btn {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
body.dark-mode .theme-toggle-btn:hover {
  background: var(--paper-2);
  color: var(--text-strong);
}

/* Language toggle separator + active/inactive states.
   NOTE: theme.js sets inline .style.opacity on .lang-th/.lang-en — keep them. */
.lang-sep { color: var(--text-subtle); }
.lang-th { opacity: 1; transition: opacity 0.2s ease; }
.lang-en { opacity: 0.4; transition: opacity 0.2s ease; }

body.dark-mode .sun-icon { display: none; }
body.dark-mode .moon-icon { display: inline; }
body:not(.dark-mode) .sun-icon { display: inline; }
body:not(.dark-mode) .moon-icon { display: none; }

/* AI settings + auth get a subtle brand-washed treatment */
.ai-settings-btn,
.auth-btn,
.header-user-chip {
  background: var(--brand-wash);
  border: 1px solid var(--brand-tint);
  color: var(--accent-dark);
}
.ai-settings-btn:hover,
.auth-btn:hover {
  background: var(--brand-tint);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.header-user-chip {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

/* ── User menu dropdown (History / AI Settings / Logout) ── */
.user-menu { position: relative; display: inline-flex; }
#user-menu-trigger { gap: 6px; cursor: pointer; }
.user-menu-caret {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}
#user-menu-trigger[aria-expanded="true"] .user-menu-caret { transform: rotate(180deg); }
.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 224px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1200;
}
.user-menu-panel.hidden { display: none; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Kanit', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.user-menu-item:hover { background: var(--paper); color: var(--text-strong); }
.user-menu-item:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
/* Reset the pill treatment these classes carry in the header bar. */
.user-menu-item.ai-settings-btn,
.user-menu-item.auth-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
}
.user-menu-item.auth-btn { color: var(--accent-dark); }
.user-menu-item.auth-btn:hover { background: var(--brand-wash); color: var(--accent-dark); }
.user-menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
body.dark-mode .user-menu-panel { background: var(--bg-elevated); border-color: var(--border-strong); }
body.dark-mode .user-menu-item:hover { background: var(--paper-2); }

/* ── Warning Banner ── */
.warning-banner {
  background: rgba(245, 158, 11, 0.10);
  border-bottom: 1px solid rgba(245, 158, 11, 0.28);
  color: #8a5300;
  text-align: center;
  padding: 9px 32px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
body.dark-mode .warning-banner {
  background: rgba(245, 158, 11, 0.10);
  border-bottom: 1px solid rgba(245, 158, 11, 0.20);
  color: #fbbf24;
}

/* ════════════════════════════════════════════════
   Main dashboard layout (3-column grid)
   ════════════════════════════════════════════════ */
.dashboard {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 340px;
  gap: 22px;
  padding: 26px 32px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

/* Sticky footer on the main app page: make the body a flex column and let the
   dashboard grow, so the footer sits at the bottom of the viewport instead of
   dropping below the fold. Scoped to .page-app so login/landing are untouched. */
body.page-app { display: flex; flex-direction: column; }
.page-app .dashboard { flex: 1 0 auto; }

/* ── Panels ── */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
body.dark-mode .panel { box-shadow: var(--shadow-md); }

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  margin: 0;
}
.panel-header .icon { font-size: 15px; opacity: 0.8; }

.panel-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.panel-body { padding: 20px; flex: 1; }

/* ── Instructions list — elegant numbered steps ── */
.instructions-list {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.instructions-list li {
  counter-increment: step;
  position: relative;
  padding-left: 42px;
  min-height: 28px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
}
.instructions-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', 'Kanit', sans-serif;
  box-shadow: var(--shadow-sm);
}
.instructions-list li strong {
  color: var(--text-strong);
  font-weight: 600;
}

/* New 4-step layout: title + short desc stacked, optional detail button. */
.step-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.step-item strong { display: block; font-size: 13.5px; }
.step-item > span { color: var(--text-secondary); }
.step-detail-btn {
  align-self: flex-start;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Kanit', sans-serif;
  color: var(--accent-dark);
  background: var(--brand-wash);
  border: 1px solid var(--brand-tint);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.step-detail-btn:hover {
  background: var(--brand-tint);
  border-color: var(--accent);
}
.step-detail-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.step-detail-btn .icon { width: 14px; height: 14px; }

.instruction-warning {
  margin-top: 18px;
  padding: 13px 15px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-md);
  font-size: 12.5px;
}
.instruction-warning .warning-title {
  font-weight: 600;
  color: #8a5300;
  margin-bottom: 4px;
  font-size: 13px;
}
.instruction-warning p {
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.6;
}
body.dark-mode .instruction-warning .warning-title { color: #fbbf24; }
body.dark-mode .instruction-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.18);
  border-left-color: var(--warning);
}

/* ── Upload panel: progress overview ── */
.progress-grid {
  display: flex;
  gap: 8px;
  padding: 14px 18px 6px;
  align-items: center;
  justify-content: center;
}
.progress-dot {
  width: 36px;
  height: 5px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  transition: var(--transition);
}
.progress-dot.active { background: var(--accent); }
.progress-dot.done { background: var(--success); }
.progress-dot.error { background: var(--error); }
.progress-dot.scanning {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

/* ════════════════════════════════════════════════
   Accordion slots
   ════════════════════════════════════════════════ */
.slot-list { padding: 14px 16px 16px; }

.slot-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 11px;
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg-secondary);
}
.slot-item:last-child { margin-bottom: 0; }
.slot-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.slot-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint), var(--shadow-sm);
}

.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.slot-header:hover { background: var(--hover-bg); }
.slot-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.slot-status-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
.slot-number {
  width: 30px;
  height: 30px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', 'Kanit', sans-serif;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.slot-item.active .slot-number {
  background: var(--accent);
}
.slot-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-strong);
}
.slot-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}
.slot-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}
.slot-item.open .slot-arrow { transform: rotate(180deg); }

.slot-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.slot-item.open .slot-body { max-height: 3000px; }
.slot-body-inner { padding: 0 16px 16px; }

/* ── Status chips (restyled, names preserved for JS) ── */
.slot-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.status-pending {
  background: var(--paper);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}
.status-scanning,
.status-processing {
  background: rgba(37, 99, 235, 0.10);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
  animation: pulse 1.5s infinite;
}
.status-passed {
  background: rgba(31, 138, 91, 0.10);
  color: #157a4d;
  border: 1px solid rgba(31, 138, 91, 0.25);
}
.status-failed,
.status-error {
  background: rgba(220, 38, 38, 0.09);
  color: #c81e1e;
  border: 1px solid rgba(220, 38, 38, 0.22);
}
body.dark-mode .status-pending { color: var(--text-muted); }
body.dark-mode .status-passed { color: #34d399; border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.10); }
body.dark-mode .status-failed,
body.dark-mode .status-error { color: #f87171; border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.10); }
body.dark-mode .status-scanning,
body.dark-mode .status-processing { color: #60a5fa; border-color: rgba(96,165,250,0.3); background: rgba(96,165,250,0.10); }

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

/* ── Dropzone ── */
.upload-area {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-primary);
  position: relative;
  margin-top: var(--space-2);
}
.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent);
  background: var(--brand-wash);
}
.upload-area.dragover {
  box-shadow: 0 0 0 3px var(--accent-tint);
}
body.dark-mode .upload-area:hover,
body.dark-mode .upload-area.dragover { background: var(--brand-wash); }
.upload-area .upload-icon {
  font-size: 26px;
  margin-bottom: 8px;
  opacity: 0.65;
  line-height: 1;
  display: block;
}
.upload-area p {
  font-size: 12.5px;
  color: var(--text-secondary);
}
.upload-area .file-name {
  font-size: 12px;
  color: var(--accent-dark);
  font-weight: 600;
  margin-top: 6px;
  word-break: break-all;
}

/* ── Primary scan button (orange solid) ── */
.btn-scan {
  width: 100%;
  margin-top: 12px;
  padding: 11px 18px;
  background: var(--brand);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Kanit', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}
.btn-scan:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-scan:active:not(:disabled) { transform: translateY(0); }
.btn-scan:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.btn-scan:disabled {
  background: var(--paper-2);
  color: var(--text-subtle);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
body.dark-mode .btn-scan:disabled {
  background: var(--paper-2);
  color: var(--text-muted);
}
/* JS toggles .loading (spinner) and .scanning (deeper accent) */
.btn-scan.scanning { background: var(--brand-deep); }
.btn-scan.loading { background: var(--brand-deep); }
.btn-scan.loading .spinner { display: inline-block; }
.btn-scan.loading .btn-text { display: none; }

.btn-scan .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Error / success blocks inside slot ── */
.error-list {
  margin-top: 14px;
  padding: 14px;
  background: rgba(220, 38, 38, 0.05);
  border: 1px solid rgba(220, 38, 38, 0.16);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
}
.error-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(220, 38, 38, 0.10);
  font-size: 13px;
  color: var(--error);
}
.error-item:last-child { border-bottom: none; }
.error-item .err-icon { flex-shrink: 0; margin-top: 1px; }

.success-msg {
  margin-top: 14px;
  padding: 14px;
  background: rgba(31, 138, 91, 0.06);
  border: 1px solid rgba(31, 138, 91, 0.18);
  border-radius: var(--radius-md);
  color: var(--success);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* AI feedback block */
.ai-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--subtle-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.ai-feedback-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  letter-spacing: 0.3px;
}

/* ════════════════════════════════════════════════
   Right panel: insights
   ════════════════════════════════════════════════ */
.insights-panel {
  position: sticky;
  top: 92px;
  /* #insights-panel is now stretched to #upload-panel's height (see .dashboard);
     cap it to the viewport too so a very tall upload column doesn't push the
     sticky panel below the fold — the quota LIST scrolls internally instead. */
  max-height: calc(100vh - 92px - var(--space-5));
}
.insight-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  margin-bottom: 11px;
  transition: var(--transition);
}
.insight-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
body.dark-mode .insight-card { background: var(--bg-elevated); }
.insights-panel .insight-card {
  margin-left: var(--space-4);
  margin-right: var(--space-4);
  /* The single remaining card (per-Agent quota) fills the stretched panel height
     and is the only thing that scrolls — header + session-info stay fixed. */
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.insights-panel .insight-card:first-of-type { margin-top: var(--space-4); }

.insight-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Cross-check rows */
.crosscheck-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  border: 1px solid transparent;
  transition: transform 0.18s ease-in-out;
}
.crosscheck-row:hover { transform: translateX(2px); }
.crosscheck-row.matched {
  background: rgba(31, 138, 91, 0.08);
  border-color: rgba(31, 138, 91, 0.18);
  color: var(--success);
}
.crosscheck-row.missing {
  background: rgba(220, 38, 38, 0.07);
  border-color: rgba(220, 38, 38, 0.16);
  color: var(--error);
}
.crosscheck-row.extra {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.18);
  color: #a16207;
}
body.dark-mode .crosscheck-row.extra { color: var(--warning); }
.crosscheck-count {
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.crosscheck-label { font-size: 13px; }

.unmatched-list { margin-top: 8px; padding: 0; list-style: none; }
.unmatched-list li {
  font-size: 13px;
  padding: 4px 0;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Session overview */
.session-info {
  font-size: 12px;
  color: var(--text-muted);
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.session-info code {
  font-family: 'Inter', monospace;
  background: var(--paper);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
}

/* ── Footer ── */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-6);
  margin-top: var(--space-5);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
.footer a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}
.footer a:hover { color: var(--brand-hover); text-decoration: underline; }
.footer-credit {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.9em;
  color: var(--text-muted);
  letter-spacing: .01em;
}

/* ── Inline SVG icons (icons.js) — replace decorative emoji ── */
.icon { width: 1.05em; height: 1.05em; flex: none; vertical-align: -0.15em; }
.ic-label { display: inline-flex; align-items: center; gap: .45em; }

/* ── Empty states ── */
.empty-state { text-align: center; padding: 32px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 38px; margin-bottom: 12px; opacity: 0.55; }
.empty-state p { font-size: 13.5px; line-height: 1.6; }

/* ════════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .dashboard { grid-template-columns: minmax(0, 1fr) 340px; }
  #instructions-panel { grid-column: 1 / -1; }
  .instructions-list {
    flex-flow: row wrap;
  }
  .instructions-list li { flex: 1 1 240px; }
}

@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px;
  }
  #instructions-panel,
  #upload-panel,
  #insights-panel { grid-column: 1 / -1; }
  /* Prioritize the upload column */
  #upload-panel { order: 1; }
  #instructions-panel { order: 2; }
  #insights-panel { order: 3; }
  /* Single-column stack: each panel is alone in its row, so the desktop
     stretch-to-match-#upload-panel + internal-scroll setup no longer applies —
     let everything size naturally and let the page itself scroll instead. */
  .insights-panel { position: static; max-height: none; }
  .insights-panel .insight-card { flex: initial; min-height: auto; }
  #agent-quota-area { flex: initial; min-height: auto; max-height: none; overflow-y: visible; }
  .instructions-list li { flex: 1 1 100%; }
  .header-content { flex-wrap: wrap; gap: 12px; padding: 12px 20px; }
  .header-actions { flex-wrap: wrap; }
  .warning-banner { padding: 9px 20px; }
}

@media (max-width: 560px) {
  .header-subtitle { display: none; }
  .header-buttons { gap: 6px; }
  .theme-toggle-btn { padding: 7px 11px; }
  .dashboard { padding: 14px; }
  .panel-body { padding: 16px; }
}

/* ════════════════════════════════════════════════
   Slot 4: chapter sub-slots (nested accordion)
   ════════════════════════════════════════════════ */
.chapter-progress {
  display: flex;
  gap: 6px;
  margin: 4px 0 16px;
}
.chapter-dot {
  flex: 1;
  height: 30px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', 'Kanit', sans-serif;
  color: var(--text-muted);
  transition: var(--transition);
}
.chapter-dot.done {
  background: rgba(31, 138, 91, 0.12);
  border-color: var(--success);
  color: var(--success);
}
.chapter-dot.error {
  background: rgba(220, 38, 38, 0.12);
  border-color: var(--error);
  color: var(--error);
}
.chapter-dot.scanning {
  background: rgba(245, 158, 11, 0.14);
  border-color: var(--warning);
  color: #a16207;
  animation: pulse 1.5s infinite;
}
body.dark-mode .chapter-dot.scanning { color: var(--warning); }

.sub-slot {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
  transition: var(--transition);
  background: var(--bg-primary);
}
.sub-slot:last-child { margin-bottom: 0; }
.sub-slot:hover { border-color: var(--border-strong); }
.sub-slot.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-tint);
}
.sub-slot-header {
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
  user-select: none;
}
.sub-slot-header:hover { background: var(--hover-bg); }
.sub-slot-badge {
  min-width: 32px;
  height: 22px;
  padding: 0 6px;
  background: var(--brand-tint);
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', 'Kanit', sans-serif;
  flex-shrink: 0;
}
.sub-slot-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}
.sub-slot.open .sub-slot-title { color: var(--text-strong); }
.sub-slot-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sub-slot.open .sub-slot-body { max-height: 600px; }
.sub-slot-body .upload-area { margin: 0 14px; padding: 16px; }
.sub-slot-body .upload-area .upload-icon { font-size: 22px; margin-bottom: 4px; }
.sub-slot-body .upload-area p { font-size: 12.5px; }
.sub-slot-body .btn-scan-chapter {
  margin: 12px 14px 0;
  width: calc(100% - 28px);
  padding: 10px;
  font-size: 13px;
}
.sub-slot-body .error-list,
.sub-slot-body .success-msg,
.sub-slot-body .ai-feedback {
  margin-left: 14px;
  margin-right: 14px;
}
.sub-slot-body > div:last-child { padding-bottom: 14px; }

/* ════════════════════════════════════════════════
   Chunk progress bar
   ════════════════════════════════════════════════ */
.chunk-progress-wrap { margin: 12px 0 4px; padding: 6px 0; }
.chunk-progress-wrap.hidden { display: none; }
.chunk-status-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-2);
}
.chunk-progress-bg {
  height: 7px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.chunk-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
  animation: chunk-pulse 1.8s ease-in-out infinite;
}
@keyframes chunk-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(224, 99, 59, 0.3); }
  50% { box-shadow: 0 0 12px rgba(31, 138, 91, 0.55); }
}

/* ════════════════════════════════════════════════
   Disclaimer modal — startup popup
   ════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 0.3s ease;
}
.modal-overlay.hidden { display: none; }
.modal-overlay.closing { animation: modalFadeOut 0.3s ease; }

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalFadeOut { from { opacity: 1; } to { opacity: 0; } }

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  width: 100%;
  max-width: 520px;
  padding: var(--space-8);
  position: relative;
  text-align: center;
  animation: modalSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
body.dark-mode .modal-box {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--error);
}
.modal-icon {
  font-size: 46px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(245, 158, 11, 0.3));
}
.modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: var(--space-4);
  letter-spacing: -0.01em;
}
.modal-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  text-align: left;
  background: var(--bg-primary);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.modal-body p { margin-bottom: var(--space-3); }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body strong { color: var(--text-main); font-weight: 600; }
.modal-accept-btn {
  display: block;
  width: 100%;
  padding: 14px var(--space-5);
  background: var(--brand);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Kanit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.modal-accept-btn:hover {
  background: var(--brand-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.modal-accept-btn:active { transform: translateY(0); }
.modal-accept-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* ════════════════════════════════════════════════
   Summary modal (full-screen checklist) + history modal
   ════════════════════════════════════════════════ */
.summary-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: var(--overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 0.3s ease;
}
.summary-overlay.hidden { display: none; }

.summary-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
body.dark-mode .summary-modal { border-color: var(--border-strong); }

.summary-modal-header {
  padding: 22px 28px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.summary-modal-title { display: flex; align-items: center; gap: 12px; }
.summary-modal-title span { font-size: 26px; }
.summary-modal-title h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-strong);
}
.summary-close-btn {
  width: 36px;
  height: 36px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.summary-close-btn:hover {
  background: rgba(220, 38, 38, 0.10);
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--error);
  transform: rotate(90deg);
}

/* AI disclaimer alert inside summary modal */
.modal-ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  box-sizing: border-box;
  margin: var(--space-4) var(--space-6) 0;
  padding: var(--space-3) var(--space-5);
  background: rgba(245, 158, 11, 0.09);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
  color: #8a5300;
  font-weight: 500;
  letter-spacing: 0.01em;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
body.dark-mode .modal-ai-disclaimer {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
}
.modal-ai-disclaimer-icon { font-size: 16px; flex-shrink: 0; line-height: 1.6; opacity: 0.95; }
.modal-ai-disclaimer-text {
  flex: 1; min-width: 0;
  word-wrap: break-word; overflow-wrap: break-word; line-height: 1.55;
}

.summary-modal-stats { display: none; }

.summary-modal-body { padding: 22px 28px; overflow-y: auto; flex: 1; }

/* Modal tables */
.modal-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: var(--space-3);
}
.modal-table th:nth-child(1) { width: 30%; }
.modal-table th:nth-child(2) { width: 40%; }
.modal-table th:nth-child(3) { width: 30%; }
.modal-table th,
.modal-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.modal-table th {
  background: var(--paper);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.modal-table td { font-size: 14px; line-height: 1.6; color: var(--text-main); }
.modal-table tbody tr:nth-child(even) { background: var(--subtle-bg); }
.modal-table tbody tr { transition: background-color 0.15s ease; }
.modal-table tbody tr:hover { background: var(--hover-bg); }
.modal-table tbody tr:last-child td { border-bottom: none; }

/* History table column widths (6 cols) */
#history-table th:nth-child(1) { width: 17%; }
#history-table th:nth-child(2) { width: 26%; }
#history-table th:nth-child(3) { width: 15%; }
#history-table th:nth-child(4) { width: 14%; }
#history-table th:nth-child(5) { width: 14%; }
#history-table th:nth-child(6) { width: 14%; }
.history-row { cursor: pointer; }
.history-detail-row > td { background: var(--bg-primary); padding: 16px; }

/* Expand button */
.btn-expand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-4);
  background: var(--brand-wash);
  color: var(--accent-dark);
  border: 1px solid var(--brand-tint);
  border-radius: var(--radius-md);
  font-family: 'Kanit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: var(--space-2);
}
.btn-expand:hover {
  background: var(--brand-tint);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-expand:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* AI tables */
.ai-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: var(--space-3);
  font-size: 13px;
  color: var(--text-main);
}
.ai-table th:nth-child(1) { width: 30%; }
.ai-table th:nth-child(2) { width: 40%; }
.ai-table th:nth-child(3) { width: 30%; }
.ai-table th {
  background: var(--paper);
  color: var(--text-secondary);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.ai-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.6;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.ai-table tbody tr:nth-child(even) { background: var(--subtle-bg); }
.ai-table tbody tr { transition: background-color 0.15s ease; }
.ai-table tr:hover { background: var(--hover-bg); }
.ai-table tbody tr:last-child td { border-bottom: none; }

/* AI summary container */
#ai-summary-area { max-height: 300px; overflow-y: auto; padding-right: 4px; }
#ai-summary-area::-webkit-scrollbar { width: 6px; }
#ai-summary-area::-webkit-scrollbar-track { background: var(--subtle-bg); }
#ai-summary-area::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.ai-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text-main);
}
.ai-summary-table th {
  text-align: left;
  padding: var(--space-3) 0;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.ai-summary-table td {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ════════════════════════════════════════════════
   Toast notifications (bottom-center, non-interactive)
   ════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 11000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;        /* container never intercepts clicks */
  width: max-content;
  max-width: min(92vw, 460px);
}
.toast {
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.01em;
  word-break: break-word;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
body.dark-mode .toast { background: var(--bg-elevated); }
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast.toast-hide { opacity: 0; transform: translateY(14px); }
.toast-success { border-left-color: var(--success); }
.toast-info    { border-left-color: var(--brand); }
.toast-error   { border-left-color: var(--error); }

/* ════════════════════════════════════════════════
   Disclaimer modal — TH/EN language toggle
   ════════════════════════════════════════════════ */
.modal-lang-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  z-index: 2;
}
.modal-lang-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Kanit', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  letter-spacing: 0.03em;
}
.modal-lang-btn:hover { color: var(--text-strong); }
.modal-lang-btn.active { color: var(--accent-dark); }
.modal-lang-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.modal-lang-sep { color: var(--text-subtle); font-size: 11px; }

/* ════════════════════════════════════════════════
   Reduced motion
   ════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ════════════════════════════════════════════════
   AI Settings modal — styles live in ai_settings.css
   ════════════════════════════════════════════════ */
