/* Croqui — 配色とサイズ */

/*
 * 既定はライト。ほぼ白の地に、ふちの無い薄いグレーのカードを置く。
 * 押してほしいものは「黒いピル」で示し、色は小さい要素にだけ差す。
 * 色数を増やすとお題の写真の色と喧嘩するので、面はグレースケールに寄せてある。
 *
 * 書体はシステムの丸ゴシック。Web フォントを読まないのは、
 * オフラインでも同じ見た目で立ち上がってほしいから。
 */
:root, body[data-theme='light'] {
  --bg: #f7f7f5;
  --surface: #ededea;
  --surface-2: #e3e3df;
  --line: transparent;
  --line-strong: transparent;
  --text: #111111;
  --text-soft: #45443f;
  --muted: #8b8b85;
  --accent: #111111;          /* 押してほしいもの＝黒 */
  --accent-ink: #ffffff;
  --accent-soft: #e3e3df;
  --accent-dim: #c9c9c3;
  --cta-bg: #111111;
  --cta-ink: #ffffff;
  --brand: #ff6fa5;           /* ピンク。塗り */
  --brand-ink: #e03d7f;       /* ピンク。文字（白地で読める濃さ） */
  --lime: #8ed94b;            /* 黄緑。塗り */
  --lime-ink: #5a9c1e;        /* 黄緑。文字 */
  --mint: #8ed94b;
  --sun: #ffcc3d;
  --good: #4aa80c;            /* 「できた」の緑。塗りの黄緑と同系で、白地でも読める */
  --danger: #f2544b;
  --radius: 22px;
  --radius-sm: 14px;
  --pad: 18px;
  --lift: none;
  --lift-accent: none;
  --font-display: 'Special Gothic Expanded One', 'Arial Black', 'Helvetica Neue',
                  'Hiragino Maru Gothic ProN', 'Yu Gothic UI', system-ui, sans-serif;
  --font-ja: 'DotGothic16', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
}

/* 夜用。同じ設計のまま地と文字を入れ替える */
body[data-theme='dark'] {
  --bg: #000000;
  --surface: #151515;
  --surface-2: #202020;
  --text: #ffffff;
  --text-soft: #c9c9c9;
  --muted: #7e7e7e;
  --accent: #ffffff;
  --accent-ink: #000000;
  --accent-soft: #202020;
  --accent-dim: #3a3a3a;
  --cta-bg: #ffffff;
  --cta-ink: #000000;
  --brand: #ff6fa5;
  --brand-ink: #ff8ab8;       /* 黒地なので明るい方が読める */
  --lime: #a6e864;
  --lime-ink: #a6e864;
  --mint: #a6e864;
  --good: #a6e864;
}

/* claude.ai 寄りの紙っぽい配色も残してある */
body[data-theme='paper'] {
  --bg: #f5f4ee;
  --surface: #fffefb;
  --surface-2: #efeee7;
  --line: #e4e2d8;
  --line-strong: #d6d3c7;
  --text: #2b2a27;
  --text-soft: #55534d;
  --muted: #8a8880;
  --accent: #c96442;
  --accent-ink: #fffefb;
  --accent-soft: #f4e7e0;
  --accent-dim: #e0b9a8;
  --cta-bg: #c96442;
  --cta-ink: #fffefb;
  --brand: #c96442;
  --brand-ink: #c96442;
  --lime: #6f8f3a;
  --lime-ink: #55702a;
  --mint: #4f7d5e;
  --sun: #c08a2e;
  --good: #4f7d5e;
  --danger: #b3503c;
  --radius: 12px;
  --radius-sm: 9px;
  --font-display: 'Special Gothic Expanded One', 'Arial Black', 'Helvetica Neue',
                  'Hiragino Maru Gothic ProN', 'Yu Gothic UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

.icon { display: block; }
.icon-wrap { display: inline-flex; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* display を持つクラスが hidden 属性に勝ってしまうので、ここで押さえておく */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DotGothic16', -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body.in-session { overflow: hidden; }

.filter-defs { position: absolute; width: 0; height: 0; }

a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 13px; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif; }
.label { font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }

html:lang(ja) h2,
html:lang(ja) .bridge-card h2,
html:lang(ja) .sheet-inner h2,
html:lang(ja) .btn.big,
html:lang(ja) .menu-title,
html:lang(ja) .drill-name,
html:lang(ja) .bridge-meta,
html:lang(ja) .chip { font-family: var(--font-ja); }

/* ---------- 画面 ---------- */

.screen { display: none; padding: max(12px, env(safe-area-inset-top)) 0 40px; }
.screen.is-active { display: block; }
.screen:not(.session) { max-width: 640px; margin: 0 auto; padding-left: var(--pad); padding-right: var(--pad); }
.screen.center { display: none; }
.screen.center.is-active { display: flex; align-items: center; justify-content: center; min-height: 100dvh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 18px;
}
.topbar-actions { display: flex; gap: 6px; }
.brand {
  font-size: 23px; margin: 0; letter-spacing: .03em;
  font-family: var(--font-display); font-weight: 800; color: var(--text);
}
.brand.plain { font-size: 21px; font-weight: 700; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { font-size: 15px; margin: 0; color: var(--muted); font-weight: 700; letter-spacing: .04em; }

.card, .streak-card, .focus-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  padding: var(--pad);
  margin-bottom: 14px;
}

/* ---------- ホーム ---------- */

.streak-main { display: flex; align-items: baseline; gap: 8px; }
.streak-num { font-size: 44px; font-weight: 700; line-height: 1; }
.streak-unit { color: var(--muted); }
.streak-label { font-size: 11px; color: var(--muted); }
.streak-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }

.pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
  font-size: 12px; color: var(--muted);
}
.pill { background: var(--surface-2); }
.pill.done { color: #fff; background: var(--brand-ink); font-weight: 700; }

.streak-dots { display: flex; gap: 4px; margin-top: 12px; }
.dot { width: 100%; height: 6px; border-radius: 3px; background: var(--surface-2); }
.dot.on { background: var(--brand); }
.streak-flame { filter: saturate(.85); }

/* 押せないものはカードにしない。カードだらけだとどれがボタンか分からなくなる */
.focus-card {
  background: none; border: none; box-shadow: none;
  padding: 4px 4px 12px; margin-bottom: 10px;
}
.focus-title { font-size: 19px; font-weight: 700; margin-top: 2px; font-family: var(--font-display); }
.focus-title.small-title { font-size: 17px; }
.focus-desc { margin: 6px 0 0; font-size: 14px; }

.badge {
  font-size: 12px; color: var(--accent-ink); background: var(--accent);
  border-radius: 999px; padding: 3px 11px; font-weight: 700;
}

.menu-card {
  display: block; width: 100%; text-align: left;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--lift);
  padding: 14px var(--pad); margin-bottom: 12px;
  font: inherit; cursor: pointer;
  transition: border-color .15s, transform .06s, box-shadow .06s;
}
.menu-card:hover { border-color: var(--accent-dim); }
.menu-card:active { transform: translateY(3px); box-shadow: none; }
.menu-title { font-size: 18px; font-weight: 800; font-family: var(--font-display); letter-spacing: .02em; }
.menu-sub { font-size: 13px; margin-top: 2px; }
.menu-steps { margin-top: 6px; }
.menu-time { margin-top: 8px; font-size: 13px; color: var(--brand-ink); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-soft);
  border-radius: 999px; padding: 7px 15px; font: inherit; font-size: 14px; cursor: pointer;
  box-shadow: var(--lift); transition: transform .06s, box-shadow .06s;
}
.chip:active { transform: translateY(2px); box-shadow: none; }
.chip.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700;
  box-shadow: var(--lift-accent);
}
.chip.locked { opacity: .4; cursor: not-allowed; }

.home-footer { text-align: center; margin-top: 20px; }

/* ---------- ボタン ---------- */

.btn {
  font: inherit; font-weight: 600; border-radius: 999px; padding: 11px 20px; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  box-shadow: var(--lift); transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-weight: 700; box-shadow: var(--lift-accent);
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
.btn.small { padding: 6px 12px; font-size: 14px; }

.icon-btn {
  background: var(--surface); border: none; color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.92); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.input {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.note {
  width: 100%; font: inherit; padding: 12px; border-radius: 10px; resize: vertical;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}

/* ---------- セッション画面 ---------- */

.screen.session { padding: 0; }
.screen.session.is-active { display: block; }

.stage {
  position: fixed; inset: 0; background: #0b0c0f;
  display: flex; align-items: center; justify-content: center;
}
.stage-inner {
  position: relative; display: flex;
  max-width: 100%; max-height: 100dvh;
}
.ref-image {
  display: block; max-width: 100vw; max-height: 100dvh;
  object-fit: contain; transition: filter .2s;
}

.grid-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.32) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.32) 1px, transparent 1px);
  background-size: 25% 25%;
  mix-blend-mode: difference;
}

