/* ═══════════════════════════════════════════════════════════
   Ocuport Dashboard — Biostate Design System
   Fonts: Sora (headings) + Manrope (body/UI)
   Dark mode default, #0f172a background
   ═══════════════════════════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  --color-accent: #45d0bd;
  --color-accent-blue: #44b6e9;
  --color-accent-dark: #108080;
  --color-purple: #8258c8;
  --color-purple-alt: #6766c8;
  --color-blue: #2c84c8;
  --color-success: #0a875a;
  --color-warning: #f59e0b;
  --color-error: #dc2626;

  --g-primary: linear-gradient(90deg, #45d0bd, #44b6e9);
  --g-purple: linear-gradient(135deg, #8258c8, #2c84c8);
  --g-dark-card: linear-gradient(135deg, #A3F5FF 0%, #E987C4 100%);

  --font-heading: 'Sora', Arial, Helvetica, sans-serif;
  --font-body: 'Manrope', Arial, Helvetica, sans-serif;

  /* Dark mode (default) */
  --page-bg: #0f172a;
  --surface: #1e293b;
  --surface-elevated: #2c3338;
  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.7);
  --text-muted: rgba(255,255,255,0.4);
  --border-subtle: rgba(255,255,255,0.07);
  --card-hover-shadow: 0 12px 32px rgba(0,0,0,0.3);

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 15px;
  --r-xl: 16px;
  --r-2xl: 20px;
  --r-3xl: 25px;
  --r-pill: 9999px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-teal-glow: 0 4px 16px rgba(69,208,189,0.35);
}

/* ── Light mode overrides ── */
body.light-mode {
  --page-bg: #f9fafa;
  --surface: #ffffff;
  --surface-elevated: #f1f2f3;
  --text-primary: #111111;
  --text-secondary: #333333;
  --text-muted: #adadad;
  --border-subtle: rgba(0,0,0,0.07);
  --card-hover-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

/* ── Base ── */
body {
  font-family: var(--font-body);
  background: var(--page-bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 72px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

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

.dash-logo-link { display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }
.dash-logo {
  display: flex;
  align-items: center;
}

.dash-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Auth UI ── */
.dash-auth-area { display: flex; align-items: center; }
.dash-signin-btn {
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: var(--r-pill);
  background: var(--color-accent); color: #fff; border: none;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.dash-signin-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.dash-user-menu { position: relative; }
.dash-avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border-subtle);
  overflow: hidden; cursor: pointer; padding: 0; background: var(--surface);
}
.dash-avatar { width: 100%; height: 100%; object-fit: cover; display: block; }
.dash-user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--r-md); padding: 12px 16px; min-width: 200px;
  box-shadow: var(--shadow-lg); z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
}
.dash-user-email { font-size: 12px; color: var(--text-secondary); word-break: break-all; }
.dash-signout-btn {
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: var(--r-sm);
  background: rgba(220,38,38,0.08); color: #dc2626; border: none;
  cursor: pointer; transition: all 0.2s;
}
.dash-signout-btn:hover { background: rgba(220,38,38,0.15); }

