/* ═══════════════════════════════════════════════════════════════
   BrooklineProven Intranet — Paper/Beige Theme · Mobile-First
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* ── Paper / Beige palette ─────────────────────────────────────
     Variable names are kept (--navy, --pink, --teal) so existing
     rules continue to work; values are remapped to a warm paper
     palette: cream paper, espresso ink, rust accent, sage support. */

  /* Ink (was navy) — primary text + headings */
  --navy:       #2C2418;        /* espresso ink */
  --navy-med:   #7A2D1B;        /* rust — primary accent / links */
  --navy-light: #E8DFC6;        /* light kraft */
  --navy-bg:    #F2EAD8;        /* cream highlight */

  /* Accent (was pink) — active states, CTAs */
  --pink:       #B8593A;        /* warm terracotta */
  --pink-lt:    #F7E4D7;        /* peach cream */

  /* Sage (was teal) — secondary chips */
  --teal:       #5E7E4F;        /* sage */
  --teal-lt:    #E8EFE0;

  /* Warning (was red) — oxblood */
  --red:        #9B2D1F;
  --red-lt:     #F4DDD5;

  /* Neutrals — all warmed toward brown */
  --white:      #FFFEF7;        /* warm white for card surfaces */
  --black:      #1A1410;        /* deepest ink */
  --gray-dark:  #5C4F3A;        /* dark warm brown */
  --gray:       #7A6850;        /* medium warm brown */
  --gray-med:   #A89878;        /* warm tan */
  --gray-lt:    #E8DFC6;        /* kraft border */
  --offwhite:   #F5EFE0;        /* paper cream — body bg */

  /* Paper-specific tokens (new) */
  --paper:      #F5EFE0;
  --paper-card: #FFFEF7;
  --paper-edge: #E0D4B8;
  --ink:        #2C2418;
  --ink-soft:   #5C4F3A;
  --rust:       #7A2D1B;
  --rust-soft:  #B8593A;
  --kraft:      #D4A574;        /* highlight on dark sidebar */
  --espresso:   #2C2418;        /* sidebar / tab bar bg */
  --espresso-2: #1A1410;        /* deeper espresso */
  --sage:       #5E7E4F;
  --pass:       #4A6B3F;
  --pass-bg:    #E8EFE0;

  --shadow:     0 1px 2px rgba(44,36,24,0.06), 0 2px 8px rgba(44,36,24,0.05);
  --shadow-md:  0 2px 6px rgba(44,36,24,0.08), 0 6px 18px rgba(44,36,24,0.07);
  --radius:     10px;
  --radius-sm:  6px;
  --transition: 0.2s ease;

  /* Safe areas for iPhone notch/home indicator */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  /* Type stacks — system sans for body, warm serif for headings */
  --font-body:    -apple-system, 'SF Pro Text', system-ui, 'Segoe UI', sans-serif;
  --font-display: 'Iowan Old Style', 'Charter', 'Georgia', 'Cambria', serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  /* Subtle paper grain — repeating SVG noise, cheap and flat. */
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 30% 10%, rgba(212,165,116,0.10) 0%, transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(212,165,116,0.06) 0%, transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.34  0 0 0 0 0.20  0 0 0 0.07 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  background-attachment: fixed;
  background-size: auto, auto, 320px 320px;
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.005em; }

a { color: var(--rust); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--rust-soft); }

code, pre {
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* ── Layout Shell ────────────────────────────────────────────── */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE-FIRST: Top Header + Bottom Tab Bar
   ══════════════════════════════════════════════════════════════ */

/* ── Top Header (mobile) ──────────────────────────────────────── */
.mobile-header {
  display: flex;
  background: var(--espresso);
  color: var(--white);
  padding: 0.65rem 1rem;
  padding-top: calc(0.65rem + var(--sat));
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  align-items: center;
  gap: 0.6rem;
}

.mobile-header .logo-img { height: 30px; width: 30px; border-radius: 6px; }
.mobile-header .logo-text { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }

/* ── Bottom Tab Bar (mobile — primary nav) ───────────────────── */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--espresso);
  z-index: 200;
  padding-bottom: var(--sab);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.bottom-nav .tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.25rem;
  text-decoration: none;
  color: rgba(255,255,255,0.5);
  font-size: 0.62rem;
  font-weight: 500;
  gap: 0.2rem;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}

.bottom-nav .tab-item .tab-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav .tab-item.active {
  color: var(--kraft);
}

.bottom-nav .tab-item:active {
  transform: scale(0.92);
}

/* ── "More" Drawer ──────────────────────────────────────────── */
.more-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 250;
}

.more-drawer-overlay.open { display: block; }

.more-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1rem calc(1rem + var(--sab));
  z-index: 260;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.more-drawer.open { transform: translateY(0); }

.more-drawer-handle {
  width: 36px; height: 4px;
  background: var(--gray-lt);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.more-drawer .drawer-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 0.5rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--black);
  font-size: 0.95rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}

.more-drawer .drawer-item:active { background: var(--offwhite); }

.more-drawer .drawer-item .drawer-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.more-drawer .drawer-item .drawer-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-med);
  background: var(--offwhite);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

/* ── Sidebar (DESKTOP ONLY) ──────────────────────────────────── */
.sidebar {
  display: none; /* Hidden on mobile */
  width: 260px;
  background: var(--espresso);
  color: var(--white);
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: transparent;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo .logo-icon img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-logo .logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section { padding: 0 0.75rem; margin-bottom: 0.5rem; }

.nav-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  padding: 0.75rem 0.75rem 0.4rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #FFFEF7; }
.nav-item.active { background: rgba(212,165,116,0.18); color: var(--kraft); font-weight: 600; }

/* Featured sidebar entry (e.g. Handyman 101) */
.nav-item.nav-featured {
  background: linear-gradient(135deg, rgba(212,165,116,0.18), rgba(122,45,27,0.18));
  border: 1px solid rgba(212,165,116,0.35);
  color: var(--kraft);
  font-weight: 700;
  margin: 0.4rem 0;
  position: relative;
  box-shadow: 0 0 0 0 rgba(212,165,116,0.45);
  animation: navFeaturedPulse 2.4s ease-out 1;
}
.nav-item.nav-featured:hover {
  background: linear-gradient(135deg, rgba(212,165,116,0.28), rgba(122,45,27,0.28));
  color: #FFFEF7;
}
.nav-item.nav-featured.active {
  background: linear-gradient(135deg, rgba(212,165,116,0.4), rgba(122,45,27,0.4));
  color: #FFFEF7;
  border-color: var(--kraft);
}
.nav-featured-pill {
  display: inline-flex; align-items: center;
  margin-left: 0.25rem;
  background: var(--kraft);
  color: var(--espresso);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}
.nav-featured-badge { background: var(--kraft); color: var(--espresso); }
@keyframes navFeaturedPulse {
  0%   { box-shadow: 0 0 0 0   rgba(212,165,116,0.55); }
  60%  { box-shadow: 0 0 0 10px rgba(212,165,116,0); }
  100% { box-shadow: 0 0 0 0   rgba(212,165,116,0); }
}

.drawer-item.drawer-featured {
  background: linear-gradient(135deg, var(--paper-card), var(--navy-bg));
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
}
.nav-item .nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .badge { margin-left: auto; background: var(--kraft); color: var(--espresso); font-size: 0.65rem; font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 10px; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
}

/* ── Main Content (mobile-first) ─────────────────────────────── */
.main-content {
  flex: 1;
  /* top header ~52px + safe area, bottom tab bar ~58px + safe area */
  padding: calc(60px + var(--sat)) 1rem calc(66px + var(--sab));
  width: 100%;
  max-width: 100%;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 1.25rem; }

.page-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.15rem;
}

