/*
 * SAEUM product system
 * This layer is the single visual source of truth while legacy screens are
 * migrated feature by feature. Keep selectors component-oriented.
 */

:root {
  color-scheme: light;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-line: #bfdbfe;
  --secondary: #0f766e;
  --secondary-soft: #f0fdfa;
  --ink: #111827;
  --text: #374151;
  --muted: #667085;
  --subtle: #8a94a6;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --divider: #eef2f7;
  --canvas: #f6f8fc;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --google: #2563eb;

  --sidebar-width: 240px;
  --topbar-height: 64px;
  --content-width: 1440px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .04);
  --shadow-md: 0 8px 30px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .08);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html {
  background: var(--canvas);
}

body {
  color: var(--text);
  background: var(--canvas);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -.006em;
}

button,
input,
textarea,
select {
  font-size: 16px;
}

h1,
h2,
h3,
h4,
strong {
  color: var(--ink);
}

small {
  line-height: 1.45;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .32);
  outline-offset: 3px;
}

::selection {
  color: var(--ink);
  background: #dbeafe;
}

/* App shell */

.app-shell {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-color: var(--line);
  background: rgba(255, 255, 255, .98);
}

.brand {
  min-height: 52px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
}

.landing-brand > span,
.brand-mark,
.mobile-home-button {
  border-radius: var(--radius-md);
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .2);
}

.brand:hover {
  background: var(--surface-alt);
}

.brand strong {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.025em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

#mainNav {
  margin-top: var(--space-6);
  gap: var(--space-1);
}

.nav-item {
  min-height: 48px;
  padding: 0 var(--space-3);
  gap: var(--space-3);
  border-radius: var(--radius-md);
  color: #566176;
  font-size: 15px;
  font-weight: 650;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--surface-alt);
}

.nav-item.active {
  color: var(--brand);
  background: var(--brand-soft);
}

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

.sidebar-foot {
  gap: var(--space-1);
}

.sidebar-save-state,
.sidebar-utility {
  min-height: 48px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.sidebar-save-state {
  font-size: 12px;
}

.sidebar-save-state strong,
.sidebar-utility strong {
  font-size: 13px;
  font-weight: 650;
}

.sidebar-save-state small,
.sidebar-utility small {
  margin-top: 1px;
  font-size: 12px;
}

.sidebar-utility:hover {
  background: var(--surface-alt);
}

.sidebar-utility > span:first-child,
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

#appMain {
  background: var(--canvas);
}

.topbar {
  min-height: var(--topbar-height);
  padding: 0 max(var(--space-8), calc((100% - var(--content-width)) / 2));
  gap: var(--space-3);
  border-color: var(--line);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
  backdrop-filter: blur(16px) saturate(135%);
}

.page-heading .eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.page-heading h1 {
  margin-top: 1px;
  font-size: 20px;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: -.03em;
}

#pageTitle:focus {
  outline: 0;
}

.view {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) 96px;
}

.view-intro,
.ai-hero {
  min-height: auto;
  margin-bottom: var(--space-6);
  align-items: center;
  gap: var(--space-6);
}

.eyebrow,
.view-intro > div:first-child > .eyebrow,
.panel-head .eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.view-intro h2,
.ai-hero h2 {
  margin-top: var(--space-1);
  font-size: 30px;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: -.035em;
}

.view-intro > div:first-child > span,
.view-intro > div:first-child > p:not(.eyebrow),
.ai-hero p {
  max-width: 640px;
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.toolbar-actions {
  gap: var(--space-2);
}

/* Shared controls */

.primary-button,
.soft-button,
.text-button,
.link-button,
.danger-button,
.icon-button,
.close-button,
.round-timer-button {
  min-width: 48px;
  min-height: 48px;
  padding: 0 var(--space-4);
  gap: var(--space-2);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -.01em;
  transition:
    color 150ms var(--ease),
    background 150ms var(--ease),
    border-color 150ms var(--ease),
    box-shadow 150ms var(--ease),
    transform 150ms var(--ease);
}

.primary-button {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .18);
}

.primary-button:hover {
  border-color: var(--brand-hover);
  background: var(--brand-hover);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .22);
}

.soft-button {
  border-color: var(--line);
  background: var(--surface);
}

.soft-button:hover {
  border-color: #cbd5e1;
  background: var(--surface-alt);
}