/* Cloud deck cards */
.deck-card .deck-shared-badge {
  position: absolute; top: 8px; left: 8px;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 8px; border-radius: var(--r-pill);
  background: rgba(69,208,189,0.2); color: var(--color-accent);
}
.deck-card .deck-delete-btn {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(220,38,38,0.08); border: none;
  color: #dc2626; cursor: pointer; font-size: 12px;
  display: none; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.deck-card:hover .deck-delete-btn { display: flex; }
.deck-card .deck-delete-btn:hover { background: rgba(220,38,38,0.2); }
.deck-card .deck-updated {
  font-size: 10px; color: var(--text-muted); margin-top: 2px;
}

.dash-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.dash-theme-btn:hover {
  background: rgba(69,208,189,0.1);
  color: var(--color-accent);
  border-color: rgba(69,208,189,0.3);
}

.dash-language-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.dash-language-btn .ocu-locale-flag {
  width: 22px;
  height: 15px;
  display: block;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.dash-language-btn:hover,
.dash-language-btn:focus-visible {
  background: rgba(69,208,189,0.1);
  color: var(--color-accent);
  border-color: rgba(69,208,189,0.3);
}
.dash-language-btn:focus-visible {
  outline: 2px solid rgba(69,208,189,0.45);
  outline-offset: 2px;
}

/* Pill toggle switch — EN ⟷ CN, modeled on the light/dark theme toggle.
   (Rainy 2026-06-18: wanted pill switch with two segments, not single button.) */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  border-radius: 999px;
  padding: 2px;
  cursor: pointer;
  user-select: none;
  height: 32px;
  gap: 0;
}
.lang-toggle-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #4a5568);
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}
.lang-toggle-option.active {
  background: var(--color-accent, #45d0bd);
  color: #fff;
}
.lang-toggle-option .ocu-locale-flag {
  width: 16px;
  height: 11px;
  display: block;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* ── Language dropdown (active: EN/CN/ES; JA/KO remain dormant,
   Rainy 2026-07-15) ── */
.lang-dd { position: relative; display: inline-flex; }
.lang-dd-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--text-secondary, #4a5568);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.lang-dd-btn:hover { background: rgba(0, 0, 0, 0.07); }
.lang-dd-btn .ocu-locale-flag,
.lang-dd-item .ocu-locale-flag {
  width: 16px; height: 11px; display: block; object-fit: contain;
  border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.lang-dd-caret { transition: transform 0.15s ease; }
.lang-dd.open .lang-dd-caret { transform: rotate(180deg); }
.lang-dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 300;
  min-width: 148px; padding: 5px;
  background: var(--surface, #fff);
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  display: none; flex-direction: column; gap: 2px;
}
.lang-dd.open .lang-dd-menu { display: flex; }
.lang-dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border: 0; border-radius: 8px;
  background: transparent; font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary, #4a5568); cursor: pointer; text-align: left;
}
.lang-dd-item:hover { background: rgba(69, 208, 189, 0.12); }
.lang-dd-item.active { background: var(--color-accent, #45d0bd); color: #fff; }
.lang-toggle:hover {
  border-color: rgba(69, 208, 189, 0.4);
}
.lang-toggle:focus-visible {
  outline: 2px solid rgba(69, 208, 189, 0.45);
  outline-offset: 2px;
}
body:not(.light-mode) .lang-toggle {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}
body:not(.light-mode) .lang-toggle-option {
  color: rgba(255, 255, 255, 0.6);
}
body:not(.light-mode) .lang-toggle-option.active {
  color: #0e1820;
}


/* ── Main ── */
.dash-main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

/* ── Sections ── */
.dash-section {
  margin-bottom: 48px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: all 0.2s ease;
}
.section-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

/* ── Quick Actions ── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.quick-actions.quick-actions-4 {
  grid-template-columns: repeat(5, 1fr);
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 36px 20px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.action-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--g-primary);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
}
.action-card:hover::before {
  opacity: 1;
}

.action-icon {
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(69,208,189,0.1);
}

.action-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

/* ── Integration Cards ── */
.integration-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.integration-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  transition: all 0.25s ease;
}

.integration-card[data-product="ocupath"],
.integration-card[data-product="ocuseq"] {
  cursor: pointer;
}

.integration-card[data-product="ocupath"]:hover,
.integration-card[data-product="ocuseq"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
}

.integ-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex-shrink: 0;
}
.ocupath-icon { background: rgba(69,208,189,0.12); color: var(--color-accent); }
.ocuseq-icon { background: rgba(130,88,200,0.12); color: var(--color-purple); }
.ocuflow-icon { background: rgba(44,132,200,0.12); color: var(--color-blue); opacity: 0.5; }

.integ-info { flex: 1; min-width: 0; }

.integ-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.integ-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.integ-status { flex-shrink: 0; }

.integ-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  letter-spacing: 0.02em;
}
.integ-badge.scanning {
  background: rgba(69,208,189,0.1);
  color: var(--color-accent);
}
.integ-badge.ready {
  background: rgba(10,135,90,0.15);
  color: var(--color-success);
}
.integ-badge.none {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}
.integ-badge.coming {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}

body.light-mode .integ-badge.none,
body.light-mode .integ-badge.coming {
  background: rgba(0,0,0,0.04);
}
body.light-mode .integ-badge.scanning {
  background: rgba(69,208,189,0.08);
}

/* ── Deck Grid ── */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.deck-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.deck-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
}
.deck-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-hover-shadow);
}

.deck-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  /* White placeholder so light-mode templates (bold-mono / bold-forms /
     aurora / clean-light etc) don't show a gray edge through the iframe
     before/around the scaled slide content. dark-mode.css overrides this
     to surface-elevated dark for dark-bg templates. */
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.deck-thumb-text {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
  line-height: 1.4;
}

