/* 不打盹 · 第 0 章。颜色取自画布（Resurrect 64 一类的像素配色）。 */
:root {
  --ink: #1A1C2C;
  --paper: #FFF1E8;
  --gold: #FFCD75;
  --line: #566C86;
  --muted: #94B0C2;
  --soft: #C2C3C7;
  --shadow: #29366F;
  --note: #FFF6DE;
  --font: "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif;
  /* 竖屏：底部对话框占的高度（取景时让出来）。固定值，对话框内容变高变矮时画面不跳 */
  --dock-h: 192px;
  --side-w: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); font-family: var(--font); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input { font-family: var(--font); }

#boot-fail { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 24px; font-size: 18px; line-height: 1.7; background: var(--ink); }
#boot-fail[hidden] { display: none; }
#boot-fail p { margin: 0; }

#app { position: fixed; inset: 0; }

/* 舞台铺满整屏，对话框浮在地板上（画布本来就是这么画的）。padding 不挡画面，只告诉取景（main.mjs fitScene）
   哪一块被对话框或右侧栏占了：竖屏让出底下 --dock-h，横屏和电脑让出右边 --side-w。 */
.stage { position: absolute; inset: 0; overflow: hidden; padding: 0 var(--side-w) calc(var(--dock-h) + env(safe-area-inset-bottom)) 0; }
.stage.shop { background: #3E4248; }
.stage.outside { background: #3A3D42; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 场景图层开关 */
.scene .g-note, .scene .g-eyes-open, .scene .g-eyes-closed, .scene .g-eyes-happy,
.scene .g-reg, .scene .g-sleeping, .scene .g-yawn, .scene .g-corner-note { display: none; }
.scene.f-note .g-note,
.scene.f-eyes-open .g-eyes-open,
.scene.f-eyes-closed .g-eyes-closed,
.scene.f-eyes-happy .g-eyes-happy,
.scene.f-reg .g-reg,
.scene.f-sleeping .g-sleeping,
.scene.f-yawn .g-yawn,
.scene.f-corner-note .g-corner-note { display: inline; }
.scene.f-blink.f-eyes-open .g-eyes-open { display: none; }
.scene.f-blink.f-eyes-open .g-eyes-closed { display: inline; }

/* 灯：一盏一盏亮，用台阶式过渡保持像素感 */
.scene .g-lit { opacity: 0; transition: opacity 1.6s steps(4); }
.scene .g-lit rect:nth-child(2) { transition: opacity 1.6s steps(4) 0.5s; }
.scene .g-lit rect:nth-child(3) { transition: opacity 1.6s steps(4) 1s; }
.scene.f-lit .g-lit { opacity: 1; }
.scene .g-dark { opacity: 0; transition: opacity 2s steps(5); }
.scene.f-dark .g-dark { opacity: 1; }

/* 拿铁：呼吸、竖耳朵 */
.scene .g-cat { animation: breathe 3.2s steps(1) infinite; }
.scene.f-hop .g-cat { animation: none; transform: translateY(-3px); }
@keyframes breathe { 0% { transform: translateY(0); } 50% { transform: translateY(1px); } }
.scene .g-reg { animation: glow 2.4s steps(2) infinite; }
@keyframes glow { 0% { opacity: 1; } 50% { opacity: 0.85; } }

.hot { fill: transparent; cursor: pointer; }
.hot:focus { outline: none; }
.hot:focus-visible { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 4 3; }

@media (prefers-reduced-motion: reduce) {
  .scene .g-cat, .scene .g-reg { animation: none; }
  .scene .g-lit, .scene .g-dark { transition: none; }
}

/* 对话框：竖屏贴着底部、浮在地板上，平板上不拉得太宽；横屏和电脑见文件末尾 */
.dock { position: absolute; left: 0; right: 0; bottom: 0; max-width: 620px; margin: 0 auto; padding: 0 14px calc(14px + env(safe-area-inset-bottom)); }
.box {
  background: var(--ink); border: 4px solid var(--paper); box-shadow: 6px 6px 0 var(--shadow);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.box.system { border-color: var(--gold); }
.box .who { font-size: 13px; font-weight: 700; color: var(--gold); }
.box .row, .box.row { display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; }
.box .title { font-size: 16px; font-weight: 700; color: var(--gold); }
.box .tag { font-size: 11px; letter-spacing: 1px; color: var(--muted); }
.say { font-size: 16px; line-height: 1.7; margin: 0; }
/* 每天那一条带的一个数：像小票上的一行，跟在那句话后面，不抢眼 */
.today-fact { font-size: 13px; color: var(--muted); margin: -4px 0 0; letter-spacing: 0.5px; }
.today-fact::before { content: "— "; }
.today-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.today-opt { min-height: 44px; padding: 0 14px; font-size: 15px; flex: 1 1 0; }
.today-done { font-size: 13px; color: var(--muted); margin: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.today-done .link { min-height: 44px; }
.today-answer { font-size: 14px; color: var(--gold); margin: 0; line-height: 1.6; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0; }
.small { font-size: 12px; color: var(--muted); margin: 0; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.btn {
  min-height: 46px; padding: 0 12px; border: 3px solid var(--line); background: var(--ink); color: var(--paper);
  font-size: 14px; cursor: pointer; border-radius: 0;
}
.btn.primary { border-color: var(--gold); background: var(--gold); color: var(--ink); font-weight: 700; }
.btn.end { justify-self: end; align-self: flex-end; }
.btn:active { transform: translate(2px, 2px); }
.btn:focus-visible, .link:focus-visible, .idea:focus-visible { outline: 3px dashed var(--gold); outline-offset: 2px; }
.cap { min-height: 52px; font-weight: 700; font-size: 15px; }

.field { display: flex; gap: 8px; }
.field input {
  flex: 1; min-width: 0; height: 46px; padding: 0 12px; border: 3px solid var(--line); background: #0F1324; color: var(--paper);
  font-size: 16px; border-radius: 0;
}
.field input:focus { outline: none; border-color: var(--gold); }

/* 浮层：纸条、点子、结算单 */
/* 居中用 auto 外边距而不是 justify-content: center，内容比屏幕高时顶部才不会被裁掉 */
.overlay { position: absolute; inset: 0; background: rgba(7, 9, 18, 0.55); display: flex; flex-direction: column; align-items: center; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.overlay > * { flex: 0 0 auto; max-width: 420px; width: 100%; }
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }

.goal-note {
  background: var(--note); border: 3px solid #E5CF92; box-shadow: 6px 6px 0 var(--shadow); transform: rotate(-2deg);
  padding: 26px 24px; display: flex; flex-direction: column; gap: 10px; color: #2B2520; width: min(322px, 100%);
}
.goal-note .from { font-size: 12px; letter-spacing: 3px; color: #8C6A1F; }
.goal-note .text { font-family: var(--hand); font-size: 22px; line-height: 1.6; }

.ideas { gap: 10px; }
.idea {
  border: 3px solid var(--line); background: var(--ink); color: var(--paper); text-align: left; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; border-radius: 0; width: 100%;
}
.idea[aria-pressed="true"] { border-color: var(--paper); box-shadow: inset 0 0 0 2px var(--gold); }
.idea .lane { font-size: 11px; color: var(--ink); background: var(--gold); align-self: flex-start; padding: 1px 6px; }
.idea .name { font-size: 15px; font-weight: 500; }
.idea .shot { font-size: 12px; color: var(--soft); }
.mine { margin: 0; padding-left: 18px; font-size: 13px; color: var(--soft); line-height: 1.7; }

.slip {
  background: #FBFBF8; color: #1F2329; padding: 16px 16px 20px; display: flex; flex-direction: column; gap: 10px;
  transform: rotate(2deg); box-shadow: 6px 6px 0 var(--shadow); width: 200px;
}
.slip .head { font-size: 14px; font-weight: 700; text-align: center; letter-spacing: 2px; }
.slip .week { font-size: 10px; color: #5B6470; text-align: center; letter-spacing: 2px; }
.slip .rule { border-top: 2px dashed #9AA3AE; }
.slip .blank { height: 12px; border-bottom: 1px dashed #C9CDD3; }
.slip .empty { font-size: 12px; color: #5B6470; text-align: center; }
.overlay .slip + .box, .overlay .goal-note + .box { margin-top: 28px; }

.night { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 14px calc(28px + env(safe-area-inset-bottom)); }
.night .bye { font-size: 18px; letter-spacing: 4px; }

.toast { font-size: 13px; color: var(--gold); margin: 0; min-height: 1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 「这一周」（week_view.mjs）：一个系统框，里面不再套框；分组靠间距和一条虚线 */
.box.week { gap: 18px; padding: 14px 16px 18px; }
.week-head { margin-bottom: -6px; }
.week-head .title { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.icon-btn { width: 44px; height: 44px; margin: -10px -10px -10px 0; display: grid; place-items: center; background: none; border: 0; color: var(--muted); cursor: pointer; }
.icon-btn:focus-visible { outline: 3px dashed var(--gold); outline-offset: -6px; }


.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 3px solid var(--line); }
.seg button { min-height: 40px; background: var(--ink); color: var(--paper); border: 0; border-left: 3px solid var(--line); font-size: 14px; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--gold); color: var(--ink); font-weight: 700; }
.seg button:focus-visible { outline: 3px dashed var(--gold); outline-offset: -5px; }

.note { display: flex; gap: 8px; }
.note input, .wish textarea {
  flex: 1; min-width: 0; padding: 10px 12px; border: 3px solid var(--line); background: #0F1324; color: var(--paper);
  font-size: 15px; font-family: var(--font); border-radius: 0; resize: none;
}
.note input { height: 44px; }
.note input:focus, .wish textarea:focus { outline: none; border-color: var(--gold); }
.note input::placeholder, .wish textarea::placeholder { color: var(--muted); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.link.on { color: var(--gold); }
.row > .link { min-height: 40px; }

.videos { display: flex; flex-direction: column; gap: 12px; border-top: 2px dashed var(--line); padding-top: 16px; }
.video { display: flex; flex-direction: column; gap: 6px; }
.video-name { font-size: 14px; font-weight: 700; }
.video-state { font-size: 12px; color: var(--gold); }
.feedback { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; line-height: 1.6; }
.feedback dt { color: var(--muted); white-space: nowrap; }
.feedback dd { margin: 0; color: var(--soft); }
.tc { font-variant-numeric: tabular-nums; color: var(--gold); }
.upload { display: flex; flex-direction: column; gap: 8px; }
.pick { display: flex; align-items: center; justify-content: center; min-height: 48px; }
.upload-bar { height: 14px; border: 3px solid var(--line); background: #0F1324; }
.upload-bar span { display: block; height: 100%; background: var(--gold); transition: width 0.2s steps(4); }
.settle { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.wish-open { align-self: center; min-height: 40px; }
.wish { display: flex; flex-direction: column; gap: 8px; border-top: 2px dashed var(--line); padding-top: 16px; }
.wishes { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.wishes li { font-size: 13px; color: var(--soft); display: flex; flex-wrap: wrap; gap: 4px 8px; }
.wishes em { font-style: normal; font-size: 11px; color: var(--ink); background: var(--muted); padding: 0 5px; align-self: center; }
.wishes small { flex-basis: 100%; color: var(--muted); }
.btn[disabled] { opacity: 0.5; cursor: default; }
::selection { background: var(--gold); color: var(--ink); }
.box .links { display: flex; gap: 4px; margin-right: -12px; }
/* 字看起来小，能点的范围是 44×44（上下用负边距吃掉，对话框高度不变） */
.box .links .link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -13px 0; padding: 0 8px; }

/* 小票的「打印」只在第一次出现时放 */
.scene.f-reg-printed .g-slip-in { animation: none; }

/* 有鼠标的电脑上：指到能点的东西给个提示（手机上没有悬停，靠场景本身） */
@media (hover: hover) and (pointer: fine) {
  .hot:hover { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 4 3; stroke-opacity: 0.7; }
  .btn:hover { border-color: var(--paper); }
  .btn.primary:hover { border-color: var(--paper); background: #FFD98A; }
  .link:hover, .icon-btn:hover { color: var(--paper); }
  .card:hover { border-color: var(--muted); }
  .card.picked:hover { border-color: var(--gold); }
}

/* 横屏手机、平板横放、电脑：左边是店，右边一栏放对话框；打开的页（这一周、许愿、纸条、拍什么）
   占满右边这一栏，店一直看得见、还能点。按宽高比切换，不按宽度：844×390 的横屏手机也该这样，
   768×1024 的竖放平板不该。超宽屏不铺满，整体居中。 */
@media (min-aspect-ratio: 23/20) {
  :root { --dock-h: 0px; --side-w: clamp(320px, 32vw, 460px); }
  #app { max-width: 1680px; margin: 0 auto; }
  .dock { left: auto; width: var(--side-w); max-width: none; margin: 0; padding: 0 24px calc(24px + env(safe-area-inset-bottom)) 12px; }
  .overlay.drawer {
    left: auto; width: var(--side-w); background: var(--ink); border-left: 4px solid var(--paper);
    padding: 20px 24px calc(24px + env(safe-area-inset-bottom));
  }
  .overlay.drawer > * { max-width: none; }
  /* 这一栏本身就是框，里面不再套一层框 */
  .drawer > .box { border: 0; box-shadow: none; padding: 0; background: none; }
}

.expenses .note input { height: 44px; }

/* 「这一周」用设计系统「不打盹像素」（web/ds/，样式都在 .bd 下）；这里只补面板在抽屉里的位置和几处游戏自己的小件。 */
.overlay.drawer > .week-panel { max-width: 420px; }
.week-panel .bd-review { margin: 0; padding: 0 0 0 14px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.65; color: var(--muted); }
.week-panel .bd-note-field input { flex: 1; }
.week-panel .bd-banner { margin: 0 calc(-1 * var(--space-4)); }
.week-panel { gap: 12px; }
.week-panel .bd-band__marks { height: 24px; }
.week-panel .bd-band { gap: 4px; }
.week-band-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.week-band-foot p { margin: 0; }
.week-card-links { display: flex; gap: 16px; flex-wrap: wrap; }
.week-more { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; background: var(--bd-dash) top / 100% 2px no-repeat; }
.week-more__links { display: flex; gap: 24px; }
.week-more .wish, .week-more .videos { border-top: 0; padding-top: 0; }
@media (min-aspect-ratio: 23/20) {
  .drawer > .week-panel { border: 0; box-shadow: none; padding: 0; background: none; }
}

/* ---------- 像原生 app 的那几处（2026-11-24） ---------- */
/* 滚到头不带着后面的店一起动；面板里的按钮不等双击缩放、不弹长按菜单 */
.overlay { overscroll-behavior: contain; }
.bd button, .bd a, .bd summary { touch-action: manipulation; -webkit-touch-callout: none; }
.bd ::selection { background: var(--gold); color: var(--ink); }

/* 竖屏手机：面板贴着屏幕两边和底边，从下往上升（底部抽屉），顶上留一条看得见店 */
.sheet-host { padding: calc(16px + env(safe-area-inset-top)) 0 0; }
.sheet-host > :last-child { margin-bottom: 0; }
.sheet-host > .week-panel { max-width: 560px; border-bottom: 0; box-shadow: none; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.sheet-host > .box.week { max-width: 560px; margin-bottom: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* 面板自己滚动（外面那层不动）：顶上露出的那条店一直在，导航栏贴着面板顶边 */
.week-host { overflow: hidden; }
.week-host > .week-panel { max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-top: 0; }
.sheet-host > .week-panel { border-left: 0; border-right: 0; }

/* 导航栏：标题和「关上」一直在顶上，滑到哪都能关 */
.week-panel .bd-panel__head {
  position: sticky; top: 0; z-index: 3;
  margin: 0 calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4) var(--space-2);
  background: var(--ink); box-shadow: 0 2px 0 var(--ink-deep);
}
.week-panel .bd-panel__title:focus { outline: none; }

/* 打开：暗处淡入，面板升上来（指数缓出，220ms）；只放一次 */
@keyframes sheet-fade { from { background-color: rgba(7, 9, 18, 0); } }
@keyframes sheet-rise { from { transform: translateY(48px); opacity: 0; } }
.sheet-host.is-entering { animation: sheet-fade 220ms ease-out; }
.sheet-host.is-entering > * { animation: sheet-rise 260ms cubic-bezier(0.16, 1, 0.3, 1); }
.week-panel .bd-sheet { animation: sheet-rise 240ms cubic-bezier(0.16, 1, 0.3, 1); }
@media (prefers-reduced-motion: reduce) {
  .sheet-host.is-entering, .sheet-host.is-entering > *, .week-panel .bd-sheet { animation: none; }
}

/* 存不上时的提示：浮在面板底部，滑到哪都看得见 */
.week-toast {
  position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 4; align-self: center; margin: 0;
  padding: 8px 14px; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 20px; box-shadow: 4px 4px 0 var(--ink-deep);
}

/* 横屏和电脑：还是右边一栏，不要底部抽屉的样子 */
@media (min-aspect-ratio: 23/20) {
  .sheet-host { padding: 20px 24px calc(24px + env(safe-area-inset-bottom)); }
  .sheet-host.is-entering > * { animation-name: sheet-slide; }
  @keyframes sheet-slide { from { transform: translateX(32px); opacity: 0; } }
  .week-panel .bd-panel__head { margin: 0; padding: 0 0 var(--space-2); }
  .sheet-host > .week-panel { border: 0; }
}

/* 卡片里的按钮：用卡片标题同一套字（16px 粗体），不比标题抢眼；像素字留给标题、那条带和主按钮（2026-11-24 审核） */
.week-panel .bd-card .bd-btn { font: 700 16px/24px var(--font-sans); padding: 10px 16px; min-width: 96px; }
/* 「满两张」：还是一个按钮的样子（灰框），一看就知道是暂时点不了 */
.week-panel .bd-btn:disabled { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }
/* 还在整理：拿铁在，话说清楚什么时候好 */
.week-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 0 16px; text-align: center; }
.week-wait .bd-icon { width: 48px; height: 48px; color: var(--muted); }
.week-wait p { margin: 0; }
.week-more__links .bd-link { min-width: 44px; justify-content: center; }
