/*
 * Saeum mobile final override layer
 * Loaded after styles.css. Desktop keeps the existing layout; 320-720px uses
 * one compact, touch-safe system. JavaScript may update
 * --mobile-keyboard-inset while the visual viewport is reduced by a keyboard.
 */

:root {
  --mobile-keyboard-inset: 0px;
}

.ui-icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  overflow: visible;
  color: currentColor;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.upload-zone .upload-icon {
  width: 28px;
  height: 28px;
  margin-bottom: 4px;
}

.sidebar .nav-item .nav-label {
  width: auto;
  height: auto;
  display: inline;
  overflow: visible;
  font-size: inherit;
  line-height: inherit;
  text-align: left;
  white-space: nowrap;
}

#quickAddBtn,
.toolbar-actions button,
#addCalendarAgendaBtn,
#finishTimerBtn,
#addTimerSubjectBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.mobile-schedule-overview,
.mobile-timetable,
.mobile-home-button {
  display: none;
}

.more-ai-usage {
  display: none;
}

@media (min-width: 721px) {
  #moreView {
    padding-top: 8px;
  }

  #moreView .more-intro {
    min-height: 104px;
  }

  .more-profile-card {
    width: min(100%, 760px);
    min-height: 82px;
    margin: 0 0 26px;
    padding: 15px 18px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(145deg, #f4f8ff, #fff);
    color: var(--ink);
    text-align: left;
    box-shadow: var(--shadow);
  }

  .more-profile-icon,
  .more-menu-icon {
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
  }

  .more-profile-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .more-profile-card > span:nth-child(2),
  .more-menu > button > span:nth-child(2) {
    min-width: 0;
  }

  .more-profile-card strong,
  .more-profile-card small,
  .more-menu > button strong,
  .more-menu > button small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .more-profile-card strong {
    margin-top: 3px;
    font-size: 15px;
  }

  .more-profile-card small,
  .more-menu > button small {
    color: var(--muted);
    font-size: 12px;
  }

  .more-section {
    width: 100%;
    margin-bottom: 26px;
  }

  .more-section > h3 {
    margin: 0 0 10px 2px;
    font-size: 14px;
  }

  .more-menu {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
  }

  .more-menu > button {
    min-width: 0;
    min-height: 82px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--panel);
    color: var(--ink);
    text-align: left;
    box-shadow: var(--shadow);
  }

  .more-menu > button:hover,
  .more-profile-card:hover {
    border-color: #cdd8e8;
    background: #fff;
  }

  .more-menu-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .more-menu > button strong {
    font-size: 14px;
  }

  .more-chevron {
    width: 18px;
    height: 18px;
    color: #98a2b3;
  }
}

