/* 本体（v0.2）の見た目。中身の幅は --max まで。iPhone・iPad の縦・横・画面分割で崩れない作り。 */

/* 上の帯 */
.topbar .wrap { align-items: center; flex-wrap: nowrap; gap: 8px; min-height: 64px; }
.topbar .title { flex: 1 1 auto; min-width: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { background: #fff; color: var(--blue); border-color: #fff; padding: 6px 14px; flex: 0 0 auto; }
.topbar .saved { flex: 0 0 auto; white-space: nowrap; font-size: 15px; color: #000; }
.topbar .ver { flex: 0 0 auto; font-size: 13px; opacity: 0.9; white-space: nowrap; }
@media (max-width: 380px) { .topbar .ver { display: none; } }

.crumb { margin: 12px 0 0; color: var(--ink2); font-weight: 600; }
h1 .uid { font-variant-numeric: tabular-nums; }
h2 { scroll-margin-top: 80px; }
/* 長い文は行数で止める */
.clamp2, .clamp3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { -webkit-line-clamp: 2; }
.clamp3 { -webkit-line-clamp: 3; }
h1 .h1-sub { font-size: 19px; margin-top: 4px; }
/* 現場で最初に読む1行（see・stand・take） */
.lead { font-size: 20px; font-weight: 800; line-height: 1.5; margin: 10px 0; }
.lead-k { display: inline-block; margin-right: 8px; padding: 0 8px; border-radius: 6px; background: var(--blue); color: #fff; font-size: 15px; vertical-align: 2px; }
.pos { margin: 4px 0; color: var(--ink2); font-weight: 700; font-size: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tag { padding: 2px 10px; border: 2px solid var(--ink2); border-radius: 999px; font-weight: 700; font-size: 16px; }
.tag-warn { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.retired { color: var(--ink2); text-decoration: line-through; }
.ok-box { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
/* くわしく（閉じた状態で出す） */
details.more { margin: 18px 0; border: 2px solid var(--line); border-radius: 10px; padding: 0 12px; }
details.more > summary { display: flex; align-items: center; min-height: var(--tap); font-weight: 800; font-size: 19px; color: var(--blue); cursor: pointer; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "＋"; margin-right: 8px; }
details.more[open] > summary::before { content: "－"; }
/* 次へ */
.go-next { flex-direction: column; align-items: flex-start; text-align: left; margin: 12px 0; gap: 2px; padding: 10px 16px; }
.go-next.big { min-height: 84px; font-size: 21px; }
.go-next .go-t { font-size: 16px; font-weight: 600; }
.go-change { display: block; font-size: 15px; font-weight: 800; background: #ffcd00; color: #000; padding: 0 6px; border-radius: 4px; }
.go-nav { flex-direction: column; gap: 2px; }
/* 取り込み中の覆い */
.busy { position: fixed; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(255, 255, 255, 0.92); }
.busy p { max-width: 520px; padding: 16px; border: 3px solid var(--warn); border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: 20px; font-weight: 800; text-align: center; }
label.btn.disabled { opacity: 0.45; pointer-events: none; }
.alerts { padding-bottom: 0; }
.alerts .box { margin: 10px 0 0; }
.foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 28px; color: var(--ink2); font-weight: 700; }
.warn-text { color: var(--warn); }
.mark { color: var(--ok); }

/* 切り替え（日・判定） */
.segs { display: flex; gap: 8px; margin: 10px 0; }
.seg {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tap);
  border: 2px solid var(--blue);
  border-radius: 10px;
  background: #fff;
  color: var(--blue);
  font: inherit;
  font-weight: 700;
  padding: 6px 4px;
  touch-action: manipulation;
}
.seg[aria-pressed="true"] { background: var(--blue); color: #fff; }
.judge .seg.j-0[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.judge .seg.j-1[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); }
.judge .seg.j-2[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); }

/* 一覧 */
.list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.list.numbered .uids { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.uid-text { align-self: center; color: var(--ink2); font-weight: 700; }
.item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-left: 8px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
}
a.item:active { background: var(--blue-bg); }
.item.done { border-left-color: var(--ok); background: #f4fbf6; }
.item-main { font-weight: 700; }
.item-sub { color: var(--ink2); font-size: 16px; }
.item.with-thumb { flex-direction: row; align-items: center; gap: 12px; }
.item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.thumb { flex: 0 0 auto; width: 64px; height: 48px; object-fit: contain; background: var(--bg2); border-radius: 6px; }
.thumb.none { display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink2); }
.sev { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 15px; background: var(--bg2); }
.sev-A { background: var(--bad); color: #fff; }
.sev-B { background: var(--warn-bg); color: var(--warn); }
h1 .sev { font-size: 16px; vertical-align: middle; }
.judge-tag { font-weight: 700; padding: 0 6px; border-radius: 4px; }
.judge-tag.j-0 { background: var(--ok-bg); color: var(--ok); }
.judge-tag.j-1 { background: var(--bad-bg); color: var(--bad); }
.judge-tag.j-2 { background: var(--warn-bg); color: var(--warn); }
/* 撮影点の画面の「結び付く行」：行へのリンクと「見た」を並べる */
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.toggle.small { width: auto; min-width: 7.5em; min-height: var(--tap); font-size: 17px; padding: 0 10px; }
ol.plain { padding-left: 1.6em; }
ol.plain li { margin: 8px 0; }

.nav2 > * { flex: 1 1 140px; }
.card { background: var(--bg2); border-radius: 12px; padding: 4px 14px 14px; margin: 14px 0; }
.card h2 { margin-top: 12px; }

/* 見た */
.toggle {
  display: block;
  width: 100%;
  min-height: 64px;
  border: 3px solid var(--ok);
  border-radius: 12px;
  background: #fff;
  color: var(--ok);
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  touch-action: manipulation;
}
.toggle[aria-pressed="true"] { background: var(--ok); color: #fff; }

/* 測った値の欄（入力欄ではない：押すと数字ボタンが出る） */
.measure { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; font-size: 19px; font-weight: 700; }
.mfield {
  min-width: 5.5em;
  min-height: var(--tap);
  padding: 6px 10px;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  touch-action: manipulation;
}
.mfield.active { border-color: var(--blue); box-shadow: 0 0 0 3px #ffcd00; }
.mfield .ph { color: #3a3f47; font-size: 15px; font-weight: 600; }
/* 数字ボタンを出したときに、欄が下の帯に隠れない */
.mfield, .mtext { scroll-margin-top: 80px; scroll-margin-bottom: 420px; }
.mtext { width: auto; flex: 1 1 8em; min-width: 8em; font-weight: 700; }
.measure .choice { margin: 0; flex: 0 1 auto; }
.measure .choice .seg { min-width: 4em; padding: 6px 12px; }
.measure.free { display: grid; gap: 8px; }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; align-items: center; }
.mlabel { font-size: 17px; }
.composed { font-size: 16px; color: var(--ink2); }
.composed b { color: var(--ink); }
mark { background: #ffe58a; color: inherit; }
.blank { font-weight: 800; }

.chips { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 12px; font-weight: 700; }
.btn.small { min-height: var(--tap); padding: 4px 12px; font-size: 16px; }
.taken { padding-left: 1.6em; margin: 6px 0; }
.taken li { margin: 4px 0; }
.taken li.undo { list-style: none; margin-left: -1.6em; }

/* 図 */
.imgbtn { display: block; width: 100%; min-height: var(--tap); padding: 0; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: zoom-in; }
.imgbtn img { display: block; width: 100%; height: auto; border-radius: 8px; }
.fig { margin: 12px 0; }

/* 拡大 */
.zoom { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.zoom-bar { display: flex; gap: 8px; padding: 8px var(--side); background: var(--blue); }
.zoom-bar .btn { flex: 1 1 0; min-width: 0; padding: 6px; }
.zoom-bar .btn.sub[aria-pressed="true"] { background: #ffcd00; color: #000; border-color: #ffcd00; }
.zoom-body { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); overscroll-behavior: contain; touch-action: pan-x pan-y; }
.zoom-body img { display: block; width: 100%; height: auto; max-width: none; }
body.zoom-open { overflow: hidden; }

/* 数字ボタン：下に出す。横長で背の低い画面（iPhone の横）では右に出す */
.keypad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: #1f2937;
  padding: 8px var(--side) calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}
.kp-inner { max-width: var(--max); margin: 0 auto; }
.kp-note { margin: 0 0 4px; color: #fff; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-head { display: flex; align-items: center; gap: 8px; min-height: var(--tap); color: #fff; }
.kp-label { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 16px; line-height: 1.3; overflow: hidden; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kp-alt { flex: 0 0 auto; min-height: var(--tap); padding: 0 8px; border: 2px solid #fff; border-radius: 10px; background: transparent; color: #fff; font: inherit; font-size: 14px; font-weight: 700; white-space: nowrap; touch-action: manipulation; }
.kp-value {
  flex: 0 1 40%;
  min-width: 4.5em;
  min-height: 44px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 26px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.kp-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.kp-key {
  min-height: 60px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: #000;
  font: inherit;
  font-size: 28px;
  font-weight: 800;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.kp-key:active { background: #ffcd00; }
.kp-bs, .kp-clr, .kp-close { font-size: 15px; white-space: nowrap; letter-spacing: -0.02em; background: #d1d5db; }
@media (max-width: 360px) { .kp-bs, .kp-clr, .kp-close { font-size: 13px; } }
.kp-ok { font-size: 16px; white-space: nowrap; background: #ffcd00; }
.kp-dir { font-size: 22px; }
.kp-dir[aria-pressed="true"] { background: #ffcd00; }
.kp-deg { font-size: 15px; white-space: nowrap; letter-spacing: -0.02em; background: #d1d5db; }
@media (max-width: 360px) { .kp-deg, .kp-alt { font-size: 13px; } }
body.kp-open #view { padding-bottom: 460px; }

@media (orientation: landscape) and (max-height: 560px) {
  .keypad {
    left: auto;
    top: 0;
    width: min(400px, 46vw);
    padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) 10px;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.35);
  }
  .kp-inner { display: flex; flex-direction: column; flex: 1 1 auto; width: 100%; }
  .kp-head { flex: 0 0 auto; }
  .kp-keys { flex: 1 1 0; min-height: 0; grid-template-rows: repeat(4, minmax(56px, 1fr)); }
  .kp-key { min-height: 56px; font-size: 24px; }
  .kp-bs, .kp-clr, .kp-close { font-size: 14px; }
  .kp-ok { font-size: 15px; }
  body.kp-open #view { padding-bottom: 24px; }
  .mfield, .mtext { scroll-margin-bottom: 24px; }
  body.kp-open .wrap { padding-right: calc(min(400px, 46vw) + 16px); }
}