.page-header .subtitle {
  color: var(--gray);
  font-size: 0.85rem;
}

.breadcrumb {
  font-size: 0.75rem;
  color: var(--gray-med);
  margin-bottom: 0.35rem;
}

.breadcrumb a { color: var(--gray); }
.breadcrumb a:hover { color: var(--pink); }
.breadcrumb .sep { margin: 0 0.3rem; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
  transition: box-shadow var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
}

/* ── Grid Layouts (mobile-first) ─────────────────────────────── */
.grid { display: grid; gap: 0.85rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
/* Stat grids (cards with big numbers) need room: stack on phones. */
#trainings-overview .grid-3 { grid-template-columns: 1fr; }

/* ── Dashboard Stats ─────────────────────────────────────────── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
}

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--gray);
  margin-top: 0.1rem;
}

/* ── Announcements ───────────────────────────────────────────── */
.announcement {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--gray-lt);
}

.announcement:last-child { border-bottom: none; }

.announcement-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.announcement-dot.new { background: var(--pink); }
.announcement-dot.info { background: var(--teal); }
.announcement-dot.alert { background: var(--red); }

.announcement-title {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.88rem;
  margin-bottom: 0.1rem;
}

.announcement-meta {
  font-size: 0.72rem;
  color: var(--gray-med);
}

.announcement-body {
  font-size: 0.82rem;
  color: var(--gray-dark);
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* ── Quick Links Grid ────────────────────────────────────────── */
.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius);
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: var(--gray-dark);
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.quick-link:active {
  background: var(--navy-bg);
  transform: scale(0.96);
}

.quick-link .ql-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

.quick-link .ql-label {
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Document Library ────────────────────────────────────────── */
.doc-section { margin-bottom: 1.5rem; }

.doc-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  font-weight: 700;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--navy);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: all var(--transition);
  text-decoration: none;
  color: var(--black);
  margin-bottom: 0.5rem;
  -webkit-tap-highlight-color: transparent;
  /* Minimum touch target */
  min-height: 56px;
}

.doc-card:active {
  background: var(--offwhite);
  transform: scale(0.98);
}

.doc-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.doc-icon.policy { background: var(--navy-bg); color: var(--navy); }
.doc-icon.training { background: var(--pink-lt); color: var(--pink); }

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

.doc-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy);
  margin-bottom: 0.1rem;
  line-height: 1.3;
}

.doc-desc {
  font-size: 0.75rem;
  color: var(--gray);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.doc-type {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
}

.doc-type.docx { background: var(--navy-bg); color: var(--navy-med); }
.doc-type.pptx { background: var(--pink-lt); color: var(--pink); }

.doc-download {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--offwhite);
  color: var(--gray);
  font-size: 0.95rem;
  /* Big enough touch target */
}

/* ── Filter buttons ──────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .search-bar {
  flex: 1;
  min-width: 0;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--gray-lt);
  background: var(--white);
  color: var(--gray-dark);
  -webkit-tap-highlight-color: transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

/* ── Tool Pages ──────────────────────────────────────────────── */
.tool-placeholder {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.tool-placeholder .tp-icon {
  width: 68px; height: 68px;
  background: var(--navy-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 1rem;
  color: var(--navy);
}

.tool-placeholder h2 {
  font-size: 1.15rem;
  color: var(--navy);
  margin-bottom: 0.4rem;
}

.tool-placeholder p {
  color: var(--gray);
  max-width: 320px;
  margin: 0 auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

.tool-placeholder .tp-badge {
  display: inline-block;
  margin-top: 0.85rem;
  background: var(--pink-lt);
  color: var(--pink);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--navy); color: var(--white); }
.btn-outline { background: transparent; color: var(--navy); border: 1.5px solid var(--gray-lt); }

/* ── Search Bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--white);
  border: 1.5px solid var(--gray-lt);
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  transition: border-color var(--transition);
}

.search-bar:focus-within { border-color: var(--navy-med); }

.search-bar input {
  border: none;
  outline: none;
  font-size: 0.9rem;
  flex: 1;
  background: transparent;
  color: var(--black);
  /* Prevent iOS zoom on focus */
  font-size: 16px;
}

.search-bar .search-icon { color: var(--gray-med); font-size: 0.9rem; }

/* ── Safety page specifics ───────────────────────────────────── */
.emergency-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.emergency-card {
  text-align: center;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
}

/* ── Upcoming events ─────────────────────────────────────────── */
.event-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--gray-lt);
}

.event-item:last-child { border-bottom: none; }

.event-date {
  width: 44px;
  text-align: center;
  flex-shrink: 0;
}

.event-date .month {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--pink);
  font-weight: 700;
}

.event-date .day {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

.event-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
}

.event-desc {
  font-size: 0.75rem;
  color: var(--gray);
}

/* ══════════════════════════════════════════════════════════════
   VIEWER (docx + pptx)
   ══════════════════════════════════════════════════════════════ */
.viewer { display: flex; flex-direction: column; gap: 1rem; }

.viewer-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--gray-lt);
}
.viewer-back {
  display: inline-flex; align-items: center;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem; font-weight: 600;
  color: var(--gray-dark);
  background: var(--offwhite);
  border-radius: var(--radius-sm);
  text-decoration: none;
  flex-shrink: 0;
}
.viewer-back:hover { color: var(--navy); background: var(--navy-bg); }
.viewer-title { flex: 1; min-width: 0; }
.viewer-title h1 { font-size: 1.15rem; color: var(--navy); line-height: 1.25; margin: 0; word-break: break-word; }
.viewer-eyebrow {
  font-size: 0.65rem; font-weight: 700; color: var(--pink);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 0.1rem;
}
.viewer-download {
  display: inline-flex; align-items: center;
  padding: 0.4rem 0.7rem;
  font-size: 0.75rem; font-weight: 700;
  color: var(--white); background: var(--navy-med);
  border-radius: var(--radius-sm);
  text-decoration: none; flex-shrink: 0;
}
.viewer-download:hover { background: var(--navy); color: var(--white); }
.viewer-loading, .viewer-fallback {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--gray);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pdf-viewer-wrap { display: flex; flex-direction: column; gap: 0.5rem; }
.pdf-iframe {
  width: 100%;
  height: 80vh;
  min-height: 500px;
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--white);
}
.pdf-fallback-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray);
}
.viewer-fallback p { margin-bottom: 1rem; }

