/* 30 BOOK CHALLENGE
   寸法は手本（30 MUSIC CHALLENGE の作成画面）の実測に合わせた：
   本文幅640・左右18・カード角丸12/内側12×14・選ぶボタン高さ40/破線・作るボタン高さ52/角丸14。
   色は手本の緑とライムを使わず、紙と紺インクと栞の赤で別物にしている。 */
:root {
  --paper: #f6f3ed;
  --surface: #fffefb;
  --ink: #1e2a3b;
  --ink-2: #33425a;
  --muted: #6a717e;
  --line: #e3ded4;
  --line-2: #d6cfc2;
  --accent: #d0603f;
  --accent-soft: #f6dfd6;
  --focus: #3a5683;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── ヘッダー ── */
.top { border-bottom: 1px solid var(--line); }
.top-in { max-width: 640px; margin: 0 auto; padding: 12px 18px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 16px; letter-spacing: .02em; }

/* ── 本体 ── */
.app { max-width: 640px; margin: 0 auto; padding: 16px 18px 40px; }

.intro h1 { font-size: 26px; line-height: 1.35; font-weight: 800; letter-spacing: -.01em; margin: 12px 0 10px; }
.nb { display: inline-block; }
.mark { background: linear-gradient(transparent 72%, var(--accent-soft) 72%); padding: 0 1px; }
.lead { font-size: 15px; line-height: 1.8; margin: 0 0 4px; }
.note { font-size: 13px; color: var(--muted); margin: 0; }

/* 見本（できあがりのイメージ） */
.sample { display: flex; justify-content: center; padding: 22px 0 6px; }
.sample-card {
  width: 232px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px 14px; transform: rotate(-2.5deg);
  box-shadow: 0 10px 28px rgba(30, 42, 59, .12), 0 2px 6px rgba(30, 42, 59, .06);
}
.sample-title { margin: 0 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.sample-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.sample-grid i { display: block; aspect-ratio: 1 / 1.45; border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.18); }

/* 進み具合 */
.progress { display: flex; align-items: baseline; gap: 2px; margin: 22px 0 10px; }
.progress b { font-size: 24px; font-weight: 800; }
.progress span { font-size: 13px; color: var(--muted); }
.progress .resume { margin-left: auto; font-size: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }

/* ── お題のカード ── */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; scroll-margin-top: 12px; }
.label { margin: 0; font-size: 14px; font-weight: 800; line-height: 1.5; }
.label .num { color: var(--muted); margin-right: 4px; }
.body { margin-top: 8px; }

.pick {
  width: 100%; height: 40px; border: 1px dashed var(--ink-2); border-radius: 10px; background: transparent;
  font-size: 14px; font-weight: 800; color: var(--ink);
}
.pick:hover { background: rgba(30, 42, 59, .03); }

/* 検索 */
.q, .in {
  width: 100%; height: 48px; padding: 0 14px; border: 2px solid var(--line-2); border-radius: 12px;
  background: #fff; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
.q:focus, .in:focus { border-color: var(--focus); }
.in.err { border-color: var(--accent); }
.q::-webkit-search-cancel-button { -webkit-appearance: none; }
.status { margin: 6px 2px 0; font-size: 13px; color: var(--muted); min-height: 0; }
.status:empty { display: none; }
.results { list-style: none; margin: 8px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; max-height: 372px; overflow: auto; overscroll-behavior: contain; }
.results:empty { display: none; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px; border-radius: 8px;
}
.result:hover, .result:focus-visible { background: #f3f0ea; }
.result img, .result .noimg { width: 40px; height: 58px; object-fit: cover; border-radius: 3px; flex: none; background: #ece8df; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.result .noimg.text { display: grid; place-items: center; color: #fff; font-size: 8px; font-weight: 800; line-height: 1.2; padding: 3px; text-align: center; overflow: hidden; word-break: break-all; }
.rt { display: grid; min-width: 0; }
.rt b { font-size: 15px; font-weight: 700; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rt small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row { display: flex; align-items: center; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link.muted { color: var(--muted); font-size: 13px; text-decoration: none; }
.link.strong { font-weight: 800; font-size: 15px; display: inline-block; margin-top: 4px; }

/* 手で書く */
.manual { display: grid; gap: 8px; }
.photo-row { display: flex; align-items: center; gap: 12px; }
.photo-prev { width: 44px; height: 64px; border-radius: 4px; background: #ece8df; display: grid; place-items: center; overflow: hidden; flex: none; border: 1px dashed var(--line-2); }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-prev span { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.3; }
.photo-acts { display: grid; gap: 4px; justify-items: start; }
.sr { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* 選んだあと */
.picked { display: flex; align-items: center; gap: 12px; }
.thumb { width: 44px; height: 64px; border-radius: 4px; object-fit: cover; flex: none; box-shadow: 0 1px 4px rgba(0,0,0,.22); background: #ece8df; }
.thumb.text { display: grid; place-items: center; color: #fff; font-size: 9px; font-weight: 800; line-height: 1.25; padding: 4px; text-align: center; overflow: hidden; word-break: break-all; }
.pm { display: grid; min-width: 0; flex: 1; }
.pm b { font-size: 15px; font-weight: 800; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pm span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm .store { font-size: 12px; color: var(--muted); text-decoration: none; margin-top: 2px; width: fit-content; }
.pm .store:hover { text-decoration: underline; }
.acts { display: grid; gap: 6px; justify-items: end; flex: none; }
.acts .link { font-weight: 800; font-size: 15px; }

/* ── 仕上げ ── */
.finish { margin-top: 18px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 800; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border-radius: 14px;
  border: 1px solid transparent; font-size: 16px; font-weight: 800; text-decoration: none;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:disabled { background: #b9bfca; cursor: default; }
.btn.ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn.small { height: 44px; font-size: 15px; border-radius: 12px; width: auto; padding: 0 18px; }
.reset { justify-self: center; margin-top: 2px; }

.foot { max-width: 640px; margin: 0 auto; padding: 0 18px 40px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ── できあがり（下から出るシート） ── */
.sheet { position: fixed; inset: 0; background: rgba(20, 26, 36, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet-in {
  width: 100%; max-width: 640px; max-height: 94vh; overflow: auto; background: var(--paper);
  border-radius: 18px 18px 0 0; padding: 14px 18px calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 12px; animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-in { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.x { width: 40px; height: 40px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #ebe6dc; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-size: 14px; font-weight: 800; display: grid; line-height: 1.3; }
.seg button small { font-size: 11px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.preview { position: relative; display: grid; place-items: center; min-height: 200px; }
.preview img { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 8px 24px rgba(30, 42, 59, .16); background: var(--surface); }
.preview img:not([src]) { visibility: hidden; }
.wait { position: absolute; margin: 0; font-size: 14px; color: var(--muted); }
.sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-row .btn { height: 46px; font-size: 14px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 10px; z-index: 30;
  width: max-content; max-width: calc(100% - 36px); box-shadow: 0 6px 18px rgba(0,0,0,.2);
}