.memory-cover {
  position: absolute; inset: 0; background: #0b0c0f;
  display: flex; align-items: center; justify-content: center;
}
.memory-cover-inner { text-align: center; color: var(--muted); }

.stage-message {
  position: absolute; color: var(--muted); font-size: 14px;
  padding: 20px; text-align: center;
}

.hud-top, .hud-bottom {
  position: absolute; left: 0; right: 0; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(11,12,15,.85), transparent);
}
.hud-top { top: 0; padding-top: max(10px, env(safe-area-inset-top)); justify-content: space-between; }
.hud-bottom {
  bottom: 0; flex-direction: column;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(11,12,15,.85), transparent);
}

.hud-center { text-align: center; }
.drill-name { font-size: 15px; font-weight: 600; }
.drill-progress { font-size: 12px; }

.hud-cue {
  position: absolute; top: 64px; left: 0; right: 0;
  text-align: center; pointer-events: none;
}
.hud-cue p {
  display: inline-block; margin: 0; max-width: min(90%, 520px);
  background: rgba(11,12,15,.7); color: #e6e8ee;
  padding: 6px 14px; border-radius: 999px; font-size: 13px;
}

.timebar { width: 100%; height: 4px; background: rgba(255,255,255,.14); border-radius: 2px; overflow: hidden; }
.timebar-fill {
  height: 100%; background: var(--accent);
  transform-origin: left; transform: scaleX(0);
}

.hud-controls { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 12px; }
.tool-btn {
  background: rgba(255,255,255,.08); border: none; color: var(--text);
  width: 42px; height: 42px; border-radius: 50%; font-size: 17px; cursor: pointer;
}
.round-btn {
  background: var(--accent); border: none; color: var(--accent-ink);
  width: 60px; height: 60px; border-radius: 50%; font-size: 22px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3); transition: transform .06s, box-shadow .06s;
}
.round-btn:active { transform: translateY(3px); box-shadow: none; }
.time-left {
  background: transparent; border: none; color: var(--text);
  font-size: 26px; font-variant-numeric: tabular-nums; min-width: 66px; cursor: pointer;
}

.attr-box {
  position: absolute; right: 12px; top: 58px;
  background: rgba(11,12,15,.9); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted);
  max-width: 70vw;
}

/* ---------- ドリル説明 ---------- */

.bridge-card {
  max-width: 460px; width: 100%; padding: var(--pad);
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.bridge-card h2 { font-size: 27px; margin: 0; font-family: var(--font-display); font-weight: 600; }
.cue-text {
  background: var(--surface); border: 1px solid var(--accent-dim);
  border-radius: var(--radius); padding: 12px; margin: 4px 0; color: var(--accent);
}
.bridge-cue {
  font-size: 17px; font-weight: 700; font-family: var(--font-ja);
  color: var(--text-soft); margin: 0; line-height: 1.7;
}
.bridge-meta { margin-bottom: 6px; font-size: 22px; font-weight: 800; font-family: var(--font-ja); color: var(--text); }

/* ---------- ふりかえり ---------- */

.review-summary { text-align: center; }
.review-big { font-size: 46px; font-weight: 900; line-height: 1.1; font-family: var(--font-display); letter-spacing: .02em; font-stretch: expanded; }
.review-big span { font-size: 18px; color: var(--muted); margin-left: 4px; }
.review-drills { list-style: none; padding: 0; margin: 12px 0; }
.review-drills li {
  display: flex; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}

.rating-row { display: flex; gap: 8px; margin: 12px 0; }
.rate-btn {
  flex: 1; font: inherit; font-size: 13px; padding: 12px 6px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--muted);
}
.rate-btn.on { border-color: var(--accent); color: var(--accent); }

.drawing-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px; margin-top: 10px;
}
.strip-item {
  aspect-ratio: 1; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fffdf8;
}
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-item:active { opacity: .6; }

/* ---------- ホームの上段（ストリーク・XP・クエスト・バッジ） ---------- */

.hero { background: var(--surface); }
.streak-num { font-family: var(--font-display); font-weight: 900; letter-spacing: .02em; }
.level-chip { font-family: var(--font-display); color: var(--brand); }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.streak-flame { font-size: 26px; }
.streak-num { font-size: 46px; font-stretch: expanded; }

.level-chip {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2;
  font-weight: 700; color: var(--brand-ink); font-family: var(--font-display);
}

.xp-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.xp-track {
  flex: 1; height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
}
.xp-fill {
  height: 100%; width: 0;
  background: var(--brand);
  transition: width .6s cubic-bezier(.2, .8, .3, 1);
}