/* ── DOCX rendered output ─────────────────────────────────────── */
.docx-rendered {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem;
  font-size: 0.94rem;
  color: var(--black);
  line-height: 1.7;
  max-width: 820px;
  margin: 0 auto;
}
.docx-rendered h1, .docx-rendered h2, .docx-rendered h3 {
  color: var(--navy);
  font-weight: 700;
  margin: 1.5em 0 0.5em;
  line-height: 1.25;
}
.docx-rendered h1 { font-size: 1.55rem; padding-bottom: 0.35em; border-bottom: 2px solid var(--navy-bg); }
.docx-rendered h2 { font-size: 1.25rem; }
.docx-rendered h3 { font-size: 1.05rem; color: var(--navy-med); }
.docx-rendered p { margin: 0.5em 0; }
.docx-rendered ul, .docx-rendered ol { margin: 0.5em 0 0.85em 1.35em; }
.docx-rendered li { margin: 0.25em 0; }
.docx-rendered table {
  width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.85rem;
  background: var(--offwhite); border-radius: var(--radius-sm); overflow: hidden;
}
.docx-rendered th, .docx-rendered td { padding: 0.55rem 0.7rem; border: 1px solid var(--gray-lt); text-align: left; vertical-align: top; }
.docx-rendered th { background: var(--navy); color: var(--white); font-weight: 700; font-size: 0.78rem; }
.docx-rendered tr:nth-child(even) td { background: var(--white); }
.docx-rendered blockquote {
  border-left: 3px solid var(--pink);
  margin: 1em 0; padding: 0.4em 0.85em;
  color: var(--gray-dark); background: var(--pink-lt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.docx-rendered .doc-title-h { font-size: 1.7rem; text-align: center; border: none; }
.docx-print-hint {
  margin-top: 1.5rem;
  display: flex; gap: 0.85rem; align-items: center; justify-content: center;
  font-size: 0.85rem; color: var(--gray);
  flex-wrap: wrap;
}

/* ── PPTX deck viewer ─────────────────────────────────────────── */
.deck-viewer {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.deck-stage {
  background: var(--espresso);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.deck-slide {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.deck-controls {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  grid-template-areas: "prev progress step next";
  align-items: center;
  gap: 0.55rem;
}
#deck-prev { grid-area: prev; }
#deck-next { grid-area: next; }
.deck-progress { grid-area: progress; }
.deck-step    { grid-area: step; }
.deck-btn {
  background: var(--ink);
  color: #FFFEF7;
  border: none;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  min-height: 44px;            /* Apple HIG tap target */
}
.deck-btn:disabled { background: var(--gray-lt); color: var(--gray-med); cursor: not-allowed; }
.deck-btn:hover:not(:disabled) { background: var(--navy-med); }
.deck-progress {
  flex: 1;
  height: 6px;
  background: var(--gray-lt);
  border-radius: 3px;
  overflow: hidden;
}
.deck-progress-fill {
  height: 100%;
  background: var(--pink);
  width: 0%;
  transition: width 0.3s ease;
}
.deck-step {
  font-size: 0.78rem;
  color: var(--gray);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.deck-banner {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}
.deck-banner.success { background: var(--pass-bg); color: var(--pass); border: 1px solid #C8D4BA; }

.deck-diagram-btn {
  background: var(--paper-card);
  color: var(--rust);
  border: 1.5px solid var(--paper-edge);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
  display: inline-flex; align-items: center; gap: 0.4rem;
  align-self: flex-start;
}
.deck-diagram-btn::before { content: "📐"; font-size: 1rem; }
.deck-diagram-btn:hover { border-color: var(--rust); background: var(--navy-bg); }

/* ── Diagram lightbox ─────────────────────────────────────────── */
.diagram-lightbox {
  position: fixed; inset: 0;
  background: rgba(28,20,16,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 1rem;
}
.diagram-lightbox-inner {
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(28,20,16,0.35);
  max-width: 1100px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  padding: 1rem 1rem 1.1rem;
  position: relative;
}
.diagram-lightbox-close {
  position: absolute;
  top: 0.4rem; right: 0.6rem;
  width: 36px; height: 36px;
  border: none; background: transparent;
  font-size: 1.6rem; color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
}
.diagram-lightbox-close:hover { color: var(--rust); }
.diagram-lightbox-svg svg {
  width: 100%; height: auto; max-height: 76vh;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.diagram-lightbox-cap {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════
   MODAL (profile prompt + certificate overlay)
   ══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(28,20,16,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 1rem;
}
.modal {
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(28,20,16,0.35);
  width: 100%;
  max-width: 460px;
  padding: 1.5rem 1.4rem;
}
.modal h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 0.35rem;
}
.modal > p {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 1rem;
  line-height: 1.55;
}
.modal-label {
  display: block;
  margin-bottom: 0.85rem;
}
.modal-label > span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.modal-label em {
  font-weight: 400;
  text-transform: none;
  color: var(--gray-med);
  letter-spacing: 0;
  font-style: normal;
}
.modal-label input {
  display: block; width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem; /* >= 16px to prevent iOS zoom */
  font-family: var(--font-body);
  min-height: 44px;
}
.modal-label input:focus {
  outline: none; border-color: var(--rust);
  background: var(--paper-card);
}
.modal-actions {
  display: flex; gap: 0.6rem; margin-top: 1rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-actions .btn {
  padding: 0.7rem 1.1rem;
  min-height: 44px;
  font-size: 0.9rem;
}

/* ══════════════════════════════════════════════════════════════
   CERTIFICATE
   ══════════════════════════════════════════════════════════════ */
.modal-cert {
  max-width: 980px;
  width: 100%;
  padding: 0.9rem;
  background: transparent;
  box-shadow: none;
}
.cert-actions {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
  padding-bottom: 0.85rem;
}
.cert-actions-right { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cert-actions .btn { padding: 0.6rem 0.95rem; min-height: 44px; }

.cert-stage {
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(28,20,16,0.3);
}

.certificate {
  background: var(--paper);
  background-image:
    radial-gradient(circle at 30% 10%, rgba(212,165,116,0.10) 0%, transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(212,165,116,0.06) 0%, transparent 60%);
  padding: 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-display);
}
.cert-frame {
  border: 2px solid var(--rust);
  outline: 1px solid var(--rust);
  outline-offset: 6px;
  padding: 2.4rem 2.2rem 2rem;
  position: relative;
  background: transparent;
}
.cert-corner {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid var(--rust);
}
.cert-tl { top: -2px;    left: -2px;    border-right: none; border-bottom: none; }
.cert-tr { top: -2px;    right: -2px;   border-left:  none; border-bottom: none; }
.cert-bl { bottom: -2px; left: -2px;    border-right: none; border-top: none; }
.cert-br { bottom: -2px; right: -2px;   border-left:  none; border-top: none; }

.cert-header { text-align: center; margin-bottom: 1.5rem; }
.cert-eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--rust);
  text-transform: uppercase;
}
.cert-program {
  font-family: var(--font-display);
  font-size: 1.85rem;
  color: var(--ink);
  font-weight: 700;
  margin-top: 0.4rem;
  font-style: italic;
}
.cert-body { text-align: center; }
.cert-presented {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0.7rem 0;
}
.cert-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 2.6rem;
  color: var(--ink);
  margin: 0.4rem 0 0.5rem;
  border-bottom: 1px solid var(--paper-edge);
  padding-bottom: 0.4rem;
  display: inline-block;
  min-width: 60%;
}
.cert-module {
  margin: 1.1rem 0 0.5rem;
}
.cert-module-num {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--kraft);
  background: var(--ink);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  margin-right: 0.55rem;
  vertical-align: middle;
  font-weight: 700;
}
.cert-module-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  vertical-align: middle;
}
.cert-tagline {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 1.1rem;
  max-width: 600px; margin-left: auto; margin-right: auto;
}
.cert-stats {
  display: flex; align-items: center; justify-content: center;
  gap: 1.6rem;
  margin: 1.2rem 0 0.5rem;
  font-family: var(--font-body);
}
.cert-stats > div { text-align: center; }
.cert-stat-value {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  color: var(--ink);
}
.cert-stat-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin-top: 0.15rem;
}
.cert-divider {
  width: 1px; height: 40px; background: var(--paper-edge);
}
.cert-footer {
  margin-top: 1.6rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--paper-edge);
}
.cert-meta {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--ink-soft);
  display: grid; gap: 0.3rem;
}
.cert-meta span { display: block; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gray-med); }
.cert-meta strong { color: var(--ink); font-weight: 700; }
.cert-seal { width: 110px; height: 110px; flex-shrink: 0; }
.cert-seal svg { width: 100%; height: 100%; }

/* Tiny "View certificate" button on training cards */
.tc-cert-btn {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--rust);
  background: transparent;
  color: var(--rust);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  align-self: flex-start;
  -webkit-tap-highlight-color: transparent;
}
.tc-cert-btn:hover { background: var(--rust); color: #FFFEF7; }

/* Phone-specific: certificate layout adjustments */
@media (max-width: 599px) {
  .cert-frame { padding: 1.3rem 1rem 1.2rem; outline-offset: 4px; }
  .cert-program { font-size: 1.35rem; }
  .cert-name { font-size: 1.85rem; }
  .cert-module-title { font-size: 1.05rem; }
  .cert-stats { gap: 0.9rem; }
  .cert-stat-value { font-size: 1.3rem; }
  .cert-footer { flex-direction: column; align-items: flex-start; gap: 0.85rem; }
  .cert-seal { width: 80px; height: 80px; align-self: center; }
  .modal-cert { padding: 0.4rem; }
  .cert-actions { padding: 0.4rem; }
}

/* ══════════════════════════════════════════════════════════════
   PROPERTIES — repair predictor + customer DB
   ══════════════════════════════════════════════════════════════ */
.predict-summary { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.predict-eyebrow {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; color: var(--ink);
}
.predict-meta { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.15rem; }

.predict-list { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.predict-item {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.75rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
}
.predict-body { flex: 1; min-width: 0; }
.predict-label { font-family: var(--font-display); font-weight: 700; color: var(--ink); font-size: 0.98rem; }
.predict-why { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.5; margin: 0.15rem 0 0.35rem; }
.predict-link { font-size: 0.78rem; font-weight: 600; color: var(--rust); }

.sev-pill {
  flex-shrink: 0;
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.25rem 0.5rem; border-radius: 999px; margin-top: 0.15rem;
  min-width: 58px; text-align: center;
}
.sev-high { background: var(--red-lt);  color: var(--red); }
.sev-med  { background: var(--navy-bg); color: var(--navy); }
.sev-low  { background: var(--pass-bg); color: var(--pass); }

.predict-data { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.predict-data li { display: flex; flex-direction: column; gap: 0.25rem; }
.predict-data-bar {
  height: 8px; background: var(--paper-edge); border-radius: 4px; overflow: hidden;
}
.predict-data-bar span { display: block; height: 100%; background: var(--rust); border-radius: 4px; }
.predict-data-label { display: flex; justify-content: space-between; font-size: 0.85rem; }
.predict-data-label a { color: var(--rust); font-weight: 600; }
.predict-data-label span { color: var(--ink-soft); }
.predict-nodata p { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.55; }
.predict-disclaimer { font-size: 0.78rem; color: var(--gray); font-style: italic; text-align: center; margin-top: 0.25rem; }

/* Customer detail */
.cust-detail-head { margin: 0.5rem 0 0.85rem; }
.cust-detail-head h2 { font-family: var(--font-display); color: var(--ink); font-size: 1.4rem; }
.cust-contact { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.88rem; color: var(--ink-soft); margin-top: 0.25rem; }
.cust-notes { font-size: 0.88rem; color: var(--ink-soft); margin-top: 0.4rem; font-style: italic; }

.property-card { margin-top: 0.85rem; }
.property-facts { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.property-facts span {
  font-size: 0.78rem; background: var(--paper); border: 1px solid var(--paper-edge);
  color: var(--ink-soft); padding: 0.2rem 0.55rem; border-radius: 999px;
}
.property-services { border-top: 1px solid var(--paper-edge); padding-top: 0.75rem; }
.property-services-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.property-services-head strong { font-size: 0.85rem; color: var(--ink); }
.svc-form { background: var(--paper); border: 1px solid var(--paper-edge); border-radius: var(--radius-sm); padding: 0.85rem; margin-bottom: 0.75rem; }

/* ══════════════════════════════════════════════════════════════
   HANDYMAN 101 — dashboard tip card
   ══════════════════════════════════════════════════════════════ */
.h101-tip-card {
  border: 1px solid var(--paper-edge);
  border-left: 4px solid var(--kraft);
  background:
    linear-gradient(135deg, var(--paper-card) 0%, var(--paper-card) 60%, rgba(212,165,116,0.08) 100%);
}
.h101-tip-eyebrow {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.7rem; font-weight: 800; color: var(--rust);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin-bottom: 0.6rem;
}
.h101-tip-shuffle {
  font-size: 0.72rem !important; color: var(--ink-soft) !important;
  text-transform: none; letter-spacing: 0; font-weight: 600 !important;
}
.h101-tip-shuffle:hover { color: var(--rust) !important; }
.h101-tip-cat {
  font-size: 0.7rem; font-weight: 700; color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}
.h101-tip-q {
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 700; color: var(--ink);
  line-height: 1.3; margin-bottom: 0.55rem;
}
.h101-tip-excerpt {
  font-size: 0.93rem; color: var(--ink-soft); line-height: 1.55;
  margin-bottom: 0.85rem;
}
.h101-tip-actions {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
}
.h101-tip-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.h101-tip-tags span {
  font-size: 0.68rem; background: var(--paper); color: var(--ink-soft);
  padding: 0.15rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--paper-edge);
}

/* ══════════════════════════════════════════════════════════════
   HANDYMAN 101 — encyclopedia viewer
   ══════════════════════════════════════════════════════════════ */
.hm-shell { display: flex; flex-direction: column; gap: 0.85rem; }

.hm-search-bar {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--paper-card);
  border: 1.5px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
}
.hm-search-bar:focus-within { border-color: var(--rust); }
.hm-search-bar .search-icon { font-size: 1rem; color: var(--gray); }
.hm-search-bar input {
  flex: 1; border: none; outline: none;
  background: transparent; color: var(--ink);
  font-size: 16px; font-family: var(--font-body);
  min-height: 36px;
}
.hm-clear {
  width: 30px; height: 30px;
  border: none; background: var(--paper); color: var(--ink-soft);
  border-radius: 50%; cursor: pointer; font-size: 1.1rem; line-height: 1;
  flex-shrink: 0;
}

.hm-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
@media (min-width: 900px) {
  .hm-layout { grid-template-columns: 240px 1fr; }
}

/* ── Category list (sidebar on desktop, chip strip on mobile) ──── */
.hm-cats {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 0.6rem;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.hm-cats-header {
  display: none;
}
@media (min-width: 900px) {
  .hm-cats {
    flex-direction: column;
    gap: 0.2rem;
    align-self: flex-start;
    position: sticky; top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    overflow-x: hidden;
  }
  .hm-cats-header {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray);
    padding: 0.5rem 0.5rem 0.65rem;
    border-bottom: 1px solid var(--paper-edge);
    margin-bottom: 0.4rem;
  }
}
.hm-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem; font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
  min-height: 38px;
}
@media (min-width: 900px) {
  .hm-cat { border-radius: var(--radius-sm); white-space: normal; }
}
.hm-cat:hover { background: var(--navy-bg); color: var(--ink); }
.hm-cat.active { background: var(--rust); color: #FFFEF7; border-color: var(--rust); }
.hm-cat.active .hm-cat-count { background: rgba(255,254,247,0.18); color: #FFFEF7; }
.hm-cat-count {
  background: var(--paper-card);
  color: var(--gray);
  font-size: 0.72rem; font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 24px; text-align: center;
}

/* ── Main column ───────────────────────────────────────────────── */
.hm-main { display: flex; flex-direction: column; gap: 0.85rem; min-width: 0; }
.hm-list { display: flex; flex-direction: column; gap: 1rem; }

.hm-group {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 0.9rem 0.95rem 1.1rem;
}
.hm-group-head {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.7rem;
  display: flex; align-items: baseline; gap: 0.5rem;
  border-bottom: 1px solid var(--paper-edge);
  padding-bottom: 0.5rem;
}
.hm-group-count {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray);
  background: var(--paper);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.hm-group-desc {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 0.25rem;
  width: 100%;
  font-style: italic;
}
.hm-cards { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.hm-card {
  display: block;
  padding: 0.75rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.hm-card:hover { background: var(--navy-bg); border-color: var(--rust); }
.hm-card.active {
  background: var(--paper-card);
  border-color: var(--rust);
  border-left: 3px solid var(--rust);
}
.hm-card-q {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}
.hm-card-sub {
  font-size: 0.72rem; color: var(--gray); margin-top: 0.2rem;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
}
.hm-card-tags {
  margin-top: 0.4rem;
  display: flex; gap: 0.3rem; flex-wrap: wrap;
}
.hm-card-tags span {
  font-size: 0.68rem;
  background: var(--paper-card);
  color: var(--ink-soft);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--paper-edge);
}

.hm-tagbar {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  display: flex; align-items: center; gap: 0.5rem;
}
.hm-empty {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--gray);
  font-style: italic;
}

/* ── Entry detail (rendered below the card list) ───────────────── */
.hm-entry {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 1.5rem 1.3rem;
  border-left: 4px solid var(--rust);
}
.hm-entry-eyebrow {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--rust);
  margin-bottom: 0.3rem;
}
.hm-entry-q {
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 1rem;
}
.hm-section { margin-bottom: 1.1rem; }
.hm-section h3 {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray);
  margin-bottom: 0.4rem;
}
.hm-section p {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
}
.hm-reasoning p { color: var(--ink-soft); }
.hm-insight {
  background: var(--paper);
  border-left: 3px solid var(--kraft);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.1rem;
}
.hm-insight-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rust);
  margin-bottom: 0.3rem;
}
.hm-insight p {
  font-size: 0.92rem;
  font-style: italic;
  color: var(--ink);
  line-height: 1.55;
}

