:root {
  /* 默认原主题：墨绿底 + 金色强调（与现网一致）；浅色主题见 html[data-theme] */
  --bg: #0a3d2e;
  --bg-deep: #06281e;
  --bg-soft: #0f4a39;
  --bg-mid: #0c4534;
  --gold: #d4af37;
  --gold-bright: #f0d878;
  --gold-dim: #a8882a;
  /* 供 rgba(var(--gold-rgb), a) / rgba(var(--ink-rgb), a) 随主题换色 */
  --gold-rgb: 212, 175, 55;
  --ink-rgb: 10, 61, 46;
  --card: #f7f5ef;
  --card-solid: #ffffff;
  --ink: #1a2e26;
  --muted: #5a6b63;
  /* 浅色底上的强调绿（比正文明显更绿，用于「无课」等状态） */
  --green-mark: #0f7a52;
  --line: rgba(var(--ink-rgb), 0.12);
  --line-gold: rgba(var(--gold-rgb), 0.45);
  --danger: #9b2c2c;
  --shadow: 0 8px 28px rgba(6, 40, 30, 0.28);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  /* 顶栏 / 启动屏：深色壳上的浅金字 */
  --shell-glow: rgba(var(--gold-rgb), 0.06);
  --shell-brand: var(--gold-bright);
  --shell-sub: rgba(240, 216, 120, 0.78);
  --shell-border: rgba(var(--gold-rgb), 0.28);
  --icon-border: rgba(var(--gold-rgb), 0.45);
  --icon-bg: rgba(255, 255, 255, 0.06);
  --icon-hover: rgba(var(--gold-rgb), 0.14);
  --panel-border: rgba(var(--gold-rgb), 0.22);
  --boot-fg: rgba(255, 255, 255, 0.78);
  /* 浅底控件字色、主按钮字色（浅色主题会覆盖） */
  --accent-deep: #0a3d2e;
  --on-accent: #06281e;
  --theme-color: #0a3d2e;
  /* 「本周无课」插画：随主题换天空/强调色；顶栏标题与 icon 本就用 shell 变量 */
  --empty-sky: #0a3d2e;
  --empty-sky-deep: #06281e;
  --empty-accent: #d4af37;
  --empty-accent-bright: #f0d878;
  --empty-surface: #f3efe6;
  --empty-ink: #0a3d2e;
  --empty-shadow: rgba(6, 40, 30, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--shell-glow), transparent 180px),
    linear-gradient(165deg, var(--bg-deep) 0%, var(--bg) 42%, var(--bg-mid) 100%);
  background-attachment: fixed;
}

body {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

/* 首屏脚本加载期间立即展示轻量状态，避免手机网络较慢时只看到空白背景 */
body.is-booting .top-actions {
  visibility: hidden;
}

.boot-splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--boot-fg);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

body:not(.is-booting) .boot-splash {
  display: none;
}

.boot-splash-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(var(--gold-rgb), 0.48);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold-bright);
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(6, 40, 30, 0.22);
  animation: boot-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes boot-pulse {
  from {
    opacity: 0.62;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot-splash-mark {
    animation: none;
  }
}

.app {
  width: min(920px, 100%);
  margin: 0 auto;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  /* iOS 刘海/灵动岛：viewport-fit=cover 时内容会顶到状态栏下，用安全区把顶栏顶下来 */
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(12px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
}

.top {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 4px 2px 10px;
  border-bottom: 1px solid var(--shell-border);
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--icon-border);
  border-radius: 10px;
  background: var(--icon-bg);
  color: var(--shell-brand);
  cursor: pointer;
  padding: 0;
}

.icon-btn:hover {
  background: var(--icon-hover);
}

.brand {
  margin: 0;
  font-size: clamp(1.15rem, 3.6vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--shell-brand);
  line-height: 1.25;
}

.sub {
  margin: 6px 0 0;
  color: var(--shell-sub);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1.4;
  /* 避免「期」等单字落到下一行；过长时在词间断行 */
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
  padding: 18px 16px 20px;
}

.panel[hidden] {
  display: none !important;
}

/**
 * 课表视图：周次导航 +「选择周次」固定，仅下方课程卡片区域滚动。
 */
#viewSchedule.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}

.schedule-stack {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#viewSchedule .week-nav,
#viewSchedule .week-jump {
  flex-shrink: 0;
  overflow-y: hidden;
}

/**
 * 课程滚动外壳：宽度与「本周」同一栏；裁掉系统粗滑槽。
 */
#viewSchedule .schedule-scroll-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/**
 * 课程列表滚动层。若系统仍占滑槽宽，由 JS 加宽并由外壳裁掉，卡片右缘与「本周」齐。
 */
#viewSchedule .schedule-scroll {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0 0 8px;
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#viewSchedule .schedule-scroll::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent;
}

#viewSchedule .schedule-scroll > .days {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/**
 * 细指示条：贴在外壳右缘，静止完全消失（课表 / 设置共用）。
 */
.overlay-scroll-thumb,
.schedule-scroll-thumb {
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  border-radius: 2px;
  background: rgba(var(--ink-rgb), 0.42);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  will-change: transform, opacity;
  transition: opacity 0.12s ease;
}

.overlay-scroll-thumb.is-visible,
.schedule-scroll-thumb.is-visible {
  opacity: 1;
}

