:root {
  --paper: #edf0f3;
  --card: #fbfcfd;
  --ink: #17233b;
  --sub: #5a667d;
  --rule: #c9d2de;
  --rule-soft: #e1e6ed;
  --shu: #c23b22;
  --marker: #fbe86a;
  --marker-ink: #17233b;
  --real: #3f6b4e;
  --heart: #9a4e6e;
  --vision: #a86d12;
  --lock: rgba(237, 240, 243, .82);
  --shadow: 0 1px 0 rgba(23, 35, 59, .06), 0 8px 24px -12px rgba(23, 35, 59, .25);
  --display: 'Shippori Mincho B1', 'Hiragino Mincho ProN', serif;
  --body: 'BIZ UDPGothic', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --num: 'BIZ UDGothic', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10161f; --card: #182130; --ink: #e6eaf0; --sub: #9aa6b8; --rule: #2c384a; --rule-soft: #222c3c;
    --shu: #e0573c; --marker: #6b5e12; --marker-ink: #fff6c2; --real: #7fb592; --heart: #d58fae; --vision: #e2a849;
    --lock: rgba(16, 22, 31, .85); --shadow: 0 8px 24px -12px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10161f; --card: #182130; --ink: #e6eaf0; --sub: #9aa6b8; --rule: #2c384a; --rule-soft: #222c3c;
  --shu: #e0573c; --marker: #6b5e12; --marker-ink: #fff6c2; --real: #7fb592; --heart: #d58fae; --vision: #e2a849;
  --lock: rgba(16, 22, 31, .85); --shadow: 0 8px 24px -12px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.75 var(--body); }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--vision); outline-offset: 2px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.35; margin: 0; letter-spacing: .02em; }
p { margin: 0 0 .8em; }
.sub { color: var(--sub); font-size: 14px; }
.num { font-family: var(--num); }

