:root {
  --bg: #f7f4f0;
  --card: #ffffff;
  --text: #2f2a33;
  --muted: #857c8a;
  --line: #e6dfe8;
  --brand: #5b3f6b;
  --brand-soft: #efe7f3;
  --accent: #b07a3c;
  --danger: #b23b3b;
  --danger-soft: #fbeaea;
  --ok: #2e7d5b;
  --ok-soft: #e5f4ec;
  --warn-soft: #fff5e0;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a20;
    --card: #28242c;
    --text: #ece6ef;
    --muted: #a99fae;
    --line: #3b3540;
    --brand: #c9a6dc;
    --brand-soft: #3a2f42;
    --accent: #e0b07a;
    --danger: #ef8a8a;
    --danger-soft: #4a2626;
    --ok: #7fd1a8;
    --ok-soft: #21392d;
    --warn-soft: #43361c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0.4em 0 0.6em; line-height: 1.4; }
h2 { font-size: 1.1rem; margin: 0 0 0.6em; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }

/* ---- ヘッダー ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #3a2a45; } }
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: 0.05em; }
.menu-btn { display: none; margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.5rem; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; opacity: 0.85; font-size: 0.95rem; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,0.18); opacity: 1; }
.nav .logout { margin-left: auto; }
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .nav { display: none; flex-basis: 100%; flex-direction: column; }
  .nav-open .nav { display: flex; }
  .nav .logout { margin-left: 0; }
}

.main { max-width: 1040px; margin: 0 auto; padding: 16px; padding-bottom: 60px; }

/* ---- 部品 ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin-bottom: 4px; }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1.3; }
.stat-num small { font-size: 0.9rem; font-weight: 400; margin-left: 4px; color: var(--muted); }
.warn { background: var(--warn-soft); }
.flash { background: var(--ok-soft); color: var(--ok); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 8px; white-space: pre-wrap; }
.message { white-space: pre-wrap; }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  min-height: 44px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #1d1a20; } }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 700; }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.chip { border: 1px solid var(--line); background: var(--brand-soft); color: var(--text); border-radius: 999px; padding: 2px 10px; font: inherit; font-size: 0.8rem; cursor: pointer; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; background: var(--brand-soft); color: var(--text); margin: 2px 2px 2px 0; }
.badge.subscribed { background: var(--ok-soft); color: var(--ok); }
.badge.unsubscribed, .badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.pending { background: var(--warn-soft); }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=number],
input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px;
}
textarea { line-height: 1.7; }
label { display: block; font-size: 0.92rem; color: var(--muted); }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }
label.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text); }
label.inline input[type=checkbox], label.inline input[type=radio] { width: auto; margin: 0; }
label.inline select { width: auto; }
input.num { width: 90px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; min-width: 0; }
fieldset[disabled] { border: 0; padding: 0; opacity: 0.85; }
legend { color: var(--muted); font-size: 0.9rem; padding: 0 4px; }
.req { color: var(--danger); font-size: 0.75rem; }

.stack > * + * { margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input[type=email], .row input[type=datetime-local] { width: auto; flex: 1; min-width: min(200px, 100%); }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; padding: 0; }
.card .table { display: block; overflow-x: auto; }
.card .table tbody { display: table; width: 100%; }
.table-wrap .table { margin: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.table tr.head-line td { color: var(--muted); font-style: italic; }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 8px; align-items: center; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters input[type=search] { grid-column: 1 / -1; } }

.contact-list { display: grid; gap: 8px; }
.contact-row { display: flex; justify-content: space-between; gap: 12px; text-decoration: none; color: var(--text); margin: 0; padding: 12px 16px; }
.contact-row:hover { border-color: var(--brand); }
.contact-main strong { margin-right: 8px; }
.contact-meta { text-align: right; max-width: 45%; }
@media (max-width: 640px) { .contact-row { flex-direction: column; } .contact-meta { text-align: left; max-width: none; } }
.tags { color: var(--muted); }

.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
.pager a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; background: var(--card); }
.pager a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.quick-btn { display: block; text-align: center; padding: 16px 8px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 600; }
.quick-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
@media (prefers-color-scheme: dark) { .quick-btn.primary { color: #1d1a20; } }
@media (max-width: 520px) { .quick { grid-template-columns: 1fr; } }

/* ---- 撮影 ---- */
.capture-form { max-width: 520px; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.segmented label { flex: 1; text-align: center; padding: 10px; color: var(--text); cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented label:has(input:checked) { background: var(--brand); color: #fff; }
.shoot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 170px; border: 2px dashed var(--brand); border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); cursor: pointer; text-align: center; padding: 16px; }
.shoot span { font-size: 1.2rem; font-weight: 700; }
.shoot input { display: none; }
.preview { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.preview img { width: calc(50% - 4px); border-radius: 8px; border: 1px solid var(--line); }

.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos img { max-width: 100%; width: 320px; border-radius: 8px; border: 1px solid var(--line); }
.confirm-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.confirm-layout .sticky { position: sticky; top: 70px; }
@media (max-width: 860px) { .confirm-layout { grid-template-columns: 1fr; } .confirm-layout .sticky { position: static; } }

.send-box { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.step summary { cursor: pointer; }
.step[open] summary { margin-bottom: 12px; }

/* ---- 読者向けページ ---- */
body.public { display: flex; flex-direction: column; min-height: 100vh; }
.public-box { width: 100%; max-width: 520px; margin: 40px auto 20px; padding: 28px 24px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
@media (max-width: 560px) { .public-box { margin: 16px; width: auto; } }
.public-brand { letter-spacing: 0.25em; color: var(--accent); font-size: 0.8rem; margin: 0 0 8px; }
.public-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 16px; margin-top: auto; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- クロードの判断 / 瓜田の判断 ---- */
.judge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.judge-grid > .card { margin-bottom: 16px; }
@media (max-width: 760px) { .judge-grid { grid-template-columns: 1fr; } .judge-grid > .card { margin-bottom: 0; } .judge-grid { margin-bottom: 16px; } }
.judge.ai { border-top: 4px solid #6b8fb5; }
.judge.mine { border-top: 4px solid var(--accent); }
.judge p { margin: 0.4em 0; }
.judge fieldset label { margin: 2px 0; }
.prio { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: var(--brand-soft); margin-right: 4px; }
.prio-A { background: #fde3dc; color: #a2401f; }
.prio-B { background: var(--warn-soft); color: #8a6414; }
.prio-C { background: var(--brand-soft); color: var(--muted); }
@media (prefers-color-scheme: dark) { .prio-A { background: #4a2a22; color: #f4a68a; } .prio-B { color: #e9c77a; } }

/* ---- やりとりの記録 ---- */
.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { position: relative; padding: 10px 0 10px 18px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.log-body { white-space: normal; margin: 4px 0; }
.next { font-size: 0.9rem; background: var(--warn-soft); border-radius: 8px; padding: 4px 8px; display: inline-flex; gap: 6px; align-items: center; }
.next.done { background: var(--ok-soft); color: var(--muted); text-decoration: line-through; }
.check { border: 0; background: none; font-size: 1.1rem; cursor: pointer; padding: 0; color: inherit; }
.inline-form { display: inline; margin-left: 8px; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.error-text { color: var(--danger); }
details > summary { cursor: pointer; }

/* ---- ご案内・見本 ---- */
.invite .row { margin-top: 8px; }
.invite-body { white-space: pre-wrap; font-family: inherit; font-size: 0.9rem; background: var(--bg); padding: 12px; border-radius: 8px; margin: 8px 0; }
.sample-body { line-height: 1.9; margin: 16px 0; }

/* イベント申込ページ */
.event-hero { display: block; width: calc(100% + 48px); max-width: none; margin: -28px -24px 16px; border-radius: var(--radius) var(--radius) 0 0; }
.event-title { font-size: 1.5rem; text-align: center; }
.event-lead { text-align: center; font-weight: 700; color: var(--brand); }
.event-body { line-height: 1.9; }
.event-body h2 { font-size: 1.15rem; margin: 1.6em 0 0.6em; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.event-body img { max-width: 100%; height: auto; }
.event-h2 { font-size: 1.25rem; margin: 1.8em 0 0.6em; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.slot-list { display: grid; gap: 8px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.slot input { width: auto; margin: 0; }
.slot-date { flex: 1; font-weight: 700; }
.slot-left { color: var(--accent); font-size: 0.9rem; white-space: nowrap; }
.slot.full { opacity: 0.55; cursor: default; }
.slot.full .slot-left { color: var(--muted); }
.event-next { display: block; text-align: center; margin-top: 16px; background: #2f9e55; border-color: #2f9e55; color: #fff; text-decoration: none; }
@media (max-width: 560px) { .event-hero { width: calc(100% + 48px); } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.slot-days { display: grid; gap: 14px; }
.slot-day-label { margin: 0 0 6px; font-weight: 700; }
.slot-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.slot-time { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: center; }
.slot-time input { position: absolute; opacity: 0; pointer-events: none; }
.slot-time:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.slot-time:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.slot-hour { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.slot-time .slot-left { font-size: 0.75rem; }
.slot-time.full { opacity: 0.45; cursor: default; }
/* 動画講座 */
.public-sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 4px; }
.video-title { font-size: 1.25rem; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; margin: 8px 0 12px; }
.video-frame iframe, .video-frame #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-note { font-size: 0.92rem; }
.video-list { padding-left: 1.4em; display: grid; gap: 6px; }
.video-list li.current a { font-weight: 700; }
.video-pct { color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.video-next { border: 1px solid var(--brand); background: var(--brand-soft); border-radius: var(--radius); padding: 16px; margin-top: 16px; display: grid; gap: 8px; }
.video-next-lead { font-weight: 700; margin: 0; }
.video-toc { padding-left: 1.4em; }
.video-list li.locked { color: var(--muted); }

/* Claudeからのお知らせ(ホーム) */
.notices { border-color: var(--brand); }
.notices h3 { font-size: 0.95rem; margin: 14px 0 6px; color: var(--brand); }
.notice-auto { list-style: none; padding: 0; margin: 0 0 8px; }
.notice-auto li { padding: 8px 10px; background: var(--brand-soft); border-radius: 8px; margin-bottom: 6px; }
.notice-list { list-style: none; padding: 0; margin: 0; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.notice:first-child { border-top: none; }
.notice-check { flex: 0 0 auto; }
.notice-check label { display: flex; gap: 4px; align-items: center; white-space: nowrap; font-size: 0.85rem; cursor: pointer; }
.notice-check input { width: 22px; height: 22px; }
.notice-text { flex: 1 1 auto; min-width: 0; }
.notice-conflict { background: var(--warn-soft); border-radius: 8px; padding: 10px; }
.notice-keep { flex: 0 0 auto; }

/* タスクのページ(相談・完了の報告) */
.task-badge { display: inline-block; font-size: 0.8rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--brand); color: var(--brand); text-decoration: none; white-space: nowrap; }
.task-badge.task-review { background: var(--warn-soft); border-color: var(--muted); color: inherit; }
.task-status { display: inline-block; font-weight: 600; font-size: 0.85rem; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); margin: 0 0 8px; }
.task-status.task-review { background: var(--warn-soft); }
.howto { line-height: 1.8; }
.thread { list-style: none; padding: 0; margin: 0 0 12px; }
.msg { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; background: var(--brand-soft); }
.msg-user, .msg-report { background: transparent; border: 1px solid var(--line); margin-left: 15%; }
.msg-report { border-style: dashed; }
.msg-who { color: var(--muted); margin-bottom: 4px; }
.msg-body { line-height: 1.8; overflow-wrap: anywhere; }
.ask-form textarea, .card textarea[name=report] { width: 100%; }

/* 有料イベントの申込(お支払い方法・キャンセルの決まり) */
.pay-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.pay-box legend { font-weight: 700; padding: 0 4px; }
.pay-box label { display: flex; flex-wrap: nowrap; gap: 6px; align-items: flex-start; margin: 6px 0; }
.policy-box { background: var(--brand-soft); border-radius: var(--radius); padding: 10px 14px; }
.policy-box ul { margin: 4px 0 8px; padding-left: 1.2em; }
.policy-box p { margin: 4px 0; }
.pay-box label input[type=radio] { width: auto; flex: 0 0 auto; margin: 5px 0 0; }

/* タスクのやりとりの画像 */
.msg-img { display: block; max-width: 100%; max-height: 320px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); }
.img-preview { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.img-preview img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* 参加者特典の表示 */
.perk-box { background: var(--warn-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 14px; text-align: center; }

/* ホーム: お申し込み・お支払い(一番上・目立たせる) */
.notices h3.notice-booking-h { color: var(--accent); margin-top: 4px; }
.notice-list.notice-booking { background: var(--warn-soft); border: 1px solid var(--accent); border-radius: 10px; padding: 2px 12px; margin-bottom: 12px; }
.notice-list.notice-booking .notice { border-top-color: var(--line); }

/* 受講生台帳 */
.badge.st-check { background: var(--warn-soft); color: var(--text); }
.badge.st-active { background: var(--ok-soft); color: var(--ok); }
.badge.st-completed { background: var(--brand-soft); color: var(--text); }
.badge.st-canceled { opacity: .6; }
.enroll-list { list-style: none; padding: 0; margin: 0 0 12px; }
.enroll-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
#school h3 { font-size: 1rem; margin: 18px 0 8px; }
progress { width: 70px; vertical-align: middle; }

/* 撮影して登録: 表・裏 */
.shoot-pair, .preview-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shoot-pair .shoot span { font-size: 1rem; }
.preview-pair .preview { margin: 8px 0; }
.preview-pair .preview img { width: 100%; }
.research-body { white-space: normal; font-size: .93rem; }

/* この方についてClaudeに相談 */
.consult-log { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.consult-msg { border-radius: 10px; padding: 8px 12px; border: 1px solid var(--line); }
.consult-user { background: var(--brand-soft); margin-left: 12%; }
.consult-assistant, .consult-claude { margin-right: 6%; }
.copy-btn { margin: 4px 0 8px; }