/**
 * 其它滚动区：滑槽始终占位但静止透明，滑动显色（勿在滚动时改 width）。
 */
.scroll-fade {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.scroll-fade::-webkit-scrollbar {
  width: 1px;
  height: 1px;
}

.scroll-fade::-webkit-scrollbar-track {
  background: transparent;
}

.scroll-fade::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 1px;
}

.scroll-fade.is-scrolling {
  scrollbar-color: rgba(var(--ink-rgb), 0.45) transparent;
}

.scroll-fade.is-scrolling::-webkit-scrollbar-thumb {
  background: rgba(var(--ink-rgb), 0.45);
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--accent-deep);
  letter-spacing: 0.02em;
}

/* 「导入课表」标题与「返回课表」同一行：标题左、按钮右且随文字缩短 */
.import-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.import-heading h1 {
  margin: 0;
  flex: 1;
  min-width: 0;
}

#btnBackToSchedule {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.hint,
.tip,
.status {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.field {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  font-weight: 600;
  color: var(--accent-deep);
  font-size: 0.92rem;
}

/* 设置里标题已写明「选择班级」时，下拉单独出现，少留顶距并贴紧保存 */
.field-select-only {
  margin: 4px 0 0;
}

/* 导入页 / 设置页班级下拉同一套：略收矮、文字左对齐 */
.settings-section-schedule select,
#settingsClass,
#classSelect {
  min-height: 40px;
  padding: 8px 32px 8px 12px;
  font-size: 0.92rem;
  text-align: left;
  text-align-last: left;
}

/**
 * 设置「保存」条：夹在滚动区与主题坞之间，不跟列表滚。
 * <p>须盖过通用 {@code .dialog-actions} 的 margin-top，否则横线下方空隙会虚高。</p>
 * <p>左右垫与 {@code .settings-scroll} 对齐；上方多留空白，与列表底文案拉开。</p>
 */
#settingsDialog .settings-save-bar {
  flex: 0 0 auto;
  margin: 0;
  padding: 14px 20px 0;
  box-sizing: border-box;
}

#settingsDialog .settings-save-bar[hidden] {
  display: none !important;
}

/**
 * 设置内容三区：课表操作（可滚）→ 贴底主题 → 重新导入。
 * 主题与重新导入在 {@code .settings-dock} 内常显，不再跟课表区一起滚。
 */
.settings-section {
  margin: 0;
  padding: 0;
}

.settings-section[hidden] {
  display: none !important;
}

.theme-picker + .settings-section-manage:not([hidden]) {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/**
 * 设置贴底坞：主题色 + 重新导入固定在弹层下方，打开即可改色，不必先滚到底。
 * <p>左右内边距与 {@code .settings-scroll} 对齐；顶部分隔线与头栏同款（1px、内缩）。</p>
 * <p>线画在坞顶缘；与滚动区的空白由 {@code .settings-dialog-body} 的 gap 负责。</p>
 */
.settings-dock {
  flex: 0 0 auto;
  margin: 0;
  /* 线在顶缘；线下方再到「主题颜色」文案；略收内边距，把高度让给滚动区 */
  padding: 10px 20px 12px;
  border-top: 0;
  /* 与头栏底边同款：1px var(--line)，左右内缩 16px */
  background:
    linear-gradient(var(--line), var(--line)) 16px 0 / calc(100% - 32px) 1px no-repeat,
    var(--card);
  box-sizing: border-box;
}

select,
button {
  font: inherit;
}

select {
  appearance: none;
  border: 1px solid var(--line-gold);
  border-radius: var(--radius-sm);
  padding: 14px 34px 14px 14px;
  min-height: 48px;
  font-size: 1rem;
  background: var(--card-solid)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%230a3d2e' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  color: var(--ink);
  touch-action: manipulation;
  /* 仅 accent-color；勿改 option 文字色，部分浏览器会白字无底导致选项“消失” */
  accent-color: var(--accent-deep);
}

select:focus {
  outline: 2px solid rgba(var(--gold-rgb), 0.55);
  outline-offset: 1px;
}

.upload {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 112px;
  margin: 0;
  border: 1.5px dashed var(--gold-dim);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(var(--ink-rgb), 0.04), rgba(var(--gold-rgb), 0.08));
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-deep);
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

#uploadLabel {
  pointer-events: none;
}

.upload:hover {
  background: linear-gradient(180deg, rgba(var(--ink-rgb), 0.07), rgba(var(--gold-rgb), 0.14));
}

.upload.is-busy {
  pointer-events: none;
}

.upload.is-busy #uploadLabel {
  opacity: 0.72;
}

.upload.is-dimmed #uploadLabel {
  opacity: 0.55;
}

.upload[hidden] {
  display: none !important;
}

/**
 * 真正选文件的控件藏在 label 内：靠原生 label 关联打开选择器。
 * <p>不要用 display:none，也不要再走按钮 preventDefault + input.click()，PWA 里容易丢掉用户手势。</p>
 */
.file-input-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

/**
 * 不挂在 label 里、只靠脚本 {@code input.click()} 打开的文件框（相册/拍摄）。
 * <p>绝不能用 {@code inset:0} 铺满——挂在 body 下会盖住整页，点「设置」也会点到它。</p>
 */
