/* ——— 动效语言 ———
   与阳台观星日历、窗前过境、地球今天的声音共用：--ease 用于出现、移动、换位（快起慢停），--ease-exit 用于离场。
   按下 90ms，小的换内容 160ms，面板与位置 240ms，首次呈现 420ms。系统要求减少动态效果时归零。 */
:root {
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --dur-press: 90ms;
  --dur-quick: 160ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;

  --bg: #e8e1d2;
  --paper: #f4eee2;
  --ink: #2c261e;
  --muted: #776a57;
  --line: #d3c9b5;
  --accent: #b9572a;
  --accent-ink: #fff8ef;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f;
    --ink: #ece6d8;
    --muted: #a59a86;
    --line: #34302a;
    --accent: #e08a52;
    --accent-ink: #1b140d;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-press: 0ms;
    --dur-quick: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
  }
}

* {
  box-sizing: border-box;
}
/* hidden 永远胜过组件自己的 display。 */
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a,
button,
summary {
  transition:
    color var(--dur-quick) var(--ease),
    background-color var(--dur-quick) var(--ease),
    border-color var(--dur-quick) var(--ease),
    opacity var(--dur-quick) var(--ease),
    scale var(--dur-press) var(--ease);
}

/* ——— 顶栏 ——— */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.08em;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 30%, #d9a441 0 1.6px, #e59a74 2px 5.5px, transparent 6px),
    linear-gradient(var(--ink), var(--ink)) 50% 100% / 1.6px 55% no-repeat,
    var(--paper);
  box-shadow: inset 0 0 0 1px #2c261e33;
}
#language {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
}
#language:hover {
  border-color: var(--muted);
}
#language:active,
.primary:not(:disabled):active,
.secondary:not(:disabled):active,
.quiet:active,
.thumb:active {
  scale: 0.96;
}

/* ——— 版面：手机上下排，宽屏左画右文 ——— */
.layout {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) 24px;
  display: grid;
  gap: 22px;
  align-content: start;
}
@media (min-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "plate panel" "shelf shelf";
    align-items: center;
    padding-top: 24px;
  }
  .plate {
    grid-area: plate;
    justify-self: center;
    width: min(100%, calc((100dvh - 190px) * 0.8));
  }
  .panel {
    grid-area: panel;
  }
  .shelf {
    grid-area: shelf;
  }
}

/* ——— 画板：纸面上的版画，深色模式下也保持纸色，像桌上的一张印刷品 ——— */
.plate {
  margin: 0;
  background: var(--paper);
  border-radius: 6px;
  box-shadow:
    0 1px 0 #ffffff80 inset,
    0 24px 50px -30px #3b2a1366,
    0 2px 6px -2px #3b2a1333;
  overflow: hidden;
}
.art {
  position: relative;
  aspect-ratio: 4 / 4.4;
}
#garden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}
.label {
  min-height: 72px;
  padding: 2px 18px 16px;
  display: grid;
  justify-items: center;
  align-content: start;
  text-align: center;
  color: #2c261e;
  border-top: 1px solid #2c261e1a;
  margin: 0 18px;
}
.label-name {
  margin-top: 10px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.label-meta {
  color: #7a6c58;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ——— 右侧文字与按钮 ——— */
.panel {
  min-height: 210px;
}
.step {
  display: grid;
  gap: 14px;
  justify-items: start;
}
@media (max-width: 859px) {
  .step {
    justify-items: center;
    text-align: center;
  }
}
h1,
h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.04em;
}
h1 {
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.15;
}
#done-panel h2,
#problem-panel h2 {
  font-size: clamp(24px, 6vw, 30px);
}
.lede {
  margin: 0;
  color: var(--muted);
  max-width: 24em;
  text-wrap: pretty;
}
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
}
.fineprint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 26em;
}
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
@media (max-width: 859px) {
  .buttons {
    justify-content: center;
  }
}
.primary,
.secondary {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
}
.primary {
  border: 0;
  background: var(--ink);
  color: var(--bg);
}
.primary:not(:disabled):hover {
  background: color-mix(in oklab, var(--ink) 86%, var(--bg));
}
.secondary {
  border: 1.5px solid var(--line);
  background: transparent;
}
.secondary:not(:disabled):hover {
  border-color: var(--muted);
}
.quiet {
  border: 0;
  background: none;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--muted) 45%, transparent);
  text-underline-offset: 4px;
}
.quiet:hover {
  color: var(--ink);
}
.links {
  display: flex;
  gap: 4px;
  margin-left: -10px;
}
.how {
  max-width: 26em;
  color: var(--muted);
  font-size: 14px;
}
.how summary {
  cursor: pointer;
  list-style: none;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--muted) 45%, transparent);
  text-underline-offset: 4px;
}
.how summary::-webkit-details-marker {
  display: none;
}
.how summary:hover {
  color: var(--ink);
}
.how ul {
  margin: 10px 0 0;
  padding-left: 1.2em;
  text-align: left;
}
.how li + li {
  margin-top: 4px;
}