.hm-entry-tags {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  margin-bottom: 1.1rem;
}
.hm-tag {
  font-size: 0.75rem;
  background: var(--paper);
  color: var(--ink-soft);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--paper-edge);
  cursor: pointer;
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
.hm-tag:hover { background: var(--navy-bg); color: var(--ink); border-color: var(--rust); }
.hm-tag.active { background: var(--rust); color: #FFFEF7; border-color: var(--rust); }

.hm-related-wrap ul { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.hm-related {
  display: flex; flex-direction: column;
  padding: 0.55rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.88rem;
}
.hm-related:hover { background: var(--navy-bg); border-color: var(--rust); }
.hm-related span {
  font-size: 0.7rem; color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  margin-top: 0.1rem;
}

@media (max-width: 599px) {
  .hm-entry { padding: 1.1rem 0.95rem; }
  .hm-entry-q { font-size: 1.25rem; }
  .hm-section p { font-size: 0.95rem; }
}

/* ══════════════════════════════════════════════════════════════
   CREW HOURS
   ══════════════════════════════════════════════════════════════ */
.hours-shell { display: flex; flex-direction: column; gap: 1rem; }
.hours-loading {
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--gray);
  font-style: italic;
}
.hours-fallback { padding: 1.5rem; }
.hours-fallback h2 { font-family: var(--font-display); color: var(--ink); margin-bottom: 0.5rem; }
.hours-fallback p { color: var(--ink-soft); margin-bottom: 0.85rem; line-height: 1.55; }

/* ── Tabs ───────────────────────────────────────────────────── */
.hours-tabs {
  display: flex; gap: 0.4rem;
  overflow-x: auto;
  padding: 0.25rem 0.1rem 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--paper-edge);
}
.hours-tab {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem; font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  border: 1px solid transparent;
  min-height: 38px;
}
.hours-tab:hover { background: var(--paper); color: var(--ink); }
.hours-tab.active {
  background: var(--paper-card);
  color: var(--rust);
  border-color: var(--paper-edge);
  border-bottom-color: var(--paper-card);
  position: relative;
  top: 1px;
}
.hours-tab .hours-tab-icon { font-size: 1rem; opacity: 0.8; }
.hours-tab .hours-tab-lock { margin-left: 0.2rem; font-size: 0.75rem; opacity: 0.6; }
.hours-tab.admin-tab.admin-unlocked {
  color: var(--sage);
}
.hours-tab.admin-tab.admin-unlocked.active {
  color: var(--sage);
  border-color: rgba(94,126,79,0.35);
}

