:root {
  --bg: #f5f7f1;
  --card: #ffffff;
  --ink: #2b2a27;
  --ink-2: #5f5c55;
  --ink-3: #8d897f;
  --line: #e4ded3;
  --accent: #2f7d48;
  --accent-ink: #ffffff;
  --accent-soft: #e4f2e6;
  --warn: #b26a00;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --ok: #2e7d32;
  --ok-soft: #e3f2e4;
  --s1: #2a78d6;
  --s2: #eb6834;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171716; --card: #222220; --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8d84; --line: #393834;
    --accent: #5cb878; --accent-ink: #0d1f12; --accent-soft: #1f3524;
    --warn: #e0a24a; --warn-soft: #3a2e1a; --bad: #f08a80; --bad-soft: #3d2120; --ok: #7cc684; --ok-soft: #1f3321;
    --s1: #3987e5; --s2: #d95926; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171716; --card: #222220; --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8d84; --line: #393834;
  --accent: #5cb878; --accent-ink: #0d1f12; --accent-soft: #1f3524;
  --warn: #e0a24a; --warn-soft: #3a2e1a; --bad: #f08a80; --bad-soft: #3d2120; --ok: #7cc684; --ok-soft: #1f3321;
  --s1: #3987e5; --s2: #d95926; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 16px; line-height: 1.6;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.brand { font-weight: 700; letter-spacing: .06em; font-size: 13px; color: var(--accent); }
.demo-bar { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 6px 16px; text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { font-size: 12px; font-weight: 400; color: var(--ink-3); }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 16px; min-height: 44px; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .label { font-size: 13px; color: var(--ink-2); }
.input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; min-height: 48px; font-size: 20px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.unit-input { position: relative; }
.unit-input .input { padding-right: 44px; }
.unit-input span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 15px; pointer-events: none; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 10px 6px; white-space: nowrap; min-height: 44px; font-size: 15px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 48px; }
.stepper button { width: 48px; height: 48px; border: 0; background: transparent; font-size: 22px; color: var(--accent); }
.stepper output { flex: 1; text-align: center; font-size: 20px; }
.stepper output.empty { color: var(--ink-3); font-size: 15px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.badge.complete { background: var(--ok-soft); color: var(--ok); }
.badge.partial { background: var(--warn-soft); color: var(--warn); }
.badge.none { background: var(--bad-soft); color: var(--bad); }
.badge.waiting { background: var(--accent-soft); color: var(--accent); }
.badge.muted { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }

.msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.info { background: var(--accent-soft); color: var(--accent); }

/* グラフ */
.wchart { position: relative; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.wchart .grid { stroke: var(--line); stroke-width: 1; }
.wchart .tick { fill: var(--ink-3); font-size: 12px; }
.wchart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.wchart .line.s1 { stroke: var(--s1); }
.wchart .line.s2 { stroke: var(--s2); }
.wchart .dot { stroke: var(--card); stroke-width: 2; }
.wchart .dot.s1 { fill: var(--s1); }
.wchart .dot.s2 { fill: var(--s2); }
.wchart .endlabel { fill: var(--ink-2); font-size: 12px; font-weight: 700; }
.wchart .cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.s1 { background: var(--s1); }
.sw.s2 { background: var(--s2); }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.12); pointer-events: none; white-space: nowrap; }
.chart-empty { color: var(--ink-3); text-align: center; padding: 30px 0; margin: 0; }

dialog.viewer { border: 0; padding: 0; background: transparent; max-width: 94vw; }
dialog.viewer::backdrop { background: rgba(0,0,0,.8); }
dialog.viewer img { max-width: 94vw; max-height: 80vh; object-fit: contain; border-radius: 8px; margin: 0 auto; }
dialog.viewer .cap { color: #fff; text-align: center; margin: 8px 0; font-size: 14px; }
dialog.viewer button { display: block; margin: 0 auto; background: #fff; color: #222; border: 0; border-radius: 999px; padding: 10px 28px; font-weight: 700; }

/* ロゴ */
[data-logo] { display: inline-flex; align-items: center; gap: 10px; }
.logo-mark { width: 40px; height: 40px; flex: none; border-radius: 12px; background: #fff; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.logo-mark img { width: 32px; height: 32px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text b { font-weight: 800; letter-spacing: .05em; font-size: 17px; }
.logo-text small { font-size: 11px; opacity: .85; font-weight: 400; }

/* 写真ビューア（スワイプ） */
dialog.gallery { border: 0; padding: 0; margin: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; background: #000; color: #fff; display: flex; flex-direction: column; }
dialog.gallery:not([open]) { display: none; }
dialog.gallery::backdrop { background: #000; }
.g-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px 16px; font-size: 15px; }
.g-cap { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-count { font-size: 13px; opacity: .75; font-variant-numeric: tabular-nums; }
.g-close { border: 0; background: rgba(255,255,255,.15); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
.g-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; touch-action: pan-y; user-select: none; }
.g-stage img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.g-nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; width: 44px; height: 64px; background: rgba(255,255,255,.12); color: #fff; font-size: 30px; border-radius: 10px; }
.g-nav:disabled { opacity: .15; }
.g-prev { left: 8px; } .g-next { right: 8px; }
.g-hint { text-align: center; font-size: 12px; opacity: .6; padding: 8px 0 calc(14px + env(safe-area-inset-bottom, 0px)); }