@media (max-width: 720px) {
  :root {
    --page-gutter: 16px;
    --topbar-height: calc(60px + env(safe-area-inset-top));
    --mobile-nav-height: 68px;
    --mobile-control: 44px;
    --mobile-primary-control: 48px;
    --mobile-space-1: 4px;
    --mobile-space-2: 8px;
    --mobile-space-3: 12px;
    --mobile-space-4: 16px;
    --mobile-space-5: 24px;
    --mobile-radius-sm: 8px;
    --mobile-radius-md: 12px;
    --mobile-radius-lg: 16px;
    --mobile-radius-sheet: 22px;
    --mobile-bg: #f6f8fb;
    --mobile-surface: #fff;
    --mobile-surface-muted: #f7f9fc;
    --mobile-ink: #172033;
    --mobile-muted: #667085;
    --mobile-line: #e3e8ef;
    --mobile-accent: #f97316;
    --mobile-accent-strong: #c2410c;
    --mobile-accent-soft: #fff2e8;
    --motion-fast: 120ms;
    --motion-base: 180ms;
    --motion-sheet: 220ms;
    --motion-ease: cubic-bezier(.2, .8, .2, 1);
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    background: var(--mobile-bg);
  }

  html {
    font-size: 14px;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    color: var(--mobile-ink);
    font-size: 14px;
    line-height: 1.5;
    overscroll-behavior-x: none;
  }

  [hidden] {
    display: none !important;
  }

  img,
  video,
  canvas,
  svg {
    max-width: 100%;
  }

  .app-shell,
  .app-shell main,
  .app-shell .view,
  .app-shell .panel,
  .app-shell .panel-head,
  .app-shell .toolbar-actions,
  .app-shell .schedule-workspace,
  .app-shell .stopwatch-layout,
  .app-shell .ai-layout {
    min-width: 0;
    max-width: 100%;
  }

  .ui-icon {
    display: block;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    overflow: visible;
    color: currentColor;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
  }

  button .ui-icon,
  a .ui-icon {
    margin: 0;
  }

  button,
  a,
  input,
  textarea,
  select,
  summary {
    -webkit-tap-highlight-color: transparent;
  }

  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible,
  summary:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .28);
    outline-offset: 2px;
  }

  /* App chrome */
  .app-shell {
    display: block;
    width: 100%;
    min-height: 100dvh;
  }

  .app-shell main {
    width: 100%;
    padding: 0 var(--page-gutter)
      calc(var(--mobile-nav-height) + 20px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    width: calc(100% + (var(--page-gutter) * 2));
    height: var(--topbar-height);
    margin: 0 calc(var(--page-gutter) * -1) !important;
    padding: env(safe-area-inset-top) var(--page-gutter) 0 !important;
    gap: var(--mobile-space-2);
    background: rgba(246, 248, 251, .96);
    border-bottom: 1px solid rgba(227, 232, 239, .94);
    box-shadow: none;
    backdrop-filter: blur(14px) saturate(125%);
  }

  .menu-button {
    display: none !important;
  }

  .mobile-home-button {
    position: relative;
    z-index: 1;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    display: grid !important;
    place-items: center;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(145deg, #2563eb, #0f9f8f);
    box-shadow: none;
  }

  .mobile-home-button .ui-icon {
    width: 20px;
    height: 20px;
  }

  .page-heading {
    min-width: 0;
    margin-left: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  .page-heading .eyebrow {
    display: none !important;
  }

  .topbar h1 {
    max-width: 100%;
    margin: 0 !important;
    overflow: hidden;
    color: var(--mobile-ink);
    font-size: 20px !important;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.035em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    flex: 0 0 auto;
    gap: 6px;
    margin-left: auto;
  }

  .top-actions .account-button,
  .top-actions #quickAddBtn {
    width: var(--mobile-control) !important;
    min-width: var(--mobile-control) !important;
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    padding: 0 !important;
    border-radius: var(--mobile-radius-md) !important;
    display: grid;
    place-items: center;
    box-shadow: none !important;
  }

  .top-actions .account-button #accountLabel {
    display: none !important;
  }

  .top-actions .account-dot {
    margin: 0;
    font-size: 12px;
  }

  .top-actions #quickAddBtn {
    border-color: var(--mobile-accent);
    background: var(--mobile-accent);
    font-size: 0 !important;
  }

  .top-actions #quickAddBtn > span {
    display: none !important;
  }

  .top-actions #quickAddBtn .ui-icon {
    display: block;
    width: 20px;
    height: 20px;
  }

  .sidebar {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    z-index: 120;
    width: 100% !important;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)) !important;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom)) !important;
    overflow: visible !important;
    transform: none !important;
    background: rgba(255, 255, 255, .98);
    border: 0;
    border-top: 1px solid var(--mobile-line);
    box-shadow: 0 -8px 26px rgba(23, 32, 51, .07);
    backdrop-filter: blur(14px) saturate(120%);
  }

  .sidebar.open {
    transform: none !important;
  }

  .sidebar-foot,
  .nav-section {
    display: none !important;
  }

  .sidebar nav {
    width: 100%;
    height: 60px;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px !important;
  }

  .sidebar .nav-item {
    position: relative;
    width: 100%;
    min-width: 0;
    height: 60px;
    min-height: 60px;
    padding: 5px 2px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px !important;
    overflow: hidden;
    border-radius: var(--mobile-radius-md);
    color: #748096;
    background: transparent;
    box-shadow: none !important;
    font-size: 11px !important;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
  }

  .sidebar .nav-item > span:not(.ui-icon):not(.nav-label) {
    width: 20px !important;
    height: 20px !important;
    display: grid;
    place-items: center;
    overflow: hidden;
    font-size: 18px !important;
    line-height: 20px !important;
  }

  .sidebar .nav-item > .nav-label {
    width: auto !important;
    height: auto !important;
    min-width: 0;
    display: block;
    overflow: hidden;
    font-size: 11px !important;
    line-height: 1 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar .nav-item .ui-icon {
    width: 20px;
    height: 20px;
  }

  .sidebar .nav-item:hover {
    color: #536075;
    background: transparent;
    transform: none !important;
  }

  .sidebar .nav-item.active,
  .sidebar .nav-item[aria-current="page"] {
    color: var(--mobile-accent-strong);
    background: var(--mobile-accent-soft);
  }

  .sidebar .brand {
    display: none !important;
  }

  .sidebar .brand > span:last-child {
    display: none;
  }

  .sidebar .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    font-size: 0;
    box-shadow: none;
  }

  .sidebar .brand-mark .ui-icon {
    width: 19px;
    height: 19px;
  }

  .section-nav {
    width: calc(100% + (var(--page-gutter) * 2));
    height: var(--mobile-control);
    margin: 0 calc(var(--page-gutter) * -1);
    padding: 0 var(--page-gutter);
    display: flex;
    gap: 2px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    background: var(--mobile-surface);
    border-bottom: 1px solid var(--mobile-line);
  }

  .section-nav::-webkit-scrollbar {
    display: none;
  }

  .section-nav button {
    flex: 0 0 auto;
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    padding: 0 12px !important;
    border-bottom-width: 2px;
    border-radius: 0;
    font-size: 12px !important;
    white-space: nowrap;
  }

  /* Type and reusable controls */
  .view {
    width: 100%;
    margin: 0;
  }

  .view-intro {
    min-height: 0 !important;
    padding: 16px 0 12px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-3) !important;
  }

  .view-intro .eyebrow,
  .eyebrow {
    font-size: 12px !important;
    line-height: 1.35;
    letter-spacing: .04em;
  }

  .view-intro h2 {
    margin: 0 !important;
    font-size: 20px !important;
    line-height: 1.3 !important;
    letter-spacing: -.035em;
  }

  .view-intro > div > span {
    color: var(--mobile-muted);
    font-size: 12px !important;
    line-height: 1.5;
  }

  #tasksView > .view-intro > div:first-child,
  #timetableView > .view-intro > div:first-child,
  #gradesView > .view-intro > div:first-child {
    display: none;
  }

  #timerView > .view-intro {
    display: none !important;
  }

  .view-intro .toolbar-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--mobile-space-2) !important;
  }

  .view-intro .toolbar-actions > * {
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  .panel,
  .task-card,
  .calendar-panel {
    min-width: 0;
    padding: var(--mobile-space-4);
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-lg);
    background: var(--mobile-surface);
    box-shadow: none;
  }

  .panel-head {
    min-width: 0;
    margin-bottom: var(--mobile-space-3);
    gap: var(--mobile-space-2);
  }

  .panel-head > div {
    min-width: 0;
  }

  .panel h3,
  .panel-head h3,
  .schedule-task-divider h3 {
    margin: 0;
    font-size: 16px !important;
    line-height: 1.35;
    letter-spacing: -.02em;
  }

  .primary-button,
  .soft-button,
  .icon-button,
  .link-button,
  .toolbar-menu > summary {
    min-height: var(--mobile-control);
    border-radius: var(--mobile-radius-md);
    font-size: 12px;
    line-height: 1.2;
  }

  .primary-button {
    min-height: var(--mobile-primary-control);
    padding: 0 16px;
    box-shadow: none !important;
  }

  .soft-button {
    padding: 0 14px;
  }

  .icon-button {
    width: var(--mobile-control);
    height: var(--mobile-control);
    padding: 0;
    display: grid;
    place-items: center;
  }

  .link-button {
    min-width: var(--mobile-control);
    padding: 0 8px;
    background: transparent;
    white-space: nowrap;
  }

  .empty,
  .compact-empty {
    min-height: 88px;
    padding: 20px 10px;
    display: grid;
    place-content: center;
    gap: var(--mobile-space-1);
    color: var(--mobile-muted);
    font-size: 12px !important;
    line-height: 1.5;
    text-align: center;
  }

  .content-tabs,
  .filter-tabs {
    width: 100%;
    min-width: 0;
    padding: 4px;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 2px;
    overflow: visible;
    border-radius: var(--mobile-radius-md);
  }

  .content-tabs button,
  .filter-tabs button,
  .pack-tabs button {
    width: 100%;
    min-width: 0;
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    padding: 0 8px !important;
    border-radius: var(--mobile-radius-sm);
    font-size: 12px !important;
    white-space: nowrap;
  }

  .search-box,
  .schedule-search {
    width: 100%;
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    padding: 0 12px;
    display: flex;
    align-items: center;
    border-radius: var(--mobile-radius-md);
  }

  .search-box input,
  .schedule-search input {
    width: 100%;
    min-width: 0;
    font-size: 14px;
  }

  /* Today: deadline -> upcoming work -> today -> week -> two summaries. */
  #dashboardView.active {
    width: 100%;
    padding-top: var(--mobile-space-4) !important;
    display: flex !important;
    flex-direction: column;
    gap: var(--mobile-space-3) !important;
  }

  #dashboardView .dashboard-top-grid {
    order: 1;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-3);
  }

  #dashboardView .dashboard-grid {
    order: 2;
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: var(--mobile-space-3) !important;
  }

  #dashboardView .dashboard-agenda-grid {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-3) !important;
  }

  #dashboardView .dashboard-week {
    order: 4;
  }

  #dashboardView .stats-grid {
    order: 5;
  }

  #dashboardView .dashboard-top-grid .dday-widget {
    width: 100%;
    height: auto !important;
    min-height: 106px !important;
    padding: 14px 16px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: var(--mobile-space-3) !important;
    border: 1px solid #fed7aa;
    border-radius: var(--mobile-radius-lg);
    background: linear-gradient(145deg, #fff8f1, #fff2e8);
    box-shadow: none;
  }

  #dashboardView .dashboard-top-grid .dday-widget > div:first-child {
    min-width: 0;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 3px 10px;
  }

  #dashboardView .dashboard-top-grid .dday-widget .eyebrow {
    grid-column: 1 / -1;
    display: block !important;
    color: var(--mobile-accent-strong);
    font-size: 12px !important;
  }

  #dashboardView .dashboard-top-grid .dday-widget strong {
    grid-row: 2 / 4;
    margin: 0 !important;
    color: var(--mobile-accent-strong);
    font-size: 22px !important;
    line-height: 1.1;
    white-space: nowrap;
  }

  #dashboardView .dashboard-top-grid .dday-widget h3 {
    grid-column: 2;
    min-width: 0;
    margin: 0 !important;
    overflow: hidden;
    font-size: 14px !important;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dashboardView .dashboard-top-grid .dday-widget span {
    grid-column: 2;
    display: block !important;
    margin: 0;
    overflow: hidden;
    color: #92552f;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dashboardView .dashboard-top-grid .dday-actions {
    display: flex !important;
    align-items: center;
  }

  #dashboardView .dashboard-top-grid .dday-actions .primary-button {
    width: auto;
    min-width: 88px;
    height: var(--mobile-primary-control);
    min-height: var(--mobile-primary-control) !important;
    padding: 0 12px;
    font-size: 12px;
  }

  #dashboardView .dashboard-top-grid .dday-actions .soft-button {
    display: none !important;
  }

  #dashboardView .dashboard-grid > .panel {
    min-height: 0 !important;
    padding: var(--mobile-space-4);
  }

  #dashboardView .dashboard-grid .task-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px;
  }

  #dashboardView .dashboard-grid .task-row {
    min-width: 0;
    min-height: 56px;
    padding: 8px;
    gap: 10px;
    border-radius: var(--mobile-radius-md);
  }

  #dashboardView .dashboard-grid .task-row strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dashboardView .dashboard-grid .task-row small,
  #dashboardView .dashboard-grid .due-chip {
    font-size: 12px;
  }

  #dashboardView .dashboard-agenda-grid > .panel {
    height: auto !important;
    min-height: 132px !important;
    padding: var(--mobile-space-4);
    overflow: hidden;
  }

  #dashboardView .dashboard-agenda-grid .panel-head {
    height: auto;
    min-height: var(--mobile-control);
    margin-bottom: var(--mobile-space-2);
  }

  #dashboardView .dashboard-agenda-grid .panel-head .eyebrow {
    display: none;
  }

  #dashboardView .dashboard-agenda-grid .panel-head h3 {
    font-size: 16px !important;
  }

  #dashboardView .dashboard-agenda-grid .link-button {
    height: var(--mobile-control);
    min-height: var(--mobile-control) !important;
    font-size: 12px;
  }

  #dashboardView .dashboard-day-events,
  #dashboardView .dashboard-timetable-panel .today-schedule {
    max-height: 164px !important;
    gap: 6px !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #dashboardView .dashboard-day-events button,
  #dashboardView .dashboard-day-events > div,
  #dashboardView .dashboard-timetable-panel .schedule-row {
    min-height: var(--mobile-control) !important;
    padding: 8px 10px !important;
    font-size: 14px;
  }

  #dashboardView .dashboard-week {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    padding: 10px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px !important;
    overflow: hidden !important;
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-lg);
    background: var(--mobile-surface);
  }

  .dashboard-week > div:first-child {
    min-width: 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .dashboard-week > div:first-child .eyebrow {
    display: none;
  }

  .dashboard-week > div:first-child strong {
    font-size: 14px;
    line-height: 1.3;
  }

  .dashboard-week-strip {
    width: 100%;
    min-width: 0;
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 0 !important;
    overflow: visible !important;
  }

  .dashboard-week-strip button {
    width: 100%;
    min-width: 0 !important;
    height: 52px;
    min-height: 52px !important;
    padding: 4px 0 !important;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1px;
    border-radius: 10px !important;
  }

  .dashboard-week-strip button small,
  .dashboard-week-strip button span {
    min-height: 0;
    font-size: 11px !important;
    line-height: 1.1;
  }

  .dashboard-week-strip button strong {
    font-size: 14px !important;
    line-height: 1.15;
  }

  #dashboardView .stats-grid {
    width: 100%;
    margin: 0 !important;
    padding: 0;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: var(--mobile-space-2) !important;
    overflow: visible;
  }

  #dashboardView .stats-grid .stat-active,
  #dashboardView .stats-grid .stat-grade,
  #dashboardView .stats-grid .stat-card:nth-child(1),
  #dashboardView .stats-grid .stat-card:nth-child(4) {
    display: none !important;
  }

  #dashboardView .stats-grid .stat-urgent,
  #dashboardView .stats-grid .stat-focus,
  #dashboardView .stats-grid .stat-card:nth-child(2),
  #dashboardView .stats-grid .stat-card:nth-child(3) {
    display: flex;
  }

  #dashboardView .stats-grid .stat-card {
    min-width: 0;
    min-height: 72px !important;
    padding: 10px 12px !important;
    gap: 10px;
    border-radius: var(--mobile-radius-md);
  }

  #dashboardView .stats-grid .stat-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 10px;
    font-size: 13px;
  }

  #dashboardView .stats-grid .stat-card small {
    overflow: hidden;
    font-size: 12px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dashboardView .stats-grid .stat-card strong {
    font-size: 18px;
  }

  /* Schedule: week and agenda first; the full month is explicitly opened. */
  .mobile-schedule-overview {
    width: 100%;
    margin: 12px 0;
    padding: var(--mobile-space-4);
    display: grid !important;
    gap: var(--mobile-space-3);
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-lg);
    background: var(--mobile-surface);
  }

  .mobile-schedule-overview .panel-head,
  .mobile-schedule-overview .mobile-schedule-head {
    min-height: var(--mobile-control);
    margin: 0;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: var(--mobile-space-2);
  }

  .mobile-schedule-head > div {
    min-width: 0;
    display: grid;
    justify-items: center;
    line-height: 1.25;
    text-align: center;
  }

  .mobile-schedule-head small {
    color: var(--mobile-muted);
    font-size: 11px;
  }

  .mobile-schedule-head strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-schedule-overview h2,
  .mobile-schedule-overview h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
  }

  #toggleMobileMonthBtn {
    min-width: var(--mobile-control);
    min-height: var(--mobile-control);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: var(--mobile-radius-md);
    font-size: 12px;
  }

  #mobileScheduleWeekStrip {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0;
  }

  #mobileScheduleWeekStrip button {
    width: 100%;
    min-width: 0;
    height: 54px;
    min-height: 54px;
    padding: 4px 1px;
    display: grid;
    place-content: center;
    gap: 2px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--mobile-surface-muted);
    color: var(--mobile-muted);
    font-size: 11px;
    text-align: center;
  }

  #mobileScheduleWeekStrip button strong {
    color: var(--mobile-ink);
    font-size: 14px;
  }

  #mobileScheduleWeekStrip .mobile-date-dot {
    width: 4px;
    height: 4px;
    margin: 0 auto;
    border-radius: 50%;
    background: transparent;
  }

  #mobileScheduleWeekStrip .mobile-date-dot.has-events {
    background: var(--mobile-accent);
  }

  #mobileScheduleWeekStrip button.today {
    border-color: #fdba74;
  }

  #mobileScheduleWeekStrip button.active,
  #mobileScheduleWeekStrip button.selected,
  #mobileScheduleWeekStrip button[aria-pressed="true"] {
    border-color: var(--mobile-accent);
    color: var(--mobile-accent-strong);
    background: var(--mobile-accent-soft);
  }

  .mobile-schedule-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--mobile-space-2);
  }

  .mobile-schedule-actions .soft-button {
    width: 100%;
    min-width: 0;
    height: var(--mobile-control);
  }

  .mobile-google-row {
    width: 100%;
    min-width: 0;
    min-height: 58px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-md);
    background: var(--mobile-surface-muted);
  }

  .mobile-google-row .calendar-sync-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .mobile-google-row > div {
    min-width: 0;
  }

  .mobile-google-row strong,
  .mobile-google-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-google-row strong {
    font-size: 12px;
  }

  .mobile-google-row small {
    margin-top: 2px;
    color: var(--mobile-muted);
    font-size: 11px;
  }

  .mobile-google-row .soft-button {
    min-width: 58px;
    height: var(--mobile-control);
    padding: 0 10px;
  }

  .schedule-workspace {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: var(--mobile-space-3);
  }

  .schedule-calendar-panel {
    display: none !important;
  }

  .schedule-calendar-panel.mobile-month-open,
  .mobile-month-open .schedule-calendar-panel,
  #tasksView.mobile-month-open .schedule-calendar-panel {
    display: block !important;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    padding: 12px !important;
    overflow: hidden !important;
  }

  .schedule-calendar-panel .calendar-sync-bar {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 56px !important;
    margin: 0 0 10px;
    padding: 8px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 8px;
    border-radius: var(--mobile-radius-md);
  }

  .schedule-calendar-panel .calendar-sync-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 9px;
    font-size: 12px;
  }

  .schedule-calendar-panel .calendar-sync-bar strong {
    font-size: 12px !important;
  }

  .schedule-calendar-panel .calendar-sync-bar small {
    overflow: hidden;
    font-size: 11px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .schedule-calendar-panel .calendar-sync-bar .soft-button {
    width: auto;
    min-width: 82px !important;
    max-width: 100px;
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    padding: 0 9px !important;
    overflow: hidden;
    font-size: 11px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .schedule-calendar-panel .calendar-head {
    width: 100%;
    min-width: 0;
    height: var(--mobile-control);
    min-height: var(--mobile-control) !important;
    margin: 0 0 6px !important;
    padding: 0;
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px 44px !important;
    gap: 4px !important;
  }

  .schedule-calendar-panel .calendar-head h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 16px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .schedule-calendar-panel .calendar-head .icon-button,
  .schedule-calendar-panel .calendar-head > .soft-button {
    width: var(--mobile-control);
    height: var(--mobile-control) !important;
    min-height: var(--mobile-control) !important;
    padding: 0 !important;
    font-size: 12px;
  }

  .schedule-calendar-panel .calendar-tools {
    display: none !important;
  }

  .schedule-calendar-panel .calendar-weekdays {
    height: 28px;
  }

  .schedule-calendar-panel .calendar-weekdays span {
    height: 28px;
    padding: 5px 0 !important;
    font-size: 11px;
  }

  .schedule-calendar-panel .calendar-grid {
    width: 100%;
    height: auto !important;
    min-height: 264px !important;
    padding: 3px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(6, 44px) !important;
    gap: 2px;
    overflow: hidden;
  }

  .schedule-calendar-panel .calendar-day {
    width: 100%;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 3px !important;
    overflow: hidden;
    border-radius: 8px !important;
  }

  .schedule-calendar-panel .day-number {
    width: 22px;
    height: 22px;
    margin-inline: auto;
    font-size: 11px;
  }

  .schedule-calendar-panel .calendar-event,
  .schedule-calendar-panel .calendar-event-dot {
    width: 6px !important;
    height: 6px !important;
    margin: 2px auto 0 !important;
    padding: 0 !important;
    border-radius: 50%;
    font-size: 0 !important;
  }

  .schedule-agenda-panel {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    padding: var(--mobile-space-4) !important;
    display: block !important;
    overflow: visible !important;
  }

  .schedule-agenda-head {
    min-height: var(--mobile-control);
    margin: 0 0 var(--mobile-space-3);
    align-items: center !important;
  }

  .schedule-agenda-head .soft-button {
    min-height: var(--mobile-control) !important;
    padding: 0 10px !important;
    font-size: 12px;
    white-space: nowrap;
  }

  .calendar-agenda-list {
    max-height: none !important;
    margin-bottom: var(--mobile-space-4);
    display: grid;
    gap: var(--mobile-space-2);
    overflow: visible;
  }

  .calendar-agenda-item {
    min-width: 0;
    min-height: 52px !important;
    padding: 8px 10px;
    grid-template-columns: 54px minmax(0, 1fr) 18px !important;
    gap: 8px;
    border-radius: var(--mobile-radius-md);
  }

  .calendar-agenda-item:not(button) {
    grid-template-columns: 54px minmax(0, 1fr) !important;
  }

  .agenda-time,
  .agenda-copy small {
    font-size: 11px;
  }

  .agenda-copy strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .schedule-task-divider {
    min-width: 0;
    margin-top: var(--mobile-space-2);
    padding-top: var(--mobile-space-4);
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-2) !important;
    border-top: 1px solid var(--mobile-line);
  }

  .schedule-task-divider .filter-tabs {
    width: 100%;
    margin: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .schedule-task-list {
    width: 100%;
    max-height: none !important;
    margin-top: var(--mobile-space-3);
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: var(--mobile-space-2);
    overflow: visible !important;
  }

  .schedule-task-list .task-card {
    width: 100%;
    min-width: 0;
    min-height: 0 !important;
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px;
  }

  .schedule-task-list .task-card h3 {
    margin: 6px 0 2px;
    font-size: 14px;
  }

  .schedule-task-list .task-card p,
  .schedule-task-list .task-meta {
    font-size: 12px;
  }

  .schedule-task-list .task-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px;
  }

  .schedule-task-list .task-actions button {
    width: 100%;
    min-width: 0;
    height: var(--mobile-control);
    min-height: var(--mobile-control) !important;
    padding: 0 6px !important;
    overflow: hidden;
    font-size: 11px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Timetable: day tabs and readable period rows replace the desktop grid. */
  .desktop-timetable {
    display: none !important;
  }

  .mobile-timetable {
    width: 100%;
    margin: 12px 0 0;
    padding: var(--mobile-space-4);
    display: grid !important;
    gap: var(--mobile-space-3);
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-lg);
    background: var(--mobile-surface);
  }

  #mobileTimetableDays {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  #mobileTimetableDays button {
    width: 100%;
    min-width: 0;
    height: var(--mobile-control);
    min-height: var(--mobile-control);
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--mobile-surface-muted);
    color: var(--mobile-muted);
    font-size: 12px;
    font-weight: 750;
  }

  #mobileTimetableDays button.active,
  #mobileTimetableDays button.selected,
  #mobileTimetableDays button[aria-pressed="true"] {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
  }

  #mobileTimetableList {
    width: 100%;
    display: grid;
    gap: var(--mobile-space-2);
  }

  #mobileTimetableList > button,
  #mobileTimetableList > article,
  #mobileTimetableList > [data-slot],
  #mobileTimetableList .mobile-period-row,
  #mobileTimetableList .mobile-timetable-row,
  #mobileTimetableList .mobile-class-row {
    width: 100%;
    min-width: 0;
    min-height: 58px;
    padding: 9px 10px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-md);
    background: var(--mobile-surface);
    color: var(--mobile-ink);
    text-align: left;
  }

  #mobileTimetableList .mobile-period-row {
    border-left: 3px solid var(--subject-color, #cbd5e1);
  }

  #mobileTimetableList .mobile-period-number {
    color: var(--mobile-muted);
    font-size: 15px;
    font-weight: 800;
    text-align: center;
  }

  #mobileTimetableList .mobile-period-number small {
    margin-top: 0;
    font-size: 10px;
    font-weight: 650;
  }

  #mobileTimetableList .mobile-period-copy {
    min-width: 0;
  }

  #mobileTimetableList .mobile-period-action {
    width: 18px;
    height: 18px;
    color: #98a2b3;
  }

  #mobileTimetableList strong,
  #mobileTimetableList small {
    display: block;
  }

  #mobileTimetableList strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #mobileTimetableList small {
    margin-top: 2px;
    overflow: hidden;
    color: var(--mobile-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-table-hint {
    display: none !important;
  }

  /* Grades */
  #gradesView > .content-tabs {
    margin: 12px 0;
  }

  #gradesView > [data-content-panel] {
    margin-bottom: var(--mobile-space-3);
  }

  #gradesView .grade-term-summary {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    grid-auto-columns: unset !important;
    gap: var(--mobile-space-2);
    overflow: visible !important;
  }

  #gradesView .grade-term-card {
    width: 100%;
    min-width: 0 !important;
    min-height: 100px;
    padding: 12px;
    gap: 4px;
    border-radius: var(--mobile-radius-md);
  }

  #gradesView .grade-term-card span,
  #gradesView .grade-term-card small {
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
  }

  #gradesView .grade-term-card strong {
    font-size: 24px;
    line-height: 1.2;
  }

  #gradeChart.bar-chart {
    width: 100%;
    height: 210px;
    padding: 32px 0 0;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  #gradeChart .bar-item {
    flex: 1 0 44px;
    min-width: 44px;
  }

  #gradeChart .bar-item span,
  #gradeChart .bar em {
    font-size: 11px;
  }

  #gradesView .grade-list {
    gap: 0;
  }

  #gradesView .grade-row {
    min-width: 0;
    min-height: 56px;
    padding: 10px 2px;
    gap: 10px;
  }

  #gradesView .grade-row > div {
    min-width: 0;
  }

  #gradesView .grade-row strong,
  #gradesView .grade-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #gradesView .grade-row strong {
    font-size: 14px;
  }

  #gradesView .grade-row small {
    font-size: 12px;
  }

  /* Focus timer */
  #timerView {
    padding-top: var(--mobile-space-4);
  }

  #timerView .study-summary {
    width: 100%;
    min-width: 0;
    min-height: 86px;
    margin: 0 0 var(--mobile-space-3);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--mobile-space-3);
    border-radius: var(--mobile-radius-lg);
    box-shadow: none;
  }

  #timerView .study-summary > .level-summary,
  #timerView .study-summary > .goal-setting {
    display: none !important;
  }

  #timerView .study-summary .eyebrow {
    font-size: 11px !important;
  }

  #timerView .study-summary > div:first-child strong {
    margin: 3px 0 1px;
    font-size: 24px;
    line-height: 1.2;
  }

  #timerView .goal-ring {
    width: 56px;
    height: 56px;
  }

  #timerView .stopwatch-layout {
    width: 100%;
    margin: 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: var(--mobile-space-3) !important;
  }

  #timerView .stopwatch-card,
  #timerView .subject-timers {
    width: 100%;
    min-width: 0;
    min-height: 0 !important;
    padding: var(--mobile-space-4);
  }

  #timerView .stopwatch-card-head {
    min-width: 0;
    gap: var(--mobile-space-2);
  }

  #timerView .running-badge {
    min-height: 28px;
    padding: 5px 9px;
    display: inline-flex;
    align-items: center;
    font-size: 11px;
  }

  #timerView .focus-room-open {
    width: auto;
    max-width: 52%;
    height: var(--mobile-control);
    min-height: var(--mobile-control);
    padding: 0 10px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #timerView .current-subject {
    margin: 18px 0 8px;
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #timerView .task-link-label {
    width: 100%;
    margin-top: var(--mobile-space-3);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    color: var(--mobile-muted);
    font-size: 12px;
    text-align: left;
  }

  #timerView #focusTaskSelect {
    width: 100%;
    max-width: none;
    min-height: var(--mobile-control);
    margin: 0;
    padding: 0 12px;
    border-radius: var(--mobile-radius-md);
    font-size: 16px;
  }

  #timerView .stopwatch-display {
    margin: 18px 0 6px;
    overflow: hidden;
    font-size: clamp(38px, 12vw, 48px) !important;
    line-height: 1.12;
    letter-spacing: -.04em;
    white-space: nowrap;
  }

  #timerView .stopwatch-card > p:last-of-type {
    min-height: 36px;
    margin: 0;
    color: var(--mobile-muted);
    font-size: 12px;
    line-height: 1.5;
  }

  #timerView .stopwatch-actions {
    width: 100%;
    margin-top: var(--mobile-space-4);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
    align-items: center;
    gap: var(--mobile-space-2);
  }

  #timerView .stopwatch-actions .soft-button,
  #timerView .stopwatch-actions .primary-button {
    width: 100%;
    min-width: 0;
    height: var(--mobile-primary-control);
    min-height: var(--mobile-primary-control);
    padding: 0 8px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #timerView .round-timer-button {
    width: 64px;
    min-width: 64px;
    height: 64px;
    min-height: 64px;
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .2);
  }

  #timerView .timer-subject-list {
    max-height: none;
    display: grid;
    gap: 4px;
    overflow: visible;
  }

  #timerView .timer-subject-row {
    min-width: 0;
    min-height: 60px;
    padding: 8px 6px;
    grid-template-columns: 10px minmax(0, 1fr) auto 44px;
    gap: 8px;
  }

  #timerView .timer-subject-row > div {
    min-width: 0;
  }

  #timerView .timer-subject-row strong,
  #timerView .timer-subject-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #timerView .timer-subject-row strong {
    font-size: 14px;
  }

  #timerView .timer-subject-row small,
  #timerView .subject-total {
    font-size: 12px;
  }

  #timerView .subject-play,
  #timerView .delete-focus {
    width: var(--mobile-control);
    min-width: var(--mobile-control);
    height: var(--mobile-control);
    min-height: var(--mobile-control);
  }

  /* AI is a work surface, not a second landing page. */
  #aiView .ai-hero {
    display: none !important;
  }

  #aiView {
    padding-top: var(--mobile-space-4);
  }

  #aiView > .content-tabs {
    margin: 0 0 var(--mobile-space-3);
  }

  #aiView .ai-layout,
  #aiView .ai-maker {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: var(--mobile-space-3);
  }

  #aiView .ai-maker {
    padding: var(--mobile-space-4);
  }

  #aiView .ai-maker .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #aiView .upload-zone {
    min-height: 112px;
    padding: 16px !important;
    border-radius: var(--mobile-radius-md) !important;
    font-size: 24px !important;
  }

  #aiView .upload-zone strong {
    font-size: 14px;
  }

  #aiView .upload-zone small,
  #aiView .ocr-progress p {
    font-size: 12px;
    line-height: 1.5;
  }

  #aiView #studySourceText {
    min-height: 132px;
    max-height: 40svh;
  }

  #aiView #generateStudyPackBtn {
    width: 100%;
    min-height: var(--mobile-primary-control);
  }

  #aiView .study-pack-panel,
  #aiView .flashcard-library {
    width: 100%;
    min-height: 0;
    margin-top: var(--mobile-space-3);
  }

  #aiView .study-pack-panel .panel-head {
    align-items: stretch;
    flex-wrap: wrap;
  }

  #aiView #saveCardsBtn {
    width: 100%;
  }

  #aiView .pack-tabs {
    width: 100%;
    margin-bottom: var(--mobile-space-3);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px;
    overflow: visible;
  }

  #aiView .generated-cards,
  #aiView .flashcard-deck {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-2);
  }

  #aiView .mini-flashcard {
    min-height: 132px;
    padding: 14px;
    border-radius: var(--mobile-radius-md);
  }

  #aiView .mini-flashcard p {
    font-size: 14px;
  }

  /* More: compact destinations, never a wall of forms. */
  #moreView {
    padding-top: var(--mobile-space-4);
  }

  #moreView > .view-intro {
    padding-top: 0 !important;
  }

  #moreView .more-intro > div > span {
    display: none;
  }

  .more-profile-card {
    width: 100%;
    min-width: 0;
    min-height: 74px;
    margin: 0 0 var(--mobile-space-4);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-lg);
    background: linear-gradient(145deg, #f4f8ff, #fff);
    color: var(--mobile-ink);
    text-align: left;
  }

  .more-profile-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--primary);
    background: var(--primary-soft);
  }

  .more-profile-card > span:nth-child(2) {
    min-width: 0;
  }

  .more-profile-card strong,
  .more-profile-card small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .more-profile-card strong {
    margin-top: 2px;
    font-size: 14px;
  }

  .more-profile-card small {
    color: var(--mobile-muted);
    font-size: 12px;
  }

  .more-ai-usage {
    width: 100%;
    margin: 0 0 var(--mobile-space-4);
    padding: 12px 14px;
    display: grid;
    gap: 9px;
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-md);
    background: var(--mobile-surface);
  }

  .more-ai-usage > div:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--mobile-muted);
    font-size: 12px;
  }

  .more-ai-usage strong {
    color: var(--mobile-ink);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }

  .more-ai-usage-track {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf1f5;
  }

  .more-ai-usage-track > span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0f9f8f, #2563eb);
    transition: width var(--motion-base) var(--motion-ease),
      background-color var(--motion-base) var(--motion-ease);
  }

  .more-ai-usage-track > span.low {
    background: #ef4444;
  }

  .more-section {
    width: 100%;
    margin-bottom: var(--mobile-space-4);
  }

  .more-section > h3 {
    margin: 0 0 8px 4px;
    color: var(--mobile-muted);
    font-size: 12px;
    font-weight: 750;
  }

  .more-menu,
  .more-groups {
    width: 100%;
    display: grid;
    gap: var(--mobile-space-3);
  }

  .more-menu,
  .more-group {
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--mobile-line);
    border-radius: var(--mobile-radius-lg);
    background: var(--mobile-surface);
  }

  .more-row {
    width: 100%;
    min-width: 0;
    min-height: 60px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    border: 0;
    border-radius: 0;
    background: var(--mobile-surface);
    color: var(--mobile-ink);
    text-align: left;
  }

  .more-menu > button {
    width: 100%;
    min-width: 0;
    min-height: 64px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    border: 0;
    border-radius: 0;
    background: var(--mobile-surface);
    color: var(--mobile-ink);
    text-align: left;
  }

  .more-menu > button + button {
    border-top: 1px solid var(--mobile-line);
  }

  .more-menu > button > span:nth-child(2) {
    min-width: 0;
  }

  .more-menu > button strong,
  .more-menu > button small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .more-menu > button strong {
    font-size: 14px;
  }

  .more-menu > button small {
    margin-top: 2px;
    color: var(--mobile-muted);
    font-size: 12px;
  }

  .more-menu-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--primary);
    background: var(--primary-soft);
  }

  .more-menu-icon.ai {
    color: #7c3aed;
    background: #f3efff;
  }

  .more-menu-icon.plan {
    color: #0f766e;
    background: #e9f8f5;
  }

  .more-menu-icon.record {
    color: var(--mobile-accent-strong);
    background: var(--mobile-accent-soft);
  }

  .more-menu-icon.setting {
    color: #475467;
    background: #f2f4f7;
  }

  .more-chevron {
    width: 18px;
    height: 18px;
    color: #98a2b3;
  }

  .more-row + .more-row {
    border-top: 1px solid var(--mobile-line);
  }

  .more-row-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--primary);
    background: var(--primary-soft);
  }

  .more-row-copy,
  .more-row > span:nth-child(2) {
    min-width: 0;
  }

  .more-row strong,
  .more-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .more-row strong {
    font-size: 14px;
  }

  .more-row small {
    margin-top: 2px;
    color: var(--mobile-muted);
    font-size: 12px;
  }

  .more-row-chevron {
    color: #98a2b3;
  }

  /* Forms, OCR review and keyboard-safe bottom sheets. */
  dialog:not(.focus-room-dialog) {
    position: fixed;
    inset: auto 0 var(--mobile-keyboard-inset, 0px) 0;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--mobile-keyboard-inset, 0px) - max(12px, env(safe-area-inset-top)));
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: contain;
    border-radius: var(--mobile-radius-sheet) var(--mobile-radius-sheet) 0 0;
    box-shadow: 0 -18px 50px rgba(23, 32, 51, .18);
  }

  dialog:not(.focus-room-dialog)::backdrop {
    background: rgba(23, 32, 51, .48);
  }

  .bottom-sheet {
    bottom: var(--mobile-keyboard-inset, 0px);
    width: 100%;
    max-height: calc(100dvh - var(--mobile-keyboard-inset, 0px) - max(12px, env(safe-area-inset-top)));
    margin: 0;
    overflow: hidden;
    border-radius: var(--mobile-radius-sheet) var(--mobile-radius-sheet) 0 0;
  }

  .modal-form,
  .detail-sheet {
    width: 100%;
    max-height: calc(100dvh - var(--mobile-keyboard-inset, 0px) - max(12px, env(safe-area-inset-top)));
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    display: grid;
    gap: 14px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding: 16px 0 calc(96px + env(safe-area-inset-bottom));
  }

  .sheet-handle {
    width: 42px;
    height: 4px;
    margin: -4px auto 0;
  }

  .modal-head {
    min-width: 0;
    min-height: var(--mobile-control);
    gap: var(--mobile-space-2);
  }

  .modal-head h2,
  .detail-sheet h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
    letter-spacing: -.03em;
  }

  .close-button {
    width: var(--mobile-control);
    min-width: var(--mobile-control);
    height: var(--mobile-control);
    min-height: var(--mobile-control);
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 20px;
  }

  .modal-form label,
  .wide-label,
  fieldset legend {
    color: #475467;
    font-size: 12px;
    line-height: 1.4;
  }

  .modal-form input,
  .modal-form select,
  .modal-form textarea,
  .wide-label input,
  .wide-label select,
  .wide-label textarea,
  .ai-maker input,
  .ai-maker select,
  .ai-maker textarea {
    width: 100%;
    min-width: 0;
    min-height: var(--mobile-primary-control);
    padding: 11px 12px;
    border: 1px solid #d7dee8;
    border-radius: var(--mobile-radius-md);
    color: var(--mobile-ink);
    background: #fff;
    font-size: 16px;
    line-height: 1.45;
    scroll-margin-block: 72px 112px;
  }

  .modal-form textarea,
  .wide-label textarea,
  .ai-maker textarea {
    min-height: 112px;
    resize: vertical;
  }

  .form-grid {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-3);
  }

  .modal-actions {
    position: sticky;
    bottom: calc(-18px - env(safe-area-inset-bottom));
    z-index: 3;
    width: calc(100% + 32px);
    margin: 2px -16px calc(-18px - env(safe-area-inset-bottom));
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--mobile-space-2);
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--mobile-line);
    backdrop-filter: blur(12px);
  }

  .modal-actions > * {
    width: 100%;
    min-width: 0;
    min-height: var(--mobile-control);
    margin: 0;
  }

  .modal-actions > .primary-button {
    min-height: var(--mobile-primary-control);
  }

  #taskDetailDialog #detailEditBtn {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  #classDialog .split-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--mobile-space-2);
  }

  #classDialog .split-actions > span:empty {
    display: none;
  }

  #classDialog .split-actions .danger-button {
    grid-column: 1 / -1;
  }

  .upload-zone {
    min-height: 120px;
    padding: 18px !important;
    border-radius: var(--mobile-radius-md) !important;
  }

  .upload-zone strong {
    font-size: 14px;
  }

  .upload-zone small,
  .ocr-progress p,
  .helper {
    font-size: 12px;
    line-height: 1.5;
  }

  .vision-review-action {
    width: 100%;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--mobile-space-2);
    border-radius: var(--mobile-radius-md);
  }

  .vision-review-action .soft-button {
    width: 100%;
  }

  .timetable-preview-row {
    width: 100%;
    display: grid;
    grid-template-columns: 72px 64px minmax(0, 1fr) !important;
    gap: var(--mobile-space-2);
  }

  .timetable-preview-row [data-time-room] {
    grid-column: 1 / -1;
  }

  .grade-preview-row {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 76px 62px;
    gap: 6px;
  }

  .custom-reminder {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 92px 44px;
    gap: 6px;
  }

  .custom-reminder input,
  .custom-reminder select {
    min-width: 0;
  }

  .focus-room-close {
    width: var(--mobile-control);
    min-width: var(--mobile-control);
    height: var(--mobile-control);
    min-height: var(--mobile-control);
  }

  .focus-room-brand {
    min-height: var(--mobile-control);
  }

  .focus-room-actions button {
    min-height: var(--mobile-primary-control);
  }

  .toast {
    bottom: calc(var(--mobile-nav-height) + 14px + env(safe-area-inset-bottom) + var(--mobile-keyboard-inset, 0px));
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 11px 14px;
    border-radius: var(--mobile-radius-md);
    font-size: 12px;
    text-align: center;
  }

  /* One restrained interaction language. */
  button,
  a,
  summary,
  .more-row,
  .calendar-day,
  .task-row {
    transition:
      color var(--motion-fast) var(--motion-ease),
      background-color var(--motion-fast) var(--motion-ease),
      border-color var(--motion-fast) var(--motion-ease),
      box-shadow var(--motion-base) var(--motion-ease),
      opacity var(--motion-fast) var(--motion-ease);
  }

  .view.active {
    animation: mobile-view-in var(--motion-base) var(--motion-ease) both !important;
  }

  dialog[open]:not(.focus-room-dialog),
  dialog[open].bottom-sheet {
    animation: mobile-sheet-in var(--motion-sheet) var(--motion-ease) both !important;
  }

  button:hover,
  a:hover,
  .task-card:hover,
  .task-row:hover,
  .calendar-day:hover,
  .time-cell:hover {
    transform: none !important;
  }

  button:active,
  .more-row:active {
    opacity: .78;
  }

  @keyframes mobile-view-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes mobile-sheet-in {
    from { opacity: .55; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 340px) {
  :root {
    --page-gutter: 12px;
  }

  .sidebar {
    padding-inline: 4px !important;
  }

  .page-heading {
    margin-left: 0 !important;
  }

  .topbar h1 {
    font-size: 19px !important;
  }

  .panel,
  .task-card,
  .calendar-panel,
  .mobile-schedule-overview,
  .mobile-timetable {
    padding: 14px;
  }

  #dashboardView .dashboard-top-grid .dday-widget {
    padding-inline: 12px !important;
  }

  #dashboardView .dashboard-top-grid .dday-widget h3 {
    max-width: 110px;
  }

  #dashboardView .dashboard-top-grid .dday-actions .primary-button {
    min-width: 82px;
    padding-inline: 9px;
  }

  .dashboard-week-strip,
  #mobileScheduleWeekStrip {
    display: grid !important;
    grid-template-columns: none !important;
    grid-auto-flow: column;
    grid-auto-columns: 44px;
    justify-content: start;
    gap: 2px !important;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .dashboard-week-strip::-webkit-scrollbar,
  #mobileScheduleWeekStrip::-webkit-scrollbar {
    display: none;
  }

  .dashboard-week-strip button small,
  #mobileScheduleWeekStrip button {
    font-size: 10px !important;
  }

  #timerView .stopwatch-actions {
    grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr);
    gap: 6px;
  }

  #timerView .round-timer-button {
    width: 60px;
    min-width: 60px;
    height: 60px;
    min-height: 60px;
  }

  .modal-form,
  .detail-sheet {
    padding-inline: 14px;
  }

  .modal-actions {
    width: calc(100% + 28px);
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .custom-reminder {
    grid-template-columns: minmax(0, 1fr) 82px 44px;
  }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Final legibility floor: supporting copy must stay readable on real phones. */
@media (max-width: 720px) {
  .app-shell small,
  .app-shell .helper,
  .app-shell .eyebrow,
  .app-shell .ocrProviderLabel,
  .app-shell .agenda-time,
  .app-shell .nav-label,
  .app-shell .calendar-weekdays span,
  .app-shell [class*="meta"],
  .app-shell [class*="hint"] {
    font-size: 12px !important;
  }

  .search-box input,
  .schedule-search input,
  .skip-link {
    min-height: 44px !important;
  }

  .modal-form .check-row label {
    min-height: 44px;
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
  }

  .modal-form .check-row input[type="checkbox"],
  .modal-form .check-row input[type="radio"] {
    width: 20px;
    min-width: 20px;
    height: 20px;
    min-height: 20px !important;
    margin: 0;
    padding: 0;
  }

  .app-shell .sidebar .nav-item > .nav-label,
  .app-shell .dashboard-week-strip button small,
  .app-shell #mobileScheduleWeekStrip button small,
  .app-shell #mobileTimetableList .mobile-period-number small,
  .app-shell #timerView .study-summary .eyebrow {
    font-size: 12px !important;
  }
}

@media (max-width: 375px) {
  .app-shell .dashboard-week-strip,
  .app-shell #mobileScheduleWeekStrip {
    display: flex !important;
    gap: 4px !important;
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .app-shell .dashboard-week-strip::-webkit-scrollbar,
  .app-shell #mobileScheduleWeekStrip::-webkit-scrollbar {
    display: none;
  }

  .app-shell .dashboard-week-strip button,
  .app-shell #mobileScheduleWeekStrip button {
    flex: 0 0 44px;
    width: 44px !important;
    min-width: 44px !important;
  }
}