/* ── Admin mode banner ──────────────────────────────────────── */
.hours-admin-bar {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--teal-lt);
  border: 1px solid rgba(94,126,79,0.4);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem; font-weight: 700;
  color: var(--sage);
}
.hours-admin-bar-label { flex: 1; }
.hours-admin-signout {
  font-size: 0.75rem; padding: 0.3rem 0.75rem;
  color: var(--sage); border-color: var(--sage);
  background: transparent;
}
.hours-admin-signout:hover {
  background: rgba(94,126,79,0.12);
}

/* ── Hours nav highlight ────────────────────────────────────── */
.nav-item.nav-hours {
  background: linear-gradient(135deg, rgba(94,126,79,0.12), rgba(94,126,79,0.06));
  border: 1px solid rgba(94,126,79,0.25);
  color: var(--sage);
  font-weight: 700;
  margin: 0.2rem 0;
}
.nav-item.nav-hours:hover {
  background: linear-gradient(135deg, rgba(94,126,79,0.22), rgba(94,126,79,0.12));
  color: var(--sage);
}
.nav-item.nav-hours.active {
  background: linear-gradient(135deg, rgba(94,126,79,0.28), rgba(94,126,79,0.16));
  border-color: rgba(94,126,79,0.45);
  color: var(--sage);
}
.nav-item.nav-hours.hours-admin-active {
  background: linear-gradient(135deg, rgba(94,126,79,0.22), rgba(94,126,79,0.12));
  border-color: rgba(94,126,79,0.5);
}
.nav-hours-badge {
  display: inline-flex; align-items: center;
  background: var(--sage); color: #fff;
  font-size: 0.58rem; font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: auto;
}
.nav-item.nav-hours .nav-hours-badge.admin-badge {
  background: var(--sage);
}
.nav-item.nav-hours .nav-hours-badge.track-badge {
  background: rgba(94,126,79,0.5);
  color: var(--sage);
}

/* drawer-item hours highlight */
.drawer-item.drawer-hours {
  background: linear-gradient(135deg, var(--paper-card), var(--teal-lt));
  border: 1px solid rgba(94,126,79,0.25);
}
.drawer-item.drawer-hours .drawer-icon {
  background: var(--teal-lt) !important;
  color: var(--teal) !important;
}
.drawer-badge.hours-admin-badge {
  background: var(--sage) !important;
  color: #fff !important;
}

.hours-view { display: flex; flex-direction: column; gap: 1rem; }