.deck-thumb-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: var(--r-pill);
}
.deck-thumb-badge.json { background: rgba(69,208,189,0.2); color: var(--color-accent); }
.deck-thumb-badge.html { background: rgba(130,88,200,0.2); color: var(--color-purple); }

.deck-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.deck-meta {
  padding: 14px 16px;
}

.deck-name {
  /* Body font (Manrope) so deck cards in Recent Decks match the
     style-card labels in the Pick-the-Style section below. The
     original `var(--font-heading)` (Sora) caused a visible weight
     /shape mismatch. (Rainy 2026-05-29.) */
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-info {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Deck thumbnail image — shown when deck.thumbnailUrl is present.
   Falls back to .deck-thumb-text placeholder when no thumbnail yet. */
.deck-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Card-level pulse while a manual "Regenerate cover" action is in
   flight — the sidecar's chromium launch dominates the latency, so
   the user gets ~3-5s of "nothing happened" without this hint. */
.deck-card-regenerating .deck-thumb { animation: deck-thumb-pulse 1.2s ease-in-out infinite; }
@keyframes deck-thumb-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Center hover overlay — "Open deck" affordance, Chronicle-style. */
.deck-hover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 25, 0.42);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.deck-card:hover .deck-hover-overlay { opacity: 1; }
.deck-hover-open {
  pointer-events: auto;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  background: rgba(255, 255, 255, 0.96);
  border: none;
  border-radius: var(--r-pill);
  padding: 9px 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, background 0.15s ease;
}
.deck-hover-open:hover {
  background: #fff;
  transform: translateY(-1px);
}

/* Three-dot menu button (top-right of thumb). Hidden until card hover.
 * z-index bumped to 20 so it always sits above the live-thumbnail
 * iframe (which is inset:0 absolute and would otherwise visually
 * cover the menu button on certain templates). */
.deck-menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20);
  transition: background 0.15s ease;
  z-index: 20;
}
.deck-card:hover .deck-menu-btn,
.deck-card .deck-menu.open ~ .deck-menu-btn,
.deck-card:has(.deck-menu.open) .deck-menu-btn { display: flex; }
.deck-menu-btn:hover { background: #fff; }

/* Dropdown menu — position:fixed so it can escape the card's
 * overflow:hidden (which is needed for the card's rounded corners +
 * thumbnail iframe clipping). JS sets top/left based on the menu
 * button's getBoundingClientRect() at open time. */
.deck-menu {
  position: fixed;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 1px;
  z-index: 1000;
}
.deck-menu.open { display: flex; }
.deck-menu-item {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: none;
  border: none;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.12s ease;
}
.deck-menu-item:hover { background: var(--surface-elevated); }
.deck-menu-item-danger { color: #dc2626; }
.deck-menu-item-danger:hover { background: rgba(220, 38, 38, 0.08); }

/* ── Manage mode: batch-select + delete for "My decks" ────────────
   Header row puts the title on the left and the manage controls on
   the right. In manage mode the right side swaps from a "Manage"
   button to a toolbar (Select all · Delete (N) · Done) and each
   .deck-card grows a checkbox + becomes select-only (click toggles
   selection instead of opening the deck). */
.hero-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.hero-recent-header .hero-recent-title {
  margin: 0;  /* override the original 0 0 16px */
}
.deck-manage-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.deck-manage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.deck-manage-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
  /* (Rainy 2026-05-28) — accent green (69,208,189 = #45d0bd) instead
     of purple. Manage mode is part of the dashboard chrome and should
     align with the brand teal, not the purple accent. */
  border-color: rgba(69, 208, 189, 0.4);
}
.deck-manage-btn svg { opacity: 0.85; }
/* Toolbar shown while in manage mode (replaces Manage button). */
.deck-manage-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill);
  padding: 6px 8px 6px 16px;
  box-shadow: var(--shadow-sm);
  animation: ocuModalFade 0.15s ease;
}
.deck-manage-toolbar[hidden] { display: none; }
.deck-manage-count {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 70px;
}
.deck-manage-link {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  /* (Rainy 2026-05-28) — accent green instead of purple. */
  color: var(--color-accent);
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.12s ease;
}
.deck-manage-link:hover { background: rgba(69, 208, 189, 0.08); }
.deck-manage-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  background: #dc2626;
  border: none;
  border-radius: var(--r-pill);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.14s ease, opacity 0.14s ease, transform 0.14s ease;
}
.deck-manage-delete:hover:not(:disabled) {
  background: #b91c1c;
  transform: translateY(-1px);
}
.deck-manage-delete:disabled {
  background: var(--surface-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
}
.deck-manage-done {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.12s ease, color 0.12s ease;
}
.deck-manage-done:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

/* Card states while in manage mode. JS adds .deck-manage-mode to the
   grid; cards then show a checkbox and become selection toggles. */
.deck-grid.deck-manage-mode .deck-card {
  cursor: pointer;
  position: relative;
}
.deck-grid.deck-manage-mode .deck-card .deck-menu-btn,
.deck-grid.deck-manage-mode .deck-card .deck-hover-overlay {
  display: none !important;  /* no menu / open-overlay in select mode */
}
.deck-card-checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;  /* card click handles selection */
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.deck-card-checkbox svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.deck-grid.deck-manage-mode .deck-card .deck-card-checkbox { display: flex; }
.deck-grid.deck-manage-mode .deck-card.deck-selected {
  /* (Rainy 2026-05-28) — accent green for selection ring + checkbox
     fill. Matches the rest of the manage toolbar (Select all link). */
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.deck-grid.deck-manage-mode .deck-card.deck-selected .deck-card-checkbox {
  background: var(--color-accent);
  border-color: var(--color-accent);
  transform: scale(1.05);
}
.deck-grid.deck-manage-mode .deck-card.deck-selected .deck-card-checkbox svg {
  opacity: 1;
  color: #ffffff;
}

/* ── Ocuport modal (confirm/alert replacement for native dialogs) ──
   Replaces the OS-styled confirm()/alert() popups with a Biostate-themed
   card. Used by ocuConfirm() and ocuAlert() in dashboard.js. */
.ocu-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: ocuModalFade 0.16s ease;
}
.ocu-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ocu-modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  padding: 24px 24px 20px;
  animation: ocuModalPop 0.18s cubic-bezier(0.2, 0.7, 0.2, 1.02);
}
.ocu-modal-title {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.35;
}
.ocu-modal-body {
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 22px;
  white-space: pre-line;
}
.ocu-modal-input {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--surface-elevated, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md, 10px);
  padding: 10px 12px;
  margin: -6px 0 20px;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.ocu-modal-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(69, 208, 189, 0.16);
}
.ocu-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.ocu-modal-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
}
.ocu-modal-btn-cancel {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}
.ocu-modal-btn-cancel:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}
.ocu-modal-btn-ok {
  /* (Rainy 2026-05-28) — primary action = brand green (#45d0bd) instead
     of purple. Matches the manage-mode treatment + matches the visual
     convention (green = confirm, red = danger). Affects ALL confirm /
     alert modals across the dashboard (rename, duplicate, manage
     delete, etc.) so they share a single primary-action color. */
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
}
.ocu-modal-btn-ok:hover {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  transform: translateY(-1px);
}
.ocu-modal-btn-danger {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}
.ocu-modal-btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  transform: translateY(-1px);
}
@keyframes ocuModalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes ocuModalPop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Style Picker (visual deck themes, Keynote-style) ── */
.style-picker {
  animation: fadeSlideIn 0.3s ease;
}
.style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.style-card {
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.style-card:hover .style-preview {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.2);
}

