/* Accessibility foundation, dashboard flow, mobile nav and sheets */


:where(.paper-card,.panel,.stat-card,.calendar-card,.session-row,.settings-card,.field,
  .hero-copy,.hero-actions,.meeting-access-copy,.meeting-access-actions,.assignment-card-main,
  .session-assignment,.snapshot-row) { min-width: 0; }
:where(.hero-copy,.timeline-content,.assignment-card,.session-assignment,.meeting-access-card) {
  overflow-wrap: anywhere;
}
.hero-actions > * { white-space: nowrap; }
:where(button,a,input,textarea,select,[tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
:where(.nav-item,.nav-group-toggle,.primary-btn,.secondary-btn,.ghost-btn,.danger-btn,.file-btn,
  .icon-btn,.row-menu,.filter-chip,.text-btn,.danger-text-btn) { min-height: 44px; }
.icon-btn,.row-menu { min-width: 44px; }
.muted,.hero-sub,.timeline-content p,.field span,.settings-card > p,
.session-info p,.session-chapters p { color: var(--text-secondary); }
.eyebrow,.hero-kicker,.text-btn { color: var(--accent-text); }
.chapter-check,.dashboard-vocabulary-meta span,.dashboard-vocabulary-empty span { color: var(--green-text); }
.field span,.timeline-content p,.chapter-progress-top span,.session-info p,.session-chapters p,
.sync-status,.empty-state { font-size: max(12px, 0.75rem); }

.nav-group { display: grid; gap: 8px; }
.nav-group[hidden] { display: none; }
.nav-group-toggle {
  width: 100%; margin-top: 8px; padding: 10px 15px; border: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  color: rgba(93,60,71,.72); background: rgba(255,255,255,.34); font-weight: 700;
}
.nav-group-toggle:hover { color: #5d3c47; background: rgba(255,255,255,.58); }
[data-theme="dark"] .nav-group-toggle { color: rgba(255,244,246,.76); background: rgba(255,255,255,.06); }
[data-theme="dark"] .nav-group-toggle:hover { color: #fff; background: rgba(255,255,255,.12); }
.nav-group-toggle[aria-expanded="true"] span:last-child { transform: rotate(180deg); }
.nav-group-toggle span:last-child { transition: transform .2s ease; }

.dashboard-flow {
  display: none;
  gap: 22px;
}
.dashboard-flow.active { display: grid; }
.dashboard-flow > .next-card { grid-area: next; min-height: 330px; }
.dashboard-flow > .meeting-access-card { grid-area: action; }
.dashboard-flow > .upcoming-panel { grid-area: upcoming; }
.dashboard-flow > .chapter-panel { grid-area: chapter; }
.dashboard-flow > .hero-card { grid-area: hero; }
.dashboard-flow > .dashboard-vocabulary-panel { grid-area: vocabulary; }
.meeting-access-mark { min-width: 58px; }
.meeting-access-copy h2,.meeting-access-copy p { margin: 3px 0; }
.meeting-access-actions { display: flex; align-items: center; gap: 10px; }
.meeting-access-actions a { color: inherit; text-decoration: none; }
.next-card-assignment-list { display: grid; gap: 5px; margin-top: 7px; }

.sync-banner {
  margin: -4px 0 18px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface-solid); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; color: var(--text-secondary); font-size: 12px;
}
.sync-banner[hidden] { display: none; }
.sync-banner[data-sync-state="error"],.sync-banner[data-sync-state="conflict"] { border-color: #c94f6b; color: var(--accent-text); }
.sync-banner[data-sync-state="offline"],.sync-banner[data-sync-state="queued"] { border-color: #b98657; }
.sync-banner button { min-height: 36px; padding: 6px 12px; border: 0; border-radius: 10px; background: var(--ink); color: var(--surface-solid); cursor: pointer; font-size: 12px; }
.sync-banner-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#syncDiscardBtn { background: transparent; border: 1px solid var(--line); color: var(--text-primary); }
#syncDiscardBtn:hover { background: var(--surface-hover); }
.sync-status[data-sync-state="error"],.sync-status[data-sync-state="conflict"] { border-color: #c94f6b; color: var(--accent-text); }
.sync-status[data-sync-state="offline"],.sync-status[data-sync-state="queued"] { border-color: #b98657; color: #91602f; }
.conflict-card { width: min(680px, 94vw); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.conflict-comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; overflow-y: auto; max-height: 380px; }
.conflict-col { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-muted); display: flex; flex-direction: column; gap: 8px; }
.conflict-col-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.conflict-col-badge { font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.conflict-col-badge.remote { background: #e8f5e9; color: #2e7d32; }
.conflict-col-badge.local { background: #e3f2fd; color: #1565c0; }
.conflict-col-time { color: var(--text-muted); font-size: 10px; }
.conflict-col-body { font-size: 12px; line-height: 1.6; word-break: break-word; color: var(--text-primary); }
.conflict-kv { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.conflict-kv-key { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.conflict-kv-val { padding: 4px 8px; background: var(--surface-solid); border-radius: 6px; border: 1px solid var(--line); font-size: 12px; white-space: pre-wrap; }
.conflict-actions button { min-height: 42px; font-size: 13px; }
@media (max-width: 600px) {
  .conflict-comparison-grid { grid-template-columns: 1fr; }
}

.mobile-sheet,.mobile-sheet-backdrop { display: none; }
.modal-backdrop[hidden],.mobile-sheet[hidden],.mobile-sheet-backdrop[hidden] { display: none !important; }
.modal-backdrop.open:not([hidden]) { display: grid; }

@media (max-width: 840px) {
  .dashboard-flow > * { width: 100%; min-width: 0; }
  .meeting-access-card { grid-template-columns: auto minmax(0,1fr); }
  .meeting-access-actions { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  html,body { max-width: 100%; }
  .main-content { padding: 0 16px calc(102px + env(safe-area-inset-bottom)); }
  .mobile-menu { display: none; }
  .today-chip,.topbar-actions #themeToggle,.topbar-actions #quickAddBtn { display: none; }
  .topbar-actions .sync-status {
    display: block; max-width: 132px; min-height: 36px; padding: 7px 10px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .sync-banner { position: relative; margin: -3px 0 14px; }
  .dashboard-flow { gap: 14px; }
  .dashboard-flow > .next-card { min-height: auto; padding: 24px 22px; }
  .next-card-footer { position: static; margin-top: 22px; }
  .meeting-access-card { padding: 18px; grid-template-columns: 1fr; }
  .meeting-access-mark { display: none; }
  .meeting-access-actions { grid-column: auto; }
  .meeting-access-actions > * { text-align: center; }
  .dashboard-flow > .panel,.dashboard-flow > .hero-card,.book-chapter-context-card { padding: 22px; }
  .dashboard-flow > .hero-card { min-height: auto; grid-template-columns: 1fr; }
  .dashboard-flow > .hero-card .book-visual { display: none; }
  .dashboard-vocabulary-empty { min-height: 120px; }
  .upcoming-panel .timeline-item:nth-child(n+4),.chapter-mini-list .chapter-mini:nth-child(n+4) { display: none; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }

  .mobile-primary-nav {
    position: fixed; z-index: 80; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); padding: 6px;
    border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb,var(--surface-solid),transparent 4%);
    box-shadow: 0 16px 45px rgba(25,27,40,.22); backdrop-filter: blur(18px);
  }
  .mobile-primary-nav button,.mobile-primary-nav a {
    min-width: 0; min-height: 52px; padding: 6px 2px; border: 0; border-radius: 12px;
    display: grid; place-items: center; align-content: center; gap: 2px; background: transparent;
    color: var(--text-secondary); text-decoration: none; cursor: pointer;
  }
  .mobile-primary-nav [aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); }
  .mobile-primary-nav a { color: var(--surface-solid); background: var(--ink); }
  .mobile-primary-nav span { font: 700 16px var(--font-serif); }
  .mobile-primary-nav strong { max-width: 100%; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .mobile-sheet-backdrop:not([hidden]) { position: fixed; inset: 0; z-index: 89; display: block; background: rgba(18,13,17,.48); }
  .mobile-sheet:not([hidden]) {
    position: fixed; z-index: 90; left: 0; right: 0; bottom: 0; max-height: min(78vh,640px);
    padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); display: block; overflow-y: auto;
    border: 1px solid var(--line); border-radius: 24px 24px 0 0; background: var(--surface-solid);
    box-shadow: 0 -20px 60px rgba(20,10,16,.24);
  }
  .mobile-sheet-handle { width: 42px; height: 4px; margin: 0 auto 10px; border-radius: 99px; background: var(--line); }
  .mobile-sheet-head { min-height: 52px; display: flex; align-items: center; justify-content: space-between; }
  .mobile-sheet-head h2 { margin: 0; font: 700 20px var(--font-serif); }
  .mobile-sheet-grid { display: grid; gap: 8px; }
  .mobile-sheet-grid > button,.mobile-theme-toggle {
    width: 100%; min-height: 64px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 15px;
    display: grid; grid-template-columns: 38px minmax(0,1fr); text-align: left; align-items: center;
    background: var(--surface); color: var(--ink); cursor: pointer;
  }
  .mobile-sheet-grid button > span,.mobile-theme-toggle > span { grid-row: 1 / span 2; font: 700 16px var(--font-serif); color: var(--accent-text); }
  .mobile-sheet-grid strong,.mobile-theme-toggle strong { font-size: 13px; }
  .mobile-sheet-grid small { color: var(--text-secondary); font-size: 12px; }
  .mobile-preferences { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
  .mobile-preferences > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .segmented-control { padding: 3px; border-radius: 12px; background: var(--accent-soft); }
  .segmented-control button { min-height: 38px; padding: 7px 11px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
  .segmented-control button.active { background: var(--surface-solid); box-shadow: var(--shadow-sm); }
}

@media (max-width: 420px) {
  .hero-actions,.meeting-access-actions { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 8px; }
  .hero-actions > * { width: 100%; text-align: center; }
  .assignment-card-main { grid-template-columns: 46px minmax(0,1fr); }
  .session-assignment { align-items: stretch; flex-direction: column; gap: 8px; }
  .session-assignment button { min-height: 44px; align-self: stretch; border: 1px solid var(--line); border-radius: 10px; }
}

