/* Responsive Spatial Glass Layout — Desktop / iPad Air 4 (820px & 1180px) / iPhone 13 (390px) */

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--text-soft);
  transition: background-color 160ms ease, color 160ms ease, transform 180ms var(--ease-spring);
}

.sidebar-toggle:hover {
  color: var(--text);
  background: var(--surface);
  transform: translateY(-1px);
}

.sidebar-toggle svg { width: 17px; height: 17px; }

.sidebar-mobile-close,
.mobile-menu-close {
  display: none;
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--text-soft);
  place-items: center;
}

@media (max-width: 1023px) {
  .sidebar-toggle { display: none; }
  .mobile-menu-toggle { display: inline-grid; }
  .sidebar-mobile-close,
  .mobile-menu-close { display: inline-grid; }
  body.mobile-menu-open { overflow: hidden; }

  .app-shell { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    width: min(296px, 84vw);
    min-width: 0;
    flex-basis: auto;
    margin: 0;
    border-radius: 0 24px 24px 0;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.84), rgba(240, 246, 255, 0.72));
    backdrop-filter: blur(18px) saturate(175%);
    -webkit-backdrop-filter: blur(18px) saturate(175%);
    border-right: 1px solid rgba(255, 255, 255, 0.86);
    box-shadow: 16px 0 36px rgba(15, 23, 42, 0.14), inset -1px 0 0 rgba(255, 255, 255, 0.9);
    transform: translate3d(calc(-100% - 24px), 0, 0);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    z-index: 50;
  }
  :root[data-theme="dark"] .sidebar {
    background: linear-gradient(160deg, rgba(16, 23, 42, 0.82), rgba(10, 15, 28, 0.70));
    border-right-color: rgba(255, 255, 255, 0.16);
    box-shadow: 20px 0 54px rgba(0, 0, 0, 0.58), inset -1px 0 0 rgba(255, 255, 255, 0.14);
  }

  .sidebar-head .sidebar-toggle {
    display: none;
  }

  .sidebar.open,
  .sidebar.mobile-open { transform: translate3d(0, 0, 0); }
  .sidebar.wf-drawer-dragging { transition: none; }

  :root {
    --wf-gutter-x: 16px;
  }

  .main-content {
    padding: 6px var(--wf-gutter-x) calc(118px + env(safe-area-inset-bottom));
  }

  body.review-mode .main-content {
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }

  body.review-mode .mobile-bottom-nav {
    display: none !important;
  }

  .workspace-bar {
    position: relative;
    top: auto;
    width: 100%;
    height: 52px;
    min-height: 52px;
    margin: 6px 0 10px;
    padding: 0 12px;
    border-radius: 999px;
    gap: 10px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(248, 252, 255, 0.74));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  }

  :root[data-theme="dark"] .workspace-bar {
    background: linear-gradient(135deg, rgba(24, 30, 42, 0.78), rgba(15, 20, 30, 0.58));
  }

  .workspace-search-slot {
    flex: 1 1 auto;
    max-width: 380px;
    order: 2;
  }

  .workspace-search-slot .wf-cmd-trigger {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    justify-content: flex-start;
  }

  .workspace-search-slot .wf-cmd-trigger > span {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace-search-slot .wf-cmd-trigger kbd {
    display: inline-flex;
    margin-left: auto;
  }

  .workspace-bar .breadcrumb {
    display: none;
  }

  .workspace-bar .workspace-meta {
    order: 3;
    margin-left: auto;
  }

  @media (max-width: 519px) {
    .workspace-bar .breadcrumb {
      display: flex;
      order: 1;
    }

    .workspace-search-slot {
      flex: 0 0 auto;
      max-width: none;
      order: 2;
    }

    .workspace-search-slot .wf-cmd-trigger {
      width: 36px;
      height: 36px;
      padding: 0;
      justify-content: center;
    }

    .workspace-search-slot .wf-cmd-trigger > span,
    .workspace-search-slot .wf-cmd-trigger kbd {
      display: none;
    }
  }

  .page.active {
    width: 100%;
    margin: 0;
    padding: 10px 0 32px;
    border-radius: 16px;
    min-height: calc(100vh - 160px);
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-columns,
  .two-column {
    grid-template-columns: 1fr;
  }

  /* Detached Floating Pill Dock on Mobile / Tablet Portrait */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    position: fixed;
    left: var(--wf-gutter-x, 16px);
    right: var(--wf-gutter-x, 16px);
    bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px;
    border-radius: 22px;
    background: var(--surface-strong);
    backdrop-filter: var(--blur-chrome);
    -webkit-backdrop-filter: var(--blur-chrome);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg), var(--shadow-glass-inset);
    z-index: 35;
  }

  .mobile-bottom-nav .nav-item,
  .mobile-bottom-nav .mobile-more {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 7px 4px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
  }

  .mobile-bottom-nav .nav-item::before { display: none; }

  .mobile-bottom-nav .nav-item.active,
  .mobile-bottom-nav .mobile-more.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transform: none;
  }

  .mobile-bottom-nav .icon { width: 18px; height: 18px; }

  .wf-back-top {
    right: 14px;
    bottom: calc(86px + env(safe-area-inset-bottom));
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 600px) {
  .main-content {
    padding: 10px 12px calc(92px + env(safe-area-inset-bottom));
  }

  .workspace-bar {
    min-height: 46px;
    padding: 6px 10px;
    margin-bottom: 14px;
    border-radius: 14px;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .breadcrumb > span:first-child,
  .breadcrumb-divider { display: none; }

  .breadcrumb strong {
    white-space: nowrap;
    font-size: 13px;
  }

  .workspace-meta {
    gap: 5px;
    flex-wrap: nowrap;
  }

  .date-chip {
    padding: 4px 7px;
    font-size: 11px;
    white-space: nowrap;
  }

  .theme-toggle {
    width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    font-size: 11.5px;
  }

  .workspace-meta .ghost-button {
    padding: 4px 6px;
    font-size: 12px;
  }

  .wf-cmd-trigger {
    width: 30px;
    height: 30px;
    padding: 0;
    justify-content: center;
  }

  .wf-cmd-trigger > span,
  .wf-cmd-trigger kbd {
    display: none;
  }

  .page-header {
    align-items: flex-start;
    margin-bottom: 14px;
    gap: 10px;
  }

  .study-hero {
    padding: 20px 18px;
    border-radius: 22px;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  #page-dashboard .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  #page-dashboard .hero-actions > :first-child {
    grid-column: 1 / -1;
    justify-content: center;
  }

  #page-dashboard .hero-actions > button {
    justify-content: center;
  }

  .focus-summary {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .focus-ring {
    width: 108px;
    height: 108px;
  }

  .focus-ring strong { font-size: 24px; }
  .focus-ring span { font-size: 10.5px; }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card { padding: 14px 16px 12px; border-radius: 18px; }
  .stat-value strong { font-size: 28px; }

  .form-two { grid-template-columns: 1fr; gap: 10px; }

  /* Compact Library Filter Grid so cards appear cleanly above the fold on iPhone 13 */
  .library-toolbar {
    padding: 10px;
    gap: 8px;
    margin-bottom: 10px;
    border-radius: 16px;
  }

  .library-header .search-wrap,
  .search-box,
  .search-wrap {
    flex: 1 1 100%;
    max-width: none;
    min-height: 38px;
    padding: 0 10px;
  }

  .search-box input,
  .search-wrap input {
    min-height: 36px;
    font-size: 13.5px;
  }

  .library-filters {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
  }

  .library-filters label {
    display: grid;
    gap: 3px;
    font-size: 11.5px;
    color: var(--text-muted);
  }

  .library-filters select {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 5px 8px;
    font-size: 12.5px;
    border-radius: 10px;
  }

  #library-compact {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
    margin-left: 0;
    justify-content: center;
    padding: 6px 12px;
    font-size: 12.5px;
  }

  .note-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Transform wide vocabulary table into clean mobile glass cards on iPhone */
  #page-library .table-wrap table thead { display: none; }
  #page-library .table-wrap table,
  #page-library .table-wrap table tbody {
    display: grid;
    gap: 8px;
    width: 100%;
  }

  #page-library .table-wrap table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
  }

  #page-library .table-wrap table tbody td {
    border: 0;
    padding: 0;
    min-width: 0;
  }

  #page-library .table-wrap table tbody td:nth-child(1) {
    grid-column: 1;
    font-size: 16px;
  }

  #page-library .table-wrap table tbody td:nth-child(3) {
    grid-column: 2;
    justify-self: end;
  }

  #page-library .table-wrap table tbody td:nth-child(2) {
    grid-column: 1 / -1;
    font-size: 13.5px;
    color: var(--text-soft);
  }

  #page-library .table-wrap table tbody td:nth-child(4),
  #page-library .table-wrap table tbody td:nth-child(5) {
    font-size: 12px;
    color: var(--text-muted);
  }

  #page-library .table-wrap table tbody td.library-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* Transform politics questions table into mobile glass cards on iPhone */
  #page-questions .questions-table thead { display: none; }
  #page-questions .questions-table,
  #page-questions .questions-table tbody {
    display: grid;
    gap: 10px;
    width: 100%;
  }

  #page-questions .questions-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 13px 14px;
    border-radius: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
  }

  #page-questions .questions-table tbody td {
    border: 0;
    padding: 0;
    min-width: 0;
  }

  #page-questions .questions-table tbody td:nth-child(1) {
    grid-column: 1 / -1;
    font-weight: 600;
  }

  #page-questions .questions-table tbody td:nth-child(6) {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    max-width: none;
    text-align: center;
  }

  .page.active {
    padding: 8px 0 28px;
    border-radius: 14px;
  }

  .workspace-meta .date-chip {
    display: none;
  }

  .page .recent-list button,
  .page .recent-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
  }

  .page .recent-list button > *:nth-child(2),
  .page .recent-item > *:nth-child(2) {
    grid-column: 1 / -1;
    order: 3;
    font-size: 13px;
  }
}

