/* 分数学伴 · 各页面共用：作业本方格纸底、深蓝墨水字、橙色涂色块（和形象里 1/2 × 2/3 的涂法一致） */
:root {
  --ink: #1e3a5f;
  --ink-soft: #4a6382;
  --muted: #7b8ba0;
  --paper: #fffdf7;
  --grid: rgba(30, 58, 95, 0.07);
  --card: #ffffff;
  --line: #e3e8ef;
  --orange: #f59e0b;
  --orange-deep: #d97706;
  --orange-soft: #fff4de;
  --blue-soft: #e8f1fb;
  --green: #15803d;
  --red: #c2410c;
  --shadow: 0 0.15rem 0.6rem rgba(30, 58, 95, 0.08);
  /* 一体机 1920×1080 约 28px；1280×720 开 150% 缩放时 CSS 只有 853×480，最小 14px */
  font-size: clamp(14px, min(1.6vw, 2.65vh), 34px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  color: var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 1.6rem 1.6rem;
  font-family: 'HarmonyOS Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.45em 1.1em;
  font-weight: 600;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.btn:active {
  transform: scale(0.96);
}
.btn svg {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}
.btn.primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.btn.primary:hover {
  background: var(--orange-deep);
  border-color: var(--orange-deep);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.4em 0.7em;
  border-radius: 0.6em;
}
.icon-btn:hover {
  background: rgba(30, 58, 95, 0.06);
}
.icon-btn svg {
  width: 1.2em;
  height: 1.2em;
}

.tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--ink-soft);
}
.tag.offline {
  background: #fde8d7;
  color: var(--red);
}
.only-offline {
  display: none;
}
.is-offline .only-offline {
  display: inline-block;
}

/* 分数竖着排：分子 / 分数线 / 分母 */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  font-size: 0.78em;
  line-height: 1.08;
  margin: 0 0.12em;
  font-variant-numeric: tabular-nums;
}
.frac > span:first-child {
  border-bottom: 0.09em solid currentColor;
  padding: 0 0.18em 0.04em;
}
.frac > span:last-child {
  padding: 0.04em 0.18em 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 8vh;
  transform: translate(-50%, 1rem);
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.6em 1.2em;
  border-radius: 0.8em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  max-width: 80vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