/* 哼唱中 */
.hint {
  margin: 0;
  min-height: 3.2em;
  font-family: var(--serif);
  font-size: clamp(20px, 5.4vw, 24px);
  line-height: 1.35;
  text-wrap: balance;
}
.meter {
  width: 160px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  scale: var(--level, 0) 1;
  transition: scale 80ms linear;
}
@property --ring {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}
/* 完成按钮外圈：开花后保持安静，这一圈慢慢走满就自动完成；再哼一声就退回去。 */
.ring {
  position: relative;
  --ring: 0;
  transition:
    --ring 60ms linear,
    background-color var(--dur-quick) var(--ease),
    scale var(--dur-press) var(--ease),
    opacity var(--dur-quick) var(--ease);
}
.ring::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: inherit;
  padding: 2.5px;
  background: conic-gradient(from -90deg, var(--accent) calc(var(--ring) * 1turn), transparent 0);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  pointer-events: none;
}

/* 花园 */
.shelf h2 {
  font-size: 18px;
  margin-bottom: 10px;
}
.shelf-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.thumb {
  flex: none;
  width: 92px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 6px 14px -8px #3b2a1366;
  overflow: hidden;
  scroll-snap-align: start;
  display: grid;
}
.thumb canvas {
  width: 92px;
  height: 92px;
  display: block;
}
.thumb span {
  padding: 4px 6px 6px;
  font-size: 11px;
  color: #7a6c58;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumb[aria-current="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.foot {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 22px max(22px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.foot p {
  margin: 0;
}

/* 撤销提示：从底部升起，四秒后自己退下。 */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: 0 10px 30px -10px #0007;
  transition:
    opacity var(--dur-base) var(--ease),
    translate var(--dur-base) var(--ease),
    display var(--dur-base) allow-discrete;
  z-index: 5;
}
.toast[hidden] {
  display: none;
  opacity: 0;
  translate: -50% 12px;
}
@starting-style {
  .toast:not([hidden]) {
    opacity: 0;
    translate: -50% 12px;
  }
}
.toast button {
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  background: color-mix(in oklab, var(--bg) 18%, transparent);
  color: inherit;
  font-weight: 600;
}

dialog {
  max-width: min(92vw, 420px);
  padding: 18px;
  border: 0;
  border-radius: 22px;
  background: var(--paper);
  color: #2c261e;
  text-align: center;
  opacity: 0;
  scale: 0.96;
  transition:
    opacity var(--dur-base) var(--ease),
    scale var(--dur-base) var(--ease),
    overlay var(--dur-base) allow-discrete,
    display var(--dur-base) allow-discrete;
}
dialog[open] {
  opacity: 1;
  scale: 1;
}
@starting-style {
  dialog[open] {
    opacity: 0;
    scale: 0.96;
  }
}
dialog::backdrop {
  background: #0008;
}
dialog img {
  display: block;
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  border-radius: 8px;
}
dialog p {
  margin: 12px 0;
  color: #7a6c58;
  font-size: 14px;
}
dialog .primary {
  background: #2c261e;
  color: #f4eee2;
}

::view-transition {
  pointer-events: none;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--dur-base);
  animation-timing-function: var(--ease);
}
:lang(en) .eyebrow {
  letter-spacing: 0.04em;
}
.noscript {
  text-align: center;
}
