/* Layout: a streaming-app style, dark only. A page header (title, actions, search) with a soft green glow,
   sticky filter chips, list rows with a colored square tile on the left (like cover art), and a fixed
   bottom tab bar for ライブラリ / 検索. Editing happens in a dark bottom sheet. */
:root {
  --bg: #121212;          /* 画面の地 */
  --bg-elev: #1f1f1f;     /* 浮いた面（お知らせ） */
  --sheet: #282828;       /* シート・メニュー */
  --field: #3e3e3e;       /* 入力欄・チップ */
  --field-hover: #4d4d4d;
  --text: #ffffff;
  --sub: #b3b3b3;         /* 補足の文字 */
  --dim: #7f7f7f;         /* さらに控えめな文字 */
  --line: #2a2a2a;
  --track: #4d4d4d;       /* 進み具合バーの溝 */
  --accent: #1ed760;      /* 差し色（緑） */
  --accent-press: #1db954;
  --on-accent: #000000;
  --toast: #2e77d0;
  --danger: #f3727f;
  --danger-fill: #e91429;
  --want: #509bf5;
  --done: #c58af9;
  --dropped: #a7a7a7;
  --star: #1ed760;
  --scrim: rgb(0 0 0 / 70%);
  --glow: rgb(30 215 96 / 16%);

  /* ランクの色 */
  --rank-normal: #8a8a8a;
  --rank-rookie: #6fd39a;
  --rank-amateur: #4fb3e8;
  --rank-veteran: #a77df0;
  --rank-bronze: #d08a4e;
  --rank-silver: #c9ced6;
  --rank-gold: #f0c03a;
  --rank-platinum: #8fe0d8;
  --rank-diamond: #82c3ff;
  --rank-mithril: #dbe6ff;
  --rank-orichalcum: #ff7a45;

  /* ジャケット風の四角の色（作品ごとに題名から選ぶ） */
  --t0: #e8115b; --t1: #8d67ab; --t2: #1e3264; --t3: #ba5d07; --t4: #27856a; --t5: #509bf5;
  --t6: #e13300; --t7: #148a08; --t8: #dc148c; --t9: #477d95; --t10: #af2896; --t11: #0d73ec;

  --font: "Figtree", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 16px;
  --fs-xl: 26px;

  color-scheme: dark;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--glow) 0, rgb(18 18 18 / 0) 320px);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* iPhone のステータスバーの裏に、スクロールした内容が透けないようにする */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--bg);
  z-index: 30;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- header ---------- */