.file-input-detached {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.class-step {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.class-step[hidden] {
  display: none !important;
}

.course-groups {
  display: grid;
  gap: 8px;
}

.course-group {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(var(--ink-rgb), 0.03);
}

.course-group h3 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--accent-deep);
}

/** 导入页 / 设置页「选择课程」与分组标题「N选一」同级紧凑字号 */
.settings-course-title {
  margin: 0 0 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-deep);
}

/* 「选择课程」选项略收矮：少一点内边距与字号，仍够点按 */
.course-option {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0 0 4px;
  padding: 4px 8px;
  min-height: 34px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.course-option:last-child {
  margin-bottom: 0;
}

.course-option:active {
  background: rgba(var(--gold-rgb), 0.12);
}

.course-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(var(--gold-rgb), 0.14);
  box-shadow: inset 0 0 0 1px rgba(var(--gold-rgb), 0.35);
}

.course-option input {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--accent-deep);
}

.course-option-text {
  display: grid;
  gap: 0;
  min-width: 0;
  line-height: 1.2;
}

.course-name {
  font-size: 0.8rem;
}

.course-teacher {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.7rem;
}

/**
 * 选课列表：导入页与设置页共用上方 `.course-groups` / `.course-option` 尺寸与字号。
 * <p>勿再对 {@code #settingsDialog} 单独收紧字号/间距，否则会出现「设置更小、导入更大」。</p>
 */

.primary.block,
.ghost.block {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 12px;
}

.status {
  min-height: 1.4em;
  margin-top: 12px;
}

.status:empty {
  display: none;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--accent-deep);
  font-weight: 600;
}

.tip {
  margin-top: 16px;
  font-size: 0.84rem;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* 使用说明：标题与步骤同一栏对齐，灰色说明统一缩进 */
.guide {
  margin: 0 0 16px;
  padding: 14px 16px 14px;
  border: 1px solid var(--line-gold);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(var(--ink-rgb), 0.035), rgba(var(--gold-rgb), 0.07));
}

.guide-title {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-deep);
}

.guide-steps {
  --guide-index: 1.2em;
  --guide-gap: 0.3em;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.guide-lead,
.guide-note {
  margin: 0;
  line-height: 1.55;
}

.guide-lead {
  display: grid;
  grid-template-columns: var(--guide-index) minmax(0, 1fr);
  column-gap: var(--guide-gap);
  align-items: baseline;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.guide-num {
  display: inline;
  margin: 0;
  font-size: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: inherit;
}

.guide-note {
  margin: 5px 0 0;
  padding-left: calc(var(--guide-index) + var(--guide-gap));
}

.guide-note,
.guide-os li {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.guide-os {
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

.guide-os li {
  display: grid;
  grid-template-columns: var(--guide-index) minmax(0, 1fr);
  column-gap: var(--guide-gap);
  align-items: baseline;
  margin: 0;
}

.guide-os li + li {
  margin-top: 3px;
}

/* 圆点与「1.」「2.」左对齐；Android / iPhone 与「用」「添」左对齐 */
.guide-os li::before {
  content: "·";
  font-size: 1.35em;
  font-weight: 700;
  line-height: 1;
}

.ghost,
.primary,
.danger {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  cursor: pointer;
}

.ghost {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid rgba(var(--gold-rgb), 0.45);
}

#viewSchedule .ghost,
dialog .ghost,
#btnBackToSchedule {
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--accent-deep);
  border-color: var(--line-gold);
}

.primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--on-accent);
  font-weight: 700;
  /* 与 .ghost 同为 1px 边，避免切高亮时盒子变矮、带动下方按钮位移 */
  border: 1px solid rgba(var(--gold-rgb), 0.55);
}

.danger {
  background: rgba(155, 44, 44, 0.08);
  color: var(--danger);
  border: 1px solid rgba(155, 44, 44, 0.25);
}

.week-nav {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* SVG 箭头几何居中，避免 ‹ › 字体基线偏上 */
.nav-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(var(--gold-rgb), 0.35);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--gold-bright);
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn svg {
  display: block;
  width: 18px;
  height: 18px;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.week-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  text-align: center;
  line-height: 1.25;
  min-width: 0;
}

.week-title strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.week-term {
  color: var(--muted);
  /* 相对日期再小两号，层次更轻 */
  font-size: 0.7rem;
  font-weight: 600;
}

.week-empty-state {
  display: grid;
  place-items: center;
  padding: 12px 8px 8px;
}

.week-empty-state[hidden] {
  display: none !important;
}

.week-empty-state img,
.week-empty-art {
  width: min(280px, 78vw);
  height: auto;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 8px 24px var(--empty-shadow);
  display: block;
}

.week-jump {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  margin: 0 0 10px;
  box-sizing: border-box;
}

.week-picker-btn,
.week-today-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  box-sizing: border-box;
}

#viewSchedule .week-picker-btn.ghost,
#viewSchedule .week-today-btn.ghost {
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--accent-deep);
  border: 1px solid var(--line-gold);
}

#viewSchedule .week-today-btn.primary {
  border: 0;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--on-accent);
}

.week-picker-value {
  color: inherit;
  line-height: 1.3;
  white-space: nowrap;
}

/**
 * 周次弹层：白框左右内边距相同。
 * 不自定义滚动条宽高，交给系统 overlay：内容未超出或未滑动时不显示。
 */
