:root {
  --navy: #2f4f7f;
  --navy-dark: #223a5e;
  --navy-light: #e8eef7;
  --ok: #1c7c4a;
  --ok-bg: #e6f4ec;
  --bad: #c0322b;
  --bad-bg: #fdeceb;
  --na: #7a7f87;
  --na-bg: #f0f1f3;
  --ink: #1c2024;
  --ink-2: #5a626c;
  --line: #dfe3e8;
  --bg: #f5f6f8;
  --card: #fff;
  --radius: 12px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ---------------- ログイン ---------------- */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 28px 22px;
  width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.login-logo { font-size: 24px; font-weight: 700; letter-spacing: .05em; }
.login-card input {
  width: 100%; height: var(--tap); margin: 18px 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 14px; font-size: 17px; text-align: center;
}

/* ---------------- ヘッダー ---------------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 6px;
  min-height: 54px; padding: max(6px, env(safe-area-inset-top)) 10px 6px;
  background: var(--navy); color: #fff;
}
#title-wrap { flex: 1; min-width: 0; }
#title { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtitle { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar-actions { display: flex; gap: 6px; }
#topbar-actions button {
  background: rgba(255,255,255,.16); color: #fff; border: 0;
  border-radius: 8px; height: 34px; padding: 0 12px; font-size: 14px; font-weight: 600;
}
.icon-btn {
  background: transparent; border: 0; color: #fff;
  font-size: 30px; line-height: 1; width: 34px; height: 40px; padding: 0;
}

/* ---------------- 本文 ---------------- */
#view { padding: 12px 12px 96px; max-width: 720px; margin: 0 auto; }
h2.sec { font-size: 15px; margin: 20px 0 8px; color: var(--ink-2); font-weight: 700; }
h2.sec:first-child { margin-top: 4px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.card.tap { cursor: pointer; }
.card.tap:active { background: #fafbfc; }

.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* ---------------- ボタン ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 600; font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn-lg { width: 100%; min-height: var(--tap); font-size: 17px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--navy); }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }

/* ---------------- フォーム ---------------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
  min-height: 44px;
}
textarea { min-height: 68px; resize: vertical; }
select { appearance: none; 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% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.check-line { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.check-line input[type=checkbox] { width: 22px; height: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------------- タブバー ---------------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--ink-2); font-size: 11px; font-weight: 600;
  padding: 7px 0 6px; position: relative;
}
#tabbar a .ti { display: block; font-size: 18px; line-height: 1.1; }
#tabbar a.active { color: var(--navy); }
.badge {
  position: absolute; top: 3px; left: 50%; margin-left: 6px;
  background: var(--bad); color: #fff; font-size: 10px; font-style: normal;
  min-width: 17px; height: 17px; line-height: 17px; border-radius: 9px; padding: 0 4px;
}

/* ---------------- ホーム: カルテカード ---------------- */
.karte-card { display: flex; flex-direction: column; gap: 8px; }
.karte-head { display: flex; align-items: baseline; gap: 8px; }
.karte-room { font-size: 17px; font-weight: 700; }
.karte-prop { font-size: 13px; color: var(--ink-2); }
.stages { display: flex; gap: 6px; }
.stage-pill {
  flex: 1; text-align: center; font-size: 12px; font-weight: 700;
  padding: 7px 2px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--na);
}
.stage-pill.doing { background: #fff7e6; border-color: #e0b050; color: #8a5b00; }
.stage-pill.done { background: var(--ok-bg); border-color: #a5d6ba; color: var(--ok); }
.meta-line { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.alert-strip {
  background: var(--bad-bg); color: var(--bad); border: 1px solid #f2c0bd;
  border-radius: 9px; padding: 8px 10px; font-size: 13px; font-weight: 600; margin-bottom: 10px;
}

/* ---------------- チェック画面 ---------------- */
.section-nav {
  position: sticky; top: 54px; z-index: 20;
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  background: rgba(245,246,248,.96); backdrop-filter: blur(6px);
  margin: -12px -12px 8px; scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.section-chip.done { background: var(--ok-bg); border-color: #a5d6ba; color: var(--ok); }
.section-chip .cnt { font-weight: 500; opacity: .8; margin-left: 3px; font-size: 11px; }

.sec-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 700; color: var(--navy);
  padding: 14px 2px 6px; scroll-margin-top: 100px;
}

.item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 8px; overflow: hidden;
}
.item.answered-ok { border-left: 4px solid var(--ok); }
.item.answered-bad { border-left: 4px solid var(--bad); }
.item.answered-na { border-left: 4px solid var(--na); }
.item-label { padding: 11px 13px 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.item-hint { padding: 2px 13px 0; font-size: 12px; color: var(--ink-2); }
.item-carry {
  margin: 6px 13px 0; padding: 6px 9px; border-radius: 8px;
  background: var(--bad-bg); color: var(--bad); font-size: 12px; font-weight: 600;
}
.opts { display: flex; gap: 6px; padding: 9px 13px 11px; flex-wrap: wrap; }
.opt {
  flex: 1 1 0; min-width: 74px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-size: 15px; font-weight: 700; font-family: inherit; color: var(--ink-2);
  padding: 0 8px;
}
.opt[data-kind=ok].on { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt[data-kind=bad].on { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt[data-kind=na].on, .opt[data-kind=na_equipment].on { background: var(--na); border-color: var(--na); color: #fff; }
.opt.narrow { flex: 0 1 auto; font-size: 13px; font-weight: 600; }

.item-extra { border-top: 1px dashed var(--line); padding: 11px 13px; background: #fcfcfd; }
.item-extra textarea { min-height: 56px; }
.sub-list { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.sub-list label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.sub-list input { width: 20px; height: 20px; }
.field-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; }
.field-row > label { flex: 1 1 130px; margin: 0; }
.unit { font-size: 13px; color: var(--ink-2); padding-bottom: 12px; }

.photos { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.photo-thumb {
  position: relative; width: 66px; height: 66px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--line); background: #eee;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .del {
  position: absolute; top: 0; right: 0; width: 22px; height: 22px;
  background: rgba(0,0,0,.6); color: #fff; border: 0; font-size: 14px; line-height: 22px; padding: 0;
  border-bottom-left-radius: 8px;
}
.photo-thumb.pending { opacity: .55; }
.photo-thumb .pending-tag {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.6);
  color: #fff; font-size: 9px; text-align: center;
}
.add-photo {
  width: 66px; height: 66px; border: 1.5px dashed var(--navy); border-radius: 8px;
  background: var(--navy-light); color: var(--navy); font-size: 11px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.add-photo .cam { font-size: 19px; }
.photo-warn { color: var(--bad); font-size: 12px; font-weight: 700; margin-top: 6px; }

.foot-note {
  text-align: center; font-size: 12px; color: var(--ink-2);
  padding: 14px 0 6px;
}
.sticky-foot {
  position: fixed; left: 0; right: 0; bottom: 56px; z-index: 25;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  display: flex; gap: 8px; align-items: center;
}
.progress-mini { flex: 1; font-size: 13px; font-weight: 700; color: var(--ink-2); }

/* ---------------- 一覧・履歴 ---------------- */
.list-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 7px; min-height: var(--tap);
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t1 { font-weight: 600; font-size: 15px; }
.list-row .t2 { font-size: 12px; color: var(--ink-2); }
.chev { color: var(--na); font-size: 22px; line-height: 1; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2);
}
.pill.todo { background: var(--bad-bg); border-color: #f2c0bd; color: var(--bad); }
.pill.arranged { background: #fff7e6; border-color: #e0b050; color: #8a5b00; }
.pill.done { background: var(--ok-bg); border-color: #a5d6ba; color: var(--ok); }
.pill.stage { background: var(--navy-light); border-color: #c3d2e8; color: var(--navy); }

.filter-bar { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 700;
}
.filter-chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }

.timeline { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 10px; }
.tl-item { flex: 0 0 auto; width: 132px; }
.tl-item img { width: 132px; height: 132px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); display: block; }
.tl-cap { font-size: 11px; color: var(--ink-2); margin-top: 4px; line-height: 1.35; }

/* ---------------- トースト・モーダル ---------------- */
#toast-wrap { position: fixed; left: 0; right: 0; bottom: 118px; z-index: 60; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast {
  background: rgba(28,32,36,.93); color: #fff; padding: 9px 16px;
  border-radius: 999px; font-size: 14px; font-weight: 600; max-width: 88%;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.upload-status {
  position: fixed; right: 10px; bottom: 118px; z-index: 55;
  background: var(--navy); color: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: 12px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

.modal-back {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.viewer-back { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.viewer-back img { max-width: 100%; max-height: 88vh; object-fit: contain; }
.viewer-cap { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: #fff; font-size: 13px; padding: 0 20px; }

/* ---------------- 音声入力 ---------------- */
.mic-wrap { position: relative; display: block; }
.mic-wrap > input, .mic-wrap > textarea { padding-right: 46px; }
.mic-btn {
  position: absolute; top: 5px; right: 5px;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 17px; line-height: 1;
}
.mic-wrap > input + .mic-btn { top: 50%; transform: translateY(-50%); }
.mic-btn.on { background: var(--bad); border-color: var(--bad); animation: mic-pulse 1.1s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.mic-hint { font-size: 12px; color: var(--navy); font-weight: 600; padding: 3px 2px 0; }

/* ---------------- 省略（今回だけとばす） ---------------- */
.opt.skip { flex: 0 1 auto; font-size: 13px; font-weight: 600; min-width: 62px; }
.opt.skip.on { background: var(--na); border-color: var(--na); color: #fff; }
.item.skipped { opacity: .5; }
.item.skipped .item-label { text-decoration: line-through; text-decoration-color: var(--na); }

.empty { text-align: center; color: var(--ink-2); padding: 40px 20px; font-size: 14px; }
.loading { text-align: center; color: var(--ink-2); padding: 30px; font-size: 14px; }

@media (min-width: 700px) {
  .opt { min-width: 90px; }
}
