:root {
  --paper: #F5EFE4;
  --card: #FFFCF6;
  --ink: #2B3A55;
  --ink-soft: #5C6A80;
  --line: #E4DACA;
  --ribbon: #C2553D;
  --moss: #6F8A5B;
  --gold: #C89B3C;
  --shadow: 0 1px 0 rgba(43, 58, 85, .05), 0 6px 18px -10px rgba(43, 58, 85, .25);
  --r: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.7 'Zen Kaku Gothic New', system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 32px);
  background-image: radial-gradient(rgba(43,58,85,.035) 1px, transparent 1px);
  background-size: 18px 18px;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
main { max-width: 560px; margin: 0 auto; padding: 0 16px; }

.top { max-width: 560px; margin: 0 auto; padding: 18px 16px 8px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 34px; height: 34px; }
h1 { font: 700 19px/1.2 'Shippori Mincho', serif; margin: 0; letter-spacing: .04em; }
.top p { margin: 0; font-size: 12px; color: var(--ink-soft); }
.top-actions { display: flex; gap: 2px; }
.icon-btn { width: 42px; height: 42px; border: 0; background: transparent; border-radius: 50%; color: var(--ink-soft); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { background: rgba(43,58,85,.07); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin: 14px 0; }
.label { font-size: 12px; color: var(--ink-soft); letter-spacing: .08em; margin: 0 0 8px; }

/* uniform option buttons */
.options { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 8px; margin-bottom: 18px; }
.opt { height: 48px; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; font-weight: 500; transition: border-color .15s, background .15s; }
.opt[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.btn { height: 50px; border-radius: 12px; border: 0; font-weight: 700; padding: 0 20px; }
.btn.primary { background: var(--ribbon); color: #fff; width: 100%; box-shadow: 0 6px 14px -8px var(--ribbon); }
.btn.primary:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--ink-soft); }

/* theme header */
.theme { padding: 22px 18px 18px; position: relative; overflow: hidden; }
.theme::after { content: ''; position: absolute; right: 22px; top: -2px; width: 18px; height: 46px; background: var(--ribbon); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); }
.field-chip { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 99px; background: #EFE6D6; color: var(--ink); margin-right: 6px; }
.field-chip.explore { background: #E3EBDC; color: #44603A; }
.theme h2 { font: 700 24px/1.45 'Shippori Mincho', serif; margin: 10px 40px 8px 0; }
.theme p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.progress { margin-top: 16px; height: 6px; background: #EFE6D6; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--moss); border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.progress-text { font-size: 12px; color: var(--ink-soft); margin-top: 6px; text-align: right; }

/* lineup */
.lineup { list-style: none; margin: 0; padding: 0; position: relative; }
.lineup::before { content: ''; position: absolute; left: 21px; top: 24px; bottom: 24px; border-left: 2px dotted var(--line); }
.step { position: relative; padding-left: 52px; margin: 0 0 12px; }
.check { position: absolute; left: 4px; top: 18px; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); display: grid; place-items: center; color: transparent; transition: all .2s; }
.check svg { width: 20px; height: 20px; }
.step.done .check { background: var(--moss); border-color: var(--moss); color: #fff; animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.18); } }
.item { margin: 0; padding: 14px 16px; }
.step.done .item { background: #FAF8F2; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.meta svg { width: 18px; height: 18px; color: var(--ink); }
.role { font-weight: 700; color: var(--ribbon); }
.item h3 { font-size: 15.5px; line-height: 1.55; margin: 6px 0 4px; font-weight: 700; }
.item .by { font-size: 12.5px; color: var(--ink-soft); margin: 0; }
.item .why { font-size: 13.5px; margin: 8px 0 0; padding-left: 10px; border-left: 3px solid #EFE6D6; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px; background: #EFE6D6; color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.link svg { width: 15px; height: 15px; }
.link.sub { background: transparent; border: 1px solid var(--line); }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 13px; color: var(--ink-soft); }
.tool svg { width: 16px; height: 16px; }
.tool[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: #fff; font-weight: 700; }
.step.seen .item { opacity: .62; }
.step.seen .check { border-style: dashed; }
.seen-tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: #E8E2D6; color: var(--ink-soft); }
.view-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 4px; }
.view-head h2 { font: 700 20px 'Shippori Mincho', serif; margin: 0; }
.back { background: none; border: 0; color: var(--ink-soft); font-size: 14px; padding: 8px 0; }
.stock-item .sub { font-size: 12px; color: var(--ink-soft); margin: 2px 0 0; }
.stock-item .memo { font-size: 13.5px; margin: 8px 0 0; padding-left: 10px; border-left: 3px solid #EFE6D6; }
.empty { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 28px 8px; }
.rate { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.rate .options { margin-bottom: 8px; }
.rate .opt { height: 40px; font-size: 13.5px; }
.note-input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; font-size: 14px; resize: vertical; }
.reflect h3 { font: 600 17px/1.6 'Shippori Mincho', serif; }

.tomorrow .options { margin: 0; }
.redo { display: block; margin: 8px auto 0; background: none; border: 0; color: var(--ink-soft); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 8px; }
.notice { font-size: 13px; background: #FBF1DC; border: 1px solid #EBD7A8; border-radius: 10px; padding: 10px 12px; margin: 14px 0; }

/* history */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.history li:last-child { border-bottom: 0; }
.history .d { color: var(--ink-soft); white-space: nowrap; }
.history .t { flex: 1; }
.history .n { color: var(--moss); white-space: nowrap; font-weight: 700; }

/* loading */
.loading { text-align: center; padding: 48px 18px; }
.book { width: 84px; height: 60px; margin: 0 auto 18px; position: relative; perspective: 300px; }
.book span { position: absolute; top: 0; width: 42px; height: 60px; background: var(--card); border: 1.8px solid var(--ink); }
.book .l { left: 0; border-radius: 6px 0 0 6px; }
.book .r { right: 0; border-radius: 0 6px 6px 0; }
.book .p { right: 0; border-radius: 0 6px 6px 0; transform-origin: left center; animation: flip 1.6s ease-in-out infinite; background: #FBF7F0; }
@keyframes flip { 0%, 15% { transform: rotateY(0); } 60%, 100% { transform: rotateY(-180deg); } }
.loading p { color: var(--ink-soft); font-size: 14px; margin: 0; }

/* settings */
dialog { border: 0; padding: 0; background: transparent; width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0; }
dialog::backdrop { background: rgba(43, 58, 85, .35); }
.sheet { background: var(--card); border-radius: 20px 20px 0 0; padding: 22px 16px 0; max-height: 92vh; overflow: auto; }
.sheet h2 { font: 700 19px 'Shippori Mincho', serif; margin: 0 0 12px; }
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field textarea, .add input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; font-size: 15px; }
.chips { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { display: inline-flex; align-items: center; gap: 4px; background: #EFE6D6; border-radius: 99px; padding: 3px 4px 3px 12px; font-size: 13px; }
.chips button { width: 26px; height: 26px; border: 0; background: transparent; border-radius: 50%; color: var(--ink-soft); font-size: 15px; line-height: 1; }
.add { display: flex; gap: 8px; }
.add button { flex: none; height: 44px; padding: 0 16px; border-radius: 10px; border: 1.5px solid var(--ink); background: #fff; font-weight: 700; }
.sheet-actions { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--card); padding: 10px 0 calc(env(safe-area-inset-bottom) + 18px); border-top: 1px solid var(--line); }
.sheet-actions .btn { flex: 1; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .3s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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