/* Native iOS Liquid-Glass Phone App Layout (iPhone 13 390x844 & All Phones <= 699px) */
@media (max-width: 699px) {
  :root {
    --wf-gutter-x: 10px;
  }

  kbd {
    display: none !important;
  }

  .main-content {
    padding: 6px var(--wf-gutter-x) calc(122px + env(safe-area-inset-bottom));
  }

  body.wf-has-thumb-rail .main-content {
    padding-bottom: calc(164px + env(safe-area-inset-bottom));
  }

  body.review-mode.wf-has-thumb-rail .main-content {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  /* Non-overlapping Frosted Top Capsule Bar on Phone */
  .workspace-bar {
    position: relative;
    top: auto;
    z-index: 30;
    height: 48px;
    min-height: 48px;
    margin: 0 0 10px;
    padding: 0 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(248, 252, 255, 0.76));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    gap: 8px;
  }

  :root[data-theme="dark"] .workspace-bar {
    border-color: rgba(255, 255, 255, 0.14);
    background: linear-gradient(135deg, rgba(24, 30, 42, 0.78), rgba(15, 20, 30, 0.58));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .workspace-bar .breadcrumb strong {
    font-size: 16px;
    font-weight: 740;
    letter-spacing: -0.015em;
  }

  .workspace-bar .mobile-menu-toggle {
    width: 34px;
    height: 34px;
    min-height: 34px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.48);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  }

  :root[data-theme="dark"] .workspace-bar .mobile-menu-toggle {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
  }

  .workspace-search-slot .wf-cmd-trigger {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.48);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  }

  :root[data-theme="dark"] .workspace-search-slot .wf-cmd-trigger {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
  }

  /* Transparent Outer Page Wrapper so Liquid-Glass Cards Float Directly Over Aurora Mesh */
  .page.active {
    width: 100%;
    margin: 0;
    padding: 2px 0 24px;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    min-height: calc(100dvh - 120px);
    background: transparent !important;
  }

  /* Restore Rich Liquid-Glass Refraction on Cards & Panels on Mobile */
  .page .panel,
  .page .stat-card,
  .page .study-hero {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.68));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.84);
    border-radius: 24px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  }

  :root[data-theme="dark"] .page .panel,
  :root[data-theme="dark"] .page .stat-card,
  :root[data-theme="dark"] .page .study-hero {
    background: linear-gradient(155deg, rgba(26, 33, 46, 0.76), rgba(16, 21, 32, 0.58));
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  }

  .page-header {
    margin-bottom: 10px;
    gap: 8px;
  }

  .page-header h1,
  .page-header .page-title {
    font-size: 20px;
  }

  /* Compact Single-Row Review Toolbar on Phone */
  #page-review .page-header,
  #page-word-review .page-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    margin-bottom: 8px;
    gap: 8px;
  }

  #page-review .page-header .page-title,
  #page-word-review .page-header .page-title {
    display: none;
  }

  #page-review .word-header-left,
  #page-word-review .word-header-left {
    gap: 6px;
    min-width: 0;
  }

  #page-word-review .word-round-control {
    display: none;
  }

  .review-progress {
    padding: 5px 11px;
    font-size: 12px;
    white-space: nowrap;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  }

  :root[data-theme="dark"] .review-progress {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
  }

  .word-study-switch {
    padding: 3px;
    background: rgba(255, 255, 255, 0.56);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }

  :root[data-theme="dark"] .word-study-switch {
    background: rgba(22, 28, 40, 0.68);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
  }

  .word-study-switch button {
    padding: 5px 11px;
    font-size: 12.5px;
    min-height: 30px;
  }

  .wf-session-progress {
    margin: -2px 0 8px;
  }

  /* Compact Single-Row 2-Column Frosted Glass Filter Pills for Politics Review */
  #page-review .review-classification {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
    margin: 0 0 10px;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
  }

  #page-review .review-classification label {
    display: block;
    font-size: 0;
    line-height: 0;
    margin: 0;
    min-width: 0;
  }

  #page-review .review-classification select,
  #page-review .review-classification .wf-select-trigger {
    width: 100%;
    height: 38px;
    min-height: 38px;
    padding: 0 30px 0 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.90);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.92);
  }

  #page-review .review-classification .wf-select-label {
    line-height: 1.35;
  }

  :root[data-theme="dark"] #page-review .review-classification select,
  :root[data-theme="dark"] #page-review .review-classification .wf-select-trigger {
    background-color: rgba(24, 30, 42, 0.86);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  }

  /* Frosted Glass Undo Strip on Phone */
  .word-undo-strip {
    padding: 7px 11px;
    margin-bottom: 10px;
    border-radius: 14px;
    font-size: 12.5px;
    gap: 8px;
    background: rgba(255, 255, 255, 0.68);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.84);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.92);
  }

  :root[data-theme="dark"] .word-undo-strip {
    background: rgba(24, 30, 42, 0.74);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  }

  .word-undo-strip button {
    padding: 5px 10px;
    min-height: 30px;
    font-size: 12px;
    border-radius: 10px;
    white-space: nowrap;
  }

  /* Single-Layer Liquid-Glass Stage Card on Phone (Zero Double/Triple Nesting) */
  #page-review #review-card,
  #page-word-review #word-review-card,
  #page-practice #practice-session .practice-card {
    width: 100%;
    padding: 16px 15px 18px;
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.68));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.86);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.96);
  }

  :root[data-theme="dark"] #page-review #review-card,
  :root[data-theme="dark"] #page-word-review #word-review-card,
  :root[data-theme="dark"] #page-practice #practice-session .practice-card {
    background: linear-gradient(160deg, rgba(26, 33, 46, 0.80), rgba(16, 21, 32, 0.60));
    border-color: rgba(255, 255, 255, 0.13);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.11);
  }

  #page-word-review #word-review-card {
    min-height: calc(100dvh - 280px);
    justify-content: center;
  }

  #word-review-term,
  .word-flashcard-term {
    font-size: 36px;
    max-width: 100%;
  }

  #word-review-meaning,
  .word-answer-meaning {
    font-size: 20px;
    max-width: 100%;
    line-height: 1.6;
  }

  /* Crisp Mobile Politics Reading Density + Tactile Frosted Option Cards */
  #page-review .review-meta {
    gap: 6px;
    font-size: 12px;
    margin-bottom: 8px;
  }

  #review-question {
    font-size: 16.5px;
    line-height: 1.62;
    font-weight: 680;
    margin: 2px 0 12px;
  }

  .review-options {
    gap: 8px;
  }

  .review-option {
    padding: 12px 12px;
    border-radius: 16px;
    gap: 10px;
    font-size: 14.5px;
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.92);
    transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  }

  :root[data-theme="dark"] .review-option {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .review-option:active {
    transform: scale(0.985);
  }

  .review-explanation {
    gap: 10px;
    padding-top: 12px;
    margin-top: 12px;
  }

  .review-result {
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13.5px;
  }

  .explanation-card {
    padding: 12px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  }

  :root[data-theme="dark"] .explanation-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow: none;
  }

  /* Hide Buried In-Card Duplicate Action & Rating Buttons While Mobile Thumb Bar Is Active */
  body.wf-has-thumb-rail #word-review-card #reveal-word-answer,
  body.wf-has-thumb-rail #word-review-card .word-rating-row,
  body.wf-has-thumb-rail #practice-session #practice-recall-front,
  body.wf-has-thumb-rail #practice-session #practice-ratings,
  body.wf-has-thumb-rail #practice-session #practice-next,
  body.wf-has-thumb-rail #review-card #submit-review-answer,
  body.wf-has-thumb-rail #review-card .rating-row {
    display: none !important;
  }

  /* Floating iOS Liquid-Glass Bottom Navigation Pill Dock */
  .mobile-bottom-nav {
    left: 10px;
    right: 10px;
    bottom: max(12px, env(safe-area-inset-bottom));
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.94);
    padding: 5px 6px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(245, 250, 255, 0.96));
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.96);
    gap: 4px;
  }

  :root[data-theme="dark"] .mobile-bottom-nav {
    border-color: rgba(255, 255, 255, 0.18);
    background: linear-gradient(145deg, rgba(16, 24, 42, 0.98), rgba(12, 18, 34, 0.96));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .mobile-bottom-nav .nav-item,
  .mobile-bottom-nav .mobile-more {
    padding: 6px 2px;
    border-radius: 16px;
    font-size: 10.5px;
    gap: 2px;
  }

  .mobile-bottom-nav .icon {
    width: 19px;
    height: 19px;
  }

  /* Floating iOS Liquid-Glass Bottom Thumb Action Capsule (Words, Politics, Practice) */
  .wf-mobile-action-bar.visible {
    display: block;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(70px + max(12px, env(safe-area-inset-bottom)));
    z-index: 34;
    padding: 7px;
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.96));
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.96);
  }

  body.review-mode .wf-mobile-action-bar.visible {
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  :root[data-theme="dark"] .wf-mobile-action-bar.visible {
    border-color: rgba(255, 255, 255, 0.16);
    background: linear-gradient(145deg, rgba(22, 30, 46, 0.98), rgba(15, 21, 34, 0.96));
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .wf-mob-action {
    width: 100%;
    height: 46px;
    border: 1px solid rgba(15, 130, 94, 0.28);
    border-radius: 999px;
    background: linear-gradient(150deg, rgba(220, 248, 235, 0.96), rgba(188, 236, 214, 0.90));
    color: #08543d;
    font-size: 15.5px;
    font-weight: 720;
    letter-spacing: 0.01em;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 6px 16px rgba(15, 130, 94, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.92);
    transition: transform 110ms ease, opacity 140ms ease;
  }

  :root[data-theme="dark"] .wf-mob-action {
    border-color: rgba(52, 211, 153, 0.34);
    background: linear-gradient(150deg, rgba(16, 185, 129, 0.24), rgba(16, 185, 129, 0.14));
    color: #b5f5d9;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  }

  .wf-mob-action:active:not(:disabled) {
    transform: scale(0.97);
  }

  .wf-mob-ratings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .wf-mob-ratings[hidden] {
    display: none;
  }

  .wf-mob-ratings button {
    height: 46px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    font-size: 14.5px;
    font-weight: 740;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
    transition: transform 110ms ease, opacity 140ms ease;
  }

  :root[data-theme="dark"] .wf-mob-ratings button {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
  }

  .wf-mob-ratings button:active:not(:disabled) {
    transform: scale(0.95);
  }

  .wf-mob-ratings button:disabled {
    opacity: 0.32;
    cursor: not-allowed;
    box-shadow: none;
  }

  .wf-mob-wrong:not(:disabled) {
    background: linear-gradient(160deg, color-mix(in srgb, #ef4444 16%, rgba(255, 255, 255, 0.85)), color-mix(in srgb, #ef4444 24%, rgba(255, 255, 255, 0.65)));
    border-color: color-mix(in srgb, #ef4444 42%, rgba(255, 255, 255, 0.8));
    color: #b91c1c;
  }

  .wf-mob-fuzzy:not(:disabled) {
    background: linear-gradient(160deg, color-mix(in srgb, #f59e0b 18%, rgba(255, 255, 255, 0.85)), color-mix(in srgb, #f59e0b 26%, rgba(255, 255, 255, 0.65)));
    border-color: color-mix(in srgb, #f59e0b 45%, rgba(255, 255, 255, 0.8));
    color: #b45309;
  }

  .wf-mob-known:not(:disabled) {
    background: linear-gradient(160deg, color-mix(in srgb, #10b981 18%, rgba(255, 255, 255, 0.85)), color-mix(in srgb, #10b981 26%, rgba(255, 255, 255, 0.65)));
    border-color: color-mix(in srgb, #10b981 42%, rgba(255, 255, 255, 0.8));
    color: #047857;
  }

  :root[data-theme="dark"] .wf-mob-wrong:not(:disabled) {
    background: color-mix(in srgb, #ef4444 22%, rgba(20, 26, 38, 0.78));
    border-color: color-mix(in srgb, #ef4444 46%, rgba(255, 255, 255, 0.14));
    color: #fca5a5;
  }

  :root[data-theme="dark"] .wf-mob-fuzzy:not(:disabled) {
    background: color-mix(in srgb, #f59e0b 22%, rgba(20, 26, 38, 0.78));
    border-color: color-mix(in srgb, #f59e0b 48%, rgba(255, 255, 255, 0.14));
    color: #fcd34d;
  }

  :root[data-theme="dark"] .wf-mob-known:not(:disabled) {
    background: color-mix(in srgb, #10b981 22%, rgba(20, 26, 38, 0.78));
    border-color: color-mix(in srgb, #10b981 46%, rgba(255, 255, 255, 0.14));
    color: #6ee7b7;
  }

  body.wf-has-thumb-rail .wf-back-top {
    bottom: calc(144px + env(safe-area-inset-bottom));
    right: 12px;
  }

  body.wf-has-thumb-rail .toast {
    bottom: calc(146px + env(safe-area-inset-bottom));
  }

  body.review-mode.wf-has-thumb-rail .wf-back-top,
  body.review-mode.wf-has-thumb-rail .toast,
  body.review-mode .wf-toast-stack {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .wf-back-top {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .toast {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 519px) {
  .page-header h1,
  .page-header h2.page-title {
    display: none;
  }

  .page-header:has(> .page-title:only-child),
  .page-header:has(> div:only-child > .page-title:only-child) {
    display: none;
  }

  .page-header {
    margin-bottom: 10px;
  }

  #page-dashboard .page-header {
    justify-content: flex-end;
    margin-bottom: 10px;
  }
}

/* iOS / iPadOS Home Screen Standalone PWA Polish */
@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
  }

  .main-content {
    padding-top: calc(env(safe-area-inset-top) + 12px);
  }

  .app-shell .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    padding-top: max(26px, calc(env(safe-area-inset-top) + 16px));
  }

  .mobile-bottom-nav {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  @media (max-width: 699px) {
    .main-content {
      padding-top: calc(env(safe-area-inset-top) + 6px);
    }

    .mobile-bottom-nav {
      bottom: max(8px, env(safe-area-inset-bottom));
    }
  }

  .site-header,
  .login-page {
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .workspace-meta .date-chip {
    display: none;
  }
}

@media (min-width: 720px) and (max-width: 1023px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .page .recent-list button,
  .page .recent-item {
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  .page,
  .sidebar,
  .nav-item,
  .nav-item::before,
  .nav-item .icon,
  .primary-button,
  .primary-button::after,
  .secondary-button,
  .stat-card,
  .analytics-kpi,
  .focus-ring,
  .quick-action,
  .wf-tab-pill,
  .wf-card-enter,
  .wf-num-roll,
  .wf-undo-ring-fill,
  .wf-copy-ok,
  .wf-copy-ok::after,
  .practice-choices button.wrong,
  .practice-finish-icon,
  details[open] > *,
  dialog.prompt-dialog[open],
  dialog.math-editor[open],
  dialog.wf-cmd-dialog[open],
  dialog.wf-lightbox-dialog[open],
  dialog.wf-shortcuts-dialog[open],
  .wf-read-progress > span,
  .wf-session-progress > span,
  .wf-tablet-thumb-rail button,
  .wf-nav-pill,
  .nav-more-items,
  .wf-back-top,
  .word-memorize-meaning,
  .toast {
    animation: none !important;
    transition: none !important;
  }
}
