/* 白と黒が基本。ミントはアクセントだけ(2点以上の印・選択中の☆・フォーカス) */
:root {
  --bg: #FFFFFF;
  --box: #F4F4F4;
  --ink: #111111;
  --sub: #666666;
  --line: #E4E4E4;
  --mint: #2EC4A6;
  --mint-ink: #0E7C6E;
  --warn: #B3261E;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  font-weight: 500;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.top h1 { font-size: 19px; margin: 0; font-weight: 800; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back, .lock-btn { background: none; border: 0; color: var(--ink); font: inherit; font-weight: 700; padding: 8px 8px 8px 0; cursor: pointer; }
.lock-btn { padding: 8px 0 8px 8px; }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 120px; }

.box { background: var(--box); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.box h2 { font-size: 18px; margin: 0 0 8px; font-weight: 800; }
.muted { color: var(--sub); font-size: 14px; font-weight: 500; }
.note { color: var(--sub); font-size: 13px; margin: 6px 0 0; }

/* buttons */
button { font: inherit; cursor: pointer; color: var(--ink); }
button:disabled { opacity: .35; cursor: default; }
.btn-main {
  display: block; width: 100%; min-height: 56px;
  background: var(--ink); color: #fff;
  border: 0; border-radius: var(--radius);
  font-size: 18px; font-weight: 800;
}
.btn-sub {
  min-height: 44px; padding: 0 16px;
  background: #fff; color: var(--ink);
  border: 0; border-radius: var(--radius); font-weight: 700;
}
.box .btn-sub { background: #fff; }
main > .row .btn-sub { background: var(--box); }
.btn-text { background: none; border: 0; color: var(--ink); font-weight: 700; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: none; border: 0; color: var(--warn); font-weight: 700; padding: 8px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--bg);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.bottom-bar > * { max-width: 688px; margin: 0 auto; }

/* list */
.case {
  display: block; width: 100%; text-align: left;
  background: var(--box); border: 0; border-radius: var(--radius);
  padding: 14px 16px; margin: 10px 0;
}
.case .name { font-size: 18px; font-weight: 800; }
.case .meta { color: var(--sub); font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { background: #fff; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }
.chip .up { color: var(--mint-ink); }
.empty { text-align: center; color: var(--sub); padding: 40px 0; }

/* tabs */
.tabs { display: flex; gap: 6px; margin: 8px 0 4px; }
.tab {
  flex: 1; min-height: 44px; border: 0; border-radius: var(--radius);
  background: var(--box); font-weight: 700; white-space: nowrap; padding: 0 8px;
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; }

/* forms */
label.f { display: block; margin: 10px 0; }
label.f > span { display: block; font-size: 14px; color: var(--sub); font-weight: 700; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 0; border-radius: 10px;
  padding: 10px 12px; min-height: 46px;
}
main > input, .plain input { background: var(--box); }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--mint); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 12px; }
.grid2 > * { min-width: 0; }
input[type=date] { min-width: 0; display: block; }

/* score cards:高さ・文字をそろえる */
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.score-grid.g4 { grid-template-columns: repeat(4, 1fr); }
/* スコアの箱:見出しのすぐ下に大きな数字。下に余白を残さない */
.score {
  background: #fff; border-radius: 10px;
  padding: 8px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-align: center;
}
.score .k { font-size: 13px; color: var(--sub); font-weight: 700; line-height: 20px; white-space: nowrap; display: flex; justify-content: center; align-items: center; gap: 4px; }
.score .v { font-size: 40px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.score .v small { font-size: 14px; color: var(--sub); font-weight: 700; margin-left: 2px; letter-spacing: 0; }
.score-grid.g4 .v { font-size: 26px; }
.badge { display: inline-block; background: var(--mint); color: #062B25; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 800; line-height: 20px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 8px; text-align: center; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
thead th { color: var(--sub); font-size: 13px; }
tbody tr { border-top: 1px solid var(--line); }
.box tbody tr { border-top-color: #fff; border-top-width: 2px; }

/* QUEST picker */
.qitem { padding: 10px 0; }
.qitem + .qitem { border-top: 2px solid #fff; }
.qname { font-weight: 800; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pick { display: grid; grid-template-columns: repeat(5, 1fr) 1.4fr; gap: 6px; margin-top: 6px; }
.pick button { min-height: 44px; border: 0; border-radius: 10px; background: #fff; font-weight: 800; }
.pick button[aria-pressed="true"] { background: var(--mint); color: #062B25; }
.pick button.na { font-size: 13px; }
.star { border: 0; background: #fff; color: var(--sub); border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }
.star[aria-pressed="true"] { background: var(--mint); color: #062B25; }

/* COPM 質問紙 */
.ask { padding-top: 8px; }
.ask .progress { color: var(--sub); font-weight: 700; font-size: 15px; }
.ask .bar { height: 6px; background: var(--box); border-radius: 3px; margin: 4px 0 12px; overflow: hidden; }
.ask .bar i { display: block; height: 100%; background: var(--ink); }
.ask .task { font-size: 24px; font-weight: 800; line-height: 1.3; margin: 0 0 4px; }
.ask .q { font-size: 19px; font-weight: 700; line-height: 1.5; margin: 0 0 14px; }
.ask > .muted:first-of-type { margin: 0; }
.vscale { display: flex; flex-direction: column; gap: 5px; }
.vscale button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 40px; border: 0; border-radius: 12px; background: var(--box);
  padding: 3px 8px;
}
.vscale button.has-lab { min-height: 52px; }
.vscale .n { font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.vscale .lab { font-size: 14px; font-weight: 700; color: var(--sub); line-height: 1.3; }
.vscale button[aria-pressed="true"] { background: var(--mint); color: #062B25; }
.vscale button[aria-pressed="true"] .lab { color: #062B25; }
/* 目盛りを画面いっぱいに(スクロールなし) */
main.asking { padding-bottom: 0; }
.ask.fill { display: flex; flex-direction: column; }
.ask.fill .vscale { flex: 1; min-height: 0; }
.ask.fill .vscale button { flex: 1 1 0; min-height: 36px; }
.ask.fill .vscale button.has-lab { flex-grow: 1.25; }
.ask.fill .vscale button.na { flex-grow: .8; }
.ask.fill .vscale .n { font-size: 30px; }
.ask.fill .vscale .lab { font-size: 15px; }
.vscale button.na { margin-top: 8px; min-height: 52px; }
.vscale button.na .n { font-size: 18px; }
.anchors { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 15px; font-weight: 700; color: var(--sub); }
.anchors span:last-child { text-align: right; }
.ask-nav { display: flex; gap: 8px; }
.ask-nav .btn-sub { background: var(--box); flex: 0 0 auto; min-height: 56px; }
.ask-nav .btn-main { flex: 1; }
.cand { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.cand input { flex: 1; background: var(--box); }
.cand .n { width: 28px; font-weight: 800; text-align: center; }
.choose {
  display: flex; width: 100%; align-items: center; gap: 12px; text-align: left;
  background: var(--box); border: 0; border-radius: var(--radius); padding: 14px 16px; margin: 8px 0; min-height: 56px;
}
.choose .mark { width: 28px; height: 28px; border-radius: 50%; background: #fff; flex: 0 0 auto; display: grid; place-items: center; font-weight: 800; }
.choose[aria-pressed="true"] .mark { background: var(--ink); color: #fff; }
.choose .t { flex: 1; font-weight: 800; }
.choose .imp { color: var(--sub); font-weight: 700; font-size: 14px; }

/* lock */
.lock { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.lock .icon { width: 72px; height: 72px; margin: 0 auto 12px; }
.lock h2 { font-size: 22px; margin: 0 0 4px; }
.lock input { background: var(--box); text-align: center; font-size: 20px; margin: 16px 0 12px; }
.lock .err { color: var(--warn); font-weight: 700; min-height: 1.6em; }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px;
  font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

@media print {
  .top, .bottom-bar, .tabs, .no-print, #toast { display: none !important; }
  .box { break-inside: avoid; padding: 8px 0; background: none; }
  .score { background: none; }
  main { padding: 0; }
}

/* 送る画面 */
.send-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.send-grid .btn-sub { min-height: 52px; padding: 6px 10px; line-height: 1.35; }
.preview { white-space: pre-wrap; word-break: break-all; font-family: inherit; font-size: 14px; background: #fff; border-radius: 10px; padding: 12px; margin: 0; max-height: 50vh; overflow: auto; }
.warn { background: #fff; border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 14px; color: var(--warn); }
.warn b { color: var(--ink); }
.box .choose { background: #fff; }