.top {
  display: grid;
  gap: 12px;
  padding-block: 16px 12px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
/* 丸いアイコン（自分の写真）。.face が中身、.ringed でランクの色の輪を付ける */
.avatar {
  --size: 36px;
  display: block;
  flex: none;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  font-size: calc(var(--size) * 0.42);
  font-weight: 800;
  line-height: 1;
}
.avatar.ringed { padding: 2px; border: 2px solid var(--rk, var(--field)); }
.avatar.xl { --size: 132px; }
.avatar.xl.ringed { padding: 4px; border-width: 4px; }
.face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--field);
  color: var(--text);
  user-select: none;
}
.face[class*=" c"] { background: var(--tc); color: #fff; }
.face.blank { color: var(--sub); }
.face svg { width: 62%; height: 62%; margin-top: 12%; }
.face img { width: 100%; height: 100%; object-fit: cover; }
button.avatar:active .face { filter: brightness(0.85); }

/* ランクの色（app.js の RANKS の id と合わせる） */
[data-rank="normal"] { --rk: var(--rank-normal); }
[data-rank="rookie"] { --rk: var(--rank-rookie); }
[data-rank="amateur"] { --rk: var(--rank-amateur); }
[data-rank="veteran"] { --rk: var(--rank-veteran); }
[data-rank="bronze"] { --rk: var(--rank-bronze); }
[data-rank="silver"] { --rk: var(--rank-silver); }
[data-rank="gold"] { --rk: var(--rank-gold); }
[data-rank="platinum"] { --rk: var(--rank-platinum); }
[data-rank="diamond"] { --rk: var(--rank-diamond); }
/* 上の2つは、メダルを特別な色の重ねにする */
[data-rank="mithril"] { --rk: var(--rank-mithril); --rk-fill: linear-gradient(135deg, #ffffff 0%, #c7d8ff 45%, #7fa2ff 100%); }
[data-rank="orichalcum"] { --rk: var(--rank-orichalcum); --rk-fill: linear-gradient(135deg, #ffd56b 0%, #ff7a45 50%, #c94cff 100%); }
[data-rank="secret"] { --rk: var(--dim); }
.title-row h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.top-actions { display: flex; gap: 2px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}
.icon-btn:active { background: var(--line); }
.summary {
  margin: -6px 0 0;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.search {
  position: relative;
  display: block;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sub);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 42px; /* 右は × ボタンのぶん */
  border: 0;
  border-radius: 6px;
  background: var(--line);
  color: var(--text);
  font-size: 16px; /* 16px 未満だと iPhone で入力時に拡大される */
  font-weight: 500;
}
.search input::placeholder { color: var(--sub); }
/* ブラウザが付ける消すボタンは出さない（自前の × と二重になるため） */
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
/* 入力した文字を一度に消す × ボタン（文字があるときだけ出る）。押しやすいよう 44px 四方 */
.search-clear {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--sub);
  cursor: pointer;
}
.search-clear path { stroke: var(--line); }
/* 検索画面の入力欄は白く大きく */
body[data-mode="find"] .search input {
  height: 48px;
  border-radius: 500px;
  background: var(--text);
  color: #121212;
}
body[data-mode="find"] .search input::placeholder { color: #535353; }
body[data-mode="find"] .search-icon { color: #121212; }
body[data-mode="find"] .search-clear { color: #535353; }
body[data-mode="find"] .search-clear path { stroke: var(--text); }

/* ---------- filter chips ---------- */
.tabbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--bg);
}
.chips {
  display: flex;
  gap: 8px;
  padding-block: 8px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 500px;
  background: var(--line);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
}
.chips .n {
  color: var(--sub);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chips button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}
.chips button[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.chips button[aria-pressed="true"] .dot { display: none; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}

/* 状態ごとの色。チップの点・行の文字・入力欄で共通 */
.s-want { --c: var(--want); }
.s-watching { --c: var(--accent); }
.s-done { --c: var(--done); }
.s-dropped { --c: var(--dropped); }

/* ---------- main ---------- */
.main {
  padding-block: 6px calc(100px + env(safe-area-inset-bottom, 0px));
}
.view {
  display: grid;
  gap: 8px;
}
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--sub);
  font-size: var(--fs-sm);
}
.notice p { margin: 0; flex: 1 1 16em; min-width: 0; }
.notice.warn { color: var(--danger); }
/* ホーム画面への追加のしかた（「追加のしかた」を押すと開く） */
#install-note > p { flex-basis: 100%; } /* 文は全幅、ボタンはその下に並べる */
.install-steps { flex: 1 1 100%; display: grid; gap: 8px; justify-items: start; }
.install-steps ol { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }
.install-steps p { flex: none; }
.menu-sec .backup-status.due { color: var(--text); font-weight: 700; }
.pill-btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #727272;
  border-radius: 500px;
  background: none;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 2px 4px;
}
.sort {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.sort select {
  height: 34px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
}
.sort select option { background: var(--sheet); color: var(--text); }
.result-count {
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* ---------- ジャケット風の四角 ---------- */
.tile {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--tc), color-mix(in srgb, var(--tc) 45%, #000));
  background-color: var(--tc);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 12px rgb(0 0 0 / 35%);
  user-select: none;
}
/* ポスターがあるときは、読み込むまで灰色の四角にする。頭文字と色は、ポスターがない・読み込めないときだけ出す
   （読み込めない画像は app.js が外すので、:has(img) が外れて頭文字に戻る） */
.tile:has(img) { background: var(--field); color: transparent; }
/* ポスターは四角いっぱいに、中央を切り抜いて表示 */
.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.c0 { --tc: var(--t0); } .c1 { --tc: var(--t1); } .c2 { --tc: var(--t2); } .c3 { --tc: var(--t3); }
.c4 { --tc: var(--t4); } .c5 { --tc: var(--t5); } .c6 { --tc: var(--t6); } .c7 { --tc: var(--t7); }
.c8 { --tc: var(--t8); } .c9 { --tc: var(--t9); } .c10 { --tc: var(--t10); } .c11 { --tc: var(--t11); }

/* ---------- ライブラリの行 ---------- */
.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 4px 16px;
}
.card {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px;
  margin-inline: -8px;
  border-radius: 6px;
}
.card-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  border-radius: inherit;
  background: transparent;
}
.card-hit:active { background: rgb(255 255 255 / 6%); }
@media (hover: hover) {
  .card:hover { background: var(--line); }
}
.card-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.card-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.card-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 6px;
  margin: 0;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--c);
  font-weight: 700;
}
.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
}
.sep { color: var(--dim); }
.tag {
  padding: 0 5px;
  border-radius: 3px;
  background: var(--field);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.6;
}
.count b { color: var(--text); font-weight: 700; }
.stars {
  color: var(--star);
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.stars .off { color: var(--track); }
.note {
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--dim);
  font-size: var(--fs-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* 細い進み具合バー */
.bar {
  display: block;
  width: 100%;
  height: 3px;
  margin: 5px 0 2px;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: var(--track);
  -webkit-appearance: none;
  appearance: none;
}
.bar::-webkit-progress-bar { background: var(--track); border-radius: 2px; }
.bar::-webkit-progress-value { background: var(--c); border-radius: 2px; }
.bar::-moz-progress-bar { background: var(--c); border-radius: 2px; }

.ep-btns {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 8px;
}
.plus, .minus {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: var(--fs-sm);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform 0.08s ease-out;
}
.plus { border: 0; background: var(--accent); color: var(--on-accent); }
.minus { border: 1px solid #727272; background: transparent; color: var(--text); }
.plus:active, .minus:active { transform: scale(0.92); }
.plus:active { background: var(--accent-press); }

/* ---------- 検索の行 ---------- */
.works { display: grid; gap: 2px; }
.work {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.work .tile { width: 48px; height: 48px; font-size: 20px; }
.work-main { display: grid; gap: 1px; min-width: 0; }
.work-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.work-meta {
  margin: 0;
  overflow: hidden;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.add-btn, .added {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
}
.add-btn {
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--sub);
}
.add-btn:active { color: var(--text); background: var(--line); }
.added {
  width: auto;
  min-width: 44px;
  gap: 2px;
  color: var(--accent);
  justify-items: center;
}
.added .stars { font-size: 10px; }
.more {
  justify-self: center;
  margin-top: 8px;
}
.find-capped {
  margin: 12px 0 0;
  color: var(--sub);
  font-size: var(--fs-sm);
  text-align: center;
}
.credit {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: var(--fs-xs);
}
.credit a { color: var(--sub); }

/* ---------- アカウント ---------- */
/* 画面上の光を、今のランクの色にする */
body[data-mode="account"] { --glow: color-mix(in srgb, var(--rk, var(--accent)) 22%, transparent); }

.account { gap: 24px; }
.profile-hero {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-block: 4px 0;
  text-align: center;
}
.profile-hero .avatar.xl { margin-bottom: 8px; box-shadow: 0 8px 28px rgb(0 0 0 / 45%); border-radius: 50%; }
.profile-name {
  margin: 0;
  max-width: 100%;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.profile-name.unset { color: var(--sub); font-size: 22px; }
.profile-meta {
  margin: 0;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.profile-hero .pill-btn { margin-top: 10px; }
.pill-btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.eyebrow {
  margin: 0;
  color: var(--sub);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.rank-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 8px;
  background: var(--bg-elev);
}
.rank-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.medal {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgb(255 255 255 / 55%) 0 14%, rgb(255 255 255 / 0) 34%),
    var(--rk-fill, var(--rk));
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 22%);
}
.rank-name h3 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.2; }
.rank-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.rank-count b { color: var(--text); font-size: 30px; font-weight: 800; line-height: 1.1; }
.rank-count span { margin-left: 8px; }
.info-btn { color: var(--sub); margin-right: -8px; }
.info-btn:active { color: var(--text); }
.rank-bar {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  background: var(--track);
  -webkit-appearance: none;
  appearance: none;
}
.rank-bar::-webkit-progress-bar { background: var(--track); border-radius: 3px; }
.rank-bar::-webkit-progress-value { background: var(--text); border-radius: 3px; }
.rank-bar::-moz-progress-bar { background: var(--text); border-radius: 3px; }
.rank-next { margin: 0; font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.ladder {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ladder li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--dim);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.ladder i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--rk); }
.ladder li.reached { color: var(--sub); }
.ladder li.reached i { background: var(--rk); }
.ladder li[aria-current] { background: var(--field); color: var(--text); font-weight: 700; }
.ladder li.reached i { background: var(--rk-fill, var(--rk)); }
.ladder .ln { overflow-wrap: anywhere; }
.ladder .now {
  padding: 0 7px;
  border-radius: 500px;
  background: var(--rk);
  color: #121212;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.8;
}
.rank-info-body .hint, .photo-field .hint { margin: 0; color: var(--dim); font-size: var(--fs-xs); }
.rank-info-body { gap: 14px; }
.info-lead { margin: 0; color: var(--sub); font-size: var(--fs-sm); }

.stats-sec { display: grid; gap: 10px; }
.sec-title { margin: 0; font-size: 20px; font-weight: 800; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  gap: 8px;
  margin: 0;
}
.stat {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg-elev);
}
.stat dt { color: var(--sub); font-size: var(--fs-sm); }
.stat dd {
  order: -1;
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.account-note { margin: 0; color: var(--dim); font-size: var(--fs-xs); max-width: 40em; }

/* プロフィール編集 */
.photo-field { display: grid; justify-items: center; gap: 12px; text-align: center; }
.photo-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; }
.photo-actions .btn { cursor: pointer; }
.photo-field .error { max-width: 28em; }

/* ---------- empty state ---------- */
.empty {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 40px 16px;
  text-align: center;
}
.empty h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.4;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.empty p { margin: 0; color: var(--sub); font-size: var(--fs-sm); max-width: 32em; }
.empty .btn { margin-top: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 500px;
  font-size: var(--fs-md);
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.08s ease-out;
}
.btn:active { transform: scale(0.97); }
a.btn { text-decoration: none; } /* リンクをボタンの見た目で出すとき */
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { background: var(--accent-press); }
.btn.light { background: var(--text); color: #121212; }
.btn.ghost { background: transparent; border-color: #727272; color: var(--text); }
.btn.danger-fill { background: var(--danger-fill); color: var(--text); }
.btn-text {
  height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  font-weight: 700;
}
.btn-text.danger { color: var(--danger); }

/* ---------- 下のタブバー ---------- */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 25;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: linear-gradient(180deg, rgb(0 0 0 / 0) 0, rgb(0 0 0 / 88%) 38%, #000 100%);
}
.bottom-inner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-block: 18px 6px;
}
/* 下のタブのアカウントは、自分の写真を小さく出す。選んでいるときは白い輪 */
.nav-avatar { --size: 26px; padding: 1px; border: 1.5px solid transparent; }
.bottom-inner button[aria-selected="true"] .nav-avatar { border-color: var(--text); }
.bottom-inner button {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
}
.bottom-inner button[aria-selected="true"] { color: var(--text); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px;
  border-radius: 8px;
  background: var(--toast);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: 0 8px 24px rgb(0 0 0 / 50%);
  transform: translateX(-50%);
  animation: toast-in 0.18s ease-out;
}
.toast span { min-width: 0; overflow-wrap: anywhere; }
.toast button {
  flex: none;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- bottom sheet ---------- */
.sheet {
  width: 100%;
  max-width: 600px;
  max-height: calc(100% - env(safe-area-inset-top, 0px) - 24px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 12px 12px 0 0;
  background: var(--sheet);
  color: var(--text);
  box-shadow: 0 -8px 32px rgb(0 0 0 / 50%);
}
.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-in 0.22s ease-out;
}
.sheet::backdrop { background: var(--scrim); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(28px); } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 12px; }
}
.sheet > form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 8px 20px;
}
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.3; }
.sheet-body {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: 20px;
  min-height: 0;
  padding: 4px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-foot {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--sheet);
  box-shadow: 0 -1px 0 rgb(255 255 255 / 6%);
}
.foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.foot-row .spacer { flex: 1; }
.foot-row.confirm p { flex: 1 1 100%; margin: 0 0 4px; font-weight: 700; overflow-wrap: anywhere; }