.hours-section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.85rem;
}
.hours-empty { text-align: center; padding: 2rem 1rem; }
.hours-empty h2 { font-family: var(--font-display); color: var(--ink); margin-bottom: 0.5rem; }
.hours-empty p { color: var(--ink-soft); margin-bottom: 1rem; }
.hours-empty-mini { color: var(--gray); font-size: 0.88rem; padding: 0.6rem 0.2rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-row { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
.form-grow { flex: 1; min-width: 200px; }
.form-grid { display: grid; gap: 0.7rem; grid-template-columns: 1fr; margin-bottom: 0.75rem; }
@media (min-width: 600px) {
  .form-grid { grid-template-columns: repeat(3, 1fr); }
}
.form-grid label, .hours-view label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.85rem;
}
.hours-view input,
.hours-view select,
.hours-view textarea,
.form-grid input,
.form-grid select,
.form-grid textarea {
  display: block; width: 100%;
  padding: 0.65rem 0.8rem;
  margin-top: 0.3rem;
  border: 1.5px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;                /* avoid iOS zoom */
  font-family: var(--font-body);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  min-height: 44px;
}
.hours-view input:focus,
.hours-view select:focus,
.hours-view textarea:focus {
  outline: none; border-color: var(--rust); background: var(--paper-card);
}
.hours-view textarea { resize: vertical; min-height: 60px; }
.form-actions {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  margin-top: 0.25rem;
}
.form-msg { font-size: 0.85rem; }
.form-msg.ok   { color: var(--pass); font-weight: 600; }
.form-msg.miss { color: var(--red);  font-weight: 600; }
.form-req { color: var(--red); font-weight: 700; margin-left: 0.15rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.hours-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.hours-table thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  padding: 0.55rem 0.55rem;
  border-bottom: 1px solid var(--paper-edge);
}
.hours-table tbody td {
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--paper-edge);
  color: var(--ink);
  vertical-align: middle;
}
.hours-table tbody tr:last-child td { border-bottom: none; }
.hours-table tbody tr:hover { background: var(--paper); }
.hours-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.hours-table thead th.num { text-align: right; }
.entry-notes {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 0.15rem;
}
.row-actions { white-space: nowrap; text-align: right; }
.link-btn {
  background: none; border: none;
  color: var(--rust);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  margin-left: 0.2rem;
  -webkit-tap-highlight-color: transparent;
}
.link-btn:hover { text-decoration: underline; }
.link-btn-warn  { color: var(--red); }
.link-btn-green { color: var(--pass); }
.link-btn-dim   { color: var(--gray-med); }

/* Paid status pill */
.paid-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.paid-pill.paid   { background: var(--pass-bg); color: var(--pass); }
.paid-pill.unpaid { background: var(--red-lt);  color: var(--red);  }

/* Entry row dimming when paid */
.hours-table tbody tr.entry-paid td { opacity: 0.55; }
.hours-table tbody tr.entry-paid:hover td { opacity: 0.8; }

/* Group header rows for same-date+project clusters */
.entry-group-row td {
  background: var(--navy-bg);
  border-top: 2px solid var(--paper-edge);
  padding: 0.35rem 0.75rem !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.entry-group-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.entry-group-tally {
  font-weight: 400;
  color: var(--gray);
  font-size: 0.78rem;
}
.entry-group-btn {
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Crew name as clickable link in crew list */
.crew-name-link {
  font-weight: 600;
  color: var(--rust);
  text-align: left;
}
.crew-name-link:hover { text-decoration: underline; color: var(--navy-med); }

/* Crew detail view */
.crew-detail-header { padding-bottom: 1rem; }
.crew-detail-back {
  font-size: 0.82rem;
  color: var(--gray);
  margin-bottom: 0.65rem;
}
.crew-detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.crew-detail-name {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--ink);
  margin: 0 0 0.15rem;
}
.crew-detail-rate {
  font-size: 0.85rem;
  color: var(--gray);
  font-weight: 600;
}
.crew-detail-edit-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--paper-edge); }
.crew-detail-count {
  font-size: 0.75rem;
  color: var(--gray-med);
}

/* Duplicate warning banner */
.log-dupe-warn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #FEF3CD;
  border: 1px solid #F5C842;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.86rem;
  color: #7A5C00;
  flex-wrap: wrap;
}
.dupe-warn-icon { font-size: 1rem; flex-shrink: 0; }
.dupe-warn-text { flex: 1; min-width: 0; }
.dupe-warn-ok {
  color: var(--rust);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Pay view — per-crew drill-down */
.pay-detail-row td { padding: 0 !important; }
.pay-detail-inner {
  padding: 0.75rem 1rem 1rem;
  background: var(--paper);
  border-top: 1px solid var(--paper-edge);
}

/* Paid checkbox in edit modal */
.ee-paid-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.ee-paid-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--pass);
  cursor: pointer;
}

.inline-input {
  padding: 0.45rem 0.6rem !important;
  margin-top: 0 !important;
  min-height: 36px !important;
  width: 100% !important;
  max-width: 280px;
}
.inline-input.num { max-width: 110px; }

.pay-due { color: var(--red); font-weight: 700; }
.action-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.action-add     { background: var(--pass-bg); color: var(--pass); }
.action-update  { background: var(--navy-bg); color: var(--navy); }
.action-delete  { background: var(--red-lt);  color: var(--red); }
.action-archive { background: var(--red-lt);  color: var(--red); }
.action-mark_paid { background: var(--pass-bg); color: var(--pass); }
.action-log       { background: var(--paper); color: var(--rust); }

.hours-firstrun h2 { font-family: var(--font-display); color: var(--ink); margin-bottom: 0.4rem; }
.hours-firstrun p { color: var(--ink-soft); line-height: 1.55; margin-bottom: 1rem; }

/* Make sure phone view collapses table actions nicely */
@media (max-width: 599px) {
  .hours-table { font-size: 0.82rem; }
  .hours-table thead th, .hours-table tbody td { padding: 0.55rem 0.4rem; }
  .row-actions { font-size: 0.75rem; }
}

/* ══════════════════════════════════════════════════════════════
   EXTERNAL TOOL LAUNCH (Hours)
   ══════════════════════════════════════════════════════════════ */
.hours-launch {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 1.4rem;
  border-left: 4px solid var(--kraft);
}
.hours-launch-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--rust);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  border: 1.5px solid var(--paper-edge);
  flex-shrink: 0;
}
.hours-launch-text h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.hours-launch-text p {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 0.85rem;
}
.hours-launch-btn { min-height: 44px; padding: 0.7rem 1.2rem; }
.hours-launch-note {
  font-size: 0.78rem !important;
  color: var(--gray) !important;
  margin: 0.6rem 0 0 !important;
}
.hours-launch-note code {
  background: var(--paper);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--paper-edge);
  font-size: 0.78rem;
}
@media (max-width: 599px) {
  .hours-launch { flex-direction: column; align-items: flex-start; text-align: left; gap: 1rem; }
  .hours-launch-icon { width: 56px; height: 56px; font-size: 1.6rem; }
}

/* ══════════════════════════════════════════════════════════════
   GAMIFICATION — rank, badges, journey, feedback, confetti
   ══════════════════════════════════════════════════════════════ */

/* ── Rank hero ──────────────────────────────────────────────── */
.rank-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "shield info" "stats stats";
  gap: 1rem;
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--rust);
}
.rank-shield { grid-area: shield; width: 70px; height: 80px; flex-shrink: 0; }
.rank-shield svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(28,20,16,0.18)); }
.rank-info { grid-area: info; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.rank-eyebrow {
  font-size: 0.65rem; font-weight: 700; color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.12em;
}
.rank-label { font-family: var(--font-display); font-size: 1.6rem; color: var(--ink); font-weight: 700; line-height: 1.05; margin-top: 0.1rem; }
.rank-desc { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.25rem; line-height: 1.4; }
.rank-stats { grid-area: stats; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: 0.4rem; }
.rank-stats > div {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.5rem; text-align: center;
}
.rank-stats span { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--ink); line-height: 1; }
.rank-stats label { display: block; font-size: 0.65rem; color: var(--gray); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.08em; }
@media (min-width: 600px) {
  .rank-hero { grid-template-areas: "shield info stats"; grid-template-columns: auto 1fr auto; }
  .rank-stats { grid-template-columns: repeat(3, 80px); margin-top: 0; }
}

