:root {
  --ink: #1f2328;
  --muted: #59636e;
  --line: #d1d9e0;
  --line-strong: #b7c0c9;
  --bg: #ffffff;
  --surface: #f6f8fa;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --error: #c62828;
  --radius: 4px;
  --font: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.7 var(--font); }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.4; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p { margin: 0; }
small, .sub { color: var(--muted); font-size: 13px; }
a { color: var(--accent); }
[hidden] { display: none !important; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font: 700 15px/1 var(--font); cursor: pointer; text-decoration: none;
}
button:hover:not(:disabled), .button:hover { background: var(--surface); }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.primary:hover:not(:disabled) { background: #3a4048; }
button.danger { color: var(--error); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font);
}
textarea { resize: vertical; min-height: 88px; }

.status { font-size: 14px; color: var(--muted); }
.status.error { color: var(--error); }
.status.ok { color: var(--ok); }

/* ---------- 職人さんの画面 ---------- */
.talk { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.talk-head { padding: 16px; border-bottom: 1px solid var(--line); }
.talk-head .sub { margin-top: 2px; }
.talk-main { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.voice-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.voice-state { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.live { background: var(--ok); }
.dot.wait { background: var(--warn); }
.voice-panel button.primary { min-height: 56px; font-size: 17px; }
.log { display: flex; flex-direction: column; gap: 12px; }
.turn { display: grid; grid-template-columns: 56px 1fr; gap: 8px; }
.turn .who { font-size: 13px; font-weight: 700; color: var(--muted); padding-top: 2px; }
.turn.me .who { color: var(--ink); }
.turn .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.turn.partial .text { color: var(--muted); }
.typed { display: flex; flex-direction: column; gap: 8px; }
.typed-row { display: flex; gap: 8px; align-items: flex-end; }
.typed-row textarea { min-height: 52px; }
.typed-row button { flex: none; white-space: nowrap; }
#talkView { display: flex; flex-direction: column; gap: 16px; }
.talk-foot { position: sticky; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); display: flex; gap: 8px; }
.talk-foot button { flex: 1; }
.fact-item { padding: 12px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.fact-item:first-child { border-top: 0; }
.fact-meta { display: flex; gap: 8px; font-size: 13px; color: var(--muted); }
.fact-meta .kind { font-weight: 700; }
.fact-meta .kind.unknown { color: var(--warn); }
.fact-item.excluded textarea { color: var(--muted); text-decoration: line-through; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 400; min-height: 32px; margin: 0; }
.check input { width: 18px; min-height: 18px; height: 18px; margin: 0; }
.notice { padding: 12px 16px; border-left: 3px solid var(--line-strong); background: var(--surface); }
.notice.error { border-left-color: var(--error); }
.done { padding: 32px 16px; text-align: left; display: flex; flex-direction: column; gap: 8px; }

/* ---------- 管理画面 ---------- */
.admin { max-width: 1200px; margin: 0 auto; padding: 0 24px 48px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.admin-head .actions { display: flex; gap: 8px; }
.section { margin-bottom: 32px; }
.section > h2 { margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.issue-result { margin-top: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.issue-result code { font-size: 14px; overflow-wrap: anywhere; }
.issue-result .row { display: flex; gap: 8px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 700; background: var(--surface); }
td.actions { text-align: right; white-space: nowrap; }
td.actions button { min-height: 36px; }
tr.inactive td { color: var(--muted); }
.state-submitted { color: var(--ok); font-weight: 700; }
.state-reviewing, .state-talking { color: var(--warn); font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.detail { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.detail .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail ul { margin: 0; padding-left: 20px; }
.detail .quote { color: var(--muted); font-size: 13px; }
.login { max-width: 360px; margin: 15vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; }
.empty { color: var(--muted); padding: 12px 0; }
.table-wrap { overflow-x: auto; }

@media (max-width: 760px) {
  .admin { padding: 0 16px 48px; }
  .two, .detail .cols { grid-template-columns: 1fr; }
  table:not(.sites) th:nth-child(4), table:not(.sites) td:nth-child(4) { display: none; }
}
.detail-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail h3 { margin: 0 0 8px; }
.detail h3 ~ h3 { margin-top: 16px; }
.detail li + li { margin-top: 8px; }
.admin-head { flex-wrap: wrap; }
.admin-head .actions button { white-space: nowrap; }
#interviewRows td:first-child { white-space: nowrap; }
.log:empty { display: none; }

/* ---------- 写真・現場・記事の材料 ---------- */
.talk-foot .button { flex: 1; }
.talk-foot .button.disabled { opacity: .45; pointer-events: none; }
.turn .text .shot { display: block; margin-top: 8px; max-width: 200px; max-height: 200px; border: 1px solid var(--line); border-radius: var(--radius); }
.site-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.review-h { margin-top: 8px; }
table .num { text-align: right; white-space: nowrap; }
td.strong { font-weight: 700; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photos figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.photos figcaption { font-size: 13px; color: var(--muted); }
.photo { display: block; aspect-ratio: 4 / 3; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.broken { display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); text-decoration: none; }
.fact-group { border-top: 1px solid var(--line); padding-top: 8px; }
.fact-group h4 { margin: 0 0 4px; font-size: 14px; }
.fact-group ul { margin: 0; padding-left: 20px; }
.kind-unknown { color: var(--warn); font-weight: 700; }
.draft { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.draft-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.draft textarea { font-size: 14px; line-height: 1.7; background: var(--bg); }
.relink { display: flex; gap: 8px; align-items: flex-end; max-width: 520px; }
.relink > div { flex: 1; }
.relink button { white-space: nowrap; }
ul.plain { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
ul.plain li + li { margin-top: 0; }
button.link { min-height: 36px; font-weight: 400; }
.craftsmen { max-width: 560px; }
@media (max-width: 760px) {
  table.sites th:nth-child(2), table.sites td:nth-child(2), table.sites th:nth-child(6), table.sites td:nth-child(6) { display: none; }
  .detail-head { flex-direction: column; }
  .site-fields { grid-template-columns: 1fr; }
}
#reviewView { display: flex; flex-direction: column; gap: 16px; }
.review-h { margin-top: 0; }
td[class^="state-"] { white-space: nowrap; }
