:root {
  --bg: #f6f1e8;
  --paper: #fffdf8;
  --ink: #2b2622;
  --muted: #776d63;
  --line: #e2d8c8;
  --accent: #c9781e;
  --accent-ink: #fff;
  --teal: #3f8a74;
  --danger: #b6412f;
  --shadow: 0 1px 2px rgb(60 40 20 / .06), 0 6px 18px rgb(60 40 20 / .08);
  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', serif;
  --sans: 'Zen Kaku Gothic New', 'Hiragino Sans', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a17;
    --paper: #27231f;
    --ink: #efe7dc;
    --muted: #a99e92;
    --line: #3b352f;
    --accent: #e8a54b;
    --accent-ink: #1d1a17;
    --teal: #7fb7a4;
    --danger: #e0806f;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 18px rgb(0 0 0 / .25);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.75 var(--sans);
}
.top, .tabs, main { max-width: 980px; margin: 0 auto; padding: 0 16px; }

.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; padding-top: 32px; }
.brand { display: flex; gap: 14px; align-items: center; }
.logo { width: 44px; height: 44px; }
.logo { color: var(--ink); } /* いちばん小さなかけらは文字の色（暗い画面でも見える） */
h1 { font: 700 30px/1.2 var(--serif); margin: 0; letter-spacing: .06em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.stats { margin: 0; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.stats b { color: var(--ink); font-size: 18px; }

.tabs { display: flex; gap: 4px; margin-top: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: 0; background: none; color: var(--muted); font: 500 15px var(--sans);
  padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

main { padding-top: 24px; padding-bottom: 80px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.lead strong { color: var(--ink); }
h2 { font: 700 18px var(--serif); margin: 32px 0 12px; }

button {
  font: 500 15px var(--sans); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 20px; cursor: pointer;
  transition: transform .1s, background .2s;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { background: transparent; }
button.small { padding: 4px 12px; font-size: 13px; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 24px; }
.tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border-radius: 999px; padding: 3px 12px; font-size: 13px; background: transparent;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* かけらカード — 割れた破片のような角 */
.table, .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.frag {
  position: relative; background: var(--paper); padding: 22px 20px 16px; box-shadow: var(--shadow);
  clip-path: polygon(0 6%, 14% 0, 100% 0, 100% 88%, 92% 100%, 0 100%);
  animation: rise .45s cubic-bezier(.2,.8,.2,1);
}
.frag:nth-child(3n+2) { clip-path: polygon(0 0, 88% 0, 100% 9%, 100% 100%, 9% 100%, 0 92%); }
.frag:nth-child(3n+3) { clip-path: polygon(6% 0, 100% 0, 100% 100%, 0 100%, 0 12%); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) rotate(-1deg); } }
.f-title { font: 700 18px/1.4 var(--serif); margin: 0 0 6px; }
.f-body { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.f-tags { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.f-tags li { font-size: 12px; color: var(--teal); }
.f-tags li::before { content: '#'; }
.frag footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.badge { border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-size: 11px; white-space: nowrap; }
.f-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.empty { color: var(--muted); font-size: 14px; padding: 24px; border: 1px dashed var(--line); border-radius: 8px; text-align: center; }

/* 閃き */
.spark {
  margin-top: 28px; padding: 24px; border-radius: 12px; background: var(--ink); color: var(--bg);
  animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
.spark .q { font: 700 21px/1.6 var(--serif); margin: 0 0 10px; }
.spark .c { margin: 0 0 16px; opacity: .8; }
.spark .credit { font-size: 12px; opacity: .65; margin: 0 0 14px; }
.spark button { background: transparent; color: var(--bg); border-color: currentColor; }

/* フォーム */
form { display: grid; gap: 16px; max-width: 680px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; position: relative; }
input:not([type]), input[type="text"], textarea {
  font: 16px/1.6 var(--sans); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
.req { font-size: 11px; color: var(--accent); font-weight: 700; margin-left: 4px; }
.count { justify-self: end; font-size: 12px; color: var(--muted); font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px 16px; margin: 0; display: grid; gap: 10px; background: var(--paper); }
legend { font-weight: 700; font-size: 14px; padding: 0 6px; }
.radio, .check { display: flex; gap: 10px; align-items: start; font-weight: 400; }
.radio input, .check input { margin-top: 6px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.consent { border-color: var(--accent); }
.note { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.error { color: var(--danger); margin: 0; }

.done { background: var(--paper); border: 1px solid var(--teal); border-radius: 12px; padding: 20px; max-width: 680px; }
.done h3 { font: 700 20px var(--serif); margin: 0 0 8px; }
.token { display: block; font: 14px ui-monospace, Menlo, monospace; background: var(--bg); padding: 10px; border-radius: 6px; overflow-wrap: anywhere; user-select: all; margin: 8px 0; }

.list { display: grid; gap: 10px; }
.item { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; gap: 12px; justify-content: space-between; align-items: start; }
.item .meta { font-size: 12px; color: var(--muted); }
.item p { margin: 0; }
.item .grow { flex: 1; min-width: 0; }
.item textarea { margin-top: 8px; font-size: 14px; }
.status-ok { color: var(--teal); }
.status-off { color: var(--danger); }

.prose ol { padding-left: 1.4em; display: grid; gap: 12px; max-width: 720px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); animation: rise .3s;
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- ヘッダーの言語・アカウント ---------- */
.top-right { display: grid; gap: 8px; justify-items: end; }
.top-tools { display: flex; gap: 8px; align-items: center; }
select {
  font: 14px var(--sans); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.tabs .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 6px; vertical-align: 2px; }
@media (max-width: 560px) { .top-right { justify-items: start; } }

/* ---------- 共通 ---------- */
.sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.opt { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 4px; }
.actions.flat { margin: 0; }
.actions.end { justify-content: end; margin: 8px 0 0; }
button.danger { color: var(--danger); }
.gate { background: var(--paper); border: 1px dashed var(--accent); border-radius: 12px; padding: 20px; max-width: 680px; display: grid; gap: 12px; justify-items: start; }
.gate p { margin: 0; }
input[type="email"], input[type="password"] {
  font: 16px/1.6 var(--sans); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}

/* ---------- カードの追加要素 ---------- */
.f-how { margin: 0 0 10px; padding: 8px 10px; border-left: 3px solid var(--teal); background: var(--bg); font-size: 14px; }
.f-rule { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.f-thanks { color: var(--accent); white-space: nowrap; }

/* ---------- 閃き・相談の結果 ---------- */
.spark .src { font-size: 12px; letter-spacing: .08em; opacity: .7; margin: 0 0 6px; }
.spark.advice { margin: 0 0 20px; }
#consultOut { margin-top: 28px; }

/* ---------- 私のフォルダー ---------- */
.toggles { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; }
.check.small { font-size: 13px; gap: 6px; }
.check.small input { margin-top: 4px; width: 16px; height: 16px; }
.item.muted { opacity: .6; }
.item.fresh { border-color: var(--accent); }
.thanks-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
h2 .new { font: 700 11px var(--sans); color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px 8px; margin-left: 8px; vertical-align: 3px; }
.profile { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; max-width: 680px; }
@media (max-width: 560px) { .profile { grid-template-columns: 1fr; } }
.legacy { margin-top: 40px; }
.legacy summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.legacy[open] summary { margin-bottom: 10px; }
.legacy form.item { display: flex; max-width: none; }
.legacy form.item input { flex: 1; }

/* ---------- ダイアログ ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 24px; background: var(--paper); color: var(--ink);
  width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(20 15 10 / .45); }
dialog h3 { font: 700 19px var(--serif); margin: 0; }
dialog form { gap: 14px; }
.seg { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.seg button { border: 0; border-radius: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; padding: 8px 14px; }
.seg button[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
.reg-only { display: grid; gap: 14px; }
.reg-only[hidden] { display: none; }

/* display を指定した要素でも hidden 属性で確実に隠す */
[hidden] { display: none !important; }

/* ---------- 利用規約・プライバシーポリシー ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 32px 16px 80px; }
.legal h1 { margin-bottom: 8px; }
.legal h2 { margin-top: 28px; }
.legal ol, .legal ul { padding-left: 1.4em; display: grid; gap: 6px; }
.legal a { color: var(--teal); }
.legal table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.legal th, .legal td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.legal th { background: var(--paper); }
.draft { background: #fff3cd; color: #5c4400; border: 1px solid #e6c65c; border-radius: 8px; padding: 10px 14px; }
@media (prefers-color-scheme: dark) { .draft { background: #3d3214; color: #f3dc9b; border-color: #7a6326; } }

/* ---------- 案内の帯（メール確認・規約の再同意） ---------- */
.notice {
  max-width: 948px; margin: 16px auto 0; padding: 12px 16px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--accent);
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
}
@media (max-width: 980px) { .notice { margin: 16px 16px 0; } }
.notice p { margin: 0; font-size: 14px; flex: 1 1 280px; }
.notice a, .gate a { color: var(--teal); }
.linklike { border: 0; background: none; padding: 0; color: var(--teal); font-size: 13px; justify-self: start; text-decoration: underline; }
.note.warn { color: var(--danger); }
.check.wide { grid-column: 1 / -1; }
.site-foot { max-width: 980px; margin: 0 auto; padding: 0 16px 40px; display: flex; gap: 20px; font-size: 13px; }
.site-foot a { color: var(--muted); }

/* ---------- 運営 ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 20px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: grid; }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.alert { border-color: var(--danger); }
.tile.alert b { color: var(--danger); }
#adminViews { margin-bottom: 16px; flex-wrap: wrap; }
#adminSearch { margin-bottom: 16px; }
#adminSearch input { flex: 1; }
.admin-item { display: block; }
.admin-title { font: 700 17px var(--serif); }
.admin-item .meta { margin-top: 4px; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 !important; }
.reason { font-size: 12px; border: 1px solid var(--danger); color: var(--danger); border-radius: 999px; padding: 0 8px; }
.clog { font: 12px ui-monospace, Menlo, monospace; color: var(--muted); padding-left: 1.2em; overflow-wrap: anywhere; }
.admin-item details { margin: 8px 0; font-size: 13px; }
.admin-item summary { cursor: pointer; color: var(--muted); }
.admin-note { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 10px 0 0; }
.admin-note input { flex: 1 1 260px; }
.admin-note .check { flex: none; white-space: nowrap; }

/* ---------- iPhone（ホーム画面から開いたとき・切り欠きのある画面） ---------- */
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
@media (display-mode: standalone) { .top { padding-top: max(16px, env(safe-area-inset-top)); } }
.toast { bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); text-align: center; }
/* iPhone は 16px 未満の入力欄をタップすると画面を拡大してしまうので、指で操作する端末では 16px にそろえる */
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px !important; }
  button.small { padding: 7px 14px; }
}
.devmail { font-size: 13px; }
.devbar { background: #3f8a74; color: #fff; text-align: center; font-size: 13px; padding: calc(4px + env(safe-area-inset-top)) 12px 4px; }
.devbar a { color: #fff; font-weight: 700; }
dialog a { color: var(--teal); }
.spark, #consultOut, .frag { scroll-margin-top: 16px; }

/* ---------- 画像 ---------- */
.image-field { display: grid; gap: 6px; justify-items: start; }
.field-label { font-size: 14px; font-weight: 500; }
.filebtn {
  display: inline-flex; align-items: center; cursor: pointer; font: 500 15px var(--sans);
  border: 1px dashed var(--accent); border-radius: 999px; padding: 10px 20px; background: var(--paper);
}
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.filebtn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.img-preview { display: grid; gap: 8px; justify-items: start; }
.img-preview img { max-width: min(100%, 360px); max-height: 280px; border-radius: 10px; box-shadow: var(--shadow); }
.f-img { display: block; width: calc(100% + 40px); margin: -22px -20px 14px; max-height: 260px; object-fit: cover; cursor: zoom-in; background: var(--line); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; cursor: zoom-in; }
.admin-img { max-width: 240px; max-height: 180px; border-radius: 8px; margin-bottom: 8px; cursor: zoom-in; display: block; }
.img-dlg { padding: 12px; width: auto; max-width: calc(100vw - 24px); background: var(--paper); display: none; }
.img-dlg[open] { display: grid; gap: 10px; justify-items: center; }
.img-dlg img { max-width: 100%; max-height: calc(100dvh - 120px); border-radius: 8px; }

/* ---------- 複数の画像 ---------- */
.img-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; width: 100%; max-width: 480px; }
.img-item { position: relative; aspect-ratio: 1; }
.img-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow); max-width: none; max-height: none; cursor: zoom-in; }
.img-remove {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; padding: 0; border-radius: 50%;
  background: var(--ink); color: var(--bg); border: 2px solid var(--paper); font-size: 16px; line-height: 1;
}
.frag { position: relative; }
.img-count {
  position: absolute; top: 12px; right: 12px; padding: 2px 10px; font-size: 12px; border: 0;
  background: rgb(20 15 10 / .65); color: #fff; border-radius: 999px;
}
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.img-nav { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); }
.img-nav button { font-size: 20px; padding: 2px 16px; }
.reminder { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; }
.notice .btns { display: flex; gap: 8px; flex-wrap: wrap; }