/* 獲得したときのお祝い */
.celebrate {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%);
  z-index: 70; text-align: center; pointer-events: none;
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--lift-accent);
  padding: 18px 26px; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1);
}
.celebrate .big { font-size: 40px; }
.celebrate .title { font-weight: 700; margin-top: 4px; }
@keyframes pop {
  0% { transform: translateX(-50%) scale(.6); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* いちばん押してほしいものだけ大きく、残りは静かに */
.primary-card {
  position: relative; background: var(--surface); color: var(--text);
  border: none; padding: 20px var(--pad); overflow: hidden;
}
.primary-card .btn.primary { margin-top: 14px; }
/* ピンクは小さく差すだけ。面は塗らない */
.primary-card .menu-kicker { font-size: 12px; letter-spacing: .06em; color: var(--brand-ink); font-weight: 700; }
.primary-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.done-badge {
  display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--good);
}
.done-badge .done-check {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--good); color: #fff; font-size: 12px; font-weight: 700;
}
.primary-card .menu-title.big { color: var(--text); }
.primary-card .menu-title.big { font-size: 32px; font-weight: 900; line-height: 1.2; font-family: var(--font-display); letter-spacing: .04em; }
.primary-card .menu-sub { color: var(--text-soft); font-size: 14px; }

.menu-card.slim {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 12px var(--pad); margin-bottom: 8px;
}
.menu-card.slim .menu-title { font-size: 15px; font-weight: 600; }
.menu-card.slim .menu-time { margin-top: 0; font-size: 12px; }

/* 理屈は読みたい人だけ開く */
.why { margin-top: 10px; }
.why > summary {
  cursor: pointer; font-size: 13px; color: var(--muted);
  list-style: none; padding: 6px 0;
}
.why > summary::-webkit-details-marker { display: none; }
.why > summary::before { content: '＋ '; }
.why[open] > summary::before { content: '− '; }
.why > p, .why > div { font-size: 13px; color: var(--text-soft); margin: 4px 0 0; }
.bridge-card .why { text-align: left; }

/* ---------- 描くところ ---------- */

/*
 * 上の帯にタイマーを真ん中で置き、その下を「左＝お題／右＝キャンバス」に割る。
 * 狭い画面では左を畳んで、お題は小窓（ref-mini）に退避する。
 * 手順は右上に置いて、写真の邪魔になったら畳めるようにしてある。
 */
.pad-wrap {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; background: #fffdf8;
}
.pad-body { flex: 1; display: flex; min-height: 0; }
.pad-ref { display: none; }
.pad-canvas { position: relative; flex: 1; min-width: 0; display: flex; }
.pad { flex: 1; width: 100%; touch-action: none; cursor: crosshair; }

