/* 表示テーマ：基本はライト（白）。アプリの設定で「ダーク」を選べる（端末の設定には左右されない）。
   設定は <html data-app-theme="light|dark"> で切り替える */
:root {
  --bg: #f2f4f9;
  --surface: #ffffff;
  --surface2: #eef1f6;
  --line: #e1e5ee;
  --text: #171a22;
  --muted: #646c7e;
  --accent2: #6a86f5;
  --shadow-sm: 0 1px 2px rgba(23, 32, 64, .06), 0 2px 10px rgba(23, 32, 64, .05);
  --shadow-md: 0 4px 10px rgba(23, 32, 64, .07), 0 12px 30px rgba(23, 32, 64, .09);
  --accent: #3d63e0;
  --accent-text: #ffffff;
  --star: #f2a100;
  --star-off: #d6d9e0;
  --danger: #d93b3b;
  --up: #1d9a5a;
  --down: #d23f3f;
  --req: #ea7a00;
  --req-text: #ffffff;
  --radius: 16px;
  color-scheme: light;
}
/* ダーク：設定で「ダーク」を選んだとき */
:root[data-app-theme="dark"] {
  --bg: #0f1116;
  --surface: #181b22;
  --surface2: #222631;
  --line: #2c313c;
  --accent2: #9db3ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 10px rgba(0, 0, 0, .25);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, .4), 0 14px 34px rgba(0, 0, 0, .35);
  --text: #eceef2;
  --muted: #9aa0ab;
  --accent: #7c9cff;
  --accent-text: #0d1020;
  --star: #ffc53d;
  --star-off: #3a3d46;
  --danger: #ff6b6b;
  --up: #4cd48a;
  --down: #ff7a7a;
  --req: #ff9a1f;
  --req-text: #1d1200;
  color-scheme: dark;
}
.theme-seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface2); margin-top: 6px; }
.theme-seg button {
  flex: 1 1 0; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px;
  font-size: 13px; color: var(--muted); line-height: 1.3;
}
.theme-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.18); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ホーム画面：種類を大きなボタンで縦に並べる */
.home { padding: 4px 0 24px; }
.home-grid { display: grid; gap: 12px; grid-template-columns: 1fr; max-width: 640px; margin: 0 auto; }
@media (min-width: 900px) { .home-grid { grid-template-columns: repeat(2, 1fr); max-width: 900px; } }
.tile {
  --c: var(--accent);
  display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 92px;
  padding: 16px 20px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-align: left;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); transition: transform .1s, border-color .15s;
}
.tile:hover { border-color: var(--c); }
.tile:active { transform: scale(.985); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tile-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; font-style: normal; }
.tile-label { font-size: 20px; font-weight: 700; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-count { flex: none; font-size: 13px; color: var(--muted); }
.tile-count b { font-size: 18px; color: var(--text); margin-right: 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 22px; }
/* 「すべて」はほかより目立たせる */
.tile.tile-all { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tile.tile-all .tile-count, .tile.tile-all .tile-count b, .tile.tile-all .tile-sub { color: var(--accent-text); }
.tile.tile-all .tile-sub { padding-left: 0; opacity: .85; }
.tile.tile-all .tile-count { opacity: .9; }
/* 種類を追加：点線の枠で「追加するボタン」と分かるように */
.tile.tile-add {
  flex-direction: row; align-items: center; justify-content: center; gap: 8px; min-height: 64px;
  background: transparent; border: 2px dashed var(--line); color: var(--muted); font-weight: 700; box-shadow: none;
}
.tile.tile-add .plus { font-size: 24px; line-height: 1; }
.tile.tile-add:hover { border-color: var(--accent); color: var(--accent); }
/* 項目別の評価 */
.subs-box { margin-top: 10px; padding: 4px 12px 10px; border-radius: 12px; background: var(--surface2); }
.sub-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
.sub-name { font-size: 14px; font-weight: 600; min-width: 0; flex: 1 1 6em; word-break: break-word; }
.rate-pick.sm { margin-top: 0; gap: 8px; flex-wrap: nowrap; }
.rate-pick.sm .stars { font-size: 26px; }
.rate-pick.sm output { font-size: 15px; min-width: 2.4em; text-align: right; }
.rate-pick.sm .icon-btn { width: 30px; height: 30px; font-size: 12px; background: var(--surface); }
.sub-avg { margin: 6px 0 0; text-align: right; }
.sub-avg:empty { display: none; }
.subs-view { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.subs-view .sv { display: inline-flex; align-items: center; gap: 4px; }
.subs-view b { color: var(--text); font-variant-numeric: tabular-nums; }
.subs-view .sv-avg { font-weight: 700; }
.stars.xs { font-size: 11px; }
#axisList .chk-row { flex-wrap: nowrap; }
#axisList .ctrls { padding-bottom: 0; }

/* 話数ごとの記録 */
.eps h4 small { font-weight: 500; margin-left: 4px; }
.eps .ep-rounds { padding: 0 0 8px; }
.eps .btn { margin-top: 8px; }
.ep-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ep {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px;
  padding: 8px 12px; border-radius: 10px; background: var(--surface2);
}
.ep.tap { cursor: pointer; }
.ep.tap:hover, .ep.tap:focus-visible { outline: 1px solid var(--accent); }
.ep-no { font-weight: 700; font-size: 14px; min-width: 5.5em; font-variant-numeric: tabular-nums; }
.ep-rate { display: inline-flex; align-items: center; gap: 6px; }
.ep-rate b { font-size: 13px; font-variant-numeric: tabular-nums; }
.ep-note { flex: 1 1 100%; font-size: 13px; color: var(--muted); word-break: break-word; }

/* 友達の棚 */
.home-sec { max-width: 640px; margin: 22px auto 10px; font-size: 14px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
@media (min-width: 900px) { .home-sec { max-width: 900px; } }
.tile.tile-friend { --c: var(--muted); background: var(--surface2); }
.tile-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-style: normal; font-weight: 700; font-size: 15px; background: var(--surface); color: var(--text); border: 1px solid var(--line);
}
.tile-friend .tile-sub { padding-left: 40px; }
.friend-bar { display: grid; gap: 8px; padding: 4px 0 8px; }
.friend-bar p { margin: 0; }
.friend-bar .row { gap: 8px; }
.home-hint { text-align: center; margin: 18px auto 0; max-width: 520px; }
.home-hint .btn { margin-top: 10px; }
.back-btn { font-size: 26px; line-height: 1; padding-bottom: 3px; margin-right: 4px; }
.top { gap: 6px; }
.top h1 { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

#app { max-width: 980px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 0 8px;
}
.top h1 { font-size: 22px; margin: 0; letter-spacing: .02em; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--surface2); font-size: 18px; line-height: 1;
  display: inline-grid; place-items: center; flex: none;
}
.icon-btn.sm { width: 32px; height: 32px; font-size: 14px; border-radius: 10px; }

.toolbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding: 6px 0 10px; }
.toolbar input[type=search] {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px;
}
.chip[aria-selected=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, .btn {
  padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
#count { margin-left: auto; font-size: 13px; }

/* 一覧：カード表示（複数列）とリスト表示（1列・横長） */
.list-wrap { display: block; }
.items.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.items.rows { display: grid; gap: 6px; grid-template-columns: 1fr; }
.list-wrap > .empty { display: block; }

.row-item {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; cursor: pointer;
}
.row-item:hover { border-color: var(--accent); }
.row-item .badge { flex: none; }
.ri-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ri-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-title .round { font-size: 10px; vertical-align: 2px; }
.ri-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-comment { display: none; flex: 0 1 32%; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .ri-comment { display: block; } } /* 感想は横幅に余裕があるときだけ */
.ri-rate { flex: none; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.ri-rate b { min-width: 2.2em; text-align: right; }
/* スマホでは星を「★4.5」の形に縮めてタイトルの幅を確保 */
@media (max-width: 520px) {
  .ri-rate .stars { display: none; }
  .ri-rate b::before { content: "★"; color: var(--star); margin-right: 1px; }
  .row-item { gap: 10px; padding: 10px 12px; }
}

/* 見出し（並び順に合わせたまとまり）：楕円＋▼で開閉 */
.grp { margin: 4px 0 10px; }
.grp.lv2 { margin-left: 14px; }
.grp-h {
  display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 8px;
  padding: 5px 12px 5px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: 14px; color: var(--text);
}
.grp.lv1 > .grp-h { font-size: 15px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.grp-h small { font-weight: 500; color: var(--muted); font-size: 12px; }
.grp-h .caret { font-style: normal; font-size: 11px; color: var(--muted); transition: transform .15s; }
.grp-h[aria-expanded="false"] .caret { transform: rotate(-90deg); }
.grp-h:hover { border-color: var(--accent); }
.grp-h .stars.sm { font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .grp-h .caret { transition: none; } }

/* 一覧の中の見出し：場所を取らない細い区切り線 */
.grp-div {
  grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px;
  margin: 8px 2px 0; padding-bottom: 4px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.grp-div:first-child { margin-top: 0; }
.grp-div small { font-weight: 500; font-size: 11px; }
.grp-anchor { display: block; width: 0; height: 0; }

/* 右端の「目次」つまみ */
.index-tab {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 15;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 34px; padding: 12px 0 12px 4px; border: 1px solid var(--line); border-right: 0;
  border-radius: 14px 0 0 14px; background: var(--surface); color: var(--muted);
  box-shadow: -2px 2px 10px rgba(0,0,0,.12); touch-action: none;
  padding-right: env(safe-area-inset-right, 0px);
}
.index-tab span { font-size: 18px; line-height: 1; }
.index-tab b { writing-mode: vertical-rl; font-size: 12px; letter-spacing: .2em; color: var(--text); }
.index-tab:hover { color: var(--accent); }

/* 横から出る見出しの一覧 */
.index-drawer { position: fixed; inset: 0; z-index: 40; }
.index-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .2s; }
.index-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(78vw, 320px);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.2);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease-out;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px);
  touch-action: pan-y;
}
.index-drawer.open .index-backdrop { opacity: 1; }
.index-drawer.open .index-panel { transform: translateX(0); }
.index-panel header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.index-list { overflow-y: auto; padding: 6px 8px 16px; }
.idx-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  border: 0; background: transparent; text-align: left; padding: 10px 12px; border-radius: 10px; color: var(--text);
}
.idx-item:hover, .idx-item:focus-visible { background: var(--surface2); }
.idx-item.lv1 { font-weight: 700; font-size: 16px; margin-top: 4px; }
.idx-item.lv2 { padding-left: 28px; font-size: 14px; }
.idx-item small { color: var(--muted); font-weight: 500; font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .index-panel, .index-backdrop { transition: none; } }

/* ツールバーの表示切り替え */
.view-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface2); }
.view-seg button { border: 0; background: transparent; padding: 5px 9px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.view-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.btn.toggle { font-size: 13px; }
.btn.toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.fields.cond { padding: 4px 12px 12px; }
.fields.cond .btn { margin-top: 4px; font-size: 13px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; min-width: 0;
  transition: transform .12s, border-color .12s;
}
.card:hover { border-color: var(--accent); }
.card:active { transform: scale(.99); }
.card h3 { margin: 6px 0 2px; font-size: 17px; line-height: 1.35; word-break: break-word; }
.meta { margin: 0; color: var(--muted); font-size: 13px; }
.prog { color: var(--text); }
.comment {
  margin: 8px 0 0; font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge, .st, .round {
  font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; letter-spacing: .03em;
}
.badge {
  --c: #8a909c;
  background: color-mix(in srgb, var(--c) 20%, transparent);
  color: color-mix(in srgb, var(--c) 72%, var(--text));
  white-space: nowrap;
}
.chip.add { font-weight: 700; padding: 6px 14px; border-style: dashed; color: var(--accent); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
form.sheet label.sw { margin: 0; }
.sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); cursor: pointer; border: 3px solid transparent; }
.sw input:checked + span { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.radios { display: grid; gap: 4px; margin-top: 4px; }
form.sheet .radios label { margin: 0; color: var(--text); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.radios input { width: 18px; height: 18px; accent-color: var(--accent); }

.chips.wrap { flex-wrap: wrap; overflow: visible; padding: 6px 0 0; }

.fields { margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.chk-row { display: flex; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid var(--line); }
#customList .chk-row:last-child { border-bottom: 0; }
form.sheet label.chk {
  display: flex; align-items: center; gap: 10px; margin: 0; flex: 1 1 auto; min-width: 0;
  color: var(--text); font-size: 15px; cursor: pointer; padding: 8px 0;
}
.chk input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.chk input:disabled { opacity: .6; }
.chk span { min-width: 0; word-break: break-word; }
.chk small { flex: none; font-size: 12px; }
.chk .warn { color: var(--danger); font-weight: 600; }
.chk-row .icon-btn { background: var(--surface2); }

/* 自分で追加した項目：狭い画面ではボタン類を次の行へ */
.chk-row.custom { flex-wrap: wrap; row-gap: 2px; padding: 2px 0; }
form.sheet .chk-row.custom label.chk { flex: 1 1 150px; }
.chk-row .ctrls { display: flex; align-items: center; gap: 6px; margin-left: auto; padding-bottom: 4px; }

/* 必須の切り替え（楕円：グレー＝任意／オレンジ＝必須） */
.req-pill {
  flex: none; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.4;
  border: 1.5px solid var(--line); background: var(--surface2); color: var(--muted); letter-spacing: .04em;
}
.req-pill[aria-pressed="true"] { background: var(--req); border-color: var(--req); color: var(--req-text); }
.req-pill:disabled { cursor: default; opacity: .85; }
/* ▼候補（オンは青） */
.cand-pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pill-legend { margin: 4px 0 0; line-height: 2; }
.pill-legend .req-pill { display: inline-block; pointer-events: none; font-size: 11px; padding: 1px 8px; vertical-align: 1px; }
.fields > .chk-row > .ctrls { padding-bottom: 0; }
.combo.no-cand input { padding-right: 12px; }
.req-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.req-mark {
  display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; vertical-align: 1px;
  font-size: 11px; font-weight: 700; line-height: 1.6; background: var(--req); color: var(--req-text);
}
form.sheet label.mini {
  display: flex; align-items: center; gap: 4px; margin: 0; flex: none;
  font-size: 12px; color: var(--muted); padding: 4px 8px; border-radius: 8px; background: var(--surface2); cursor: pointer; white-space: nowrap;
}
.mini input { width: 16px; height: 16px; accent-color: var(--accent); }
form.sheet label.chk.opt { margin-top: 8px; flex-wrap: wrap; row-gap: 2px; }
.chk.opt small { flex: 1 1 100%; padding-left: 30px; }
.chk.is-disabled { opacity: .45; cursor: default; }
.sub { padding: 2px 0 12px 30px; border-bottom: 1px solid var(--line); }
form.sheet .sub label:first-child { margin-top: 0; }
#customList:empty { display: none; }
.add-field { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
form.sheet .add-field input { flex: 1 1 180px; width: auto; margin: 0; min-width: 0; }
form.sheet .add-field select { flex: 0 1 auto; width: auto; margin: 0; }
.add-field .btn { flex: none; }

/* ▼で過去の入力から選べる欄 */
.combo { position: relative; margin-top: 4px; }
form.sheet .combo input { margin-top: 0; padding-right: 48px; }
.combo-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 36px; border: 0; border-radius: 8px; background: var(--surface2);
  color: var(--muted); font-size: 12px;
}
.combo-btn:hover { color: var(--text); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  list-style: none; margin: 0; padding: 4px; max-height: 220px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
}
.combo-list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; word-break: break-word; }
.combo-list li:hover, .combo-list li.is-active { background: var(--surface2); }
.combo-list li.is-current { font-weight: 700; color: var(--accent); }
.combo-list li.combo-empty { color: var(--muted); cursor: default; font-size: 13px; }
.combo-hint { margin: 4px 0 0; font-size: 12px; }
.combo-hint.same { color: var(--up); }
.combo-hint.new { color: var(--muted); }

/* 日付の形の切り替え（期間／1日だけ） */
.seg { display: flex; gap: 4px; margin-top: 12px; padding: 4px; border-radius: 12px; background: var(--surface2); }
form.sheet .seg label { flex: 1 1 0; margin: 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: block; text-align: center; padding: 8px 6px; border-radius: 9px; font-size: 13px;
  color: var(--muted); cursor: pointer; line-height: 1.3;
}
.seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.date-box[data-mode="single"] .d-start, .date-box[data-mode="single"] .l-range,
.date-box[data-mode="range"] .l-single { display: none; }
.date-box[data-mode="single"] .two { grid-template-columns: 1fr; }

.extra { margin: 12px 0 0; display: grid; gap: 6px; }
.extra div { display: grid; grid-template-columns: minmax(4em, max-content) 1fr; gap: 12px; }
.extra dt { color: var(--muted); font-size: 13px; }
.extra dd { margin: 0; min-width: 0; }

.type-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.type-list li { display: flex; align-items: center; gap: 6px; background: var(--surface2); border-radius: 12px; padding: 8px 10px; }
.type-list .badge { font-size: 13px; padding: 3px 10px; }
.type-list .icon-btn { background: var(--surface); }
.type-list .icon-btn:disabled { opacity: .35; cursor: default; }
.grow { flex: 1 1 auto; }
.st { background: var(--surface2); color: var(--muted); }
.s-progress { color: var(--accent); }
.round { background: var(--surface2); color: var(--text); }

.rate-row { display: flex; align-items: center; flex-wrap: wrap; row-gap: 2px; column-gap: 8px; margin-top: 8px; min-width: 0; }
.card { overflow: hidden; }
.rate-row b { font-size: 15px; }
.rate-row .date { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); }

/* Stars: 0.5 step display via clipped overlay */
.stars { position: relative; display: inline-block; font-size: 17px; line-height: 1; white-space: nowrap; color: var(--star-off); letter-spacing: 0; }
.stars::before, .stars .fill::before { content: "★★★★★"; }
.stars .fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--star); }
.stars.sm { font-size: 14px; }
.stars.lg { font-size: 42px; }