/* ── header ── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }
.brand { font-family: var(--display); font-weight: 800; font-size: 18px; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .seal { width: 26px; height: 26px; border: 2px solid var(--shu); color: var(--shu); border-radius: 50%; display: grid; place-items: center; font-size: 12px; transform: rotate(-8deg); }
.badge { font: 700 11px/1 var(--num); letter-spacing: .08em; padding: 5px 8px; border-radius: 4px; border: 1px solid var(--ink); }
.badge.pro { background: var(--ink); color: var(--card); }

/* ── tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 4px; font: 700 15px var(--body); color: var(--sub); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* ── form ── */
.card { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 18px 16px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label, .lbl { font-size: 13px; font-weight: 700; color: var(--sub); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-name { display: grid; grid-template-columns: 1fr 88px; gap: 8px; }
input, select, textarea { font: 16px var(--body); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 10px 10px; width: 100%; min-width: 0; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; }
.big-date { font: 700 22px var(--num); letter-spacing: .04em; }
details.more { border-top: 1px dashed var(--rule); margin-top: 6px; padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: '＋'; font-family: var(--num); }
details.more[open] summary::after { content: '－'; }
.fieldset-title { font: 800 14px var(--display); margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--rule-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 16px var(--body); padding: 13px 20px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--card); cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { font-size: 14px; padding: 8px 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.error { color: var(--shu); font-weight: 700; font-size: 14px; }
.lock-note { font-size: 13px; color: var(--sub); background: var(--paper); border-radius: 6px; padding: 8px 10px; margin: 8px 0 0; }

/* ── カンペ(結果) ── */
.kanpe { position: relative; margin-top: 22px; background: var(--card); border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.kanpe-head { position: relative; padding: 18px 16px 16px; padding-right: 128px; border-bottom: 2px solid var(--ink); min-height: 132px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule-soft) 31px 32px); }
.kanpe-meta { font: 12px var(--num); color: var(--sub); letter-spacing: .06em; }
.kanpe-name { font-family: var(--display); font-weight: 800; font-size: 26px; margin: 2px 0 4px; }
.kanpe-tag { font-weight: 700; }
.grp { display: inline-block; font: 700 12px var(--body); padding: 2px 8px; border-radius: 99px; color: var(--card); vertical-align: middle; }
.grp.real { background: var(--real); } .grp.heart { background: var(--heart); } .grp.vision { background: var(--vision); }

/* 判子(シグネチャー) */
.stamp { position: absolute; right: 16px; top: 16px; width: 100px; height: 100px; border-radius: 50%; border: 4px double var(--shu); color: var(--shu);
  display: grid; place-items: center; transform: rotate(-9deg); font-family: var(--display); font-weight: 800; text-align: center; mix-blend-mode: multiply; }
:root[data-theme="dark"] .stamp { mix-blend-mode: normal; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stamp { mix-blend-mode: normal; } }
.stamp-inner { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.stamp-animal { writing-mode: vertical-rl; font-size: 26px; letter-spacing: .02em; line-height: 1; }
.stamp-animal.len3 { font-size: 20px; } .stamp-animal.len4 { font-size: 16px; }
.stamp-no { font: 700 10px var(--num); margin-top: 2px; letter-spacing: .05em; }
.stamp.in { animation: stamp .42s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes stamp { 0% { transform: rotate(-9deg) scale(1.6); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotate(-9deg) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stamp.in { animation: none; } }

.sec { padding: 16px; border-bottom: 1px solid var(--rule-soft); }
.sec:last-child { border-bottom: 0; }
.sec h3 { font-size: 16px; margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }
.sec h3 small { font: 400 12px var(--body); color: var(--sub); }
.goal { background: var(--paper); border-left: 4px solid var(--ink); padding: 10px 12px; border-radius: 0 6px 6px 0; font-weight: 700; }
.goal .lbl { display: block; }
.words { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.words li { font-weight: 700; padding: 0 2px; background: linear-gradient(transparent 52%, var(--marker) 52%); color: var(--marker-ink); }
:root[data-theme="dark"] .words li, .dark-marker .words li { background: var(--marker); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .words li { background: var(--marker); border-radius: 3px; padding: 0 6px; } }
.ng { margin: 0; padding: 0; list-style: none; }
.ng li { padding-left: 1.4em; position: relative; margin-bottom: 4px; }
.ng li::before { content: '×'; position: absolute; left: 0; color: var(--shu); font-weight: 800; }
.dd { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* 流れ(本当に順番があるので番号を振る) */
.flow { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.flow > li { position: relative; padding: 0 0 18px 40px; counter-increment: step; }
.flow > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font: 700 13px var(--num); }
.flow > li::after { content: ''; position: absolute; left: 13px; top: 28px; bottom: 4px; border-left: 1.5px dotted var(--rule); }
.flow > li:last-child::after { display: none; }
.flow h4 { margin: 0 0 4px; font-size: 14px; color: var(--sub); }
.say { font-family: var(--display); font-weight: 600; font-size: 17px; margin: 0 0 6px; }
.say::before { content: '「'; } .say::after { content: '」'; }
.tip { font-size: 14px; color: var(--sub); margin: 0; }
.extras { margin: 8px 0 0; padding: 0; list-style: none; }
.extras li { font-size: 14px; background: var(--paper); border-radius: 6px; padding: 6px 10px; margin-top: 6px; border-left: 3px solid var(--vision); }
.qa { margin: 0; }
.qa dt { font-weight: 700; margin-top: 10px; }
.qa dt::before { content: 'Q '; font-family: var(--num); color: var(--shu); }
.qa dd { margin: 2px 0 0; padding-left: 1.4em; }
.qa .custom { font-size: 11px; font-weight: 700; border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; margin-left: 6px; color: var(--vision); }

/* 鍵のかかった部分 */
.locked { position: relative; }
.locked .blur { filter: blur(5px); user-select: none; pointer-events: none; max-height: 260px; overflow: hidden; }
.locked .gate { position: absolute; inset: 0; display: grid; place-items: center; background: var(--lock); padding: 16px; text-align: center; }
.gate h3 { font-size: 18px; margin-bottom: 6px; }
.gate ul { text-align: left; font-size: 14px; margin: 6px auto 12px; padding-left: 1.2em; max-width: 340px; }

/* カルテ */
.karte-list { list-style: none; margin: 0; padding: 0; }
.karte-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule-soft); }
.karte-list .mini-seal { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--shu); color: var(--shu); display: grid; place-items: center; font: 800 12px var(--display); transform: rotate(-8deg); text-align: center; line-height: 1.1; }
.karte-list .who { flex: 1; min-width: 0; }
.karte-list .who b { display: block; }
.karte-list .when { font: 12px var(--num); color: var(--sub); }
.empty { text-align: center; padding: 28px 12px; color: var(--sub); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; }
.foot { padding: 28px 0 40px; font-size: 12px; color: var(--sub); }
.foot a { margin-right: 12px; }
.hidden { display: none !important; }

@media (max-width: 520px) {
  .row { grid-template-columns: 1fr; gap: 0; }
  .dd { grid-template-columns: 1fr; }
  .kanpe-head { padding-right: 16px; padding-top: 112px; }
  .stamp { width: 88px; height: 88px; }
  .stamp-animal { font-size: 22px; } .stamp-animal.len3 { font-size: 17px; } .stamp-animal.len4 { font-size: 14px; }
}

@media print {
  body { background: #fff; }
  .top, .tabs, #form-card, .actions, .foot, .toast { display: none !important; }
  .kanpe { box-shadow: none; border: 0; }
}