/* 左上のお題。押すと大きくなる（狭い画面用） */
.ref-mini {
  position: absolute; left: 10px; top: 10px;
  width: 132px; height: 168px; padding: 0; overflow: hidden; cursor: pointer;
  border: 2px solid #2b2a27; border-radius: 12px; background: #e9e6dd;
  transition: width .18s ease, height .18s ease;
}
.ref-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-mini.big { width: min(92vw, 460px); height: min(80vh, 620px); }
.ref-mini.big img { object-fit: contain; background: #14130f; }

/* 上帯。タイマーが真ん中 */
.pad-hud {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: max(6px, env(safe-area-inset-top)) 12px 6px;
  background: rgba(255, 253, 248, .96); border-bottom: 1px solid #e2ded1;
  color: #2b2a27;
}
.pad-hud-right { text-align: right; line-height: 1.15; grid-column: 3; justify-self: end; }
.pad-hud-right { position: absolute; right: 12px; }
.pad-drill { font-size: 12px; font-weight: 700; display: block; white-space: nowrap; }
.pad-icon {
  background: none; border: none; color: #2b2a27; cursor: pointer;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
}
.pad-time {
  grid-column: 2; justify-self: center;
  background: none; border: none; color: #2b2a27; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 72px;
}
.pad-time-num { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pad-time-unit { font-size: 10px; color: #8b8b85; margin-top: 2px; }
.pad-time.paused .pad-time-num { color: #b3503c; }
.pad-time.paused .pad-time-unit::after { content: '…'; }

.pad-timebar { position: relative; height: 4px; background: #e2ded1; pointer-events: none; }
.pad-timebar-fill {
  height: 100%; width: 100%; background: var(--brand);
  transform-origin: right; transform: scaleX(1);
}

/* 手順ヒント。閉じられる */
.pad-hint { position: absolute; right: 10px; top: 10px; z-index: 3; text-align: right; }
.hint-toggle {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  background: rgba(255, 253, 248, .94); color: #55534d;
  border: 1px solid #ddd8c9; border-radius: 999px; padding: 4px 12px;
}
.hint-toggle i { font-style: normal; }
.hint-toggle i::after { content: ' ＋'; }
.pad-hint.open .hint-toggle i::after { content: ' −'; }
.pad-steps {
  display: none; margin: 6px 0 0;
  padding: 10px 14px 10px 30px; max-width: min(70vw, 300px);
  list-style: decimal; color: #55534d; font-size: 13px; line-height: 1.7; text-align: left;
  background: rgba(255, 253, 248, .94); border: 1px solid #e2ded1; border-radius: 12px;
}
.pad-hint.open .pad-steps { display: block; }
.pad-steps li::marker { color: var(--brand-ink); font-weight: 700; }

.pad-tools {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: #f1eee5; border-top: 1px solid #ddd8c9;
}
.pad-btn, .pad-size {
  background: #fffdf8; border: 1px solid #cfcabb; color: #2b2a27;
  width: 42px; height: 38px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pad-btn.on { background: #2b2a27; border-color: #2b2a27; color: #fffdf8; }
.pad-sizes { display: flex; gap: 4px; }
.pad-size { width: 32px; }
.pad-size i { display: block; background: #2b2a27; border-radius: 50%; }
.pad-size.on { border-color: #2b2a27; border-width: 2px; }

/* 線の濃さ。左の丸が、いまの濃さそのままの色で出る */
.pad-alpha {
  display: flex; align-items: center; gap: 6px;
  background: #fffdf8; border: 1px solid #cfcabb; border-radius: 10px;
  height: 38px; padding: 0 10px; cursor: pointer;
}
.pad-alpha-mark {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: #2b2a27; opacity: var(--a, 1);
}
.pad-alpha input[type="range"] { width: 74px; accent-color: #2b2a27; }
.pad-alpha-num {
  width: 38px; font: inherit; font-size: 12px; font-weight: 700; text-align: center;
  background: transparent; border: none; color: #2b2a27; padding: 0;
  -moz-appearance: textfield;
}
.pad-alpha-num::-webkit-inner-spin-button,
.pad-alpha-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* 1枚描き終えたことを、はっきり押せる場所にする */
.pad-next {
  display: flex; align-items: center; gap: 6px;
  background: #2b2a27; color: #fffdf8; border: none;
  font: inherit; font-size: 14px; font-weight: 700;
  padding: 0 16px; height: 38px; border-radius: 999px; cursor: pointer;
}
.pad-next:active { transform: translateY(1px); }

/*
 * 広い画面では、お題を小窓に閉じ込める理由が無い。
 * 左半分に写真、右半分にキャンバス。小窓は消す。
 */
@media (min-width: 900px) {
  .pad-ref {
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 46%; background: #14130f; padding: 12px; min-width: 0;
  }
  .pad-ref img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
  .ref-mini { display: none; }
}

/* ---------- カレンダー ---------- */

.cal-dow, .calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { margin-bottom: 6px; }
.cal-dow span { text-align: center; font-size: 11px; color: var(--muted); }

.cal-cell {
  position: relative; aspect-ratio: 1; padding: 0; cursor: pointer;
  border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
  font: inherit; color: var(--muted);
}
.cal-cell.empty { border: none; background: transparent; cursor: default; }
.cal-cell.today { border-color: var(--accent); border-width: 2px; }
.cal-cell.has-drawing { border-color: var(--accent-dim); }
.cal-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cal-num { position: absolute; top: 3px; left: 5px; font-size: 11px; z-index: 1; }
.cal-cell.has-drawing .cal-num,
.cal-cell.filled .cal-num { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.cal-cell.filled { background: var(--accent); }
.cal-cell.l1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface-2)); }
.cal-cell.l2 { background: color-mix(in srgb, var(--accent) 50%, var(--surface-2)); }
.cal-cell.l3 { background: color-mix(in srgb, var(--accent) 75%, var(--surface-2)); }
.cal-cell.l4 { background: var(--accent); }
.cal-dot { position: absolute; bottom: 4px; right: 5px; font-size: 10px; }

/* 下から出るシート */
.sheet {
  position: fixed; inset: 0; z-index: 65; background: rgba(30, 20, 25, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-inner {
  position: relative; width: 100%; max-width: 640px; max-height: 85dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: var(--pad) var(--pad) max(24px, env(safe-area-inset-bottom));
  animation: slide-up .25s ease-out;
}
.sheet-inner h2 { margin: 4px 0 12px; font-size: 20px; }
.sheet-close { position: absolute; top: 8px; right: 8px; }
.sheet-image { width: 100%; border-radius: var(--radius-sm); margin-bottom: 12px; }
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 復習 ---------- */

.review-card { background: var(--surface); }
.good-badge { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }

.reminder-text {
  margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 35%, transparent);
  color: var(--good);
}

.card-badge {
  display: block; margin-top: 4px; font-size: 11px; color: var(--danger);
}

/* ---------- 解剖レッスン ---------- */

.lesson-problem { font-size: 14px; margin: 8px 0 0; }

.lesson-steps { display: flex; flex-direction: column; gap: 16px; }
.lesson-step h3 { font-size: 15px; margin: 0 0 4px; color: var(--accent); }
.lesson-step p { margin: 0; font-size: 14px; color: var(--text-soft); }

.tick-list { list-style: none; padding: 0; margin: 10px 0 0; }
.tick-list li {
  position: relative; padding-left: 18px; margin-bottom: 8px; font-size: 14px; color: var(--text-soft);
}
.tick-list li::before { content: '—'; position: absolute; left: 0; color: var(--muted); }

.mistake-list { display: flex; flex-direction: column; gap: 12px; }
.mistake-bad { font-size: 14px; color: var(--danger); }
.mistake-fix { font-size: 14px; color: var(--good); padding-left: 16px; }

.plate-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; margin: 12px 0;
}
.plate-thumb {
  padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #f4f2ee; cursor: pointer; aspect-ratio: 1;
}
/* 図版は切り取ると意味が消えるので cover ではなく contain */
.plate-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.books { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.books p { margin: 4px 0; }

/* 下に貼り付くボタン。半透明にすると裏の文章が透けて読めなくなるので不透明にする */
.sticky-cta {
  position: sticky; bottom: 0; z-index: 5;
  margin: 0 calc(var(--pad) * -1);
  padding: 12px var(--pad) max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(8,9,12,.96);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 78vh; object-fit: contain; background: #f4f2ee; border-radius: 8px; }
.lightbox-close { position: absolute; top: 12px; right: 12px; font-size: 24px; }
.lightbox-caption { text-align: center; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

.check-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.check-btn {
  width: 100%; text-align: left; font: inherit; font-size: 14px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; color: var(--muted);
}
.check-btn::before { content: '□ '; }
.check-btn.on { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.check-btn.on::before { content: '☑ '; }

.todo { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.todo-item { font-size: 13px; color: var(--text-soft); }

/* ---------- 公開／非公開トグル ---------- */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; font-size: 15px; font-weight: 600;
}
.toggle-row input[type="checkbox"] { display: none; }
.toggle-track {
  position: relative; width: 44px; height: 26px; flex-shrink: 0;
  background: var(--surface-2); border-radius: 13px; transition: background .2s;
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.toggle-row input:checked + .toggle-track { background: var(--accent); }
.toggle-row input:checked + .toggle-track::after { transform: translateX(18px); }
#publish-note { margin-top: 6px; }

/* ---------- 記録 ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { text-align: center; }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--muted); }

.bar-row { display: grid; grid-template-columns: 118px 1fr 56px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 10px; overflow: hidden; }
.bar { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-value { text-align: right; }

.note-list { display: flex; flex-direction: column; gap: 12px; }
.note-item { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-date { font-size: 13px; font-weight: 600; }
.note-body { margin: 6px 0 0; font-size: 14px; }
.note-thumb { width: 100%; max-width: 220px; border-radius: 8px; margin-top: 8px; display: block; }
.rate-tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.rate-tag.r3 { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }

/* ---------- 設定 ---------- */

.radios { display: flex; flex-direction: column; gap: 10px; }
.radios label, .switch { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.switch { margin: 10px 0; }
.subcard { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.theory-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.theory-item:last-child { border-bottom: none; }
.theory-item h3 { font-size: 15px; margin: 0 0 4px; }
.theory-item p { margin: 0; }
.theory-item .source { margin-top: 4px; font-style: italic; opacity: .8; }

/* ---------- トースト ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 50;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 確認ダイアログ ---------- */

.confirm-dialog {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(30, 20, 25, .5);
  display: flex; align-items: center; justify-content: center;
  animation: confirm-fade-in .15s ease-out;
}
.confirm-dialog-inner {
  background: var(--surface); border-radius: 16px;
  padding: 24px 24px 16px; width: calc(100% - 48px); max-width: 340px;
  animation: confirm-scale-in .2s ease-out;
}
.confirm-dialog-msg {
  margin: 0 0 20px; font-size: 15px; line-height: 1.6;
  word-break: break-word;
}
.confirm-dialog-actions {
  display: flex; gap: 10px; justify-content: flex-end;
}
.confirm-dialog-btn {
  padding: 8px 20px; border-radius: 999px; font-size: 14px;
  border: none; cursor: pointer; font-family: inherit;
}
.confirm-dialog-btn.cancel {
  background: var(--surface-2); color: var(--text);
}
.confirm-dialog-btn.ok {
  background: var(--cta-bg); color: var(--cta-ink);
}
@keyframes confirm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes confirm-scale-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

@media (min-width: 720px) {
  .hud-cue p { font-size: 14px; }
}

/* ---------- 下のセグメント切替 ---------- */

/*
 * left:50% だけだと使える幅が画面の半分になり、タブを3つにした途端に
 * 文字が縦に折り返した。中身の幅に合わせて、はみ出さない上限も付ける。
 */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40;
  display: none; gap: 4px; padding: 4px;
  width: max-content; max-width: calc(100vw - 24px);
  background: var(--surface); border-radius: 999px;
}
body[data-screen='home'] .tabbar,
body[data-screen='library'] .tabbar,
body[data-screen='log'] .tabbar { display: flex; }
body[data-screen='home'] #screen-home,
body[data-screen='library'] #screen-library,
body[data-screen='log'] #screen-log { padding-bottom: 90px; }

.tabbar button {
  font: inherit; font-size: 15px; font-weight: 700; font-family: var(--font-display);
  border: none; background: transparent; color: var(--muted);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  white-space: nowrap;
}
.tabbar button.on { background: var(--cta-bg); color: var(--cta-ink); }

/* ---------- 設定シート ---------- */

.setup-label { margin-top: 16px; display: block; }
#setup-start { margin-top: 20px; }
.chip.on.lime { background: var(--lime-ink); border-color: var(--lime-ink); }

/* ---------- 写真の管理 ---------- */

.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px; margin-top: 12px;
}
.lib-item {
  position: relative; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; cursor: pointer;
  border: none; border-radius: var(--radius-sm); background: var(--surface-2);
}
.lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-tags {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
  background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
  color: #fff; font-size: 10px; text-align: left; line-height: 1.4;
}

.selectable-grid .lib-item.selected {
  outline: 3px solid var(--brand); outline-offset: -3px;
}
.sb-check {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  width: 20px; height: 20px; margin: 0; cursor: pointer;
  accent-color: var(--brand);
}
.select-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 14px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.select-bar span { font-size: 14px; font-weight: 700; margin-right: auto; }

.photo-big { width: 100%; max-height: 46vh; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-2); }

.photo-history { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.attempt { flex: none; width: 120px; }
.attempt img {
  width: 120px; height: 150px; object-fit: cover; display: block;
  border-radius: var(--radius-sm); background: #fffdf8;
}
.attempt .attempt-meta { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; }
.attempt.latest .attempt-meta { color: var(--brand-ink); font-weight: 700; }


/* ---------- ブランド・言語切替 ---------- */

/* ロゴ */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600; letter-spacing: .03em;
}
.beta {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  color: var(--brand-ink); background: color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: 999px; padding: 2px 8px; font-family: system-ui, sans-serif;
}
.lang-btn {
  font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .06em; cursor: pointer;
  background: var(--surface); color: var(--text); border: none;
  height: 40px; padding: 0 14px; border-radius: 999px;
}
.lang-btn:hover { background: var(--surface-2); }

.count-pill { background: var(--surface-2); color: var(--text-soft); }

.hero-stats {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline;
}
.hero-stat-header {
  font-size: 11px; color: var(--muted); font-weight: 600;
  letter-spacing: .06em; width: 100%; margin-bottom: -4px;
}
.hero-stat {
  display: flex; align-items: baseline; gap: 2px;
}
.hero-stat-num {
  font-size: 22px; font-weight: 900; line-height: 1;
  font-family: var(--font-display); color: var(--text);
  letter-spacing: .02em; font-stretch: expanded;
}
.hero-stat-label {
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.credit-note { margin: 18px 4px 0; }

/* ---------- この1週間 ---------- */

/*
 * 時間ではなく枚数で出す。「今日は3枚描いた」のほうが、
 * 「今日は12分やった」より、次に何をすればいいかが分かりやすい。
 */
.week-block { margin-top: 16px; }
.week-bars { display: flex; gap: 6px; margin-top: 6px; }
.week-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week-box {
  width: 100%; aspect-ratio: 1; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.week-col.on .week-box {
  background: color-mix(in srgb, var(--brand) calc(var(--fill, 1) * 100%), var(--surface-2));
  color: #fff;
}
.week-col.today .week-box { }
.week-dow { font-size: 10px; color: var(--muted); }

/* ---------- デイリーの完了と、2周目の導線 ---------- */

.done-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
.done-check {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--good); color: #fff; font-size: 13px; font-weight: 700;
}
.done-text { font-weight: 700; color: var(--good); }

.free-badge {
  display: inline-block; margin-top: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--lime-ink); background: color-mix(in srgb, var(--lime) 30%, transparent);
  border-radius: 999px; padding: 3px 10px;
}
#pay-sheet h2 { font-size: 19px; }

/* モードのカードに畳んだ説明を入れる。名前だけでは分からないものがあるので */
.menu-card .why { margin-top: 8px; }
.menu-card .why > summary { padding: 2px 0; }
.menu-card .menu-sub { margin-top: 2px; }
.big-chips .chip { font-size: 16px; padding: 10px 20px; }

/* ---------- 描いた絵の並び ---------- */

.strip-item { position: relative; }
.strip-num {
  position: absolute; left: 4px; top: 2px; font-size: 11px; font-weight: 700;
  color: var(--muted);
}
.lightbox-actions { display: flex; gap: 10px; }
.sheet-preview { margin-top: 0; }
.sheet-preview img {
  width: 100%; border-radius: var(--radius-sm); background: #fffdf8; display: block;
}
.sheet-actions { margin-top: 12px; justify-content: center; }
.sheet-actions .btn {
  background: var(--text); color: var(--bg);
  border-color: var(--text); font-size: 17px; font-weight: 800;
  padding: 16px 28px; border-radius: 999px;
}

/* ---------- 解剖学の本 ---------- */

.book-tabs { margin-bottom: 12px; }
.plate-ja { font-size: 16px; font-weight: 700; color: #fff; }
.term-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.term-list .label { width: 100%; }
.term {
  font-size: 12px; color: #e6e8ee;
  background: rgba(255,255,255,.12); border-radius: 999px; padding: 2px 10px;
}

/* ---------- 管理画面 ---------- */

.lib-badge {
  position: absolute; left: 4px; top: 4px; font-size: 9px; font-weight: 700;
  background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; padding: 1px 7px;
}
.range { width: 100%; accent-color: var(--accent); margin: 6px 0 2px; }
#screen-admin .input { margin-bottom: 6px; }

/* ---------- ログイン ---------- */

.auth-btn {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--surface); color: var(--text); border: none;
  height: 40px; padding: 0 14px; border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .06em;
}
.auth-btn:hover { background: var(--surface-2); }
.auth-avatar-wrap { display: flex; }
.auth-avatar {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--brand);
}
.auth-login-label { white-space: nowrap; }

.auth-sheet-inner { text-align: center; }
.auth-sheet-inner h2 { margin-bottom: 8px; }

.auth-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.auth-provider-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px 20px; border-radius: var(--radius-sm);
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  border: none; transition: opacity .15s;
}
.auth-provider-btn:hover { opacity: .85; }
.auth-provider-icon { flex: none; }

.x-btn {
  background: #000; color: #fff;
}
body[data-theme='dark'] .x-btn {
  background: #fff; color: #000;
}
.google-btn {
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0;
}
body[data-theme='dark'] .google-btn {
  background: #131314; color: #e3e3e3;
  border-color: #5f6368;
}

.auth-user-info { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.auth-user-row {
  display: flex; align-items: center; gap: 12px;
  justify-content: center; margin-bottom: 16px;
}
.auth-info-avatar {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
}
.auth-info-name { font-weight: 700; font-size: 16px; }

/* ---------- ギャラリー ---------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.gallery-item {
  position: relative; cursor: pointer;
  aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
  border: none; padding: 0;
}
.gallery-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.gallery-item.is-mine {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.gallery-mine-badge {
  position: absolute; right: 4px; top: 4px;
  font-size: 9px; font-weight: 700;
  background: var(--brand); color: #fff;
  border-radius: 999px; padding: 1px 7px;
}
#gallery-btn {
  background: var(--surface-2); color: var(--text);
  border: none; font-weight: 700;
}
#gallery-btn:hover { background: var(--accent-dim); }