.style-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
  transition: all 0.25s ease;
  border: 1px solid var(--border-subtle);
  /* Enables `cqi` (container-query-inline) units inside canvas-rendered
     previews (style-themes.js's daisy/signal/cobalt-grid/broadside blocks)
     so their font-sizes scale with the preview width — same canvas now
     works in both the wide dashboard library cards AND the narrower
     generate-modal style picker cards. Without this, fixed-px sizes
     calibrated for one context overflow the other.
     (Rainy 2026-05-29: gen-modal text 都溢出了.) */
  container-type: inline-size;
}

/* Preview inner layout — mimics a title slide */
.style-preview-title {
  position: absolute;
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.style-preview-sub {
  position: absolute;
  font-family: var(--font-body);
  font-weight: 400;
  opacity: 0.7;
}
/* Decorative elements inside preview */
.style-preview-deco {
  position: absolute;
  border-radius: 3px;
  pointer-events: none;
}

.style-name {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

@media (max-width: 1024px) {
  .style-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .style-grid { grid-template-columns: 1fr; }
}

/* ── Template Grid ── */
.template-picker {
  animation: fadeSlideIn 0.3s ease;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}
.template-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--g-purple);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
}
.template-card:hover::before { opacity: 1; }

.template-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.template-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.template-slides {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-purple);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Animations ── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .quick-actions.quick-actions-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .dash-header { padding: 0 20px; }
  .dash-main { padding: 24px 20px 60px; }
  .quick-actions,
  .quick-actions.quick-actions-4 { grid-template-columns: 1fr; }
  .integration-cards { grid-template-columns: 1fr; }
  .deck-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ────────────────────────────────────────────────────────────────
   Mobile / touch device polish (≤640px or coarse pointer)
   ────────────────────────────────────────────────────────────────
   Goals:
   • Slip safely under notches / home indicators (safe-area-inset)
   • All tappable controls ≥ 44×44 (Apple HIG minimum)
   • Hover-only chrome (delete / menu / overlay) becomes always-visible
     since touch devices have no :hover state
   • Tighten paddings so content uses the narrow viewport efficiently
   • Suppress iOS double-tap zoom / rubber-band scroll quirks
   (Rainy 2026-05-26: dashboard mobile pass.)
   ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  html, body {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none; /* kill iOS rubber-band on body scroll */
  }
  /* Page chrome — respect notch / home-indicator safe areas */
  .dash-header {
    padding-left:  max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top:   env(safe-area-inset-top);
  }
  .dash-main {
    padding: 18px max(16px, env(safe-area-inset-left)) max(60px, env(safe-area-inset-bottom));
  }
  /* Even tighter deck grid on small phones — 2 cols at 360px+ */
  .deck-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  /* Buttons → guarantee tappable size */
  .secondary-btn,
  .quick-action-btn,
  .deck-menu-btn,
  .deck-delete-btn,
  .recent-empty-cta,
  .see-more-btn,
  .integration-cards button,
  .dash-header button { min-height: 44px; }
}