/* ── Badges row ─────────────────────────────────────────────── */
.badges-row {
  display: flex; gap: 0.6rem;
  overflow-x: auto;
  padding: 0.25rem 0.1rem 0.5rem;
  margin-bottom: 1.25rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.badge {
  flex: 0 0 132px;
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.65rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  scroll-snap-align: start;
  text-align: center;
}
.badge.locked { opacity: 0.5; }
.badge-disc {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bc) 12%, var(--paper-card));
  color: var(--bc);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border: 1.5px solid var(--bc);
}
.badge.locked .badge-disc { background: var(--paper); border-color: var(--paper-edge); color: var(--gray-med); }
.badge-label { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: var(--ink); }
.badge-status { font-size: 0.62rem; color: var(--gray); text-transform: uppercase; letter-spacing: 0.08em; }
.badge.got .badge-status { color: var(--rust); font-weight: 700; }

/* ── Visual progress journey ────────────────────────────────── */
.journey {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 1.1rem 0.85rem 1rem;
  margin-bottom: 1.5rem;
}
.journey-track {
  position: absolute;
  left: 1rem; right: 1rem; top: 1.85rem;
  height: 4px;
  background:
    repeating-linear-gradient(to right,
      var(--paper-edge) 0 6px, transparent 6px 12px);
  z-index: 0;
}
.journey-stop {
  position: relative;
  z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  text-decoration: none;
  color: var(--ink-soft);
  -webkit-tap-highlight-color: transparent;
}
.journey-marker {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper);
  border: 2px solid var(--paper-edge);
  color: var(--gray);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform var(--transition);
}
.journey-stop:hover .journey-marker { transform: scale(1.06); border-color: var(--rust); color: var(--rust); }
.journey-stop.passed .journey-marker { background: var(--pass); border-color: var(--pass); color: #FFFEF7; }
.journey-stop.tried .journey-marker { border-color: var(--rust); color: var(--rust); background: var(--paper-card); }
.journey-label {
  font-size: 0.68rem;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.2;
  max-width: 90px;
}
.journey-stop.passed .journey-label { color: var(--pass); }
@media (max-width: 599px) {
  .journey { grid-template-columns: repeat(3, 1fr); gap: 0.85rem 0.4rem; }
  .journey-track { display: none; }
  .journey-label { font-size: 0.62rem; }
}

/* ── Per-question feedback ──────────────────────────────────── */
.quiz-choice.revealed { cursor: default; opacity: 0.85; }
.quiz-choice.correct {
  border-color: var(--pass);
  background: var(--pass-bg);
  color: var(--pass);
  opacity: 1;
}
.quiz-choice.correct .quiz-letter { background: var(--pass); }
.quiz-choice.wrong {
  border-color: var(--red);
  background: var(--red-lt);
  color: var(--red);
  opacity: 1;
}
.quiz-choice.wrong .quiz-letter { background: var(--red); }
.quiz-mark {
  margin-left: auto;
  font-size: 1.15rem;
  font-weight: 700;
}
.quiz-feedback {
  display: flex; flex-direction: column; gap: 0.2rem;
  border-left: 3px solid var(--paper-edge);
  background: var(--paper);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.5;
}
.quiz-feedback.ok { border-left-color: var(--pass); background: var(--pass-bg); }
.quiz-feedback.miss { border-left-color: var(--red); background: var(--red-lt); }
.quiz-feedback strong {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ink);
}
.quiz-feedback.ok strong { color: var(--pass); }
.quiz-feedback.miss strong { color: var(--red); }

/* ── Confetti ───────────────────────────────────────────────── */
.confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 99999;
}
.confetti-bit {
  position: absolute;
  top: -20px;
  width: 10px; height: 16px;
  border-radius: 2px;
  --sway: 0px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translate(0, -10vh) rotate(0deg);   opacity: 1; }
  100% { transform: translate(var(--sway), 110vh) rotate(720deg); opacity: 0.8; }
}

