/* まちの回覧板 MOC — 高齢の方にも読みやすい単一テーマ（明色）で固定 */
:root {
  --bordeaux: #6B1F2E;
  --bordeaux-deep: #521522;
  --ground: #F6F2EC;
  --paper: #FFFFFF;
  --beige: #EFE6D8;
  --beige-soft: #F7F2EA;
  --line: #D9CDBB;
  --ink: #2B2624;
  --muted: #6E625A;
  --gold: #B08A3E;
  --taupe: #9A6B57;
  --urgent: #B3261E;
  --urgent-bg: #FBE9E7;
  --warn: #9A6412;
  --warn-bg: #FBF1DE;
  --ok: #3D7A4B;
  --ok-bg: #E7F2E9;
  --info: #3E6A8A;
  --info-bg: #E6EEF4;
  --radius: 10px;
  --fs: 16px;
  color-scheme: light;
}
body[data-size="l"] { --fs: 18px; }
body[data-size="xl"] { --fs: 21px; }

* { box-sizing: border-box; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: "BIZ UDPGothic", "Yu Gothic", "YuGothic", "Hiragino Sans", "Meiryo", sans-serif;
  font-size: var(--fs);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; line-height: 1.35; margin: 0; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- MOC操作バー ---------- */
.mocbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 6px 16px; background: #2F2A28; color: #F2ECE4; font-size: 13px;
}
.mocbar-tag { background: var(--gold); color: #fff; font-weight: 700; padding: 0 8px; border-radius: 4px; letter-spacing: .08em; }
.mocbar-label { opacity: .8; }
.mocbar-note { flex-basis: 100%; order: 10; font-size: 11px; opacity: .75; line-height: 1.4; }
.mocbar select { background: #45403C; color: #fff; border: 1px solid #6A625C; border-radius: 6px; padding: 3px 6px; font-size: 14px; }
.mocbar-reset { margin-left: auto; background: none; border: 1px solid #6A625C; color: #E6DED4; border-radius: 6px; padding: 2px 10px; font-size: 12px; cursor: pointer; }

/* ---------- 共通部品 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border-radius: var(--radius);
  border: 1.5px solid var(--bordeaux); background: var(--bordeaux); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bordeaux-deep); }
.btn.sub { background: var(--paper); color: var(--bordeaux); }
.btn.sub:hover { background: var(--beige-soft); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .88em; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--bordeaux); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 700; font-size: .92em; }
.field .hint { font-size: .82em; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper);
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--bordeaux); outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 700;
}
.chip[aria-pressed="true"] { border-color: var(--bordeaux); background: var(--bordeaux); color: #fff; }
.chip.u-high[aria-pressed="true"] { background: var(--urgent); border-color: var(--urgent); }
.chip.u-mid[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); }
.chip.u-low[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }

.pill { display: inline-block; font-size: .76em; font-weight: 700; padding: 1px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.7; }
.pill.red { color: var(--urgent); background: var(--urgent-bg); }
.pill.amber { color: var(--warn); background: var(--warn-bg); }
.pill.green { color: var(--ok); background: var(--ok-bg); }
.pill.blue { color: var(--info); background: var(--info-bg); }
.pill.gray { color: var(--muted); background: var(--beige); }
.pill.wine { color: #fff; background: var(--bordeaux); }

.muted { color: var(--muted); }
.small { font-size: .84em; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.empty { padding: 24px; text-align: center; color: var(--muted); background: var(--beige-soft); border-radius: var(--radius); }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 50;
  background: #2F2A28; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px;
  box-shadow: 0 6px 20px rgba(40, 20, 20, .25); max-width: calc(100% - 32px);
}

/* ---------- 住民画面（スマホ） ---------- */
.phone { max-width: 480px; margin: 0 auto; min-height: calc(100vh - 38px); background: var(--ground); display: flex; flex-direction: column; }
.r-head { background: var(--bordeaux); color: #fff; padding: 14px 16px 12px; display: flex; align-items: center; gap: 10px; }
.r-head h1 { font-size: 1.12em; }
.r-head .sub { font-size: .78em; opacity: .85; }
.r-head .back { background: none; border: 0; color: #fff; font-size: 1.4em; line-height: 1; padding: 4px 8px 4px 0; cursor: pointer; }
.r-body { flex: 1; padding: 16px 16px 96px; display: grid; gap: 12px; align-content: start; }
.alert-band { background: var(--urgent); color: #fff; padding: 10px 16px; font-weight: 700; display: flex; gap: 8px; align-items: center; }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { background: none; border: 0; min-height: 62px; display: grid; place-items: center; gap: 0; font-size: 12px; color: var(--muted); cursor: pointer; position: relative; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--bordeaux); font-weight: 700; }
.tabbar button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--bordeaux); border-radius: 0 0 3px 3px; }
.tabbar .dot { position: absolute; top: 8px; right: calc(50% - 20px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--gold); color: #fff; font-size: 11px; line-height: 18px; padding: 0 4px; }

/* ガジェット（ホームのカード） */
.gadget {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 8px; text-align: left; width: 100%;
}
button.gadget { cursor: pointer; }
button.gadget:hover { border-color: var(--taupe); }
.gadget-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; color: var(--bordeaux); font-size: 1.02em; }
.gadget-title .count { background: var(--gold); color: #fff; min-width: 26px; height: 26px; border-radius: 13px; display: inline-grid; place-items: center; font-size: .8em; padding: 0 7px; }
.gadget.alert { border-color: var(--urgent); background: var(--urgent-bg); }
.gadget .line-item { display: flex; gap: 8px; align-items: baseline; font-size: .92em; }
.gadget .line-item .date { color: var(--muted); font-size: .85em; flex: none; }
.home-greet { display: grid; gap: 2px; padding: 2px 2px 4px; }
.home-greet strong { font-size: 1.15em; }

.place-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.place-buttons button {
  min-height: 64px; border-radius: 8px; border: 2px solid var(--bordeaux); background: var(--paper); color: var(--bordeaux);
  font-weight: 700; cursor: pointer; line-height: 1.3; padding: 4px;
}
.place-buttons button[aria-pressed="true"] { background: var(--bordeaux); color: #fff; }
.place-buttons button.need[aria-pressed="true"] { background: var(--urgent); border-color: var(--urgent); }

/* リスト */
.list { display: grid; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: grid; gap: 4px; padding: 14px 16px; border: 0; border-top: 1px solid var(--beige); background: none; text-align: left; cursor: pointer; width: 100%; }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--beige-soft); }
.list-item.unread { box-shadow: inset 4px 0 0 var(--gold); }
.list-item .t { font-weight: 700; }
.list-item .meta { font-size: .8em; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.article { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; display: grid; gap: 12px; }
.article h2 { font-size: 1.2em; }
.article .body { white-space: pre-wrap; }
.confirm-box { display: grid; gap: 8px; padding: 14px; border-radius: var(--radius); background: var(--beige-soft); border: 1px dashed var(--line); text-align: center; }
.confirm-box.done { background: var(--ok-bg); border: 1px solid #BFD9C4; color: var(--ok); font-weight: 700; }

.section-label { font-size: .8em; font-weight: 700; color: var(--muted); letter-spacing: .06em; margin-top: 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--beige); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; min-height: 40px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--bordeaux); box-shadow: 0 1px 3px rgba(80, 40, 30, .15); }

/* 通報 */
.photo-guide { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.photo-guide svg { display: block; width: 100%; height: auto; }
.photo-guide ol { margin: 0; padding: 10px 16px 12px 36px; font-size: .86em; display: grid; gap: 2px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 92px; height: 92px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--beige); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 13px; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.add-photo { width: 92px; height: 92px; border-radius: 8px; border: 2px dashed var(--taupe); background: var(--beige-soft); color: var(--taupe); display: grid; place-items: center; font-weight: 700; font-size: .82em; cursor: pointer; text-align: center; line-height: 1.3; }
.map { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #EDEAE3; }
.map svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.map.pickable svg { cursor: crosshair; }
.map-caption { font-size: .78em; color: var(--muted); padding: 6px 10px; background: var(--paper); border-top: 1px solid var(--line); }
.timeline { display: grid; gap: 0; list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; min-height: 40px; }
.timeline .dotcol { position: relative; display: grid; justify-items: center; }
.timeline .dotcol::before { content: ""; width: 14px; height: 14px; border-radius: 7px; background: var(--line); margin-top: 6px; z-index: 1; }
.timeline .dotcol::after { content: ""; position: absolute; top: 20px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child .dotcol::after { display: none; }
.timeline li.done .dotcol::before { background: var(--ok); }
.timeline li.now .dotcol::before { background: var(--gold); box-shadow: 0 0 0 4px var(--warn-bg); }
.timeline .tl-text { font-size: .92em; padding-bottom: 8px; }
.timeline li:not(.done):not(.now) .tl-text { color: var(--muted); }

/* 設定 */
.toggle-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--beige); }
.toggle-row:first-child { border-top: 0; }
.toggle-row .name { font-weight: 700; }
.toggle-row .req { font-size: .74em; color: var(--muted); font-weight: 400; margin-left: 6px; }
.order-btns { display: flex; gap: 2px; }
.order-btns button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; cursor: pointer; color: var(--taupe); }
.order-btns button[disabled] { opacity: .35; cursor: default; }
.switch { position: relative; width: 54px; height: 30px; border-radius: 15px; border: 0; background: #CFC8BF; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--gold); }
.switch[aria-checked="true"]::after { left: 27px; }
.switch[disabled] { opacity: .55; cursor: default; }

/* AIボックス */
.chat { display: grid; gap: 10px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.bubble.me { justify-self: end; background: var(--bordeaux); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { justify-self: start; background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble .src { display: block; margin-top: 6px; font-size: .78em; color: var(--muted); }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; }
.suggest button { border: 1px solid var(--line); background: var(--beige-soft); border-radius: 999px; padding: 4px 12px; font-size: .86em; cursor: pointer; min-height: 36px; }

/* 転入者ワンシート */
.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; display: grid; gap: 14px; }
.sheet h2 { color: var(--bordeaux); font-size: 1.25em; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-cell { background: var(--beige-soft); border-radius: 8px; padding: 10px 12px; display: grid; gap: 2px; align-content: start; }
.sheet-cell .k { font-size: .76em; font-weight: 700; color: var(--taupe); letter-spacing: .04em; }
.sheet-cell.wide { grid-column: 1 / -1; }
.qr { width: 120px; height: 120px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.qr img, .qr svg, .qr canvas { width: 108px; height: 108px; image-rendering: pixelated; }

table.tbl { width: 100%; border-collapse: collapse; background: var(--paper); font-size: .92em; }
table.tbl th, table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--beige); text-align: left; vertical-align: top; }
table.tbl th { background: var(--beige); font-size: .86em; color: var(--ink); white-space: nowrap; }
table.tbl td.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- 管理者画面 ---------- */
.staff { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }
.s-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-block: 16px 12px; border-bottom: 2px solid var(--bordeaux); }
.s-head h1 { font-size: 1.3em; color: var(--bordeaux); }
.s-head .who { font-size: .86em; color: var(--muted); }
.s-nav { display: flex; gap: 4px; flex-wrap: wrap; padding-block: 10px; }
.s-nav button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; min-height: 42px; }
.s-nav button[aria-current="page"] { background: var(--bordeaux); color: #fff; }
.s-nav .badge { display: inline-block; margin-left: 4px; background: var(--gold); color: #fff; border-radius: 9px; font-size: .74em; padding: 0 6px; }
.s-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.s-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
@media (max-width: 820px) { .s-two { grid-template-columns: 1fr; } }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.panel h2 { font-size: 1.02em; color: var(--bordeaux); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.stat .k { font-size: .8em; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 1.7em; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .v small { font-size: .5em; color: var(--muted); margin-left: 3px; }
.stat.warn { border-color: var(--urgent); box-shadow: inset 4px 0 0 var(--urgent); }
.bar { height: 10px; border-radius: 5px; background: var(--beige); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--gold); }
.report-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; text-align: left; width: 100%; }
.report-card[aria-current="true"] { border-color: var(--bordeaux); box-shadow: 0 0 0 2px var(--bordeaux) inset; }
.report-card .ph { width: 96px; height: 80px; border-radius: 6px; overflow: hidden; background: var(--beige); }
.report-card .ph img, .report-card .ph svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.report-card .spread { flex-wrap: wrap; justify-content: flex-start; }
@media (max-width: 480px) {
  .report-card { grid-template-columns: 72px 1fr; }
  .report-card .ph { width: 72px; height: 64px; }
}
.photo-box { width: 100%; max-width: 400px; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--beige); }
.photo-box svg, .photo-box img { width: 100%; height: 100%; display: block; object-fit: cover; }
body.no-chrome .mocbar { display: none; }
.big-photo { width: 100%; max-height: 300px; object-fit: contain; background: #2F2A28; border-radius: 8px; display: block; }
.hh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.hh { border-radius: 8px; padding: 8px 10px; border: 1px solid var(--line); background: var(--paper); font-size: .86em; display: grid; gap: 2px; }
.hh .nm { font-weight: 700; }
.hh.home { background: var(--ok-bg); border-color: #BFD9C4; }
.hh.shelter { background: var(--info-bg); border-color: #BCD0DE; }
.hh.need { background: var(--urgent-bg); border-color: var(--urgent); }
.hh.none { background: var(--beige-soft); color: var(--muted); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8em; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- サイネージ ---------- */
.signage { min-height: calc(100vh - 38px); background: var(--bordeaux-deep); color: #fff; display: grid; grid-template-rows: auto 1fr auto; padding: 24px clamp(16px, 4vw, 48px); gap: 20px; }
.sg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sg-top h1 { font-size: clamp(22px, 3vw, 34px); }
.sg-clock { font-size: clamp(22px, 3vw, 34px); font-variant-numeric: tabular-nums; }
.sg-slide { background: #FFFDF9; color: var(--ink); border-radius: 14px; padding: clamp(20px, 4vw, 48px); display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
@media (max-width: 700px) { .sg-slide { grid-template-columns: 1fr; } }
.sg-kind { font-size: clamp(14px, 1.6vw, 20px); font-weight: 700; color: var(--taupe); letter-spacing: .08em; }
.sg-title { font-size: clamp(26px, 4.4vw, 56px); color: var(--bordeaux); margin: 6px 0 12px; }
.sg-text { font-size: clamp(17px, 2.2vw, 28px); white-space: pre-wrap; }
.sg-qr { display: grid; justify-items: center; gap: 8px; font-size: clamp(13px, 1.4vw, 18px); color: var(--muted); text-align: center; }
.sg-qr .qr { width: 170px; height: 170px; }
.sg-qr .qr img, .sg-qr .qr svg, .sg-qr .qr canvas { width: 156px; height: 156px; }
.sg-dots { display: flex; gap: 8px; justify-content: center; }
.sg-dots span { width: 34px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.3); }
.sg-dots span.on { background: var(--gold); }
.sg-alert .sg-slide { outline: 6px solid var(--urgent); }

@media print {
  .mocbar, .tabbar, .r-head .back, .no-print { display: none !important; }
  body { background: #fff; }
  .phone { max-width: none; }
}
