/* AKIYOS 案C「編集室」(暗い固定)。値は docs/redesign/design-spec.md が正。
   テンプレートには色の実値を書かず、ここのトークンと部品だけを使う。 */

/* ── 2. トークン ───────────────────────────────────────────── */
:root {
  --paper: #17191C;
  --sheet: #1F2226;
  --sheet-2: #262A2F;
  --ink: #F1EFEA;
  --ink-2: #B6BBC0;
  --ink-3: #8E949A;
  --line: #33383E;
  --line-2: #2A2E33;
  --line-input: #6B737B;
  --red: #F0674D;
  --red-btn: #B73822;
  --ok: #5FBF86;
  --warn: #E6B450;
  --focus: var(--red);

  --font: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --fs-body: 15px;
  --fs-prose: 16px;
  --fs-title: 16.5px;
  --fs-h1: 20px;
  --fs-day: 34px;
  --fs-meta: 13px;
  --fs-small: 13.5px;
  --fs-tab: 11.5px;

  --gutter: 16px;
  --tap: 44px;
  --radius-sheet: 12px;
  --radius-btn: 10px;
  --radius-input: 8px;
  --radius-chip: 18px;
  --top-h: 60px;
  --bottom-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --actionbar-h: 64px;
}
/* 設定 > 表示 の文字の大きさ(端末ごと。html[data-text] で切り替える) */
html[data-text="large"]  { --fs-body: 16.5px; --fs-prose: 17.5px; --fs-title: 18px; --fs-meta: 14px; --fs-small: 14.5px; }
html[data-text="xlarge"] { --fs-body: 18px; --fs-prose: 19px; --fs-title: 19.5px; --fs-meta: 15px; --fs-small: 15.5px; --fs-h1: 22px; }