.empty { grid-column: 1 / -1; text-align: center; padding: 56px 16px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

.fab {
  position: fixed; right: max(20px, calc(50% - 470px)); bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 20px; border: 0;
  background: var(--accent); color: var(--accent-text); font-size: 30px; line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

/* Dialogs: bottom sheet on phone, centered on desktop */
dialog {
  padding: 0; border: 0; color: var(--text); background: var(--surface);
  width: 100%; max-width: 640px; max-height: 92dvh;
  margin: auto auto 0; border-radius: 22px 22px 0 0;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
@media (min-width: 700px) {
  dialog { margin: auto; border-radius: 22px; max-height: 88dvh; }
}
.sheet { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet h2 { margin: 8px 0 2px; font-size: 21px; line-height: 1.35; word-break: break-word; }
.sheet-head h2 { margin: 0; }
.sheet section { margin-top: 18px; }
.sheet h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }

.prog-ctl { display: flex; gap: 10px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--surface2); border-radius: 12px; padding: 4px; }
.stepper button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--surface); font-size: 20px; }
.stepper .val { min-width: 64px; text-align: center; line-height: 1.1; }
.stepper .val small { display: block; font-size: 11px; color: var(--muted); }
.stepper .val b { font-size: 20px; }

.revs { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rev { background: var(--surface2); border-radius: 12px; padding: 10px 12px; }
.rev-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rev-head .date { font-size: 12px; color: var(--muted); }
.rev-head .icon-btn { margin-left: auto; background: var(--surface); }
.chart { width: 100%; height: auto; display: block; margin-bottom: 10px; background: var(--surface2); border-radius: 12px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .ln { fill: none; stroke: var(--star); stroke-width: 2.5; stroke-linejoin: round; }
.chart .pt { fill: var(--star); }
.chart .lb { fill: var(--text); font-size: 10px; font-weight: 600; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.actions .grow { flex: 1 1 auto; }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.actions .btn { padding: 10px 14px; }

/* Forms */
form.sheet label { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }
form.sheet input:not([type=range]):not([type=radio]):not([type=checkbox]), form.sheet select, form.sheet textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px;
}
form.sheet textarea { min-height: 96px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two label { min-width: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 16px 0 0; padding: 4px 12px 12px; }
legend { font-size: 13px; color: var(--muted); padding: 0 6px; }

.rate-pick { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.rate-pick .stars { cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 6px; }
.rate-pick .stars:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.rate-pick output { font-size: 20px; font-weight: 700; min-width: 4em; color: var(--text); }
.rate-pick .btn { font-size: 13px; padding: 4px 10px; }

.export-text {
  display: block; width: 100%; min-height: 220px; margin-top: 10px; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; resize: vertical;
}
dialog.confirm { max-width: 420px; margin: auto; border-radius: 22px; }
dialog.confirm .pre { margin: 4px 0 0; font-size: 15px; }
dialog.confirm .actions { margin-top: 18px; }

/* メニュー：小さなボタンのまとまり */
.menu-sheet .menu-cap { margin: 16px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.menu-sheet .menu-cap small { font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.menu-sheet .theme-seg { margin-top: 0; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.menu-grid .menu-item { padding: 9px 11px; border-radius: 10px; min-width: 0; }
.menu-grid .menu-item b { font-size: 14px; }
.menu-grid .menu-item span { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ジャンル（チップ） */
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.tag-chips:empty { display: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  font-size: 13px; font-weight: 600; color: var(--text); max-width: 100%;
}
.tag-chip button { border: 0; background: transparent; color: var(--muted); font-size: 14px; width: 24px; height: 24px; border-radius: 50%; line-height: 1; }
.tag-chip button:hover { background: var(--surface2); color: var(--text); }
.tag-add { display: flex; gap: 8px; margin-top: 6px; align-items: stretch; }
.tag-add .combo { flex: 1 1 auto; margin-top: 0; min-width: 0; }
.tag-add .btn { flex: none; }
.tag-view {
  display: inline-block; margin: 0 4px 2px 0; padding: 1px 9px; border-radius: 999px; font-size: 12px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
}
.genre-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.genre-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.genre-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 12px; background: var(--surface2); }
.genre-list .tag-view { background: var(--surface); font-size: 13px; font-weight: 700; }
.btn.sm-btn { font-size: 12px; padding: 4px 10px; }

.menu-list { display: grid; gap: 8px; margin-top: 12px; }
.menu-item {
  text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2);
}
.menu-item b { display: block; }
.menu-item span { font-size: 12px; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast { display: flex; align-items: center; gap: 14px; }
#toast.has-action.show { pointer-events: auto; }
.toast-btn {
  flex: none; border: 0; background: transparent; font-weight: 700;
  padding: 6px 4px; margin: -6px -4px; font-size: 14px;
  /* 通知の背景は文字色（--text）なので、背景（--bg）寄りに混ぜて読みやすくする */
  color: color-mix(in srgb, var(--accent) 55%, var(--bg));
}

/* バックアップのお知らせ（ホーム画面） */
.backup-note { max-width: 640px; margin: 0 auto 12px; }
@media (min-width: 900px) { .backup-note { max-width: 900px; } }
.backup-alert {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  padding: 14px 16px; border-radius: 16px; border: 1.5px solid var(--req);
  background: color-mix(in srgb, var(--req) 12%, var(--surface));
}
.backup-alert p { margin: 0; flex: 1 1 220px; font-size: 14px; }
.backup-alert p b { display: block; font-size: 15px; }
.backup-alert .btns { display: flex; gap: 8px; margin-left: auto; }
.backup-status { margin: 14px auto 0; max-width: 640px; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.7; }

#print { display: none; }
@media print {
  body { background: #fff; color: #000; }
  #app, dialog, #toast { display: none !important; }
  #print { display: block; font-size: 10.5pt; }
  #print h1 { font-size: 16pt; margin: 0 0 4px; }
  #print table { width: 100%; border-collapse: collapse; margin-top: 10px; }
  #print th, #print td { border: 1px solid #999; padding: 4px 6px; vertical-align: top; text-align: left; }
  #print th { background: #eee; }
  #print tr { break-inside: avoid; }
  #print small { color: #555; }
}

/* ----- 画像（表紙・ポスター） ----- */
.card.has-img { display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 12px; align-content: start; }
.card.has-img > :not(.card-img) { grid-column: 2; }
.card-img {
  grid-column: 1; grid-row: 1 / span 5; align-self: start;
  width: 64px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--line);
}
.detail-img {
  display: block; margin: 10px auto 4px; max-width: 100%; max-height: 220px;
  border-radius: 10px; object-fit: contain; background: var(--surface2);
}
.img-pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.img-prev { width: 72px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface2); }
.img-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.img-field .muted.small { margin: 6px 0 0; }

/* ----- シリーズ ----- */
.series-two { align-items: start; }
.series-note { margin: 4px 0 0; }
.ser-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ser-item {
  width: 100%; display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.ser-item:hover:not(:disabled) { border-color: var(--accent); }
.ser-item.cur { background: var(--surface2); cursor: default; opacity: 1; }
.ser-item.cur .ser-title { font-weight: 700; }
.ser-no { flex: none; min-width: 3.2em; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ser-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ser-rate { flex: none; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ----- 進み具合のバー（全○話） ----- */
.total-field { margin-top: 8px; }
.prog-bar-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.prog-frac { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prog-frac b { color: var(--text); font-size: 15px; }
.prog-bar { flex: 1; min-width: 0; height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.prog-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s; }
@media (prefers-reduced-motion: reduce) { .prog-bar i { transition: none; } }

/* 見出しの「（補足）」は小さく、グレーで */
small.paren { font-size: .8em; font-weight: 400; color: var(--muted); }


/* =========================================================
   デザインの見直し（2026/11/19）
   方針：白を基本に、枠線より「やわらかい影」で区切る。角は大きめに丸く、
   文字の大きさにメリハリを付け、操作する場所（ボタン）は押しやすい大きさに。
   ========================================================= */
body { font-size: 15px; letter-spacing: .01em; -webkit-font-smoothing: antialiased; }
#app { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* 見出し（上のバー） */
.top { padding: calc(14px + env(safe-area-inset-top)) 0 6px; }
.top h1 { font-size: 23px; font-weight: 800; letter-spacing: .01em; cursor: default; }
#count {
  flex: none; margin: 0 6px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
  background: var(--surface2); padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  max-width: 46vw; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn { border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); }
.icon-btn.sm { width: 36px; height: 36px; border-radius: 11px; box-shadow: none; background: var(--surface2); }
.back-btn { font-size: 28px; }

/* ツールバー：検索＋1行の切り替え */
.toolbar { padding: 4px 0 10px; background: linear-gradient(var(--bg) 85%, transparent); }
.search { position: relative; }
.toolbar input[type=search] {
  border: 0; background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 14px;
  padding: 12px 40px 12px 40px; font-size: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a91a3' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.6-3.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px 50%;
}
.toolbar input[type=search]::-webkit-search-cancel-button { display: none; }
.toolbar input[type=search]:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; }
.q-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface2); color: var(--muted); font-size: 13px;
}
.tool-row { flex-wrap: nowrap; overflow-x: auto; padding: 10px 2px 2px; margin: 0 -2px; scrollbar-width: none; }
.tool-row::-webkit-scrollbar { display: none; }
.tool-row > * { flex: none; }
.tool-row select, .tool-row .btn {
  border: 0; background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text);
}
.tool-row select { padding-right: 28px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1 3l4 4 4-4' fill='none' stroke='%238a91a3' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.tool-row .view-seg { background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 999px; padding: 3px; }
.tool-row .view-seg button { border-radius: 999px; padding: 4px 11px; font-weight: 600; }
.tool-row .view-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.tool-row .btn.toggle[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); }

/* 一覧：カード */
.items.cards { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 16px 15px;
  transition: transform .12s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h3 { font-size: 16.5px; font-weight: 750; margin: 7px 0 2px; }
.card .meta { font-size: 12.5px; }
.card .comment { font-size: 13px; line-height: 1.6; }
.price { color: var(--text); font-weight: 700; }
.row-item { border: 0; box-shadow: var(--shadow-sm); border-radius: 14px; padding: 11px 14px; }
.row-item:hover { box-shadow: var(--shadow-md); }
.ri-title { font-weight: 700; }

/* 小さなラベル（種類・ステータス・周目） */
.badge, .st, .round { border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; }
.st { background: var(--surface2); }
.s-progress { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); }
.s-planned { color: color-mix(in srgb, var(--req) 80%, var(--text)); background: color-mix(in srgb, var(--req) 12%, var(--surface)); }

/* 見出しでまとめたときの区切り */
.grp-div { border-bottom: 0; margin: 14px 4px 2px; font-size: 13px; font-weight: 800; color: var(--text); letter-spacing: .02em; }
.grp-div small { color: var(--muted); font-weight: 600; }
.grp-div::after { content: ""; flex: 1; height: 1px; background: var(--line); align-self: center; margin-left: 4px; }

/* ホーム：まとめ（すべての記録） */
.home { padding-top: 2px; }
.hero {
  display: grid; gap: 6px; width: 100%; max-width: 640px; margin: 4px auto 0; text-align: left;
  padding: 18px 20px 16px; border: 0; border-radius: 22px; color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #5b7cf0 60%, #7c8ff7 100%);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 35%, transparent);
  position: relative; overflow: hidden;
}
:root[data-app-theme="dark"] .hero { background: linear-gradient(135deg, #2c4bc0 0%, #3c5bd8 60%, #5468d8 100%); }
.hero::after { /* 右上の★の模様 */
  content: "★"; position: absolute; right: -6px; top: -28px; font-size: 150px; line-height: 1; color: rgba(255,255,255,.10); pointer-events: none;
}
.hero:active { transform: scale(.99); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hero-label { font-size: 14px; font-weight: 700; opacity: .92; }
.hero-go { font-size: 12px; font-weight: 700; background: rgba(255,255,255,.18); padding: 3px 10px; border-radius: 999px; }
.hero-count { font-size: 14px; font-weight: 700; }
.hero-count b { font-size: 40px; line-height: 1.05; font-weight: 800; margin-right: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.hero-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-stats > span { display: flex; align-items: baseline; gap: 6px; background: rgba(255,255,255,.16); border-radius: 12px; padding: 5px 11px; }
.hero-stats small { font-size: 11px; opacity: .85; }
.hero-stats b { font-size: 15px; font-variant-numeric: tabular-nums; }
.hero-last { font-size: 12.5px; opacity: .88; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 900px) { .hero { max-width: 900px; } }

.home-sec { margin: 22px auto 10px; font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .06em; }

/* ホーム：種類（スマホでは2列） */
.home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile {
  border: 0; box-shadow: var(--shadow-sm); border-radius: 18px; min-height: 104px; padding: 14px 15px 13px;
  justify-content: flex-start; gap: 6px; position: relative; overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--c); opacity: .9; }
.tile:hover { box-shadow: var(--shadow-md); }
.tile-top { flex-wrap: wrap; row-gap: 2px; }
.tile-label { font-size: 17px; font-weight: 800; flex: 1 1 0; }
.tile-count { flex: 1 0 100%; padding-left: 22px; }
.tile-count b { font-size: 24px; font-weight: 800; }
.tile-sub { padding-left: 22px; font-size: 12px; }
.tile.tile-add { min-height: 104px; border: 2px dashed var(--line); box-shadow: none; flex-direction: column; gap: 2px; font-size: 14px; }
.tile.tile-add::before { display: none; }
.tile.tile-friend { background: var(--surface); }
.tile.tile-friend::before { background: var(--muted); opacity: .35; }
.tile-friend .tile-count, .tile-friend .tile-sub { padding-left: 40px; }

/* ホーム：続きから */
.going { display: grid; gap: 8px; max-width: 640px; margin: 0 auto; }
@media (min-width: 900px) { .going { max-width: 900px; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.going-item {
  display: flex; align-items: stretch; gap: 0; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-sm);
  overflow: hidden; box-shadow: inset 4px 0 0 var(--c), var(--shadow-sm);
}
.going-main {
  flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; color: var(--text);
}
.going-main b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.going-main span { font-size: 12px; color: var(--muted); }
.going-bar { display: block; height: 5px; border-radius: 99px; background: var(--surface2); overflow: hidden; margin-top: 4px; }
.going-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.going-plus {
  flex: none; width: 70px; border: 0; background: color-mix(in srgb, var(--accent) 11%, var(--surface));
  color: var(--accent); font-weight: 800; font-size: 17px; display: grid; place-content: center; line-height: 1.1;
}
.going-plus small { font-size: 11px; font-weight: 700; }
.going-plus:active { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }

/* 右下の＋ */
.fab {
  width: 60px; height: 60px; border-radius: 50%; font-size: 30px;
  background: linear-gradient(140deg, var(--accent2), var(--accent));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent), 0 2px 6px rgba(0,0,0,.15);
}
.fab:active { transform: scale(.95); }

/* 画面の下から出るシート */
dialog { border-radius: 26px 26px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(12, 16, 28, .5); }
@media (max-width: 699px) {
  dialog:not(.confirm) > .sheet::before { /* つまみ（下から出る画面の目印） */
    content: ""; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: -8px auto 10px;
  }
}
@media (min-width: 700px) { dialog { border-radius: 24px; } }
.sheet { padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 22px; font-weight: 800; }
.sheet h4 { font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.sheet section { margin-top: 20px; }

/* ボタン */
.btn, select { border-radius: 12px; }
.actions .btn { padding: 11px 16px; font-weight: 600; }
.btn.primary { box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; }
.actions .sub-actions { display: flex; gap: 8px; flex: 1 1 100%; }
.actions .sub-actions .btn { flex: 1 1 0; }
.actions .sub-actions .ghost { flex: 0 0 auto; }

/* 入力欄 */
form.sheet label { font-size: 13px; font-weight: 600; }
form.sheet input:not([type=range]):not([type=radio]):not([type=checkbox]), form.sheet select, form.sheet textarea {
  background: var(--surface2); border-color: transparent; border-radius: 12px;
}
form.sheet input:focus, form.sheet select:focus, form.sheet textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; background: var(--surface);
}
fieldset { border-radius: 16px; }
.fields { border-radius: 16px; }

/* 詳細画面のステータス（その場で変えられる） */
.st-pick {
  position: relative; display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface2);
  color: var(--muted); font-size: 11px; font-weight: 700;
}
.st-pick.s-progress { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); }
.st-pick.s-planned { background: color-mix(in srgb, var(--req) 12%, var(--surface)); color: color-mix(in srgb, var(--req) 80%, var(--text)); }
.st-pick select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: inherit; font: inherit;
  padding: 3px 22px 3px 10px; border-radius: 999px; cursor: pointer;
}
.st-pick::after { content: "▾"; position: absolute; right: 8px; pointer-events: none; font-size: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 詳細画面の記録 */
.rev { border-radius: 14px; }
.chart { border-radius: 14px; }

/* 種類の設定：詳細設定（畳める） */
details.adv { margin-top: 14px; border-radius: 16px; background: var(--surface2); padding: 0 12px; }
details.adv > summary {
  list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 13px 26px 13px 2px; position: relative;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::after { content: "▾"; position: absolute; right: 4px; top: 13px; color: var(--muted); transition: transform .15s; }
details.adv[open] > summary::after { transform: rotate(180deg); }
.adv-title { font-weight: 800; font-size: 15px; }
.adv-sub { font-size: 12px; color: var(--muted); min-width: 0; }
details.adv .fields { background: var(--surface); border: 0; margin-top: 0; }
details.adv > label:first-of-type { margin-top: 14px; }
details.adv > .muted.small:last-child { padding-bottom: 12px; margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { details.adv > summary::after { transition: none; } }

/* お知らせ */
#toast { border-radius: 14px; box-shadow: var(--shadow-md); padding: 11px 16px; }

/* メニュー */
.menu-grid .menu-item { border: 0; background: var(--surface2); border-radius: 12px; }

/* ===== 長い文字でも崩れないように（2026/11/19） ===== */
/* 区切りのない英数字やURLも、枠の中で折り返す */
body { overflow-wrap: anywhere; }
/* 種類・ステータス・回数のラベルは1行。長いときは「…」で省く */
.badge, .st, .round { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.row-item .badge { flex: 0 1 auto; max-width: 28%; }
.ri-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ri-head .ri-title { min-width: 0; }
.ri-head .round { flex: none; font-size: 10px; }
/* カード：タイトルは4行、制作会社・ジャンルなどは2行まで（全部は詳細で見られる） */
.card h3, .card .meta { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.card h3 { -webkit-line-clamp: 4; }
.card .meta { -webkit-line-clamp: 2; }
/* 1列の並びは、中身が長くても列の幅を超えない */
.ep-list, .friend-bar, .items.rows, .radios, .extra, .type-list, .revs, .genre-list, .menu-list, .ser-list, .going, .hero, .going-main { grid-template-columns: minmax(0, 1fr); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.items.cards { grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); }
.extra div { grid-template-columns: fit-content(40%) minmax(0, 1fr); }
.type-list .badge { min-width: 0; }
/* せまいスマホ（320px）でも、項目名が縮んで折り返し、ボタンがはみ出さない */
.chk-row > label.chk { flex: 1 1 auto; min-width: 0; }
.chk-row .ctrls { flex: none; }
.sheet-head > :first-child { flex: 1 1 auto; min-width: 0; }
.sheet-head > .icon-btn { flex: none; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-item .badge { flex: none; }
.ser-item .badge { flex: 0 1 auto; min-width: 0; max-width: 35%; }
.type-list .grow { white-space: nowrap; }
/* お知らせ：画面の幅いっぱいまで広げ、長い文は3行で省く */
#toast { width: max-content; max-width: min(560px, calc(100% - 32px)); }
#toast > span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-width: 0; }
#toast .toast-btn { flex: none; }
/* 文字を大きくする設定のスマホ向け */
fieldset { min-width: 0; }
.prog-bar-row { flex-wrap: wrap; }
.prog-frac { flex: 0 1 auto; min-width: 0; }
.rate-pick { max-width: 100%; min-width: 0; }
.rate-row .date { white-space: normal; text-align: right; min-width: 0; }

/* ===== たくさん登録しても重くならないように（2026/11/19） ===== */
/* 画面の外にあるカードは、見えるまで配置の計算を省く */
.items > .card { content-visibility: auto; contain-intrinsic-size: auto 170px; }
.items > .row-item { content-visibility: auto; contain-intrinsic-size: auto 62px; }

/* ===== 初めて開いたときの案内（2026/11/19） ===== */
.welcome {
  max-width: 640px; margin: 8px auto 0; padding: 22px 18px 18px; border-radius: var(--radius, 16px);
  background: var(--surface); box-shadow: var(--shadow-md);
}
.welcome h2 { margin: 0 0 4px; font-size: 22px; text-wrap: balance; }
.welcome > p { margin: 0; font-size: 14px; }
.wel-picks { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 18px; }
.wel-pick {
  --c: var(--accent); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--muted);
}
.wel-pick[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text); }
.wel-pick[aria-pressed="true"]::before { content: "✓ "; color: var(--c); }
.wel-start { width: 100%; padding: 14px; font-size: 16px; }
.wel-note { margin: 10px 0 0; text-align: center; }
.wel-sub { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.wel-sub .btn { flex: 1 1 auto; }

/* 作品の追加：「もっと入力する」（畳める） */
details.more-fields { margin-top: 16px; border-top: 1px solid var(--line); }
details.more-fields > summary {
  list-style: none; cursor: pointer; position: relative; padding: 14px 26px 4px 2px;
  font-weight: 700; color: var(--accent); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
}
details.more-fields > summary::-webkit-details-marker { display: none; }
details.more-fields > summary small { font-weight: 400; color: var(--muted); font-size: 12px; }
details.more-fields > summary::after { content: "▾"; position: absolute; right: 4px; top: 14px; color: var(--muted); transition: transform .15s; }
details.more-fields[open] > summary::after { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { details.more-fields > summary::after { transition: none; } }

/* 入力欄が背景と同じ色にならないように：グレーの枠（詳細設定など）の中の入力欄は白にして、細い枠線を付ける */
form.sheet details.adv :is(input:not([type=range]):not([type=radio]):not([type=checkbox]), select, textarea) {
  background: var(--surface); border: 1px solid var(--line);
}
form.sheet details.adv .fields :is(input:not([type=range]):not([type=radio]):not([type=checkbox]), select, textarea) {
  background: var(--surface2); border-color: transparent;
}

/* =========================================================
   デザイン案A「ノート」（2026/11/21）
   方針：紙とインクのノート。影やグラデーションを使わず、細い罫線で区切る。
   角は小さく（4px）、色は紺のインク1色と種類の色だけ。見出しは明朝。
   変更前の見た目は「元の状態_2026-11-21（デザイン変更前）」に保存してある。
   ========================================================= */
:root {
  --bg: #f6f4ee;          /* 紙 */
  --surface: #fffdf8;     /* ページ */
  --surface2: #eeebe2;    /* うすい塗り */
  --line: #dcd7ca;        /* 罫線 */
  --text: #1e2330;        /* インク */
  --muted: #6c685f;       /* 鉛筆 */
  --accent: #284783;      /* 紺のインク */
  --accent2: #284783;
  --accent-text: #ffffff;
  --star: #d99a06;
  --star-off: #dad5c8;
  --req: #c0561b;         /* 朱 */
  --shadow-sm: none;
  --shadow-md: none;
  --radius: 4px;
  --r: 4px;
  --r-sm: 2px;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
}
:root[data-app-theme="dark"] {
  --bg: #15161a;
  --surface: #1c1e23;
  --surface2: #25272d;
  --line: #34363d;
  --text: #ebe7de;
  --muted: #a5a097;
  --accent: #91a9e3;
  --accent2: #91a9e3;
  --accent-text: #111522;
  --star: #f0b429;
  --star-off: #3b3d43;
  --req: #f08a4b;
  --shadow-sm: none;
  --shadow-md: none;
}

/* 見出しは明朝（ノートの手書きの見出しのように） */
.top h1, .sheet h2, .welcome h2, .card h3, .tile-label, .hero-count b, .hero-label, .home-sec, .grp-div > span, .adv-title, #detail .sheet h2 {
  font-family: var(--serif); letter-spacing: .02em;
}
.top h1 { font-weight: 700; }
.sheet h2, .welcome h2 { font-weight: 700; }
.card h3 { font-weight: 700; font-size: 17px; }

/* ページ（カード・タイル・一覧）は、影ではなく細い線で区切る */
.card, .row-item, .tile, .going-item, .welcome, .type-list li, .genre-list li, .rev, .menu-grid .menu-item {
  box-shadow: none; border: 1px solid var(--line); border-radius: var(--r);
}
.card:hover, .row-item:hover, .tile:hover { box-shadow: none; border-color: var(--accent); }
.card:active, .tile:active, .hero:active { transform: none; }
.menu-grid .menu-item { background: var(--surface); }
.type-list li, .genre-list li { background: var(--surface); }
.rev { background: var(--surface); }

/* ホーム：すべての記録（グラデーションと大きな★の飾りをやめ、ノートの表紙の見出しのように） */
.hero {
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: none; padding: 16px 18px 14px; border-top: 3px solid var(--accent);
}
:root[data-app-theme="dark"] .hero { background: var(--surface); }
.hero::after { content: none; }
.hero-label { font-size: 15px; opacity: 1; }
.hero-go { background: transparent; color: var(--accent); padding: 0; border-radius: 0; }
.hero-count { color: var(--muted); }
.hero-count b { color: var(--text); font-weight: 700; }
.hero-stats { gap: 0; }
.hero-stats > span { background: transparent; border-radius: 0; padding: 2px 14px 2px 0; margin-right: 14px; border-right: 1px solid var(--line); }
.hero-stats > span:last-child { border-right: 0; margin-right: 0; }
.hero-stats small { opacity: 1; color: var(--muted); }
.hero-last { opacity: 1; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 2px; }

/* 見出し（ホームの「続きから」「種類」など）：小さな見出し＋罫線 */
.home-sec { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .08em; }
.home-sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.grp-div { font-weight: 700; }

/* 種類のタイル：上の色の帯は細く、角は小さく */
.tile { border-radius: var(--r); }
.tile::before { height: 3px; opacity: 1; }
.tile-label, .tile-count b { font-weight: 700; }
.tile-dot { border-radius: var(--r-sm); }
.tile.tile-add { border: 1px dashed var(--line); }

/* 続きから */
.going-item { border-radius: var(--r); box-shadow: inset 3px 0 0 var(--c); }
.going-plus { background: transparent; border-left: 1px solid var(--line); }
.going-bar, .going-bar i, .prog-bar, .prog-bar i { border-radius: 0; }
.going-bar, .prog-bar { height: 4px; }

/* ラベル（種類・ステータス・周目）：丸いピル型をやめ、小さな四角のラベルに */
.badge, .st, .round { border-radius: var(--r-sm); padding: 1px 7px; font-weight: 700; }
.round { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.st-pick, .st-pick select { border-radius: var(--r-sm); }
.tag-chip, .tag-view { border-radius: var(--r-sm); }
.wel-pick { border-radius: var(--r); }
.req-pill, .cand-pill { border-radius: var(--r-sm); }

/* ツールバー：検索欄と切り替えは、線で囲った四角に */
.toolbar input[type=search] { box-shadow: none; border: 1px solid var(--line); border-radius: var(--r); }
.q-clear { border-radius: var(--r-sm); }
.tool-row select, .tool-row .btn, .tool-row .view-seg { box-shadow: none; border: 1px solid var(--line); border-radius: var(--r); }
.tool-row .view-seg button { border-radius: var(--r-sm); }
#count { border-radius: var(--r-sm); background: transparent; border: 1px solid var(--line); }
.chip { border-radius: var(--r); }

/* ボタン */
.btn, select, .icon-btn, .icon-btn.sm, .stepper, .stepper button, .theme-seg, .seg, .view-seg { border-radius: var(--r); }
.theme-seg button, .seg span, .view-seg button { border-radius: var(--r-sm); }
.theme-seg button[aria-pressed="true"], .seg input:checked + span, .view-seg button[aria-pressed="true"] { box-shadow: 0 0 0 1px var(--line); }
.icon-btn { box-shadow: none; border: 1px solid var(--line); }
.icon-btn.sm { border: 0; }
.btn.primary { box-shadow: none; }

/* 右下の＋：グラデーションの丸をやめ、紺の四角いボタンに */
.fab { border-radius: var(--r); width: 56px; height: 56px; background: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }

/* 下から出る画面 */
dialog { border-radius: 8px 8px 0 0; box-shadow: 0 -2px 12px rgba(0, 0, 0, .12); }
@media (min-width: 700px) { dialog { border-radius: 6px; } }
dialog.confirm { border-radius: 6px; }
dialog:not(.confirm) > .sheet::before { border-radius: 0; height: 4px; width: 36px; }

/* 入力欄：白いページに線で囲む（背景と同じ色にならない） */
form.sheet input:not([type=range]):not([type=radio]):not([type=checkbox]), form.sheet select, form.sheet textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
form.sheet input:focus, form.sheet select:focus, form.sheet textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
fieldset, .fields, details.adv, .subs-box, .combo-list, .combo-list li, .chart, .detail-img, .card-img, .img-prev, .ser-item, .ep, .ep-list li, .menu-list > *, .backup-note { border-radius: var(--r); }
details.adv { background: transparent; border: 1px solid var(--line); }
form.sheet details.adv :is(input:not([type=range]):not([type=radio]):not([type=checkbox]), select, textarea) { background: var(--surface); border: 1px solid var(--line); }
form.sheet details.adv .fields :is(input:not([type=range]):not([type=radio]):not([type=checkbox]), select, textarea) { background: var(--surface); border: 1px solid var(--line); }
.subs-box { background: transparent; border: 1px solid var(--line); }
.chart { background: var(--surface); border: 1px solid var(--line); }
.combo-list { box-shadow: 0 4px 12px rgba(0, 0, 0, .14); }

/* 目次 */
.index-tab { border-radius: var(--r) 0 0 var(--r); box-shadow: none; border: 1px solid var(--line); border-right: 0; }
.index-panel { box-shadow: none; }
.index-list button, .index-list a { border-radius: var(--r-sm); }

/* お知らせ */
#toast { border-radius: var(--r); box-shadow: none; }

/* 初めて開いたときの案内 */
.welcome { border-top: 3px solid var(--accent); }

/* リンク（URL）の項目：押せるリンク */
.ext-link { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.ext-link::after { content: "↗"; text-decoration: none; }
.ext-link small { color: var(--muted); font-weight: 400; text-decoration: none; }
.link-text { min-height: 80px; font-size: 12px; }

/* iPhone の Safari で開いたとき：ホーム画面への追加の案内 */
.ios-hint { max-width: 640px; margin: 6px auto 12px; padding: 12px 16px; border: 1px solid var(--accent); border-radius: var(--r, 4px); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.ios-hint p { margin: 0 0 6px; }
.ios-hint ol { margin: 0 0 6px; padding-left: 1.4em; font-size: 14px; line-height: 1.7; }
.ios-share { font-weight: 700; color: var(--accent); }
.ios-hint .btn { margin-top: 4px; }