#weekPickerDialog {
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
}

#weekPickerDialog .week-picker-dialog {
  width: auto;
  max-width: 100%;
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 18px 0 12px;
  overflow: hidden;
}

#weekPickerDialog h2 {
  margin: 0 40px 12px 16px;
}

#weekPickerDialog .dialog-close {
  right: 8px;
}

#weekPickerDialog .week-picker-list {
  display: grid;
  gap: 6px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 8px;
  margin: 0;
  overscroll-behavior: contain;
}

.week-picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.week-picker-option:active {
  background: rgba(var(--gold-rgb), 0.12);
}

.week-picker-option.is-selected {
  border-color: var(--gold);
  background: rgba(var(--gold-rgb), 0.14);
  box-shadow: inset 0 0 0 1px rgba(var(--gold-rgb), 0.35);
}

.week-picker-option-text {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI", "PingFang SC", "Microsoft YaHei", monospace;
  letter-spacing: 0.01em;
  white-space: pre;
}

/** 周次列表/按钮上的「无课」：浅底上用更醒目的系统绿，与正文墨色区分 */
.week-picker-option .week-empty-tag,
.week-picker-value .week-empty-tag {
  color: var(--green-mark);
  font-weight: 700;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.week-picker-option-mark {
  flex-shrink: 0;
  color: var(--accent-deep);
  font-size: 0.85rem;
}

.confirm-msg {
  margin: 8px 0 16px;
  color: var(--ink);
  line-height: 1.5;
}

.days {
  display: grid;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 800px) {
  .days {
    grid-template-columns: 1fr 1fr;
  }
}

.day {
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px;
  box-sizing: border-box;
  min-width: 0;
}

.day h2 {
  margin: 0 0 4px;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--accent-deep);
  padding-bottom: 8px;
}

.day h2 span {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.88rem;
}

.slot {
  display: grid;
  gap: 3px;
  /* 左右内边距一致，与日期卡片左右留白对齐 */
  padding: 10px 12px;
  border-top: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.slot:first-of-type {
  border-top: 0;
}

.slot-time,
.slot-meta {
  display: grid;
  /* 与「选择周次 / 本周」同为 1fr 1fr，右列时间与教室居中对齐 */
  grid-template-columns: 1fr 1fr;
  column-gap: 8px;
  align-items: baseline;
}

.slot-time {
  font-size: 0.78rem;
  color: var(--gold-dim);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.slot-period,
.slot-teacher {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-period,
.slot-clock {
  font-variant-numeric: tabular-nums;
}

.slot-course {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

/* 选修待选：设置已有组但本格匹配不上时显示，避免整格消失像「少课」 */
.slot-needs-pick {
  opacity: 0.85;
  border-style: dashed;
}

.slot-needs-pick .slot-course {
  font-weight: 600;
  color: var(--muted);
}

.slot-meta {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.45;
}

.slot-clock,
.slot-loc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.slot:not(.empty):not(.note) {
  background: rgba(var(--ink-rgb), 0.04);
}

.slot.empty .slot-course {
  color: #8a9791;
  font-weight: 600;
}

.slot.note {
  background: rgba(var(--gold-rgb), 0.1);
}

.slot.note .slot-course {
  color: var(--gold-dim);
}

dialog {
  border: 1px solid var(--line-gold);
  border-radius: 12px;
  padding: 0;
  width: min(420px, calc(100vw - 24px));
  box-shadow: var(--shadow);
  background: var(--card);
}

dialog::backdrop {
  background: rgba(6, 40, 30, 0.62);
}

/* 弹层刚打开时短暂屏蔽内部点击，避免与外层按钮同一触点穿透 */
.dialog-body.is-click-guard,
.settings-dialog-body.is-click-guard {
  pointer-events: none;
}

/* 分享层保持非模态，遮罩只负责视觉和点击关闭 */
.share-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(6, 40, 30, 0.62);
  cursor: pointer;
}

.share-backdrop[hidden] {
  display: none !important;
}

#shareDialog[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 71;
}

.dialog-body {
  padding: 18px;
  position: relative;
}

.dialog-body h2 {
  margin: 0 36px 12px 0;
  color: var(--accent-deep);
}

.dialog-close {
  position: absolute;
  /* 分享页原样即全局默认：热区 top/right 8px，字形居中 */
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  margin: 0;
  /* 手机端关闭键只保留字形，不要灰底方块；hover/active 也不加底色 */
  background: transparent;
  color: var(--accent-deep);
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dialog-close:hover,
.dialog-close:active,
.dialog-close:focus,
.dialog-close:focus-visible {
  background: transparent;
  color: var(--accent-deep);
  outline: none;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* display/grid/flex 规则不能覆盖原生 hidden，否则未导入时仍会露出保存按钮 */
.dialog-actions[hidden] {
  display: none !important;
}

.dialog-actions.dialog-actions-confirm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.dialog-actions.dialog-actions-confirm .ghost,
.dialog-actions.dialog-actions-confirm .primary,
.dialog-actions.dialog-actions-confirm .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin: 0;
  text-align: center;
}

.dialog-actions-save .primary,
.dialog-actions-save .ghost {
  width: 100%;
  /* 禁用/高亮切换时字重一致，避免文字略变宽把高度再挤一下 */
  font-weight: 700;
}

/* 未改课程时保存不金底高亮，仍保持可读、不可点 */
#btnSaveSettings:disabled,
#btnSaveSlotNote:disabled {
  opacity: 1;
  cursor: default;
}

.dialog-actions-bottom {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/*
 * 空态文案：仅提示，不再单独画底部分隔线（与下方主题区共用分区线）。
 */
.settings-empty {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 10px 0 4px;
  border-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
}

.settings-empty[hidden] {
  display: none !important;
}

/* 重新导入：轻量文字次要钮，与上方「保存」描边/金底主操作区分 */
.settings-reimport-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 9px 13px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.settings-reimport-btn svg {
  flex: 0 0 auto;
  display: block;
}

.settings-reimport-btn:active {
  color: var(--accent-deep);
  background: rgba(var(--ink-rgb), 0.04);
}

/* 设置弹层：默认随内容收缩；仅内容超出时再定高内滚（见 .is-scrollable） */
#settingsDialog {
  max-height: min(94vh, 880px);
  height: fit-content;
  overflow: hidden;
}

#settingsDialog.is-scrollable {
  /* 选课列表过长：顶到上限，中间滚动区吃满剩余高度 */
  height: min(94vh, 880px);
}

#settingsDialog .settings-dialog-body {
  position: relative;
  display: flex;
  flex-direction: column;
  /* 头栏 ↔ 滚动 ↔ 保存 ↔ 底坞：尽量紧 */
  gap: 4px;
  height: auto;
  max-height: min(94vh, 880px);
  padding: 0;
  overflow: hidden;
}

