/* 通用：页面框、纸纹、字体类、底栏、按钮、底部面板 */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #EDE4CE; }
body { color: var(--ink); font-family: var(--font-hand); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input, textarea { font: inherit; color: inherit; }
img { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 手机宽度的页面框；桌面上居中显示 */
.app {
  position: relative;
  max-width: var(--page-max);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper) url("../assets/paper.jpg") center / cover;
  background-blend-mode: multiply;
}
.view { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.view.no-nav { padding-bottom: 0; }

/* 字体类 */
.song { font-family: var(--font-song); }
.hand { font-family: var(--font-hand); }
.latin { font-family: var(--font-latin); }
.mono { font-family: var(--font-mono); }
.cap { font-family: var(--font-latin); letter-spacing: .3em; text-transform: uppercase; }
.soft { color: var(--ink-soft); }
.rule { height: 1px; background: var(--rule); }

/* 图标按钮（44px 触控区） */
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn svg { stroke: currentColor; }

/* 底栏 */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: var(--page-max);
  padding: 0 var(--gutter) env(safe-area-inset-bottom);
  background: var(--paper); z-index: 20;
}
.tabbar.hidden { display: none; }
.tabbar-inner { height: var(--nav-h); border-top: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 6px; color: var(--ink-soft); }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.tab span { font-family: var(--font-song); font-size: 10px; letter-spacing: .3em; padding-left: .3em; }
.tab i { width: 16px; height: 2px; border-radius: 2px; }
.tab.active { color: var(--ink); }
.tab.active i { background: var(--accent-soft); }

/* 胶囊、纸卡 */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill); border: 1px solid var(--rule); background: var(--paper-card); }
.card { background: var(--paper-card); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: var(--shadow-card); }
.ruled { background: var(--paper-card) repeating-linear-gradient(transparent 0 25px, var(--paper-line) 25px 26px); background-position: 0 14px; }

/* 主按钮 */
.btn { height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--font-song); font-size: 13px; letter-spacing: .2em; padding: 0 16px 0 calc(16px + .2em); }
.btn-dark { background: var(--ink); color: var(--paper-card); }
.btn-line { border: 1px solid var(--rule); }
.btn[disabled] { opacity: .45; cursor: default; }

/* 开关 */
.switch { width: 44px; height: 26px; border-radius: var(--r-pill); background: #E2D6BE; position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper-card); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--accent-soft); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* 底部面板 */
.sheet-mask { position: fixed; inset: 0; background: rgba(74, 64, 56, .28); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet-mask.show { opacity: 1; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%);
  width: 100%; max-width: var(--page-max); max-height: 88vh; overflow-y: auto;
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  background: var(--paper-card) url("../assets/paper.jpg") center / cover; background-blend-mode: multiply;
  border-radius: 26px 26px 0 0; box-shadow: var(--shadow-sheet); z-index: 41;
  transition: transform .26s cubic-bezier(.3, .7, .3, 1);
  display: flex; flex-direction: column; gap: 14px;
}
.sheet.show { transform: translate(-50%, 0); }
.sheet > * { flex-shrink: 0; }   /* 内容多时面板整体滚动，不压扁里面的块 */
.sheet-handle { align-self: center; width: 40px; height: 4px; border-radius: 4px; background: #E0D2B6; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; }
.sheet-title { font-family: var(--font-song); font-size: 18px; letter-spacing: .25em; }
.sheet-label { font-family: var(--font-song); font-size: 11px; letter-spacing: .3em; color: var(--ink-soft); }
.sheet-box { border: 1px solid var(--rule); border-radius: var(--r-md); background: rgba(251, 245, 230, .7); overflow: hidden; }
.sheet-row { min-height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 14px; width: 100%; }
.sheet-row + .sheet-row { border-top: 1px solid #EDE2CC; }

/* 轻提示 */
.toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: var(--r-pill); background: rgba(90, 80, 72, .92); color: var(--paper-card);
  font-family: var(--font-hand); font-size: 14px; z-index: 60; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }
