:root {
  --paper: #f4eee2; --paper-2: #ebe3d3;
  --ink: #2d3038; --ink-2: #5a5e6a; --ink-3: #9a9da6;
  --gold: #b48f3c; --indigo: #3d4c70; --lotus: #c47f86; --ok: #4c7a5a;
  --line: rgba(45, 48, 56, .14);
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  --kai: "Kaiti SC", "KaiTi", "STKaiti", "楷体", "AR PL UKai CN", "Noto Serif CJK SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;
  font-family: var(--sans);
  color: var(--ink); background: var(--paper); color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { background: transparent; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh; position: relative; }
/* 全页背景：水墨莲池铺满视口（淡）+ 左右下角花饰，固定不随滚动 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: url("/assets/hero.webp") center / cover no-repeat; opacity: .28;
}
body::after, html::before {
  content: ""; position: fixed; bottom: 0; left: 0; z-index: -1; pointer-events: none;
  width: min(42vw, 380px); aspect-ratio: 1;
  background: url("/assets/corner.webp") left bottom / contain no-repeat; opacity: .6;
  mask-image: linear-gradient(to top right, #000 45%, transparent 85%);
  -webkit-mask-image: linear-gradient(to top right, #000 45%, transparent 85%);
}
html::before { left: auto; right: 0; transform: scaleX(-1); }
html { background: var(--paper); }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* 顶部：一条窄横幅 */
.hero {
  position: relative; z-index: 1; isolation: isolate; text-align: center;
  padding: 22px 16px 14px; min-height: 150px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.hero-art {
  position: absolute; inset: 0; z-index: -1;
  background: url("/assets/hero.webp") center 62% / cover no-repeat; opacity: .85;
  mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
}
.hero > * { text-shadow: 0 0 10px rgba(244, 238, 226, 1), 0 0 3px rgba(244, 238, 226, 1); }
.mark { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--paper); box-shadow: 0 0 0 2px rgba(244, 238, 226, .9); }
.hero h1 { font-family: var(--serif); margin: 4px 0 0; font-size: 28px; font-weight: 600; letter-spacing: .3em; text-indent: .3em; color: var(--indigo); }
.verse { font-family: var(--serif); margin: 4px 0 0; font-size: 15px; color: var(--indigo); letter-spacing: .1em; transition: opacity .6s; min-height: 1.5em; }
.verse.fade { opacity: 0; }

main { max-width: 920px; margin: 0 auto; padding: 6px 16px 40px; position: relative; z-index: 1; }
.week-title { margin: 0; text-align: center; font-size: 18px; letter-spacing: .08em; color: var(--ink-2); }
.status-line { margin: 0 0 8px; text-align: center; font-size: 12px; color: var(--ink-3); min-height: 1.3em; }

/* 一周：左侧上午/下午两行标签，右侧周一至周五五列，上下两格 */
.week {
  display: grid;
  grid-template-columns: auto repeat(5, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 8px;
}
.corner { }
.dh { text-align: center; font-size: 15px; color: var(--ink-2); padding-bottom: 2px; line-height: 1.2; }
.dh b { display: block; font-size: 20px; color: var(--ink); font-weight: 600; }
.dh.today b { color: var(--gold); }
.dh.past { color: var(--ink-3); }
.dh.past b { color: var(--ink-3); }
.rh { writing-mode: vertical-rl; text-orientation: upright; letter-spacing: .3em; font-size: 15px; color: var(--ink-2); display: flex; align-items: center; justify-content: center; padding: 0 2px; }

.cell {
  min-height: 132px; border-radius: 10px; padding: 8px 8px;
  background: #fffdf8; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; font-size: 15px;
}
.cell.s-none { background: var(--paper-2); border-color: transparent; color: var(--ink-3); align-items: center; justify-content: center; font-size: 18px; letter-spacing: .2em; text-indent: .2em; }
.cell.s-upcoming { background: rgba(255, 253, 248, .5); border-style: dashed; }
.cell.s-locked { background: rgba(61, 76, 112, .05); color: var(--ink-2); }
.cell.s-open { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(180, 143, 60, .25); }

.entry { display: flex; align-items: baseline; justify-content: center; gap: 4px; min-width: 0; text-align: center; font-family: var(--kai); border: 0; background: none; padding: 2px 2px; border-radius: 5px; color: var(--ink); line-height: 1.25; font-size: 22px; }
button.entry:hover { background: rgba(196, 127, 134, .12); }
button.entry:hover .name::after { content: " ✕"; color: var(--lotus); font-size: 11px; }
.entry .n { flex: none; color: var(--gold); font-weight: 700; font-size: .6em; }
.cell.s-locked .entry .n { color: var(--ink-3); }
.entry .name { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; font-weight: 700; }
.entry.mine .name { color: var(--indigo); }

.book { margin-top: auto; border: 1px solid var(--gold); background: #fff; color: var(--gold); border-radius: 8px; padding: 6px 0; font-size: 15px; letter-spacing: .1em; }
.book:hover { background: var(--gold); color: #fff; }
.full { margin-top: auto; text-align: center; font-size: 13px; color: var(--ink-3); }

.rules { margin: 18px 0 4px; font-size: 14px; color: var(--ink-2); text-align: center; line-height: 1.6; }
.tiny { margin: 0; text-align: center; font-size: 12px; color: var(--ink-3); }

/* 弹层 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(45, 48, 56, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: min(400px, 100%); background: var(--paper); border-radius: 12px; padding: 18px 20px 16px; border-top: 3px solid var(--gold); box-shadow: 0 8px 24px rgba(45, 48, 56, .2); }
.modal-card h3 { margin: 0 0 2px; font-size: 19px; letter-spacing: .15em; color: var(--indigo); }
.modal-slot { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }
.modal-card label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.modal-card label small { color: var(--ink-3); }
.modal-card input { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.modal-card input:focus { outline: 2px solid rgba(180, 143, 60, .5); border-color: var(--gold); }
.modal-hint { min-height: 1.4em; margin: 0 0 8px; font-size: 13px; color: #a9642f; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { padding: 8px 18px; border-radius: 8px; border: 1px solid var(--line); letter-spacing: .1em; }
.modal-actions .ghost { background: transparent; color: var(--ink-2); }
.modal-actions .primary { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.modal-actions .primary.danger { background: var(--lotus); border-color: var(--lotus); }
.modal-actions button[disabled] { opacity: .6; cursor: wait; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 30; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(45, 48, 56, .2); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--lotus); }

@media (max-width: 480px) {
  .hero { min-height: 130px; padding-top: 16px; }
  .hero h1 { font-size: 22px; }
  .verse { font-size: 12.5px; letter-spacing: .05em; }
  main { padding: 4px 6px 24px; }
  .week { gap: 4px; }
  .week-title { font-size: 15px; }
  .dh { font-size: 12px; }
  .dh b { font-size: 15px; }
  .rh { font-size: 12px; }
  .cell { min-height: 88px; padding: 5px 3px; font-size: 12px; gap: 2px; }
  .cell.s-none { font-size: 14px; }
  .entry { font-size: 18px; gap: 2px; padding: 1px 1px; justify-content: flex-start; text-align: left; }
  .entry .name { flex: 1; }
  .book { font-size: 13px; padding: 4px 0; }
  .rules { font-size: 12.5px; }
  .book { font-size: 12px; }
}