/* Touch-device-specific (any width) — hover chrome → always visible */
@media (hover: none) and (pointer: coarse) {
  .deck-card .deck-delete-btn,
  .deck-card .deck-menu-btn { display: flex !important; opacity: 1 !important; }
  .deck-card .deck-hover-overlay { opacity: 0 !important; pointer-events: none; }
  /* Disable hover lifts that don't do anything without :hover */
  .deck-card:hover,
  .template-card:hover,
  .entry-card:hover { transform: none; box-shadow: var(--card-shadow, 0 1px 2px rgba(0,0,0,0.04)); }
}

/* ────────────────────────────────────────────────────────────────
   Mobile dashboard — focus mode: ONLY recent decks
   ────────────────────────────────────────────────────────────────
   On phones the dashboard is overwhelmingly used for one thing:
   browsing previously-made decks. Welcome hero / Generate-AI banner
   / style picker / template picker / integrations panels all add
   noise without value (they're discovery/creation entry points,
   and creation flows are unusable on touch anyway).
   Hide all that, keep only:
     • The top floating header (logo + user menu)
     • The "My decks" section, with bigger thumbnails so the cover
       art is actually legible
   (Rainy 2026-05-26: "移动端的dashboard主要能用的功能就是看 recent
    deck" + 封面无法展示清楚.)
   ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Hide everything except the floating header and the recent-decks block */
  .hero-title,                                              /* welcome H1 */
  .hero-secondary,                                          /* quick actions / entry cards */
  .hero-section.section-styles,                             /* style picker */
  .hero-section.section-templates,                          /* template picker */
  .hero-section.section-integrations { display: none !important; }

  /* Recent decks promoted — single column, big thumbnail */
  .hero-recent {
    margin-top: 80px !important;                           /* room below floating header */
    padding: 0 max(14px, env(safe-area-inset-left)) 40px !important;
  }
  .hero-recent-title {
    font-size: 18px !important;
    margin-bottom: 14px !important;
  }
  /* 1-column grid on phones — every card gets the full viewport width.
     Override the 2-col rule from dashboard-hero.css media query. */
  .hero-recent .deck-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  /* Bigger thumbnail — 16:9 at full viewport width = much more legible
     cover art than the old shrunk-down 2-col version. */
  .deck-card .deck-thumb {
    aspect-ratio: 16 / 9;
    background: var(--surface-elevated, #f4f6fa);
  }
  .deck-card .deck-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    /* Crisp scaling on high-DPI phones */
    image-rendering: -webkit-optimize-contrast;
  }
  /* Show first ~20 instead of 8 since the user came specifically to
     browse. (Default rule hides nth-child > 8 unless `.expanded`.) */
  .hero-recent .deck-grid:not(.expanded) > .deck-card:nth-child(n+9) {
    display: block !important;
  }
}