/* ── Badge unlock toast ─────────────────────────────────────── */
.badge-toast-stack {
  position: fixed;
  top: calc(60px + var(--sat));
  right: 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 99998;
  pointer-events: none;
  max-width: calc(100vw - 2rem);
}
.badge-toast {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--paper-card);
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 360px;
  animation: toast-in 0.5s ease forwards;
  opacity: 0;
}
@keyframes toast-in {
  0%   { opacity: 0; transform: translateX(60px) scale(0.95); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
.badge-toast-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.badge-toast-eyebrow {
  font-size: 0.62rem; font-weight: 700; color: var(--rust);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.badge-toast-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.badge-toast-desc { font-size: 0.78rem; color: var(--ink-soft); line-height: 1.4; }

/* Print: hide everything except the certificate */
@media print {
  body.printing-cert > *:not(.modal-overlay) { display: none !important; }
  .modal-overlay.cert-overlay {
    background: transparent !important;
    position: static !important;
    padding: 0 !important;
  }
  .cert-actions { display: none !important; }
  .modal-cert {
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  .cert-stage { box-shadow: none !important; }
  .certificate { background: var(--paper) !important; padding: 0.5in; }
  @page { size: letter landscape; margin: 0.4in; }
}

/* ── Quiz UI inside the deck stage ────────────────────────────── */
.quiz-slide {
  padding: 2rem 1.5rem;
  background: var(--white);
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  overflow-y: auto;
}
.deck-stage:has(.quiz-slide), .deck-stage:has(.quiz-results) {
  background: var(--white);
  aspect-ratio: auto;
  min-height: 480px;
}
.quiz-meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pink);
  font-weight: 700;
}
.quiz-question {
  font-size: 1.25rem;
  color: var(--navy);
  font-weight: 700;
  line-height: 1.35;
}
.quiz-choices {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr;
}
.quiz-choice {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1rem;
  background: var(--paper-card);
  border: 1.5px solid var(--paper-edge);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 60px;            /* roomy thumb target on phones */
}
.quiz-choice:hover { border-color: var(--navy-med); background: var(--navy-bg); }
.quiz-choice.selected { border-color: var(--navy); background: var(--navy-bg); color: var(--navy); font-weight: 600; }
.quiz-letter {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #FFFEF7;
  border-radius: 50%;
  font-size: 0.9rem; font-weight: 700;
  flex-shrink: 0;
}
.quiz-choice.selected .quiz-letter { background: var(--rust); }
.quiz-text { flex: 1; }
.quiz-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: auto;
  justify-content: space-between;
}
.quiz-actions .btn {
  padding: 0.75rem 1.15rem;
  min-height: 48px;            /* roomy thumb target */
  font-size: 0.9rem;
}

/* ── Quiz results ─────────────────────────────────────────────── */
.quiz-results {
  padding: 1.5rem 1.25rem;
  width: 100%;
  height: 100%;
  overflow-y: auto;
}
.quiz-results-hero {
  text-align: center;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}
.quiz-results-hero.passed { background: linear-gradient(135deg, var(--pass-bg), #F2F4E8); border: 1px solid #C8D4BA; }
.quiz-results-hero.missed { background: linear-gradient(135deg, var(--red-lt), #F8E7E0); border: 1px solid #E0BBB0; }
.qrh-status {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.quiz-results-hero.passed .qrh-status { color: var(--pass); }
.quiz-results-hero.missed .qrh-status { color: var(--red); }
.qrh-score {
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
  margin: 0.3rem 0 0.4rem;
}
.qrh-score span { font-size: 1.4rem; color: var(--gray-med); font-weight: 600; }
.qrh-sub { color: var(--gray-dark); font-size: 0.92rem; max-width: 420px; margin: 0 auto 1rem; }
.qrh-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.quiz-review-title {
  font-size: 0.95rem;
  color: var(--navy);
  margin: 0.5rem 0 0.85rem;
  font-weight: 700;
}
.quiz-review { list-style: none; display: flex; flex-direction: column; gap: 0.65rem; }
.quiz-review-item {
  display: flex; gap: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--offwhite);
  border-left: 3px solid var(--gray-lt);
}
.quiz-review-item.ok { border-left-color: #2E7D32; background: #F2F9F3; }
.quiz-review-item.miss { border-left-color: var(--red); background: var(--red-lt); }
.qri-num {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--navy); color: var(--white);
  border-radius: 50%;
  font-size: 0.78rem; font-weight: 700;
  flex-shrink: 0;
}
.qri-body { flex: 1; }
.qri-q { font-weight: 600; color: var(--navy); margin-bottom: 0.25rem; font-size: 0.9rem; line-height: 1.4; }
.qri-line { font-size: 0.85rem; margin: 0.1rem 0; color: var(--gray-dark); }
.qri-label { font-weight: 600; color: var(--gray); margin-right: 0.3rem; font-size: 0.78rem; }
.ok-text { color: var(--pass); font-weight: 600; }
.miss-text { color: var(--red); font-weight: 600; }
.qri-explain { font-size: 0.82rem; color: var(--gray); font-style: italic; margin-top: 0.45rem; line-height: 1.5; }

.qri-source {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--espresso);
  text-decoration: none;
  border-bottom: 1px dotted var(--espresso);
  padding-bottom: 1px;
}
.qri-source:hover { color: var(--kraft-dark, #6B5538); border-bottom-style: solid; }

.quiz-related {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--gray-light, #D9D2C4);
}
.quiz-related-sub {
  font-size: 0.85rem;
  color: var(--gray);
  margin: 0 0 0.85rem;
  line-height: 1.5;
}
.hm-related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.55rem;
}
.hm-related-card {
  display: block;
  padding: 0.7rem 0.85rem;
  background: var(--kraft, #F0E6D2);
  border: 1px solid #DCC9A6;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--espresso);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.hm-related-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.hm-related-q {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.25rem;
}
.hm-related-cat {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray);
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   TRAININGS HUB
   ══════════════════════════════════════════════════════════════ */
.training-track { margin-bottom: 1.75rem; }
.training-track-header {
  display: flex; align-items: center; gap: 0.85rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px solid var(--navy);
}
.training-track-header h2 {
  font-size: 1.05rem; color: var(--navy); margin: 0;
  line-height: 1.2;
}
.training-track-header p {
  font-size: 0.8rem; color: var(--gray); margin: 0.15rem 0 0;
}
.training-track-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--navy-bg); color: var(--navy);
  font-size: 1.15rem; flex-shrink: 0;
}
.training-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
.training-card {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 1.1rem 1.15rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--black);
  border-left: 4px solid var(--navy);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.training-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.training-card.tone-pink  { border-left-color: var(--pink); }
.training-card.tone-teal  { border-left-color: var(--teal); }
.training-card.tone-kraft { border-left-color: var(--kraft); }
.tc-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.4rem;
}
.tc-eyebrow {
  font-size: 0.65rem; font-weight: 700;
  color: var(--gray);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.tc-badge {
  font-size: 0.68rem; font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tc-badge.neutral { background: var(--gray-lt); color: var(--gray-dark); }
.tc-badge.passed { background: #E6F4EA; color: var(--pass); }
.tc-badge.missed { background: var(--red-lt); color: var(--red); }
.tc-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.tc-tagline {
  font-size: 0.82rem;
  color: var(--gray-dark);
  font-style: italic;
  line-height: 1.45;
}
.tc-meta {
  margin-top: 0.25rem;
  display: flex; gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--gray);
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   PHONE-SPECIFIC POLISH (≤599px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  /* Tighter horizontal gutters; trust safe-area inset */
  .main-content { padding-left: 0.85rem; padding-right: 0.85rem; }

  /* Viewer header: stack on phones so the title doesn't get squeezed */
  .viewer-header { flex-wrap: wrap; gap: 0.55rem 0.65rem; }
  .viewer-title { order: 0; flex-basis: 100%; }
  .viewer-back  { order: 1; }
  .viewer-download { order: 2; margin-left: auto; }
  .viewer-title h1 { font-size: 1.05rem; }

  /* Deck controls: hide step counter on tiny screens to keep buttons big */
  .deck-controls { gap: 0.45rem; }
  .deck-step { font-size: 0.72rem; }
  .deck-btn { padding: 0.7rem 0.7rem; font-size: 0.78rem; }

  /* Quiz: full-width Submit button on phones */
  .quiz-actions { gap: 0.5rem; }
  .quiz-actions .btn { flex: 1; padding: 0.85rem 0.6rem; font-size: 0.85rem; }
  .quiz-question { font-size: 1.1rem; }
  .quiz-slide { padding: 1.25rem 1rem; }

  /* Results hero: tighter on small screens */
  .quiz-results { padding: 1.1rem 0.85rem; }
  .quiz-results-hero { padding: 1.2rem 0.85rem; }
  .qrh-score { font-size: 2.5rem; }
  .qrh-actions .btn { flex: 1; }

  /* Training cards — bigger tap target, less cramped */
  .training-card { padding: 1.1rem 1rem; }
  .tc-title { font-size: 1.05rem; }

  /* Doc cards: bump min height for thumb-friendly tapping */
  .doc-card { min-height: 64px; padding: 0.95rem 1rem; }
  .doc-icon { width: 44px; height: 44px; }

  /* Filter chips: bigger */
  .filter-btn { padding: 0.55rem 0.95rem; font-size: 0.82rem; min-height: 38px; }
}

/* ══════════════════════════════════════════════════════════════
   TABLET (600px+)
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  #trainings-overview .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .emergency-grid { grid-template-columns: repeat(3, 1fr); }

  .main-content { padding-left: 1.5rem; padding-right: 1.5rem; }

  .training-grid { grid-template-columns: repeat(2, 1fr); }
  .quiz-choices { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════
   DESKTOP (900px+) — show sidebar, hide mobile nav
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  .mobile-header { display: none; }
  .bottom-nav { display: none; }
  .more-drawer-overlay { display: none !important; }
  .more-drawer { display: none !important; }

  .sidebar {
    display: flex;
  }

  .site-wrapper {
    flex-direction: row;
  }

  .main-content {
    margin-left: 260px;
    padding: 2rem 2.5rem;
    max-width: 1100px;
    width: calc(100% - 260px);
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid { gap: 1.25rem; }

  .card { padding: 1.5rem; }
  .page-header h1 { font-size: 1.75rem; }

  .doc-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
  }

  .doc-card:hover .doc-download {
    background: var(--navy-med);
    color: var(--white);
  }

  .quick-link:hover {
    background: var(--navy-bg);
    border-color: var(--navy-light);
    color: var(--navy);
    transform: translateY(-2px);
  }

  .emergency-grid { grid-template-columns: repeat(3, 1fr); }

  .search-bar { max-width: 360px; }
}