#settingsDialog.is-scrollable .settings-dialog-body {
  height: 100%;
  max-height: 100%;
}

.settings-header {
  position: relative;
  flex: 0 0 auto;
  /* 左右 16px = 内容右缘（导出钮）；× 的 top/right 与此对齐，同分享页「标题顶 / 内容右缘」 */
  padding: 16px 16px 0;
  background: var(--card);
  border-bottom: 0;
  z-index: 2;
  overflow: visible;
}

/* 左：标题 / 选择课程；右：导出笔记（× 不在栅格内，避免各页各算一套） */
.settings-header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  /* 班级模式无副标题时更紧；有「选择课程」时仍够分两行 */
  row-gap: 10px;
  align-items: start;
  /* 分隔线左右留白，与底部「重新导入课表」上横线同宽，不封到弹层边缘 */
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.settings-header-grid h2 {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  min-width: 0;
  /* 给右上 × 留空，与分享页标题避让同一量级 */
  padding: 0 36px 0 0;
  font-size: 1.25rem;
  line-height: 1;
  height: 1em;
}

/*
 * 设置 ×：横向仍套分享公式（right = 垫−12、居中）；纵向再上移一点，避免比「设置」矮半截。
 * 分享本身不改。
 */
#settingsDialog .settings-header .dialog-close {
  top: 0;
  right: 4px;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

#settingsDialog .settings-header .dialog-close:hover,
#settingsDialog .settings-header .dialog-close:active,
#settingsDialog .settings-header .dialog-close:focus {
  background: transparent;
  color: var(--accent-deep);
}

.settings-header-grid .settings-course-title {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  min-width: 0;
  align-self: center;
  /* 与下方「主题颜色」标签同款字号/字重/颜色 */
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.settings-header-grid .settings-course-title[hidden] {
  display: none !important;
}

.settings-export-btn {
  position: relative;
  grid-column: 2;
  /* 固定第二行，避开「设置」标题行的 × */
  grid-row: 2;
  justify-self: end;
  align-self: center;
  margin: 0;
  padding: 6px 10px;
  min-height: 32px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: visible;
}

/**
 * 设置列表外壳：与课表同理，裁掉系统粗滑槽；自身吃掉剩余高度，内层才能滚。
 * <p>与上下横线的空白由 {@code .settings-dialog-body} 的 gap 负责，不放在可滚层里。</p>
 */
.settings-scroll-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-sizing: border-box;
}

.settings-scroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  /* 仅左右留白；上下不贴横线靠 dialog-body gap */
  padding: 0 20px;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* 空态：列表区贴内容；主题坞仍在下方常显 */
#settingsDialog.is-empty .settings-scroll-shell,
#settingsDialog.is-empty .settings-scroll {
  flex: 0 0 auto;
}

#settingsDialog.is-empty .settings-scroll {
  padding: 0 20px;
  overflow: hidden;
}

/**
 * 选课列表底部标识：滚到尽头时出现「— 滑到底啦 —」。
 */
.settings-scroll-end {
  flex: 0 0 auto;
  margin: 12px 0 2px;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: center;
  opacity: 0.78;
  user-select: none;
  pointer-events: none;
}

.settings-scroll-end[hidden] {
  display: none !important;
}

.settings-scroll::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent;
}

.dialog-actions .block {
  width: 100%;
  text-align: center;
}

.share-status {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 10px 0 0;
}

.share-status:empty {
  display: none;
}

.share-dialog-body {
  padding: 20px;
}

/* 分享 ×：保持原布局，不要改 */
#shareDialog .dialog-close {
  top: 8px;
  right: 8px;
  align-items: center;
  justify-content: center;
}