/* ---------- form ---------- */
.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.label {
  padding: 0;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field input[type="text"],
.field input[type="number"],
.field textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--field);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--text); background: var(--field-hover); }
.field textarea { resize: vertical; min-height: 6.5em; }
.field input::placeholder, .field textarea::placeholder { color: var(--dim); }
.error { margin: 0; color: var(--danger); font-size: var(--fs-sm); font-weight: 700; }
/* 作品の画像の出典（公式サイトの画像は、権利者の表記も添える） */
.image-credit { margin: 0; color: var(--dim); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.image-credit a { color: var(--sub); }
.image-credit .copyright { margin-left: 0.6em; }
.season-note {
  margin: 0;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: grid;
  place-items: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 500px;
  background: var(--field);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
}
.seg input:checked + span { background: var(--c); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

.stepper {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  border-radius: 4px;
  background: var(--field);
  overflow: hidden;
}
.stepper button {
  border: 0;
  background: none;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}
.stepper button:active { background: var(--field-hover); }
.field .stepper input {
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}
.with-unit span { color: var(--sub); flex: none; }

.rating {
  display: flex;
  align-items: center;
  gap: 2px;
}
.rating button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--track);
  font-size: 28px;
  line-height: 1;
}
.rating button.on { color: var(--star); }
.rating-text {
  margin-left: 8px;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* タイトル入力中の候補 */
.suggest {
  display: grid;
  border-radius: 4px;
  background: var(--field);
  overflow: hidden;
}
.suggest button {
  display: grid;
  gap: 1px;
  padding: 9px 12px;
  border: 0;
  border-top: 1px solid var(--sheet);
  background: none;
  color: var(--text);
  text-align: left;
}
.suggest button:first-child { border-top: 0; }
.suggest button:active { background: var(--field-hover); }
.suggest .s-title { font-weight: 700; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.suggest .s-meta { color: var(--sub); font-size: var(--fs-xs); }

/* ---------- menu ---------- */
.menu-body { gap: 24px; }
.menu-sec { display: grid; gap: 10px; }
.menu-sec h3 { margin: 0; font-size: var(--fs-lg); font-weight: 800; }
.menu-sec p { margin: 0; color: var(--sub); font-size: var(--fs-sm); max-width: 40em; }
.menu-actions { display: grid; gap: 10px; }
.menu-actions .btn { width: 100%; cursor: pointer; }
.version { margin: 0; color: var(--dim); font-size: var(--fs-xs); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