.text-button,
.link-button {
  color: var(--brand);
}

.text-button:hover,
.link-button:hover {
  background: var(--brand-soft);
}

.icon-button,
.close-button,
.notification-button,
.settings-button {
  width: 48px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
}

.close-button {
  border-color: transparent;
  background: transparent;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.5;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

textarea {
  min-height: 112px;
  padding-block: var(--space-3);
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #929bad;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

label {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

label > input,
label > select,
label > textarea {
  margin-top: var(--space-2);
  font-weight: 450;
}

/* Shared surfaces and states */

.panel,
.stat-card,
.task-card,
.grade-term-card,
.exam-plan-card,
.mistake-card,
.pro-panel,
.weekly-planner-panel,
.study-pack-panel,
.flashcard-library {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: var(--space-6);
}

.panel-head {
  min-height: 48px;
  gap: var(--space-4);
}

.panel-head h3 {
  margin-top: 2px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.025em;
}

.panel-head small,
.helper {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.content-tabs,
.pack-tabs,
.filter-tabs {
  gap: var(--space-1);
}

.content-tabs {
  margin-bottom: var(--space-5);
  padding: var(--space-1);
  border-color: var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.content-tabs button,
.pack-tabs button,
.filter-tabs button {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.content-tabs button.active,
.pack-tabs button.active,
.filter-tabs button.active {
  color: var(--brand);
  background: var(--brand-soft);
}

.content-tabs button.active {
  color: #fff;
  background: var(--brand);
}

.empty,
.empty-state,
.compact-empty,
.task-first-empty,
.dashboard-empty,
.records-empty-state {
  min-height: 112px;
  padding: var(--space-6);
  gap: var(--space-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 14px;
  line-height: 1.55;
}

.empty-state strong,
.compact-empty strong,
.task-first-empty strong,
.dashboard-empty strong {
  font-size: 16px;
  font-weight: 700;
}

.empty-state span,
.compact-empty span,
.task-first-empty span,
.dashboard-empty span {
  font-size: 14px;
}

.toast[popover] {
  inset: calc(var(--topbar-height) + var(--space-4)) var(--space-6) auto auto;
  max-width: min(420px, calc(100vw - 32px));
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
}

/* Dashboard */

.home-primary-grid {
  margin-bottom: var(--space-4);
}

.today-priority-card {
  min-height: 0;
  padding: var(--space-8);
  border: 1px solid #dbe5f5;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 88% 15%, rgba(37, 99, 235, .1), transparent 28%),
    linear-gradient(135deg, #fff 0%, #f8fbff 100%);
  box-shadow: var(--shadow-sm);
}

.today-next-task {
  align-items: center;
  gap: var(--space-5);
}

#ddayCount {
  background: var(--ink);
}

.today-next-task small,
.today-progress-copy .eyebrow {
  font-size: 12px;
}

.today-next-task h3 {
  font-size: clamp(24px, 2.4vw, 36px);
  line-height: 1.25;
}

.today-primary-actions {
  margin-top: var(--space-5);
  gap: var(--space-2);
}

.today-card-stats {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top-color: var(--divider);
}

.today-card-stats small {
  font-size: 13px;
}

.today-card-stats strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.dashboard-agenda-grid {
  gap: var(--space-4);
}

.dashboard-agenda-panel,
.dashboard-timetable-panel {
  min-height: 300px;
  padding: var(--space-6);
}

.task-row,
.schedule-row {
  min-height: 56px;
}

.home-more-summary {
  margin-top: var(--space-4);
  border-radius: var(--radius-lg);
}

.stats-grid {
  gap: var(--space-3);
}

.stat-card {
  min-height: 104px;
  padding: var(--space-5);
}

.stat-card small {
  font-size: 13px;
}

.stat-card strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

/* Calendar and timetable */

.schedule-workspace {
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr) minmax(320px, .72fr);
}

.schedule-calendar-panel,
.schedule-agenda-panel {
  min-height: 560px;
}

.calendar-day {
  min-height: 76px;
  border-radius: var(--radius-sm);
}

.calendar-day:hover {
  background: var(--surface-alt);
}

.calendar-day.selected {
  box-shadow: inset 0 0 0 2px var(--brand);
}

.calendar-day > span,
.calendar-weekdays span,
.agenda-time,
.calendar-agenda-item small {
  font-size: 13px;
}

.calendar-agenda-item {
  min-height: 58px;
  border-radius: var(--radius-md);
}

.schedule-task-collection {
  margin-top: var(--space-4);
}

.task-board {
  gap: var(--space-3);
}

.task-card {
  padding: var(--space-5);
}

.subject-badge {
  min-height: 28px;
  padding-inline: var(--space-3);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.desktop-timetable {
  overflow: auto;
}

.timetable-grid {
  min-width: 820px;
}

.timetable-cell,
.timetable-head {
  min-height: 56px;
  font-size: 14px;
}

/* Focus */

.stopwatch-layout {
  gap: var(--space-4);
}

.timer-hero-card,
.subject-timer-panel {
  border-radius: var(--radius-xl);
}

.timer-display,
.focus-room-time {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.055em;
}

.timer-subject-row {
  min-height: 64px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.timer-subject-row:hover {
  background: var(--surface-alt);
}

.timer-subject-row.active {
  background: var(--brand-soft);
}

.subject-play {
  width: 44px;
  height: 44px;
}

.timer-subject-row strong {
  font-size: 16px;
}

.timer-subject-row small,
.subject-action-label {
  font-size: 13px;
}

.subject-total {
  font-variant-numeric: tabular-nums;
}

/* Records and AI */

.record-primary-grid {
  gap: var(--space-3);
}

.record-primary-grid > * {
  min-height: 112px;
  border-radius: var(--radius-lg);
}

.record-primary-grid span,
.record-primary-grid small {
  font-size: 13px;
}

.record-primary-grid strong {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

.grade-summary-panel,
.panel[data-content-panel="grade-records"],
.study-pack-panel,
.flashcard-library,
.weekly-planner-panel,
.pro-panel {
  padding: var(--space-6);
}

.grade-row,
.focus-row,
.school-event-row {
  min-height: 60px;
}

.ai-hero {
  padding: 0;
  border: 0;
  background: transparent;
}

.ai-maker-grid,
.ai-planner-panel {
  gap: var(--space-4);
}

.ai-source-card,
.ai-control-card,
.ai-planner-panel {
  padding: var(--space-6);
  border-radius: var(--radius-lg);
}

.ai-maker .upload-zone {
  min-height: 132px;
}

#studySourceText {
  min-height: 160px;
  height: 160px;
}

.study-upload-zone,
.ai-plan-file {
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}

.study-upload-zone:hover,
.ai-plan-file:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.upload-zone input[type="file"],
.ai-plan-file input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.upload-zone:focus-within,
.ai-plan-file:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* Dialogs */

dialog {
  max-width: min(620px, calc(100vw - 32px));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(15, 23, 42, .46);
  backdrop-filter: blur(3px);
}

.modal-form {
  padding: var(--space-6);
}

.modal-head {
  margin-bottom: var(--space-5);
}

.modal-head h2 {
  font-size: 24px;
  line-height: 1.3;
}

.dialog-actions,
.modal-actions {
  gap: var(--space-2);
  padding-top: var(--space-5);
}

/* Landing */

.landing-page {
  color: var(--text);
  background:
    radial-gradient(circle at 82% 8%, rgba(37, 99, 235, .09), transparent 30rem),
    linear-gradient(180deg, #fff 0, #f8fbff 56%, var(--canvas) 100%);
}

.landing-header {
  height: 68px;
  padding-inline: max(var(--space-6), calc((100vw - 1200px) / 2));
  border-color: rgba(229, 231, 235, .72);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(16px) saturate(135%);
}

.landing-hero {
  min-height: min(760px, calc(100dvh - 68px));
  padding-inline: max(var(--space-6), calc((100vw - 1200px) / 2));
}

.landing-hero h1 {
  max-width: 720px;
  font-size: clamp(42px, 5.5vw, 68px);
  line-height: 1.12;
}

.landing-hero p {
  max-width: 580px;
  font-size: 18px;
  line-height: 1.65;
}

.landing-section {
  padding-inline: max(var(--space-6), calc((100vw - 1200px) / 2));
}

.landing-footer {
  padding-inline: max(var(--space-6), calc((100vw - 1200px) / 2));
  font-size: 14px;
}

/* Tablet: compact, collapsible-style rail */

@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --sidebar-width: 88px;
  }

  .sidebar {
    padding-inline: var(--space-3);
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand-copy,
  .brand > span:last-child,
  .nav-label,
  .sidebar-foot,
  .sidebar-section-label {
    display: none;
  }

  #mainNav {
    gap: var(--space-2);
  }

  .nav-item {
    min-height: 52px;
    justify-content: center;
    padding: 0;
  }

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

  .view {
    padding: var(--space-6) var(--space-6) 88px;
  }

  .topbar {
    padding-inline: var(--space-6);
  }

  .dashboard-agenda-grid,
  .stopwatch-layout,
  .schedule-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .schedule-calendar-panel,
  .schedule-agenda-panel {
    min-height: auto;
  }
}

/* Mobile first presentation */

@media (max-width: 767px) {
  :root {
    --topbar-height: 58px;
  }

  body.entry-app {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 350;
    inset: auto 0 0;
    width: auto;
    height: calc(70px + env(safe-area-inset-bottom));
    padding: var(--space-2) var(--space-2) env(safe-area-inset-bottom);
    border: 0;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -8px 28px rgba(15, 23, 42, .06);
    backdrop-filter: blur(18px) saturate(140%);
  }

  .brand,
  .sidebar-foot,
  .sidebar-section-label {
    display: none;
  }

  #mainNav {
    height: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--space-1);
  }

  #mainNav .nav-item {
    min-width: 0;
    min-height: 54px;
    padding: var(--space-1) 2px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border-radius: var(--radius-md);
    font-size: 12px;
    line-height: 1.25;
  }

  #mainNav .nav-item .ui-icon {
    width: 22px;
    height: 22px;
  }

  #appMain {
    height: calc(var(--app-viewport-height) - 70px - env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: var(--topbar-height);
    padding: 0 var(--space-4);
    gap: var(--space-2);
  }

  .page-heading {
    display: block;
    min-width: 0;
    margin-right: auto;
  }

  .page-heading .eyebrow,
  .save-state,
  .notification-button,
  .settings-button {
    display: none;
  }

  .page-heading h1 {
    font-size: 18px;
  }

  .account-button {
    max-width: 48px;
    width: 48px;
    padding: 0;
  }

  .account-button > span:last-child,
  #quickAddBtn > span {
    display: none;
  }

  #quickAddBtn {
    width: 48px;
    padding: 0;
  }

  .section-nav {
    top: var(--topbar-height);
    padding: var(--space-2) var(--space-4);
    gap: var(--space-2);
    border-bottom: 1px solid var(--line);
    background: rgba(246, 248, 252, .96);
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .section-nav button {
    min-height: 44px;
    padding-inline: var(--space-4);
    border-radius: 999px;
    font-size: 14px;
  }

  .view {
    width: 100%;
    padding: var(--space-5) var(--space-4) calc(96px + env(safe-area-inset-bottom));
  }

  .view small,
  .view .due-chip,
  #todaySchedule .schedule-row span,
  .task-card span,
  #studyDraftStatus,
  .weekly-plan-actions label span,
  .more-ai-usage span {
    font-size: 12px !important;
  }

  .view-intro,
  .ai-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
  }

  .view-intro h2,
  .ai-hero h2 {
    font-size: 24px;
  }

  .ai-hero > span {
    display: none;
  }

  .view-intro > div:first-child > span,
  .view-intro > div:first-child > p:not(.eyebrow),
  .ai-hero p {
    display: none;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-actions > button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: var(--space-3);
  }

  .toolbar-actions > .text-button,
  .toolbar-actions > .link-button {
    flex: 0 1 auto;
  }

  .primary-button,
  .soft-button,
  .text-button,
  .link-button,
  .danger-button,
  .icon-button,
  .close-button {
    font-size: 15px;
  }

  .panel,
  .grade-summary-panel,
  .panel[data-content-panel="grade-records"],
  .study-pack-panel,
  .flashcard-library,
  .weekly-planner-panel,
  .pro-panel {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .panel-head {
    min-height: 44px;
  }

  .panel-head h3 {
    font-size: 17px;
  }

  .today-priority-card {
    padding: var(--space-5);
    border-radius: var(--radius-lg);
  }

  .today-next-task {
    gap: var(--space-4);
  }

  #ddayCount {
    width: 76px;
    height: 76px;
    font-size: 18px;
  }

  .today-next-task h3 {
    font-size: 24px;
  }

  .today-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .today-card-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .today-card-stats > * {
    min-width: 0;
    padding-inline: var(--space-2);
  }

  .today-card-stats small {
    font-size: 12px;
  }

  .today-card-stats strong {
    font-size: 16px;
  }

  .dashboard-agenda-grid,
  .stats-grid,
  .task-board,
  .grade-term-summary,
  .record-primary-grid,
  .stopwatch-layout,
  .schedule-workspace,
  .settings-grid,
  .pro-grid,
  .ai-maker-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-agenda-panel,
  .dashboard-timetable-panel {
    min-height: 220px;
    padding: var(--space-4);
  }

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

  .stat-card {
    min-height: 92px;
    padding: var(--space-4);
  }

  .content-tabs {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .content-tabs::-webkit-scrollbar {
    display: none;
  }

  .content-tabs button {
    flex: 1 0 auto;
  }

  .mobile-schedule-overview,
  .mobile-timetable {
    border-radius: var(--radius-lg);
  }

  .mobile-schedule-week small,
  .mobile-period-copy small,
  .mobile-week-day small,
  .mobile-period-number small {
    font-size: 12px;
  }

  .mobile-schedule-week > div > button small,
  .mobile-timetable-days button,
  .mobile-date-kinds .event-kind,
  .schedule-kind-legend .event-kind {
    font-size: 12px;
  }

  .mobile-date-kinds .event-kind,
  .schedule-kind-legend .event-kind {
    min-width: 20px;
    min-height: 20px;
  }

  .mobile-period-row {
    min-height: 68px;
    border-radius: var(--radius-md);
  }

  .calendar-day {
    min-height: 52px;
  }

  .timer-display {
    font-size: clamp(46px, 15vw, 68px);
  }

  .timer-subject-row {
    min-height: 64px;
  }

  #runningBadge,
  .stopwatch-kind,
  #mobileFocusSettingsSummary,
  .focus-progress-details summary > span:last-child,
  #todayGoalText,
  #goalPercent,
  #pointText,
  .goal-setting > span,
  .achievement-chip strong,
  .achievement-chip small,
  .focus-day strong,
  .focus-day span {
    font-size: 12px;
  }

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

  .record-primary-grid > * {
    min-height: 96px;
  }

  .ai-source-card,
  .ai-control-card,
  .ai-planner-panel {
    padding: var(--space-4);
  }

  .ocrProviderLabel,
  .ai-options > summary span,
  .ai-output-summary span,
  .ai-create-actions > span,
  .ai-usage-inline,
  .ai-planner-copy > span,
  .ai-planner-copy small,
  .ai-plan-file span,
  .ai-planner-status,
  .queue-item span,
  .queue-item small,
  .grade-term-card span,
  .grade-term-card small,
  .report-grid small,
  #focusProReport .helper {
    font-size: 12px;
  }

  #studySourceText {
    min-height: 176px;
    height: 176px;
  }

  dialog {
    width: calc(100vw - 24px);
    max-width: none;
    max-height: min(88dvh, 760px);
    margin: auto 12px 12px;
    border-radius: var(--radius-xl);
  }

  dialog.bottom-sheet {
    width: 100%;
    margin: auto 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .modal-form {
    padding: var(--space-5) var(--space-4);
  }

  .toast[popover] {
    inset: auto var(--space-4) calc(82px + env(safe-area-inset-bottom)) var(--space-4);
    width: auto;
    max-width: none;
    text-align: center;
  }

  .landing-header {
    height: 60px;
    padding-inline: var(--space-4);
  }

  .landing-header nav {
    display: none;
  }

  .landing-hero {
    min-height: auto;
    padding: 72px var(--space-4) var(--space-16);
  }

  .landing-hero h1 {
    font-size: clamp(38px, 12vw, 52px);
  }

  .landing-hero p {
    font-size: 17px;
  }

  .landing-section {
    padding-inline: var(--space-4);
  }
}

@media (max-width: 380px) {
  .view {
    padding-inline: var(--space-3);
  }

  .topbar {
    padding-inline: var(--space-3);
  }

  #mainNav .nav-item {
    font-size: 11px;
  }

  .today-card-stats small {
    font-size: 11px;
  }

  .toolbar-actions > button {
    padding-inline: var(--space-2);
  }
}

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