.share-dialog-body h2 {
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.share-combined {
  --share-accent-line: rgba(184, 145, 30, 0.5);
}

.share-qr-card {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
}

.share-link-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(90, 107, 99, 0.22);
}

.share-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 9px;
  color: var(--accent-deep);
  font-size: 0.86rem;
  font-weight: 700;
}

.share-section-label svg {
  color: var(--gold-dim);
}

.share-link-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.share-link-row input {
  flex: 1;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--line-gold);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 0.85rem;
  box-shadow: inset 0 1px 2px rgba(var(--ink-rgb), 0.04);
  user-select: text;
  -webkit-user-select: text;
}

.share-qr {
  display: block;
  width: min(240px, 70vw);
  height: auto;
  aspect-ratio: 320 / 356;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  /* 允许系统长按菜单「保存图片」；user-select:none 会在部分 WebView 里禁掉 */
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
  pointer-events: auto;
}

.share-link-row .share-action,
.share-download.share-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  text-decoration: none;
  padding: 0 12px;
  min-height: 44px;
  box-sizing: border-box;
  line-height: 1;
}

.share-combined .share-action {
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--accent-deep);
  border: 1px solid var(--line-gold);
  font-weight: 600;
  box-shadow: none;
}

/* 图标与中文同一视觉中线：固定盒高 + 字行同高，再轻微下移补偿汉字重心 */
.share-combined .share-action svg {
  flex: 0 0 auto;
  display: block;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  transform: translateY(1.5px);
}

.share-combined .share-action span {
  display: block;
  line-height: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
}

.share-combined .share-action:active {
  background: rgba(var(--ink-rgb), 0.1);
}

.share-link-row .share-action {
  flex: 0 0 auto;
  margin-top: 0;
  white-space: nowrap;
}

/* 压过 .ghost.block 的 display:block / margin，图标+文字整组水平垂直居中 */
a.share-download.share-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 0;
}

@media (hover: hover) {
  .share-combined .share-action:hover {
    background: rgba(var(--ink-rgb), 0.08);
  }
}

/* 照片 / 笔记图标绝对定位，不挤两列中线，保证时间/地点与「本周」左缘对齐 */
.slot-with-photo {
  position: relative;
}

.slot-with-photo .slot-clock,
.slot-with-photo .slot-loc,
.slot-with-photo .slot-course {
  padding-right: 28px;
}

.slot-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 照片与笔记错开约一行，避免热区挨太近误触 */
  gap: 18px;
  width: 28px;
}

.slot-photo-corner {
  position: relative;
  width: 28px;
  height: 28px;
}

.slot-photos-add {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: #9aa3a0;
  overflow: hidden;
  cursor: pointer;
}

.slot-photos-add.has-photos {
  color: #6d7773;
}

.slot-note-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #9aa3a0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.slot-note-btn.has-note {
  color: #6d7773;
}

.slot-note-meta {
  margin: 0 36px 8px 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

#slotNoteText {
  display: block;
  width: 100%;
  min-height: 168px;
  margin: 0;
  /* 上下内边距与行高对齐，横线落在每行文字下方；可直接粘贴文字 */
  padding: 0 12px;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid var(--line-gold);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  line-height: 24px;
  background-color: var(--card-solid);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 23px,
    rgba(var(--ink-rgb), 0.14) 23px,
    rgba(var(--ink-rgb), 0.14) 24px
  );
  background-attachment: local;
}

#slotNoteText:focus {
  outline: 2px solid rgba(var(--gold-rgb), 0.55);
  outline-offset: 1px;
}

.dialog-body .photo-preview-title {
  /* 只给标题让关闭×，副标题行要贴图片右缘，不能整栏 padding-right */
  margin: 0 36px 4px 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-preview-head {
  margin: 0 0 8px;
  padding-right: 0;
}

.photo-preview-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 1.2em;
  width: 100%;
}

.photo-preview-time {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-preview-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.photo-preview-stage {
  position: relative;
  width: 100%;
  height: min(52vh, 420px);
  min-height: 240px;
  margin: 4px 0 10px;
  background: var(--card);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  flex: 0 0 auto;
  contain: layout paint;
  /* 预览内手势缩放/拖移，交给 JS，避免浏览器默认滚动抢手势 */
  touch-action: none;
  cursor: zoom-in;
}

.photo-preview-stage.is-zoomed {
  cursor: grab;
}

.photo-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  object-position: center;
  background: transparent;
  /* 防止换图加载瞬间按固有尺寸撑开布局 */
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.photo-preview-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(90, 107, 99, 0.42);
  color: #fff;
  transform: translateY(-50%);
  cursor: pointer;
}

.photo-preview-arrow:disabled {
  opacity: 0.28;
  cursor: default;
}

.photo-preview-arrow[hidden] {
  display: none !important;
}

#btnPrevPhoto {
  left: 8px;
}

#btnNextPhoto {
  right: 8px;
}

.photo-preview-body {
  position: relative;
}

/*
 * 预览 ×：同样套分享公式（分享不改）。
 * body 垫 18 → top/right 6、字形居中 → 光学贴课程名顶 / 日期与图右缘。
 */
.photo-preview-body > .dialog-close {
  top: 6px;
  right: 6px;
  align-items: center;
  justify-content: center;
}