/* ── 基本 ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; background: var(--paper); }
body { font-family: var(--font); background: var(--paper); color: var(--ink); font-size: var(--fs-body); line-height: 1.6; min-height: 100dvh; overflow-wrap: anywhere; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
img, svg, video, iframe { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: var(--fs-small); }
.small { font-size: var(--fs-small); }
.nowrap { white-space: nowrap; }
.ext::after { content: " ↗"; font-size: .85em; }

/* ── 3.1 ボタン ───────────────────────────────────────────── */
.btn { min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-btn); border: 1px solid var(--line-input); background: var(--sheet-2); color: var(--ink); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--red-btn); border-color: var(--red-btn); color: #FFFFFF; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.invert { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.wide { width: 100%; }
.btn[aria-busy="true"] { opacity: .75; }
.btn[aria-busy="true"]::before, .spin::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ak-spin .8s linear infinite; flex: 0 0 auto; }
.btn:disabled:not([aria-busy="true"]) { opacity: .45; }
.ibtn { width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border-radius: var(--radius-btn); color: var(--ink-2); flex: 0 0 auto; }
.ibtn:hover { background: var(--sheet-2); color: var(--ink); }
.ibtn svg, .btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn svg { width: 18px; height: 18px; }
.ibtn[aria-busy="true"] svg { animation: ak-spin .8s linear infinite; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@keyframes ak-spin { to { transform: rotate(360deg); } }

/* ── 3.2 入力 ─────────────────────────────────────────────── */
.input, .textarea, .select { width: 100%; font: inherit; font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--sheet-2); border: 1px solid var(--line-input); border-radius: var(--radius-input); padding: 10px 12px; min-height: var(--tap); outline: none; }
.textarea { resize: vertical; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.input:focus, .textarea:focus, .select:focus, [contenteditable]:focus { border-color: var(--red); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-small); color: var(--ink-2); font-weight: 700; }
.field .err { font-size: var(--fs-small); color: var(--red); }
.field .hint { font-size: var(--fs-small); color: var(--ink-3); }
.fields { display: grid; gap: 12px; }
@media (min-width: 600px) { .fields.cols { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }

/* ── 3.3 セグメント ───────────────────────────────────────── */
.seg { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a { padding: 10px 14px; min-height: var(--tap); display: inline-flex; align-items: center; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 700; font-size: 14.5px; white-space: nowrap; flex: 0 0 auto; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--red); }

/* ── 3.4 チップ ───────────────────────────────────────────── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px var(--gutter); margin: 0 calc(-1 * var(--gutter)); scrollbar-width: none; -webkit-overflow-scrolling: touch; align-items: center; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: var(--radius-chip); border: 1px solid var(--line-input); background: var(--sheet); color: var(--ink-2); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; position: relative; white-space: nowrap; }
.chip::after { content: ""; position: absolute; inset: -4px 0; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"], .chip[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.chips .sep { width: 1px; min-width: 1px; height: 24px; background: var(--line); flex: 0 0 auto; }

/* ── 3.5 日付の見出し ─────────────────────────────────────── */
.day { display: flex; align-items: baseline; gap: 10px; padding: 26px 0 8px; position: sticky; top: calc(var(--top-h) + var(--safe-top)); background: var(--paper); z-index: 5; }
.day b { font-size: var(--fs-day); font-weight: 400; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.day span { color: var(--ink-2); font-size: 14px; }
.day em { font-style: normal; margin-left: auto; color: var(--ink-3); font-size: var(--fs-small); white-space: nowrap; }
.day em .n { color: var(--red); font-weight: 700; }

/* ── 3.6 記事の行 ─────────────────────────────────────────── */
.rows { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); overflow: hidden; }
.row { display: grid; grid-template-columns: 10px minmax(0, 1fr); border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: 0; }
.row .bar { background: transparent; }
.row.new .bar { background: var(--red); }
.row .body { padding: 12px 14px 12px 10px; min-width: 0; }
.row .meta { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: var(--fs-meta); margin-bottom: 3px; flex-wrap: wrap; }
.row .meta .src { font-weight: 700; }
.row .meta .tag { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; line-height: 18px; color: var(--ink-2); }
.row h3 { font-size: var(--fs-title); font-weight: 700; line-height: 1.5; }
.row h3 a { display: block; }
.row h3 a:hover { text-decoration: underline; }
.row .ja { color: var(--ink-2); font-size: 14.5px; margin-top: 2px; }
.row details { margin-top: 2px; }
.row summary { list-style: none; color: var(--ink-2); font-size: 14px; min-height: var(--tap); padding: 4px 0; margin: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; position: relative; }
.row summary::-webkit-details-marker { display: none; }
.row summary::before { content: ""; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; }
.row details[open] summary::before { transform: rotate(-135deg) translateY(2px); }
.row .origin { font-size: var(--fs-small); color: var(--ink-3); display: block; margin-bottom: 2px; }
.row .sum { color: var(--ink-2); font-size: 14.5px; line-height: 1.75; padding: 2px 0 8px; white-space: pre-line; }
.row .ogp { aspect-ratio: 16/9; border-radius: 8px; background: var(--sheet-2); overflow: hidden; margin: 4px 0 10px; display: none; }
.row .ogp img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row .ogp.on { display: block; }
.row .acts { padding-top: 2px; }
.row.hidden-more { display: none; }
.rows.hidden-rows .row[data-more] { display: none; }

/* ── 3.7 もっと見る ───────────────────────────────────────── */
.more { display: block; width: 100%; min-height: var(--tap); color: var(--ink-2); font-weight: 700; font-size: 14px; margin-top: 10px; border: 1px dashed var(--line-input); border-radius: var(--radius-sheet); }
.more:hover { color: var(--ink); }

/* ── 3.8 通知 ─────────────────────────────────────────────── */
.notice { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-btn); border: 1px solid var(--line); background: var(--sheet); font-size: 14px; margin-top: 12px; }
.notice b { white-space: nowrap; }
.notice > span { flex: 1 1 220px; color: var(--ink-2); }
.notice.error { border-color: var(--red); }
.notice.error b { color: var(--red); }
.notice.ok b { color: var(--ok); }
.notice .act { margin-left: auto; }
/* 取得状況(読む・公開済みの記事)。理由は折りたたみで、開くまで一行に収める */
.notice.fetch-status .reasons { flex: 0 0 auto; font-size: 13px; color: var(--ink-2); }
.notice.fetch-status .reasons summary { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.notice.fetch-status .reasons ul { margin: 8px 0 0; padding-left: 18px; flex-basis: 100%; }
.notice.fetch-status .reasons li { margin: 2px 0; }
.notice.fetch-status .reasons[open] { flex-basis: 100%; }
.toasts { position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(var(--bottom-h) + var(--safe-bottom) + 12px); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.toasts .notice { margin: 0 auto; max-width: 560px; width: 100%; pointer-events: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

/* ── 3.9 空の状態 / 3.10 読み込み中 ──────────────────────── */
.empty { text-align: center; color: var(--ink-2); padding: 48px 16px; display: grid; gap: 14px; justify-items: center; font-size: 15px; }
.skel { display: grid; gap: 1px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); overflow: hidden; }
.skel i { display: block; height: 72px; background: linear-gradient(90deg, var(--sheet) 0%, var(--sheet-2) 50%, var(--sheet) 100%); background-size: 200% 100%; animation: ak-shimmer 1.4s linear infinite; }
@keyframes ak-shimmer { to { background-position: -200% 0; } }
.progress { display: grid; gap: 8px; }
.progress .bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 35%; background: var(--red); animation: ak-slide 1.6s ease-in-out infinite; }
@keyframes ak-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ── 3.11 ダイアログ ──────────────────────────────────────── */
dialog.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--sheet); color: var(--ink); padding: 20px; width: min(92vw, 420px); max-height: 85dvh; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
dialog.dialog.wide { width: min(94vw, 640px); }
dialog.dialog::backdrop { background: rgba(0,0,0,.55); }
dialog.dialog h2 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
dialog.dialog p { color: var(--ink-2); font-size: 14.5px; margin-bottom: 14px; }
dialog.dialog .acts { justify-content: flex-end; margin-top: 16px; }
dialog.dialog .list { display: grid; gap: 1px; max-height: 50dvh; overflow: auto; margin: 0 -4px; }
dialog.dialog .list button { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; width: 100%; min-height: var(--tap); padding: 10px 8px; text-align: left; border-radius: 8px; font-size: 14.5px; line-height: 1.5; }
dialog.dialog .list button:hover { background: var(--sheet-2); }
dialog.dialog .list button span { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
dialog.dialog .list button[aria-current="true"] { font-weight: 700; }
dialog.dialog .list .item { display: flex; align-items: center; gap: 4px; }
dialog.dialog .list .item > button:first-child { flex: 1; }

/* ── 3.12 保存状態 ────────────────────────────────────────── */
.state { font-size: var(--fs-small); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.state.dirty::before, .state.local::before { background: var(--warn); }
.state.saving::before { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; background: none; animation: ak-spin .8s linear infinite; }
.state.error { color: var(--red); }
.state.error::before { background: var(--red); }
.state.plain::before { display: none; }

/* ── 3.13 / 3.14 骨組み: 上の帯・下タブ・左レール ─────────── */
.app { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.app > * { min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); padding: calc(8px + var(--safe-top)) var(--gutter) 8px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-2); min-height: calc(var(--top-h) + var(--safe-top)); }
.mark { font-weight: 700; font-size: 18px; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.mark svg { width: 18px; height: 16px; flex: 0 0 auto; }
.mark .r { color: var(--red); }
.today { color: var(--ink-2); font-size: var(--fs-small); white-space: nowrap; }
.top .spacer { flex: 1; }
.rail { display: none; }
.bottom { position: sticky; bottom: 0; z-index: 20; background: var(--sheet); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: var(--safe-bottom); }
.bottom.kbd { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--bottom-h); font-size: var(--fs-tab); color: var(--ink-2); }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tab[aria-current="page"] svg { stroke: var(--red); stroke-width: 2.2; }
main { padding: 0 0 24px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.wrap.wide { max-width: 1120px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 16px; }
.page-head h1 { font-size: var(--fs-h1); font-weight: 700; flex: 1; min-width: 160px; }
h1.h1 { font-size: var(--fs-h1); font-weight: 700; padding-top: 16px; }
.lead { color: var(--ink-2); font-size: 14.5px; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); padding: 14px 16px; }
.panel h2 { font-size: 14.5px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel h2 small { font-weight: 400; color: var(--ink-2); font-size: var(--fs-small); }
.panel .acts { margin-top: 10px; }

/* ── 読む: 動画・資料 ─────────────────────────────────────── */
.videos { display: grid; gap: 18px; padding-top: 14px; }
.video .thumb { aspect-ratio: 16/9; background: var(--sheet-2); border-radius: 8px; overflow: hidden; display: block; border: 1px solid var(--line); }
.video .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video h3 { font-size: 15px; font-weight: 700; line-height: 1.5; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video .meta { color: var(--ink-2); font-size: var(--fs-meta); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.reports .rows { margin-top: 4px; }
.reports .row .body { padding-left: 14px; }
.reports .row { grid-template-columns: minmax(0, 1fr); }

/* ── 書く: 下書き ─────────────────────────────────────────── */
.write { display: grid; gap: 16px; padding-top: 4px; }
.editor { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); min-width: 0; }
.editor .title { width: 100%; font: inherit; font-size: 22px; font-weight: 700; line-height: 1.4; padding: 18px 20px 8px; border: 0; background: none; color: var(--ink); outline: none; resize: none; display: block; min-height: 2.8em; overflow: hidden; field-sizing: content; }
.editor .title::placeholder { color: var(--ink-3); }
.editor .title:focus { box-shadow: inset 0 -2px 0 var(--red); }
.editor .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; padding: 0 20px 12px; border-bottom: 1px solid var(--line-2); }
.editor .fields .field > label { font-size: 13px; font-weight: 400; }
.toolbar { display: flex; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar button { min-width: var(--tap); height: var(--tap); border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--ink-2); padding: 0 10px; white-space: nowrap; flex: 0 0 auto; }
.toolbar button:hover { background: var(--sheet-2); color: var(--ink); }
.prose { padding: 16px 20px 24px; font-size: var(--fs-prose); line-height: 1.85; min-height: 260px; outline: none; }
.prose:empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; }
.prose h2 { font-size: 19px; margin: 18px 0 6px; }
.prose h3 { font-size: 16px; margin: 14px 0 4px; }
.prose p { margin: 8px 0; }
.prose ul, .prose ol { margin: 8px 0 8px 22px; }
.prose a { color: var(--red); text-decoration: underline; }
.prose img { max-width: 100%; border-radius: 6px; margin: 6px 0; display: block; }
.side { display: grid; gap: 16px; align-content: start; min-width: 0; }
.thumb-box { aspect-ratio: 1200/630; border: 1px dashed var(--line-input); border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); font-size: var(--fs-small); background: var(--sheet-2); overflow: hidden; }
.thumb-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drafts-list { list-style: none; }
.drafts-list li { border-top: 1px solid var(--line-2); }
.drafts-list li:first-child { border-top: 0; }
.drafts-list button { width: 100%; min-height: var(--tap); padding: 10px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; font-size: 14.5px; text-align: left; line-height: 1.5; }
.drafts-list button span { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.drafts-list button[aria-current="true"] { font-weight: 700; }
.actionbar { position: sticky; bottom: calc(var(--bottom-h) + var(--safe-bottom)); z-index: 15; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0; background: var(--paper); align-items: center; border-top: 1px solid var(--line-2); }
.actionbar.kbd { bottom: 0; }
.actionbar .state { margin-left: auto; }
.pad-bottom { padding-bottom: calc(var(--actionbar-h) + var(--bottom-h) + var(--safe-bottom)); }
.preview-frame { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #FFFFFF; height: 70dvh; display: block; }
.preview-wrap { overflow: auto; }
.preview-wrap iframe { margin: 0 auto; }
.images-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.images-grid button { width: 96px; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-input); background: var(--sheet-2); position: relative; }
.images-grid button img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── 書く: AI ライター ────────────────────────────────────── */
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: calc(100dvh - var(--top-h) - var(--safe-top) - var(--bottom-h) - var(--safe-bottom)); }
.chat.kbd { height: calc(100dvh - var(--top-h) - var(--safe-top)); }
.chat .head { display: flex; align-items: center; gap: 8px; padding: 10px 0; flex-wrap: wrap; }
.chat .head .title { flex: 1; min-width: 120px; color: var(--ink-2); font-size: var(--fs-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs { overflow: auto; display: grid; gap: 14px; align-content: start; padding: 4px 0 16px; }
.msg { display: grid; gap: 4px; max-width: 92%; }
.msg.user { justify-self: end; }
.msg .who { font-size: 12.5px; color: var(--ink-3); }
.msg.user .who { text-align: right; }
.msg .bubble { padding: 12px 14px; border-radius: 12px; font-size: 15px; line-height: 1.75; background: var(--sheet); border: 1px solid var(--line); min-width: 0; }
.msg.user .bubble { background: var(--sheet-2); border-color: var(--line-input); border-radius: 12px 4px 12px 12px; }
.msg.ai .bubble { border-radius: 4px 12px 12px 12px; }
.bubble h2 { font-size: 17px; margin: 12px 0 6px; }
.bubble h3 { font-size: 15.5px; margin: 10px 0 4px; }
.bubble p { margin: 8px 0; }
.bubble ul, .bubble ol { margin: 8px 0 8px 22px; }
.bubble a { color: var(--red); text-decoration: underline; }
.bubble .note { color: var(--ink-3); font-size: var(--fs-small); margin-top: 8px; }
.bubble .err { color: var(--red); font-size: 14px; margin-top: 8px; }
.dots i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); margin: 0 2px; animation: ak-dots 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes ak-dots { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { position: sticky; bottom: calc(var(--bottom-h) + var(--safe-bottom)); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; padding: 10px 0 10px; background: var(--paper); border-top: 1px solid var(--line-2); z-index: 15; }
.composer.kbd { bottom: 0; }
.composer .textarea { max-height: 160px; min-height: var(--tap); }
.suggests { display: grid; gap: 8px; width: 100%; max-width: 560px; }
.suggests button { text-align: left; min-height: var(--tap); padding: 10px 14px; border-radius: var(--radius-btn); border: 1px solid var(--line-input); background: var(--sheet); font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.suggests button:hover { border-color: var(--ink-3); }

/* ── 書く: WordPress に出す ───────────────────────────────── */
.steps { display: grid; gap: 14px; counter-reset: step; }
.step { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); padding: 14px 16px; display: grid; gap: 10px; }
.step h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; }
.step h2::before { counter-increment: step; content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--sheet-2); border: 1px solid var(--line-input); font-size: 13px; display: inline-grid; place-items: center; flex: 0 0 auto; }
.step h2 .btn { margin-left: auto; }
.codebox { background: var(--sheet-2); border: 1px solid var(--line-input); border-radius: 8px; padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--ink-2); line-height: 1.7; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto; }
.textbox { background: var(--sheet-2); border: 1px solid var(--line-input); border-radius: 8px; padding: 12px 14px; font-size: 16px; font-weight: 700; }
.kv { display: flex; flex-wrap: wrap; gap: 8px; }
.kv div { background: var(--sheet-2); border-radius: 6px; padding: 6px 12px; display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.kv b { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.checklist { display: grid; gap: 4px; list-style: none; counter-reset: chk; }
.checklist li label { display: flex; gap: 10px; align-items: center; min-height: var(--tap); font-size: 15px; cursor: pointer; }
.checklist li label::before { counter-increment: chk; content: counter(chk) "."; color: var(--ink-3); font-size: 13.5px; min-width: 1.4em; }
.checklist input { width: 22px; height: 22px; accent-color: var(--red); flex: 0 0 auto; }
.checklist input:checked + span { color: var(--ink-3); text-decoration: line-through; }
.pub-images { display: grid; gap: 8px; }
.pub-images div { display: flex; gap: 12px; align-items: center; background: var(--sheet-2); border-radius: 8px; padding: 8px 10px; }
.pub-images img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--sheet); flex: 0 0 auto; }
.pub-images code { font-size: 13px; word-break: break-all; }

