/* 初期解の実験（被験者の画面）。色を見比べるので、背景は明るい無彩色に固定する（暗い表示には切り替えない）。
   評価サイト（survey_static）と同じ配色・字。パソコンでの実施を前提にし、幅が狭いときは縦に並べる。 */
:root {
  --ink: #23221f;
  --ink-2: #4a4842;
  --muted: #6e6b63;
  --line: #e2dfd7;
  --bg: #f6f5f1;
  --card: #ffffff;
  --accent: #2b2a26;
  --accent-ink: #ffffff;
  --focus: #1f6feb;
  --error: #a3361f;
  --warn: #8a5a12;
  --frame-ref: #8f8c84;
  --lab: #9a4a0f;
  --coach: #d68200;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI",
    "Meiryo", system-ui, sans-serif;
  font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.45rem; margin: 18px 0 12px; letter-spacing: .02em; }

/* ---------- 上の帯 ---------- */
.bar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.bar-in { max-width: 1560px; margin: 0 auto; padding: 8px var(--gutter); display: flex; align-items: center; gap: 12px; }
.bar-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-right { display: flex; align-items: center; gap: 12px; flex: none; }
.bar-step { color: var(--ink-2); font-size: .95rem; }
.bar-timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.bar-btn { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.bar-btn:hover { background: #f1efe9; }
.remain { background: #fff4d6; color: var(--warn); text-align: center; font-weight: 700; padding: 4px var(--gutter); }

/* 検証用: 帯の色と札で、公開用（被験者の画面）と取り違えないようにする */
body.lab .bar { border-bottom: 3px solid var(--lab); }
.mode-tag { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; background: var(--lab); color: #fff; font-size: .8rem;
  font-weight: 700; border-radius: 999px; padding: 2px 12px; white-space: nowrap; }
@media (max-width: 1400px) { body.demo-on .mode-tag { font-size: 0; padding: 2px 8px; } body.demo-on .mode-tag::before { content: "検証用"; font-size: .8rem; } }
html[lang=en] body.demo-on .mode-tag::before { content: "Lab"; }
.bar-btn[href] { text-decoration: none; }
.lab-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.lab-card { display: block; background: var(--card); border: 1px solid #cfccc3; border-radius: var(--radius); padding: 18px; color: inherit;
  text-decoration: none; line-height: 1.5; }
.lab-card:hover { border-color: var(--accent); background: #fbfaf7; }
.lab-card b { display: block; font-size: 1.1rem; margin-bottom: 4px; }
.lab-card span { color: var(--muted); font-size: .9rem; }
.lab-note { border-left: 4px solid var(--lab); }
.lab-info { margin-top: 8px; font-size: .82rem; color: var(--lab); }
@media (max-width: 760px) { .lab-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 761px) { .lab-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
/* 検証用: 結果（試し・デモ） */
.seg.res-seg { display: inline-flex; margin: 4px 0 12px; }
#labResults .res th:last-child { text-align: left; }
#labResults .rep th, #labResults .rep td { text-align: left; }
#labResults .rep td:nth-child(-n+3), #labResults .rep td:nth-child(5), #labResults .rep td:nth-child(6), #labResults .rep td:nth-child(8) { white-space: nowrap; }
.res-banner { background: #eef0ee; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: .92rem; }
.res-banner.sample { background: #fff1dc; color: #6b3f05; border: 1px solid #e8b56a; }
.res-count { font-weight: 700; }
#labResults h2 { font-size: 1.1rem; margin: 22px 0 8px; }
.res td.res-read { text-align: left; white-space: nowrap; }
.box-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .box-grid { grid-template-columns: minmax(0, 1fr); } }
.bx { display: block; width: 100%; height: auto; margin-top: 4px; }
.bx-grid { stroke: #ece9e2; } .bx-tick { fill: var(--muted); font-size: 12px; } .bx-label { fill: var(--ink); font-size: 13px; }
.bx-wh { stroke-width: 2; } .bx-wh.bx-none { stroke: #8a877e; } .bx-wh.bx-init { stroke: #c0600a; }
.bx-box.bx-none { fill: #e4e1da; stroke: #8a877e; } .bx-box.bx-init { fill: #f6dcc3; stroke: #c0600a; }
.bx-med { stroke: var(--ink); stroke-width: 2.5; }
.bx-pt { opacity: .55; } .bx-pt.bx-none { fill: #6e6b63; } .bx-pt.bx-init { fill: #c0600a; }
.pref { display: grid; grid-template-columns: minmax(0, 22em) minmax(0, 1fr) 3em; gap: 10px; align-items: center; padding: 3px 0; }
.pref-bar { background: #f1efe9; border-radius: 4px; height: 14px; overflow: hidden; }
.pref-bar i { display: block; height: 100%; background: #c0600a; }
.pref-n { text-align: right; font-variant-numeric: tabular-nums; }
.res-how { margin-top: 18px; }
.page.wide-mid { max-width: 1240px; }
.table-wrap { overflow-x: auto; }
.rep td { vertical-align: middle; }
.rep small { display: block; color: var(--muted); font-size: .75rem; }
.rep-img { display: block; width: 120px; height: auto; border-radius: 4px; border: 1px solid var(--line); }

/* 準備の画面の、進み具合 */
.step-dots { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.step-dots .dot { border: 1px solid #cfccc3; border-radius: 999px; padding: 0 12px; font-size: .82rem; color: var(--muted); background: var(--card); }
.step-dots .dot.done { background: #e9e6dd; color: var(--ink-2); }
.step-dots .dot.now { border-color: var(--accent); color: var(--ink); font-weight: 700; }

/* チュートリアル（操作の練習）の案内 */
.coach { background: #fff8e6; border: 2px solid var(--coach); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.coach-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.coach-step { font-size: .82rem; font-weight: 700; color: var(--coach); }
.coach-text { font-size: 1.05rem; line-height: 1.6; margin: 2px 0 6px; }
.coach-text.ok { color: #2d6a2d; font-weight: 700; }
.coach-btns { display: flex; gap: 14px; align-items: center; }
.coach-hi { outline: 3px solid var(--coach) !important; outline-offset: 3px; border-radius: 8px; animation: coach-pulse 1.4s ease-in-out infinite; }
@keyframes coach-pulse { 50% { outline-color: rgba(214, 130, 0, .25); } }
@media (prefers-reduced-motion: reduce) { .coach-hi { animation: none; } }

/* デモ（?preview=1）: 初期解なし・ありの切り替えを上の帯に置く */
.demo { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
@media (max-width: 980px) { .demo { flex-wrap: wrap; } .demo-note { flex-basis: 100%; } }
body.demo-on .bar-title { flex: none; }
.seg { display: flex; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--card); padding: 4px 16px; min-height: 36px; cursor: pointer; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--accent); }
.seg button.sel { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg button small { font-variant-numeric: tabular-nums; font-weight: 400; opacity: .75; margin-left: 6px; }
.demo-img { display: flex; align-items: stretch; gap: 4px; }
.arrow { border: 1px solid #cfccc3; background: var(--card); border-radius: 8px; width: 30px; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.demo-pick { display: flex; align-items: center; gap: 8px; border: 1px solid #cfccc3; background: var(--card); border-radius: 8px; padding: 2px 12px 2px 3px;
  cursor: pointer; text-align: left; min-height: 38px; }
.arrow:hover:not(:disabled), .demo-pick:hover:not(:disabled) { background: #f1efe9; }
.demo-pick img { width: 32px; height: 32px; object-fit: cover; border-radius: 5px; display: block; background: var(--line); }
.demo-pick b { display: block; font-size: .86rem; line-height: 1.2; }
.demo-pick small { display: block; font-size: .72rem; line-height: 1.2; color: var(--muted); max-width: 13em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100vh - 48px)); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; }
.picker[open] { display: flex; flex-direction: column; }
.picker::backdrop { background: rgba(0, 0, 0, .35); }
.picker-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.picker-head select { padding: 4px 8px; min-height: 34px; font-size: .92rem; }
.picker-grid { flex: 1; overflow-y: auto; padding: 14px 18px; display: grid; gap: 8px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.picker-grid button { border: 2px solid var(--line); background: var(--card); border-radius: 8px; padding: 3px; cursor: pointer; }
.picker-grid button:hover { border-color: #b9b5a9; }
.picker-grid button.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.picker-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; background: #eceae3; }
.picker-grid span { display: block; font-size: .72rem; line-height: 1.3; padding-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-note { color: var(--muted); font-size: .82rem; line-height: 1.35; flex: 1 1 0; min-width: 0; max-height: 2.7em; overflow: hidden; }
@media (max-width: 1400px) { body.demo-on .bar-title { display: none; } }
.res { border-collapse: collapse; width: 100%; margin: 4px 0 8px; }
.res th, .res td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.res th:first-child, .res td:first-child { text-align: left; }
.res th { color: var(--muted); font-size: .85rem; font-weight: 400; }

/* ---------- ページ ---------- */
.page { margin: 0 auto; padding: 0 var(--gutter) 40px; }
.page.narrow { max-width: 760px; }
.page.mid { max-width: 1100px; }
.page.wide { max-width: 1640px; padding-bottom: 74px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; }
.prose p { margin: 0 0 .7em; }
.prose p:last-child { margin-bottom: 0; }
.prose ul { margin: .2em 0 .7em; padding-left: 1.3em; }
.lead { margin: 12px 0 8px; color: var(--ink-2); }
.note { color: var(--warn); }
.error { color: var(--error); }
.hint { color: var(--muted); font-size: .88rem; margin: 0 0 6px; }

.btn {
  background: var(--card); border: 1px solid #cfccc3; border-radius: 8px; padding: 8px 18px; cursor: pointer;
  min-height: 40px; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #f1efe9; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #45433c; }
.btn.finish { border-color: var(--accent); font-weight: 700; }
.btn.big { padding: 12px 34px; font-size: 1.05rem; }
.btn.small { padding: 3px 12px; min-height: 32px; font-size: .9rem; }
.btn.on { background: #e9e6dd; border-color: var(--accent); }
.link { background: none; border: none; color: var(--ink-2); text-decoration: underline; cursor: pointer; padding: 0; font-size: .88rem; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* はじめの画面の選択肢 */
.field { margin: 0 0 14px; }
.field-name { font-weight: 700; display: block; margin-bottom: 4px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { border: 1px solid #cfccc3; background: var(--card); border-radius: 999px; padding: 4px 14px; cursor: pointer; }
.choice.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.consent { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; cursor: pointer; }
.consent input { margin-top: 6px; }
textarea { width: 100%; font: inherit; border: 1px solid #cfccc3; border-radius: 8px; padding: 8px; }

select { font: inherit; padding: 8px 10px; border: 1px solid #cfccc3; border-radius: 8px; background: var(--card); max-width: 100%; }
.choices.col { flex-direction: column; align-items: flex-start; margin-bottom: 14px; }

/* ---------- お手本と織り上がり（同じ大きさで並べる） ---------- */
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; justify-items: center; }
.fig { margin: 0; min-width: 0; width: 100%; max-width: calc(var(--ar, 1) * var(--imgh) + 14px); }
.fig figcaption { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; flex-wrap: wrap; min-height: 1.7em; }
.fig figcaption > span:not(.busy) { color: var(--muted); font-size: .85rem; }
#work { --imgh: max(240px, calc(100vh - 212px)); }
#work.coaching { --imgh: max(220px, calc(100vh - 330px)); }
#rate { --imgh: min(46vh, 520px); }
.frame { background: #fff; border: 1px dashed #a9a69d; border-radius: 6px; padding: 6px; }
.frame.ref { border: 1px solid var(--frame-ref); }
.frame img { display: block; width: 100%; aspect-ratio: var(--ar, 1); height: auto; }
.busy { font-size: .8rem; color: var(--warn); background: #fff4d6; border-radius: 999px; padding: 0 10px; }
.toggle { font-size: .86rem; color: var(--ink-2); cursor: pointer; display: flex; gap: 4px; align-items: center; }

/* 布の候補 */
.cands { position: sticky; top: 60px; }
.strip-head { margin-bottom: 6px; line-height: 1.35; }
.strip-head span { color: var(--muted); font-size: .76rem; display: block; line-height: 1.35; }
.strip { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 210px); overflow-y: auto; padding: 8px 10px 8px 2px; }
.cloth { position: relative; }
.cloth-btn { display: block; width: 100%; border: 2px solid var(--line); border-radius: 8px; background: var(--card); padding: 4px; cursor: pointer; }
.cloth-btn:hover { border-color: #b9b5a9; }
.cloth.sel .cloth-btn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cloth-btn img { display: block; width: 100%; aspect-ratio: var(--ar, 1); max-height: 130px; object-fit: cover; border-radius: 4px; }
.cloth-btn span { display: block; font-size: .78rem; white-space: nowrap; line-height: 1.3; padding-top: 3px; text-align: center; }
.cloth.sel .cloth-btn span { font-weight: 700; }
.cloth-del { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid #cfccc3;
  background: var(--card); cursor: pointer; line-height: 1; padding: 0; }

/* ---------- 調整の画面: 左に見比べる 2 枚と布の候補、右に道具（右だけ縦に動く） ---------- */
.work-grid { display: grid; grid-template-columns: 134px minmax(0, 1fr) 396px; gap: 16px; align-items: start; padding-top: 12px; }
.side {
  position: sticky; top: 60px; max-height: calc(100vh - 142px); overflow-y: auto; padding: 0 4px 12px 0;
  scrollbar-gutter: stable;
}
.side .card { margin: 0 0 10px; padding: 10px 14px; }
.tool-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 8px; }
.link:disabled { opacity: .4; cursor: default; }
.sl { display: grid; grid-template-columns: 7.2em 28px minmax(0, 1fr) 28px 3em; gap: 6px; align-items: center; min-height: 36px; }
.pm { width: 28px; height: 28px; border: 1px solid #cfccc3; background: var(--card); border-radius: 7px; cursor: pointer; padding: 0; font-size: 1.05rem;
  line-height: 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.pm:hover:not(:disabled) { background: #f1efe9; }
.pm:active:not(:disabled) { background: #e4e0d6; }
.pm:disabled { opacity: .35; cursor: default; }
.sl-name { font-size: .9rem; line-height: 1.25; }
.sl-name small { color: var(--muted); display: block; font-size: .76rem; }
.sl input[type=range] { width: 100%; accent-color: var(--accent); min-width: 0; }
.sl-val { font-variant-numeric: tabular-nums; text-align: right; font-size: .88rem; color: var(--muted); cursor: pointer;
  background: none; border: none; padding: 2px 0; }
.sl-val.on { color: var(--ink); font-weight: 700; text-decoration: underline dotted; }
details.tool summary { cursor: pointer; padding: 2px 0; }
details.tool summary .sum-sub { color: var(--muted); font-size: .8rem; font-weight: 400; }
details.tool[open] summary { margin-bottom: 6px; }
.sub-head { font-size: .86rem; font-weight: 700; color: var(--ink-2); margin: 10px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); }
.bands { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin-bottom: 6px; }
.band { border: 2px solid transparent; background: none; border-radius: 8px; padding: 3px 0 2px; cursor: pointer; text-align: center; }
.band i { display: block; width: 24px; height: 24px; border-radius: 50%; margin: 0 auto; background: var(--c); border: 1px solid rgba(0, 0, 0, .2); }
.band span { display: block; font-size: .72rem; line-height: 1.3; color: var(--ink-2); white-space: nowrap; }
html[lang=en] .band span { font-size: .6rem; }
.band:hover { background: #f1efe9; }
.band.sel { border-color: var(--accent); background: #f6f4ee; }
.band.used span { font-weight: 700; text-decoration: underline; }

.yarn-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.yarn { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 5px 4px; text-align: center; opacity: .75; }
.yarn.btnlike { cursor: pointer; opacity: 1; border-color: #cfccc3; }
.yarn.btnlike:hover { background: #f1efe9; }
.yarn i { display: block; height: 20px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .25); }
.yarn span { display: block; font-size: .72rem; line-height: 1.25; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yarn-pick { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.yarn-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.yarn-grid button { aspect-ratio: 1; border: 1px solid rgba(0, 0, 0, .25); border-radius: 5px; cursor: pointer; padding: 0; }
.yarn-grid button.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
.yarn-grid button:disabled { opacity: .25; cursor: default; }

/* ---------- 下のボタンの帯 ---------- */
.actions { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 25; }
.actions-in { max-width: 1560px; margin: 0 auto; padding: 8px var(--gutter); display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.rate-pair { max-width: 1000px; margin: 0 auto; }

/* ---------- 答える ---------- */
.q { padding: 10px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: none; }
.q-name { font-weight: 700; margin-bottom: 6px; }
/* 5 段階: どの段にも言葉を書く（数字だけだと迷う） */
.scale5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.scale5 button { border: 1px solid #cfccc3; background: var(--card); border-radius: 8px; min-height: 64px; cursor: pointer; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.3; }
.scale5 button b { font-size: 1.05rem; }
.scale5 button span { font-size: .8rem; color: var(--ink-2); }
.scale5 button:hover { background: #f1efe9; }
.scale5 button.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scale5 button.sel span { color: var(--accent-ink); }

.help { max-width: 760px; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; }
.help::backdrop { background: rgba(0, 0, 0, .35); }
.help h2 { font-size: 1.05rem; margin: 14px 0 4px; }

@media (max-width: 980px) {
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .cands { position: static; }
  .strip { flex-direction: row; max-height: none; overflow-x: auto; }
  .cloth { width: 110px; flex: none; }
  .side { position: static; max-height: none; overflow: visible; }
  #work { --imgh: 60vh; }
  .scale5 { grid-template-columns: minmax(0, 1fr); }
  .scale5 button { flex-direction: row; justify-content: flex-start; min-height: 44px; padding: 6px 12px; gap: 10px; }
  .actions-in { flex-wrap: wrap; }
}