.photo-preview-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 浮在工具栏上方正中，不占文档流，避免把预览框撑高 */
.photo-preview-toast {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: block;
  width: max-content;
  max-width: calc(100% - 16px);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(6, 40, 30, 0.92);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: var(--shadow);
}

.photo-preview-toast[hidden] {
  display: none !important;
}

.photo-preview-add {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  overflow: hidden;
  font-weight: 600;
}

/* 预览底栏「继续添加」：描边次要态 */
dialog label.photo-preview-add.ghost,
dialog button.photo-preview-add.ghost {
  background: transparent;
  color: var(--accent-deep);
  border: 1px solid var(--line-gold);
}

.photo-icon-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(155, 44, 44, 0.35);
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.photo-icon-btn-ghost {
  border-color: var(--line-gold);
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--accent-deep);
}

.slot-photos-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--on-accent);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(6, 40, 30, 0.2);
}

.slot-photos-badge[hidden] {
  display: none !important;
}

.photo-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(6, 40, 30, 0.92);
  color: #fff;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
}

.photo-toast[hidden] {
  display: none;
}

/* 设置弹层在顶层，页面底部 toast 会被挡住；成功/失败提示改画在弹层内 */
.settings-export-toast {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(6, 40, 30, 0.92);
  color: #fff;
  font-size: 0.86rem;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.settings-export-toast[hidden] {
  display: none !important;
}

/**
 * 浅色主题：与预览 H0–H4 同结构（浅壳 + 浮起卡片 + 低饱和主色）。
 * 默认 classic 走 :root；此处仅覆盖五套可选浅色。
 */
html[data-theme="beige"] {
  --bg: #f1ece2;
  --bg-deep: #e8e2d6;
  --bg-soft: #f7f3eb;
  --bg-mid: #f1ece2;
  --gold: #a8907a;
  --gold-bright: #b9a28e;
  --gold-dim: #8f7864;
  --gold-rgb: 168, 144, 122;
  --ink-rgb: 61, 53, 46;
  --card: #fffcf7;
  --card-solid: #ffffff;
  --ink: #3d352e;
  --muted: #8c8278;
  --green-mark: #6f8a72;
  --shadow: 0 8px 28px rgba(61, 53, 46, 0.1);
  --shell-glow: rgba(168, 144, 122, 0.1);
  --shell-brand: #3d352e;
  --shell-sub: rgba(61, 53, 46, 0.62);
  --shell-border: rgba(168, 144, 122, 0.32);
  --icon-border: rgba(168, 144, 122, 0.42);
  --icon-bg: rgba(255, 255, 255, 0.55);
  --icon-hover: rgba(168, 144, 122, 0.14);
  --panel-border: rgba(168, 144, 122, 0.24);
  --boot-fg: rgba(61, 53, 46, 0.72);
  --accent-deep: #3d352e;
  --on-accent: #fffcf7;
  --theme-color: #a8907a;
  --empty-sky: #8f7864;
  --empty-sky-deep: #6f5c4c;
  --empty-accent: #c4a888;
  --empty-accent-bright: #dcc4a8;
  --empty-surface: #fffcf7;
  --empty-ink: #3d352e;
  --empty-shadow: rgba(61, 53, 46, 0.14);
}

html[data-theme="sage"] {
  --bg: #e8f0ee;
  --bg-deep: #dde8e5;
  --bg-soft: #f0f5f3;
  --bg-mid: #e8f0ee;
  --gold: #6f958a;
  --gold-bright: #7fa69a;
  --gold-dim: #5a7a70;
  --gold-rgb: 111, 149, 138;
  --ink-rgb: 47, 64, 60;
  --card: #f7fbfa;
  --card-solid: #ffffff;
  --ink: #2f403c;
  --muted: #6f827c;
  --green-mark: #4a7a6a;
  --shadow: 0 8px 28px rgba(47, 64, 60, 0.1);
  --shell-glow: rgba(111, 149, 138, 0.1);
  --shell-brand: #2f403c;
  --shell-sub: rgba(47, 64, 60, 0.62);
  --shell-border: rgba(111, 149, 138, 0.32);
  --icon-border: rgba(111, 149, 138, 0.42);
  --icon-bg: rgba(255, 255, 255, 0.55);
  --icon-hover: rgba(111, 149, 138, 0.14);
  --panel-border: rgba(111, 149, 138, 0.24);
  --boot-fg: rgba(47, 64, 60, 0.72);
  --accent-deep: #2f403c;
  --on-accent: #f4faf8;
  --theme-color: #6f958a;
  --empty-sky: #5a7a70;
  --empty-sky-deep: #3f5a52;
  --empty-accent: #8fb0a4;
  --empty-accent-bright: #b0cfc4;
  --empty-surface: #f7fbfa;
  --empty-ink: #2f403c;
  --empty-shadow: rgba(47, 64, 60, 0.14);
}

html[data-theme="blue"] {
  --bg: #e9eef5;
  --bg-deep: #dde4ef;
  --bg-soft: #f1f4f9;
  --bg-mid: #e9eef5;
  --gold: #6f86a8;
  --gold-bright: #8096b6;
  --gold-dim: #5a6f8f;
  --gold-rgb: 111, 134, 168;
  --ink-rgb: 47, 58, 74;
  --card: #f7f9fc;
  --card-solid: #ffffff;
  --ink: #2f3a4a;
  --muted: #6f7d90;
  --green-mark: #5a7a72;
  --shadow: 0 8px 28px rgba(47, 58, 74, 0.1);
  --shell-glow: rgba(111, 134, 168, 0.1);
  --shell-brand: #2f3a4a;
  --shell-sub: rgba(47, 58, 74, 0.62);
  --shell-border: rgba(111, 134, 168, 0.32);
  --icon-border: rgba(111, 134, 168, 0.42);
  --icon-bg: rgba(255, 255, 255, 0.55);
  --icon-hover: rgba(111, 134, 168, 0.14);
  --panel-border: rgba(111, 134, 168, 0.24);
  --boot-fg: rgba(47, 58, 74, 0.72);
  --accent-deep: #2f3a4a;
  --on-accent: #f4f7fb;
  --theme-color: #6f86a8;
  --empty-sky: #5a6f8f;
  --empty-sky-deep: #3f516c;
  --empty-accent: #8fa3c0;
  --empty-accent-bright: #b0bfd4;
  --empty-surface: #f7f9fc;
  --empty-ink: #2f3a4a;
  --empty-shadow: rgba(47, 58, 74, 0.14);
}

html[data-theme="lavender"] {
  --bg: #eeeaf3;
  --bg-deep: #e4deec;
  --bg-soft: #f5f1f8;
  --bg-mid: #eeeaf3;
  --gold: #8a7aa8;
  --gold-bright: #9b8cb6;
  --gold-dim: #71628f;
  --gold-rgb: 138, 122, 168;
  --ink-rgb: 58, 51, 72;
  --card: #faf8fc;
  --card-solid: #ffffff;
  --ink: #3a3348;
  --muted: #7c738d;
  --green-mark: #6a7a72;
  --shadow: 0 8px 28px rgba(58, 51, 72, 0.1);
  --shell-glow: rgba(138, 122, 168, 0.1);
  --shell-brand: #3a3348;
  --shell-sub: rgba(58, 51, 72, 0.62);
  --shell-border: rgba(138, 122, 168, 0.32);
  --icon-border: rgba(138, 122, 168, 0.42);
  --icon-bg: rgba(255, 255, 255, 0.55);
  --icon-hover: rgba(138, 122, 168, 0.14);
  --panel-border: rgba(138, 122, 168, 0.24);
  --boot-fg: rgba(58, 51, 72, 0.72);
  --accent-deep: #3a3348;
  --on-accent: #f7f5fb;
  --theme-color: #8a7aa8;
  --empty-sky: #71628f;
  --empty-sky-deep: #54486c;
  --empty-accent: #a898c0;
  --empty-accent-bright: #c4b8d6;
  --empty-surface: #faf8fc;
  --empty-ink: #3a3348;
  --empty-shadow: rgba(58, 51, 72, 0.14);
}

html[data-theme="rose"] {
  --bg: #f2ebe9;
  --bg-deep: #e9e0dd;
  --bg-soft: #f7f1ef;
  --bg-mid: #f2ebe9;
  --gold: #b0847a;
  --gold-bright: #c0968d;
  --gold-dim: #946e65;
  --gold-rgb: 176, 132, 122;
  --ink-rgb: 67, 54, 50;
  --card: #fcf8f7;
  --card-solid: #ffffff;
  --ink: #433632;
  --muted: #8a7a74;
  --green-mark: #6f7a68;
  --shadow: 0 8px 28px rgba(67, 54, 50, 0.1);
  --shell-glow: rgba(176, 132, 122, 0.1);
  --shell-brand: #433632;
  --shell-sub: rgba(67, 54, 50, 0.62);
  --shell-border: rgba(176, 132, 122, 0.32);
  --icon-border: rgba(176, 132, 122, 0.42);
  --icon-bg: rgba(255, 255, 255, 0.55);
  --icon-hover: rgba(176, 132, 122, 0.14);
  --panel-border: rgba(176, 132, 122, 0.24);
  --boot-fg: rgba(67, 54, 50, 0.72);
  --accent-deep: #433632;
  --on-accent: #fff8f6;
  --theme-color: #b0847a;
  --empty-sky: #946e65;
  --empty-sky-deep: #6f524c;
  --empty-accent: #c4a098;
  --empty-accent-bright: #dcc0b8;
  --empty-surface: #fcf8f7;
  --empty-ink: #433632;
  --empty-shadow: rgba(67, 54, 50, 0.14);
}

/* 设置页主题色板：分区线由 .settings-section 统一处理 */
.theme-picker {
  margin: 0;
  padding: 0;
  border-top: 0;
  border-bottom: 0;
}

.theme-picker-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.theme-swatches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 7px 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(var(--ink-rgb), 0.02);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-swatch:hover {
  border-color: var(--line-gold);
}

.theme-swatch.is-active {
  border-color: var(--line-gold);
  box-shadow: inset 0 0 0 1px var(--line-gold);
  background: rgba(var(--gold-rgb), 0.1);
}

.theme-swatch-chip {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 0 0 3px var(--chip-shell, #fff);
  background: linear-gradient(135deg, var(--chip-shell, #fff) 45%, var(--chip-accent, #888) 45%);
}

.theme-swatch-name {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}


