/* 運用コックピット。スマホ幅を先に設計し、PC では本文の幅を 720px までに抑える */
:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1f2a37; --sub: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --ok: #15803d; --warn: #b45309; --err: #b91c1c;
  --radius: 12px; --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --card: #1b2027; --ink: #e5e7eb; --sub: #9ca3af; --line: #2d333b;
          --accent: #60a5fa; --ok: #4ade80; --warn: #fbbf24; --err: #f87171; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.35rem; margin: 4px 0 12px; }
h2 { font-size: 1rem; margin: 0 0 8px; }
a { color: var(--accent); }
.sub { color: var(--sub); font-size: .85rem; }
small { font-size: .78rem; }

/* ヘッダーと下部タブ（スマホ） */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
       padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.logout { margin-left: auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
        height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--card); border-top: 1px solid var(--line); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
          font-size: .75rem; color: var(--sub); text-decoration: none; }
.tabs a .ic { font-size: 1.3rem; line-height: 1; }
.tabs a.on { color: var(--accent); font-weight: 600; }
@media (min-width: 800px) {
  .tabs { position: static; display: flex; gap: 4px; height: auto; padding: 0; border: 0; background: none; }
  .tabs a { flex-direction: row; font-size: .9rem; padding: 6px 12px; border-radius: 8px; }
  .tabs a.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
  main { padding-bottom: 32px; }
}

/* 部品 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.card.muted { opacity: .9; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.msg { padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.msg.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.msg.err, .err { color: var(--err); }
.msg.err { background: color-mix(in srgb, var(--err) 12%, transparent); }
.msg.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.edit-saved p { margin: 0 0 8px; }
.req { color: var(--err); }

button, .button { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
                  font: inherit; font-size: .95rem; padding: 10px 16px; min-height: 44px; border-radius: 10px;
                  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.link { border: 0; background: none; color: var(--sub); padding: 4px; min-height: 0; font-size: .85rem; }
button.link.danger { color: var(--err); background: none; }
button:disabled { opacity: .45; cursor: not-allowed; }

label { display: block; margin: 0 0 14px; font-size: .9rem; color: var(--sub); }
input[type=text], input[type=url], input[type=password], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px; /* iOS のズーム防止 */
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
textarea { resize: vertical; min-height: 9em; }
fieldset { border: 1px dashed var(--line); border-radius: 10px; margin: 0 0 14px; padding: 10px 12px; }
legend { font-size: .9rem; color: var(--sub); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { flex: 1 1 auto; }

/* ホーム */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 14px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
        text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.stat .n { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: .8rem; color: var(--sub); }
.stat.warn .n { color: var(--warn); }
.kv { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; }
.kv li { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--line); }
.switch-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
              padding: 8px 0; border-top: 1px solid var(--line); }
.state { font-size: .8rem; padding: 2px 8px; border-radius: 999px; }
.state.on { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.state.off { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }

/* 一覧 */
.list { list-style: none; padding: 0; margin: 0; }
.list li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; }
.list li > a { display: block; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.list li.empty { padding: 16px; color: var(--sub); text-align: center; }
.list.compact li { padding: 8px 12px; }
.list .title { display: block; margin: 2px 0; }
.list .sub { display: block; }
.score { float: right; font-weight: 700; color: var(--accent); margin-left: 8px; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: var(--bg);
         border: 1px solid var(--line); color: var(--sub); margin-right: 4px; }
.badge.draft { color: var(--warn); }
.badge.saved, .badge.approved { color: var(--ok); }
.badge.fail, .badge.rejected { color: var(--err); }
.badge.warn, .badge.held { color: var(--warn); }
.search, .filters { display: flex; gap: 8px; margin: 0 0 12px; }
.search input, .filters select { margin: 0; flex: 1; }
.seg { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 12px; }
.seg a { white-space: nowrap; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
         background: var(--card); color: var(--ink); text-decoration: none; font-size: .85rem; }
.seg a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 在庫・承認の詳細 */
.points { padding-left: 1.3em; margin: 6px 0; }
.figs { list-style: none; padding: 0; margin: 0; }
.figs li { padding: 6px 0; border-top: 1px dotted var(--line); }
.figs q { display: block; color: var(--sub); font-size: .85rem; }
.src { word-break: break-all; font-size: .85rem; }
.post { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 10px; padding: 12px; }   /* 長い URL を枠の中で折り返す */
.checks { list-style: none; padding: 0; }
.checks .fail b { color: var(--err); } .checks .warn b { color: var(--warn); } .checks .pass b { color: var(--ok); }
.checks .pending b { color: var(--sub); }
details summary { cursor: pointer; color: var(--accent); margin: 10px 0; }

/* メモの画像 */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 8px; }
.thumbs figure { margin: 0; text-align: center; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.danger-zone { margin: 8px 0; text-align: right; }

/* ログイン */
body.login main { display: grid; place-items: center; min-height: 100vh; padding-bottom: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card button { width: 100%; }

/* 照合で出典に無かった数字（第3段） */
mark.ng { background: color-mix(in srgb, var(--err) 25%, transparent); color: inherit; padding: 0 .2em; border-radius: 3px; }
.switch-row input[name=reason] { min-width: 0; flex: 1; }

/* 文ごとの出典との照らし合わせ（第3段の改善） */
table.claims { width: 100%; border-collapse: collapse; font-size: .9em; }
table.claims th, table.claims td { border-top: 1px solid var(--line, #8884); padding: .4em; vertical-align: top; text-align: left; }
table.claims tr.not_in_source td, table.claims tr.contradicted td { background: color-mix(in srgb, var(--err) 12%, transparent); }
table.claims tr.question td, table.claims tr.advice td { opacity: .7; }
.source-text { max-height: 20em; overflow: auto; white-space: pre-wrap; font-size: .85em; }
fieldset.reject-category { border: 0; padding: 0; margin: .5em 0; display: flex; gap: 1em; flex-wrap: wrap; }
@media (max-width: 600px) { table.claims, table.claims tr, table.claims td { display: block; } table.claims tr:first-child { display: none; } }

/* 反応のタブ・編集者チェック（10/23）。表は枠の中だけ横に動かす（ページ全体は横に動かさない） */
.scroll { overflow-x: auto; max-width: 100%; }
table.data { border-collapse: collapse; font-size: .9em; white-space: nowrap; }
table.data th, table.data td { border-top: 1px solid var(--line, #8884); padding: .35em .5em; text-align: right; vertical-align: top; }
table.data td:first-child, table.data th:first-child { text-align: left; white-space: normal; min-width: 5.5em; }
table.data tr.post-head td { text-align: left; white-space: normal; padding-top: .8em; border-top: 2px solid var(--line, #8884); }
.badge.score { font-variant-numeric: tabular-nums; }
.badge.score.hi { background: color-mix(in srgb, var(--ok, #2a7) 22%, transparent); }
.badge.score.lo { background: color-mix(in srgb, var(--err) 18%, transparent); }
ul.editor li.ng { color: var(--err); }
ul.editor li.partial { color: var(--warn, #b80); }
/* ホームの費用の表（2026-10-31）。狭い画面では横にスクロールする（表だけ） */
.table-wrap { overflow-x: auto; }
table.costs { border-collapse: collapse; font-size: .85em; white-space: nowrap; }
table.costs th, table.costs td { border-top: 1px solid var(--line, #8884); padding: .3em .5em; text-align: right; }
table.costs th:first-child, table.costs td:first-child { text-align: left; }