/* ── 素材: サムネイル ─────────────────────────────────────── */
.cands { display: grid; gap: 14px; }
.cand { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); overflow: hidden; text-align: left; padding: 0; width: 100%; display: block; }
.cand[aria-pressed="true"] { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.cand .img { aspect-ratio: 1200/630; background: var(--sheet-2); }
.cand .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand .foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 14px; color: var(--ink-2); }
.cand .foot .name { font-weight: 700; color: var(--ink); }
.cand .foot .picked { margin-left: auto; color: var(--red); font-weight: 700; display: none; align-items: center; gap: 6px; }
.cand .foot .picked::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.cand[aria-pressed="true"] .foot .picked { display: inline-flex; }
.cand .foot .pick { margin-left: auto; }
.cand[aria-pressed="true"] .foot .pick { display: none; }

/* ── 素材: 画像の軽量化 ───────────────────────────────────── */
.drop { border: 2px dashed var(--line-input); border-radius: 14px; padding: 40px 20px; text-align: center; position: relative; display: grid; gap: 6px; justify-items: center; color: var(--ink-2); background: var(--sheet); }
.drop.over { border-color: var(--red); }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.drop b { color: var(--ink); font-size: 15px; }
.opts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.opts .chips { margin: 0; padding: 0; overflow: visible; flex-wrap: wrap; }
.compare { display: grid; gap: 12px; }
.compare figure { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); overflow: hidden; }
.compare figcaption { display: flex; justify-content: space-between; padding: 8px 12px; font-size: var(--fs-small); color: var(--ink-2); border-bottom: 1px solid var(--line-2); }
.compare .pic { background: #E8E8EC; min-height: 140px; display: grid; place-items: center; padding: 10px; }
.compare .pic img { max-height: 240px; max-width: 100%; display: block; }

/* ── 素材: 公開済みの記事 ─────────────────────────────────── */
.posts { display: grid; gap: 18px; padding-top: 14px; }
.post .thumb { aspect-ratio: 16/9; background: var(--sheet-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: var(--ink-3); font-size: var(--fs-small); }
.post .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post h3 { font-size: 15px; font-weight: 700; line-height: 1.5; margin-top: 8px; }
.post .meta { color: var(--ink-2); font-size: var(--fs-meta); margin-top: 2px; display: flex; gap: 8px; }
.post .sum { color: var(--ink-2); font-size: 14px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── 設定 ─────────────────────────────────────────────────── */
.list { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); overflow: hidden; }
.list .item { border-bottom: 1px solid var(--line-2); padding: 12px 14px; display: grid; gap: 6px; }
.list .item:last-child { border-bottom: 0; }
.list .item .name { font-weight: 700; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list .item .name .tag { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; line-height: 18px; color: var(--ink-2); font-weight: 400; }
.list .item .url { color: var(--ink-2); font-size: var(--fs-small); font-family: ui-monospace, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; min-height: var(--tap); padding: 6px 0; display: block; width: 100%; }
.list .item .url.open { white-space: normal; word-break: break-all; }
.list .item .acts { justify-content: flex-start; }
.list .empty { padding: 24px; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 14px; border: 1px solid var(--line-input); border-radius: var(--radius-btn); background: var(--sheet-2); font-weight: 700; font-size: 14px; cursor: pointer; }
.radio-row input { accent-color: var(--red); width: 18px; height: 18px; }
.radio-row label:has(input:checked) { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── ログイン ─────────────────────────────────────────────── */
.login-main { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter) calc(24px + var(--safe-bottom)); }
.login-box { width: 100%; max-width: 380px; background: var(--sheet); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px 28px; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.word { display: inline-flex; align-items: baseline; gap: 8px; font-weight: 700; letter-spacing: .12em; }
.word .r { color: var(--red); }
.word small { font-size: 11px; letter-spacing: .05em; color: var(--ink-3); font-weight: 400; }
.login-box .word { display: flex; justify-content: center; font-size: 26px; }
.tagline { text-align: center; font-size: 10.5px; letter-spacing: .22em; white-space: nowrap; color: var(--ink-3); text-transform: uppercase; }
.login-box .tagline { margin: 4px 0 26px; }
.login-box .field { margin-bottom: 14px; }
.login-box .input { min-height: 48px; }
.login-box .submit { min-height: 48px; width: 100%; margin-top: 6px; font-size: 15px; letter-spacing: .04em; }
.login-err { display: flex; flex-direction: column; overflow-wrap: anywhere; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--ink); background: color-mix(in srgb, var(--red) 10%, transparent); border: 1px solid var(--red); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.login-err b { color: var(--red); white-space: normal; }
#splash { display: none; position: fixed; inset: 0; z-index: 50; place-items: center; background: radial-gradient(ellipse at 50% 42%, #231D1F 0%, var(--paper) 68%); }
#splash.show { display: grid; }
#splash.done { opacity: 0; transition: opacity .6s; pointer-events: none; }
.boot { display: grid; justify-items: center; width: 280px; }
.boot .mark-big { opacity: 0; transform: scale(.85); transition: opacity .5s ease, transform .5s ease; filter: drop-shadow(0 0 16px rgba(240,103,77,.45)); }
.boot .mark-big.on { opacity: 1; transform: none; }
.boot .word { margin-top: 18px; font-size: 40px; letter-spacing: .16em; line-height: 1; opacity: 0; transform: translateY(6px); transition: opacity .45s ease .1s, transform .45s ease .1s; }
.boot .word.on { opacity: 1; transform: none; }
.boot .tagline { margin-top: 8px; opacity: 0; transition: opacity .4s ease .25s; }
.boot .tagline.on { opacity: 1; }
.boot ol { list-style: none; margin-top: 36px; display: grid; gap: 6px; width: 100%; min-height: 66px; }
.boot li { font-size: 13px; color: var(--ok); opacity: 0; transform: translateX(-6px); transition: opacity .3s ease, transform .3s ease; display: flex; gap: 8px; align-items: center; }
.boot li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }
.boot li.on { opacity: 1; transform: none; }
.boot .bar { margin-top: 20px; width: 100%; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; opacity: 0; transition: opacity .3s; }
.boot .bar.on { opacity: 1; }
.boot .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), #F1A27E); transition: width 2s cubic-bezier(.2,.7,.3,1); }
.boot .bar.on i { width: 100%; }
.boot-ver { position: fixed; left: 16px; bottom: calc(18px + var(--safe-bottom)); font-size: 12px; color: var(--ink-3); letter-spacing: .04em; }

/* ── PC(900px 以上): 左レール ─────────────────────────────── */
@media (min-width: 900px) {
  :root { --gutter: 32px; --top-h: 0px; --bottom-h: 0px; }
  .app { grid-template-columns: 224px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .top, .bottom { display: none; }
  .rail { display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100dvh; background: var(--paper); overflow: auto; }
  .rail .mark { padding: 6px 10px 18px; font-size: 20px; }
  .rail .mark svg { width: 20px; height: 18px; }
  .rail .today { padding: 0 10px 14px; }
  .rail .tab { flex-direction: row; justify-content: flex-start; gap: 10px; height: 42px; padding: 0 10px; border-radius: var(--radius-btn); font-size: 14.5px; border: 1px solid transparent; }
  .rail .tab[aria-current="page"] { background: var(--sheet); border-color: var(--line); }
  .rail .sub { padding: 2px 0 10px 44px; display: flex; flex-direction: column; gap: 2px; }
  .rail .sub a { font-size: 14px; color: var(--ink-2); padding: 5px 0; min-height: 32px; display: flex; align-items: center; }
  .rail .sub a[aria-current="page"] { color: var(--ink); font-weight: 700; }
  .rail .foot { margin-top: auto; display: grid; gap: 6px; font-size: var(--fs-small); color: var(--ink-2); padding: 12px 10px 0; }
  .rail .foot .ver { color: var(--ink-3); font-size: 12px; }
  .rail .foot a { min-height: 32px; display: inline-flex; align-items: center; }
  .rail .foot a:hover { color: var(--ink); }
  .wrap { padding: 0 var(--gutter); }
  .day { top: 0; }
  .seg { margin-top: 20px; }
  .chips { margin: 0; padding: 12px 0; }
  .toasts { left: calc(224px + 32px); right: 32px; bottom: 24px; }
  .write { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .write .page-head, .write .actionbar { grid-column: 1 / -1; }
  .actionbar { bottom: 0; }
  .chat { height: 100dvh; }
  .composer { bottom: 0; }
  .cands { grid-template-columns: 1fr 1fr; max-width: 980px; }
  .videos, .posts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .compare { grid-template-columns: 1fr 1fr; }
  .list .item { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .list .item .acts { grid-column: 2; grid-row: 1 / span 2; }
}
@media (min-width: 600px) and (max-width: 899px) {
  .videos, .posts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── 2.4 動き ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  #splash { display: none !important; }
}

/* ── 補助 ─────────────────────────────────────────────────── */
.btn.disabled, .btn[aria-disabled="true"] { opacity: .45; }
label.btn { cursor: pointer; }
@media (max-width: 899px) { .pc-only { display: none !important; } }
