/* 画面ごとの形（ホーム・記事の編集・メディアなど） */
@layer pages {

  /* ================= ホーム */
  .hero { display: grid; gap: 8px; margin-bottom: 12px; }
  .hero-main {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
    color: var(--hero-fg);
    text-decoration: none;
    background: var(--hero);
    box-shadow: var(--hero-shadow);
    transition: transform .2s var(--ease), box-shadow .2s;
  }
  .hero-main::after { content: ""; position: absolute; right: -40px; top: -60px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
  .hero-main:hover { transform: translateY(-2px); }
  .hero-main:active { transform: scale(.98); }
  .hero-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; background: rgba(255, 255, 255, .2); }
  .hero-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
  .hero-text b { display: block; font-size: 18px; line-height: 1.35; }
  .hero-text small { display: block; font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero-main > .i:last-child { position: relative; z-index: 1; opacity: .9; }
  .hero-subs { display: grid; gap: 8px; }
  .hero-sub {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 14px;
    border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
    background: var(--surface);
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s;
  }
  .hero-sub:hover { background: var(--accent-soft); }
  .hero-sub svg.i { width: 18px; height: 18px; }

  /* ---- セキュリティの札（views/home.php・AdminApp::guardItems。編集者＝クライアントにだけ。パスキー・2段階認証）。空いている札が「足りていない」と見え、全部そろうと緑に */
  .guard { margin-bottom: 12px; padding: 14px 16px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
  .guard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  .guard-title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 15px; }
  .guard-title svg.i { width: 19px; height: 19px; color: var(--accent); }
  .guard-sum { font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: right; }
  .guard.is-all .guard-sum { color: var(--success); }
  .guard-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guard-item {
    display: flex; align-items: center; gap: 10px;
    min-height: 56px; padding: 8px 10px;
    border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); text-decoration: none;
    transition: background .15s, border-color .15s;
  }
  .guard-item:hover { border-color: var(--accent); }
  .guard-mark { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; }
  .guard-mark svg.i { width: 16px; height: 16px; stroke-width: 2.4; }
  .guard-text { min-width: 0; display: grid; gap: 1px; }
  .guard-text b { font-size: 13.5px; line-height: 1.3; }
  .guard-text small { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
  .guard-item.is-on .guard-mark { background: var(--success-soft); color: var(--success); }
  .guard-item.is-off { border-style: dashed; background: transparent; }
  .guard-item.is-off .guard-mark { border: 2px dashed var(--faint); color: var(--faint); }
  .guard-item.is-off .guard-text small { color: var(--accent); font-weight: 600; }
  .guard-note { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
  .guard.is-all { margin: 24px 0 0; } /* 全部そろったら一番下に */

  /* 種類ごとの件数：スマホは2列に折り返す（横に送る形は、隠れた分に気づかないためやめた。2026-10-16） */
  .tiles { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 14px 0 0; }
  .tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 14px 14px 12px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: transform .2s var(--ease), box-shadow .2s;
  }
  .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-l); }
  .tile-top { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
  .tile-top span { overflow: hidden; text-overflow: ellipsis; }
  .tile-top svg.i { width: 16px; height: 16px; color: var(--accent); }
  .tile b { display: flex; align-items: baseline; gap: 3px; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
  .tile b::after { content: "件"; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
  .tile small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .home-cols { display: grid; gap: 0 24px; }
  .home-cols .section-title { margin-top: 24px; }
  .home-cols .list, .home-cols .card.empty { margin-bottom: 0; }

  /* ---- ホームのアクセス解析（views/home.php・home-access.js。docs/design-analytics.md）
     読み込み中・期間の切り替え・内訳の切り替えで高さが変わらないように、各部分の高さを決めておく */
  .ana {
    --ana-row: 44px;
    --ana-cap: 24px;
    position: relative;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow);
  }
  :where(.ana button) { border: 0; background: none; cursor: pointer; }
  .ana-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
  .ana-title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 16px; }
  .ana-title svg.i { width: 20px; height: 20px; color: var(--accent); }
  .ana-range { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
  .ana-range-btn { min-height: 36px; min-width: 48px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 700; transition: background .2s, color .2s; }
  .ana-range-btn:hover { color: var(--text); }
  .ana-range-btn.is-active { background: var(--accent); color: var(--on-accent); }

  .ana-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; } /* スマホは 2×2、PC は4つ並び */
  .ana-kpi:disabled { cursor: default; transform: none; }
  .ana-kpi:disabled .ana-kpi-value b { color: var(--faint); }
  .ana-kpi {
    position: relative;
    display: grid; gap: 2px; align-content: start; justify-items: start;
    min-width: 0;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1.5px solid transparent;
    text-align: left;
    transition: border-color .2s, background .2s, transform .2s var(--ease);
  }
  .ana-kpi:hover { transform: translateY(-1px); }
  .ana-kpi.is-active { border-color: var(--accent); background: var(--accent-soft); }
  .ana-kpi-label { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
  .ana-kpi.is-active .ana-kpi-label { color: var(--accent); }
  .ana-kpi-value { display: flex; align-items: baseline; gap: 2px; min-width: 0; }
  .ana-kpi-value b { font-size: clamp(20px, 7vw, 28px); line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
  .ana-kpi-value b.is-long { font-size: clamp(17px, 5.8vw, 24px); } /* 7文字以上（1,000,000 など）は3つ並びに収まるように */
  .ana-kpi-value small { font-size: 11px; color: var(--muted); }
  .ana-delta { min-height: 18px; font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
  .ana-delta.is-up { color: var(--success); }

  .ana-chart { position: relative; height: 190px; margin: 0 -4px 12px; touch-action: pan-y; }
  .ana-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
  .ana-grid { stroke: var(--border); stroke-width: 1; }
  .ana-axis { fill: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
  .ana-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
  .ana-line.is-drawing { transition: stroke-dashoffset 1s var(--ease); }
  .ana-area { fill: url(#ana-grad); opacity: 1; transition: opacity .8s .25s var(--ease); }
  .ana-area.is-hidden { opacity: 0; transition: none; }
  .ana-grad-top { stop-color: var(--accent); stop-opacity: .28; }
  .ana-grad-bottom { stop-color: var(--accent); stop-opacity: 0; }
  .ana-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
  .ana-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
  .ana-tip {
    position: absolute; top: 0; left: 0; z-index: 2;
    padding: 6px 10px;
    border-radius: 10px;
    background: var(--toast-bg); color: var(--toast-fg);
    font-size: 12px; line-height: 1.45; white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow-l);
  }
  .ana-tip b { font-size: 15px; font-variant-numeric: tabular-nums; }

  .ana-tabs { margin-bottom: 0; }
  /* 内訳は最初は閉じておき、ボタンで開く（2026-10-16 YoKa）。開け閉めは高さをなめらかに変える。開いた高さは5つの内訳のいちばん高いもので決まり、内訳を替えても変わらない */
  .ana-drawer { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
  .ana-drawer.is-open { grid-template-rows: 1fr; }
  .ana-drawer-in { min-height: 0; overflow: hidden; }

  .ana-pc { display: none; } /* 内訳のボタンの言葉：スマホは短く（3つが横に収まるように） */
  .ana-tabs .tab { cursor: pointer; padding: 4px 8px; } /* スマホで4つが1行に収まるように */
  .ana-panels { display: grid; grid-template-columns: minmax(0, 1fr); padding-top: 8px; }
  /* 内訳は3つとも同じ場所に重ね、見えないものは visibility で隠す（いちばん高いものに揃い、切り替えで高さが変わらない）。
     行の高さを決め、ページの10行ぶんを最低の高さにする（読み込み前・行が少ないときも同じ高さ） */
  .ana-panel { grid-area: 1 / 1; min-height: calc(var(--ana-cap) + 10 * var(--ana-row) + 9 * 2px); } /* 検索ワードは上に1行の説明がつく */
  .ana-cap { height: var(--ana-cap); margin: 0; font-size: 11.5px; line-height: var(--ana-cap); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ana-panel:not(.is-active) { visibility: hidden; }
  .ana-panel.is-active { animation: kwe-fade .25s var(--ease); }
  .ana-rows { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; } /* 長い言葉で枠より広がらない */
  .ana-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 1fr auto; gap: 2px 10px; align-items: center; height: var(--ana-row); padding: 4px 2px 6px; box-sizing: border-box; }
  .ana-row-label { min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ana-row-label small { margin-left: 6px; font-weight: 400; color: var(--faint); font-size: 11.5px; }
  .ana-row-value { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .ana-row-value small { margin-left: 4px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
  .ana-bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
  .ana-bar > span { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--accent); transition: width .9s var(--ease); }
  .ana-rank { display: inline-block; min-width: 1.6em; color: var(--faint); font-variant-numeric: tabular-nums; }

  /* 過去30分以内に見た人：見出しの下の1行（高さは先にとっておく）。押すと見られているページが重なって出る（下を押し下げない） */
  .ana-recent { position: relative; min-height: 30px; margin: -4px 0 8px; }
  .ana-recent-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 10px 2px 8px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 12.5px; font-weight: 700; }
  .ana-recent-btn.is-none { background: var(--surface-2); color: var(--muted); }
  .ana-recent-btn:disabled { cursor: default; }
  .ana-live { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: ana-live 1.8s ease-in-out infinite; }
  .ana-recent-btn.is-none .ana-live { animation: none; opacity: .5; }
  @keyframes ana-live { 50% { opacity: .25; transform: scale(.8); } }
  .ana-recent-pages { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; width: min(320px, 100%); padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-l); animation: kwe-pop .15s var(--ease); }
  .ana-recent-cap { margin: 0 0 4px; font-size: 11.5px; color: var(--muted); }
  .ana-recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
  .ana-recent-list li { display: flex; justify-content: space-between; gap: 10px; }
  .ana-recent-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 地域・端末：上にスマホ・パソコンの割合（数字だけ。割合の帯は使わない：ui.md） */
  .ana-devs { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 2px 2px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
  .ana-dev { display: inline-flex; align-items: baseline; gap: 3px; }
  .ana-dev small { font-size: 12px; color: var(--muted); font-weight: 600; }
  .ana-dev b { margin-left: 4px; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

  /* 曜日・時間帯 */
  .ana-peak { margin: 2px 0 10px; font-size: 14px; }
  .ana-peak b { color: var(--accent); }
  .ana-hours { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; align-items: end; height: 120px; }
  .ana-hour { display: flex; align-items: flex-end; height: 100%; }
  .ana-hour > span { display: block; width: 100%; height: 0; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .45; transition: height .8s var(--ease); }
  .ana-hour.is-peak > span { opacity: 1; }
  .ana-hours-axis { display: flex; justify-content: space-between; margin: 4px 0 14px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
  .ana-week { display: grid; gap: 6px; }
  .ana-week-row { display: grid; grid-template-columns: 1.6em minmax(0, 1fr) 4em; align-items: center; gap: 8px; font-size: 12.5px; }
  .ana-week-day { color: var(--muted); font-weight: 700; text-align: center; }
  .ana-week-row.is-peak .ana-week-day { color: var(--accent); }
  .ana-week-row .ana-bar { grid-column: auto; } /* 一覧の棒（行の幅いっぱい）とは違い、曜日と数字の間に置く */
  .ana-week-row .ana-bar > span { opacity: .45; }
  .ana-week-row.is-peak .ana-bar > span { opacity: 1; }
  .ana-week-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

  .ana-empty { margin: 0; padding: 40px 8px; text-align: center; color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
  .ana-foot { margin: 8px 0 0; font-size: 11.5px; color: var(--faint); }
  .ana-foot.is-stale { color: var(--warning); }

  /* 読み込み中：形はそのまま、中身だけ淡く */
  .ana.is-loading .ana-kpi-value b, .ana.is-loading .ana-chart svg, .ana.is-loading .ana-panel { opacity: .35; transition: opacity .2s; }
  .ana.is-loading .ana-chart::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, var(--surface-2), transparent);
    background-size: 200% 100%;
    animation: ana-shine 1.2s linear infinite;
    opacity: .8;
  }
  @keyframes ana-shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }

  /* 取れなかった（前の数字もない）：枠の高さのまま、中に理由 */
  .ana-error { position: absolute; inset: 64px 16px 16px; display: grid; align-content: start; justify-content: center; justify-items: center; gap: 8px; padding: 72px 16px 16px; text-align: center; background: var(--surface); border-radius: var(--radius); color: var(--muted); font-size: 13.5px; }
  .ana-error[hidden] { display: none; }
  .ana-error svg.i { width: 28px; height: 28px; color: var(--warning); }
  .ana-error p { margin: 0; max-width: 46ch; overflow-wrap: anywhere; }

  /* ================= 記事の編集：上に操作バー、スマホは公開の設定を下から出す */
  .editbar {
    position: sticky;
    top: var(--topbar-h);
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -20px -16px 16px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
  }
  .editbar .back-link { margin-right: auto; min-width: 0; overflow: hidden; white-space: nowrap; }
  .editbar .back-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .editbar .autosave-status { display: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
  .editbar .btn { min-height: 38px; padding: 0 14px; font-size: 14px; }
  .editbar .btn-icon { width: 38px; padding: 0; }
  .editbar .side-toggle { padding: 0 10px; gap: 4px; }
  @media (max-width: 599px) { .editbar .back-link > span { display: none; } } /* スマホは「<」だけ（公開設定・プレビュー・公開が入らない） */
  .editbar .side-toggle .i { width: 18px; height: 18px; }
  .post-form { display: grid; gap: 20px; align-items: start; }
  .post-main { display: grid; gap: 16px; min-width: 0; }
  .title-input { font-size: 19px !important; font-weight: 700; min-height: 56px !important; }
  .post-side { display: grid; gap: 16px; align-content: start; }
  .post-side .card { margin: 0; }
  .side-title { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
  .side-subtitle { margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
  .side-title + .side-subtitle { margin-top: 0; padding-top: 0; border-top: 0; }
  /* オプションの見出しごとのまとまり（FieldForm）。最初の見出しには線を引かない */
  .field-section { display: grid; gap: 16px; }
  .side-title + .field-section > .side-subtitle:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
  /* 本文の下に置くオプション（テーマの fields_place 'main'。項目の多い種類）：まとまりの中は横に並べ、長い欄・繰り返し・写真は1行を使う */
  .post-fields { display: grid; gap: 0; margin-top: 8px; }
  .post-fields .card-title { margin-bottom: 4px; }
  .post-fields .field-section { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 14px 20px; align-items: start; padding: 18px 0 22px; border-top: 1px solid var(--border); }
  .post-fields .card-title + .field-section { border-top: 0; padding-top: 12px; }
  .post-fields .field-section:last-of-type { padding-bottom: 6px; }
  /* 見出し（開催・概要など）：項目名より一段大きく、左に青い印 */
  .post-fields .side-subtitle { display: flex; align-items: center; gap: 10px; grid-column: 1 / -1; margin: 0 0 2px; padding: 0; border: 0; font-size: 16px; color: var(--text); }
  .post-fields .side-subtitle::before { content: ""; flex: none; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); }
  .post-fields .field.is-wide, .post-fields fieldset.field, .post-fields .field-perms { grid-column: 1 / -1; }
  @media (max-width: 599px) {
    /* スマホ：日付・時刻・選択のような短い欄は2つ並べ、文字の欄は1行を使う（1列ずつだと縦に長い） */
    .post-fields .field-section { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
    .post-fields .field-section > .field:not(.is-short) { grid-column: 1 / -1; }
  }
  .post-fields .field-perms { margin-top: 10px; }
  .side-stack { display: grid; gap: 16px; }
  .side-actions { display: grid; gap: 8px; }
  .sheet-grab { display: block; width: 40px; height: 5px; border-radius: 5px; background: var(--border); margin: 0 auto 14px; }
  .url { overflow-wrap: anywhere; }

  @media (max-width: 959px) {
    .post-side {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 41;
      max-height: 85vh;
      overflow: auto;
      padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
      border-radius: 22px 22px 0 0;
      background: var(--surface);
      box-shadow: var(--shadow-l);
      transform: translateY(105%);
      visibility: hidden;
      transition: transform .32s var(--ease), visibility 0s .32s;
    }
    .post-side.is-open { transform: none; visibility: visible; transition: transform .32s var(--ease); }
    .post-side .card { padding: 0; border: 0; box-shadow: none; }
    .post-side .card + .card { padding-top: 16px; border-top: 1px solid var(--border); border-radius: 0; }
  }
  @media (min-width: 960px) {
    .editbar { top: 0; margin: 0 -32px 20px; padding: 10px 32px; }
    .editor-wrap .ql-toolbar.ql-snow { top: var(--editbar-h) !important; }
    .editbar .autosave-status { display: inline; }
    .editbar .side-toggle, .sheet-grab, .post-side .sheet-close { display: none; }
    .post-form { grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
    @media (min-width: 1280px) { .post-form { grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; } }
    /* 右の列は高くなる（公開の設定＋オプション）ので、画面の高さに収めて列の中で動かす（長い記事でも下まで届くように） */
    .post-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; overscroll-behavior: contain; }
    .hero { grid-template-columns: 1fr minmax(200px, 30%); }
    .guard { padding: 16px 22px; margin-bottom: 20px; }
    .guard-items { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
    .tiles { gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-top: 20px; }
    .tile { padding: 16px 18px; }
    .tile b { font-size: 32px; }
    .home-cols { grid-template-columns: 1fr 1fr; align-items: start; }
    .ana { padding: 22px 24px; margin-bottom: 20px; }
    .ana-title { font-size: 18px; }
    .ana-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
    .ana-kpi { padding: 14px 18px; }
    .ana-kpi-value b { font-size: 34px; }
    .ana-kpi-value b.is-long { font-size: 28px; }
    .ana-pc { display: inline; }
    .ana-sp { display: none; }
    .ana-kpi-value small { font-size: 13px; }
    .ana-chart { height: 280px; }
    .ana-error { inset: 72px 24px 24px; }
    .ana-hours { height: 140px; }
  }

  /* ================= 同時編集の比較 */
  .compare { display: grid; gap: 16px; }
  @media (min-width: 900px) { .compare { grid-template-columns: 1fr 1fr; } }
  .compare-col { display: grid; gap: 12px; align-content: start; margin: 0; }
  .body-preview { border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 480px; overflow: auto; }
  .body-preview table { border-collapse: collapse; }
  .body-preview td { border: 1px solid var(--border); padding: 4px 8px; }

  /* ================= カテゴリ */
  .category-row { display: grid; gap: 8px; width: 100%; margin: 0; }
  .category-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .category-actions .btn-danger { margin-left: auto; } /* 消すボタンは並びから離す（押し間違えないように） */
  @media (min-width: 768px) { .category-row { grid-template-columns: 1fr 1fr auto; align-items: end; } }

  /* ================= 操作ログ・ユーザー */
  .log-row { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; }
  .log-time { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
  .log-list .list-item { padding: 10px 16px; }
  .user-email { flex: 1 1 100%; overflow-wrap: anywhere; }

  /* ================= 予備コード */
  .codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; padding-left: 1.5em; margin: 0 0 20px; }
  .codes code { font-size: 1.05rem; }

  /* ================= パスキーの一覧：名前の変更・削除の欄は行の下に広げる */
  .passkey-edit { flex: 1 1 100%; margin: 4px 0 0; padding-top: 12px; border-top: 1px dashed var(--border); }
  .passkey-list .list-main { flex-basis: 0; }
  .passkey-list .post-meta > span { white-space: nowrap; }

  /* ================= 2段階認証の登録（QR コード） */
  .qr-box { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-start; margin: 0 0 20px; }
  .qr { display: block; width: 200px; height: 200px; flex: none; border-radius: var(--radius-s); }
  .qr .qr-bg { fill: var(--qr-bg); }
  .qr .qr-fg { fill: var(--qr-fg); }
  .qr-box > div { flex: 1 1 220px; min-width: 0; }
  .qr-box .secret { font-family: var(--mono); font-size: 1.05rem; letter-spacing: .04em; overflow-wrap: anywhere; }

  /* ================= メディア（views/media.php・media_results.php）
     一覧は写真のタイルだけ（スマホ3列・PC は 150px 以上で詰める）。押すと1つのファイルの画面（#media-edit）で、大きく見る・ラベルと説明文・削除。
     2026-10-16 YoKa：タイルごとに入力欄とボタンが並ぶ形は「陳腐で使いづらい」 */
  .upload-form { margin: 0 0 12px; }
  .upload-drop { display: none; align-items: center; gap: 12px; padding: 12px 16px; border: 2px dashed var(--border); border-radius: var(--radius-s); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
  .upload-drop svg.i { color: var(--faint); width: 26px; height: 26px; }
  .upload-drop strong { color: var(--text); }
  .upload-text { display: grid; gap: 1px; font-size: 14px; min-width: 0; }
  .upload-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
  .upload-status { margin: 8px 0 0; font-size: 14px; }
  .upload-status:empty { display: none; }
  .media-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .media-tile { min-width: 0; }
  .media-tile-btn {
    display: grid; gap: 4px; width: 100%; padding: 0; margin: 0;
    border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
    border-radius: 12px;
  }
  .media-tile-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  .media-tile-img { display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); transition: transform .2s var(--ease), box-shadow .2s; }
  .media-tile-btn:hover .media-tile-img { box-shadow: var(--shadow-l); transform: translateY(-2px); }
  .media-tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .media-tile-label { font-size: 12.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
  .media-tile-sub { font-size: 11px; color: var(--faint); padding: 0 2px; }
  .media-meta { margin: 0; line-height: 1.5; }
  .pdf-icon { display: inline-block; padding: 18px 14px; border-radius: 6px; background: var(--danger); color: var(--danger-fg); font-weight: 700; letter-spacing: .05em; }
  /* 1つのファイルの画面：スマホは下から、PC は真ん中に。左に大きく見せ、右に欄 */
  .media-edit { width: min(720px, calc(100vw - 24px)); }
  .media-edit-body { display: grid; gap: 16px; padding: 16px; }
  .media-edit-preview { display: grid; gap: 6px; align-content: start; }
  .media-edit-thumb { display: grid; place-items: center; min-height: 160px; max-height: 320px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; text-decoration: none; }
  .media-edit-thumb img { max-width: 100%; max-height: 320px; object-fit: contain; display: block; }
  .media-edit .media-form { align-content: start; }
  @media (max-width: 599px) {
    .media-edit { width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0; border-bottom: 0; }
    .media-edit-thumb { min-height: 120px; max-height: 200px; }
    .media-edit-thumb img { max-height: 200px; }
  }
  @media (min-width: 600px) {
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .media-edit-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 20px; }
  }
  @media (min-width: 960px) {
    .upload-drop { display: flex; } /* ドラッグできる PC だけ。スマホは右上の［アップロード］ */
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  }
  /* 絞り込み・検索は上部に固定。一覧は最低1画面分の高さを確保し、切り替えで中身が減ってもページが縮まない */
  .media-toolbar { position: sticky; top: var(--topbar-h); z-index: 5; background: var(--bg); padding: 8px 4px 0; margin: 0 -4px; }
  @media (min-width: 960px) { .media-toolbar { top: 0; } }
  .media-results { min-height: 100vh; transition: opacity .15s; }
  .media-results.is-loading { opacity: .5; pointer-events: none; }

  /* ホームのタイルの中の「件」は tile b::after。設定の一覧：広い画面では2列 */
  .set-cols { display: grid; gap: 0 28px; }
  .set-section { min-width: 0; }
  @media (min-width: 1280px) { .set-cols { grid-template-columns: 1fr 1fr; align-items: start; } }

  /* 設定 → 更新 */
  .update-offer { display: grid; gap: 10px; }
  .update-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; }
  .update-ver { color: var(--muted); font-variant-numeric: tabular-nums; }
  .update-ver strong { color: var(--text); }
  .update-notes summary { cursor: pointer; color: var(--muted); }
  .update-notes p { margin: 6px 0 0; }
  .update-blocked { margin: 0; color: var(--muted); }

  /* バックアップ（settings_backup） */
  .backup-key { display: block; padding: 8px 10px; border-radius: var(--radius-s); background: var(--surface-2); overflow-wrap: anywhere; user-select: all; }
  .release-form { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin: 4px 0 0; padding-top: 10px; border-top: 1px dashed var(--border); }
  .release-form .field { flex: 1 1 220px; }
}
