:root {
  color-scheme: light;
  --header-height: 48px;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #171a1f;
  --muted: #626b78;
  --line: #d6dbe2;
  --accent: #176b55;
  --accent-soft: #e4f1ed;
  --warning: #a54024;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
.topbar { position: relative; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: var(--header-height); padding: 8px 14px; background: rgba(255,255,255,.98); border-bottom: 1px solid var(--line); }
.topbar #progress { color: var(--muted); }
.topbar #save-status { color: var(--accent); }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
#guide-button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 9px; font-size: 12px; }
#guide-button span { display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 50%; font-size: 11px; line-height: 1; }
main { width: 100%; max-width: 1920px; height: calc(100dvh - var(--header-height)); margin: 0 auto; padding: 10px; overflow: hidden; }
.start-view, .complete-view { height: 100%; display: grid; place-items: center; }
.start-view > div, .complete-view > div { width: min(620px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }
.start-view { overflow-y: auto; padding: 12px 0; }
.start-view > .start-panel { width: min(780px, 100%); padding: 26px 30px; }
.start-lead { margin: 0 0 14px; font-size: 15px; }
.scale-guide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; border: 1px solid var(--line); background: #f8f9fa; }
.scale-guide > div { display: grid; grid-template-columns: 28px 1fr; gap: 7px; align-items: center; padding: 9px 12px; }
.scale-guide > div + div { border-left: 1px solid var(--line); }
.scale-guide strong { color: var(--accent); font-size: 17px; }
.scale-guide span { color: var(--muted); font-size: 12px; line-height: 1.25; }
.scale-help { margin: 5px 0 12px; font-size: 12px; text-align: center; }
.tour-intro { margin: 0; padding: 9px 11px; border-left: 3px solid var(--accent); background: #f1f7f5; color: #394940; font-size: 12px; line-height: 1.4; }
.participation-note { margin: 9px 0 0; font-size: 12px; }
.participant-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.participant-form > label { margin: 0; }
.participant-code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 5px; }
.participant-code-row input { margin: 0; min-height: 38px; }
.participant-code-row button { min-width: 92px; }
.participant-help { margin: 6px 0 0; font-size: 11px; line-height: 1.35; }
.participant-status { min-height: 16px; margin: 2px 0 0; color: var(--accent); font-size: 11px; line-height: 1.3; }
h1 { margin: 0 0 12px; font-size: 24px; letter-spacing: 0; }
h2 { margin: 0; font-size: 16px; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.5; }
label { display: block; margin-top: 12px; font-weight: 650; }
input[type="text"], input:not([type]), select, textarea { width: 100%; margin-top: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); font: inherit; }
button { min-height: 36px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
button:hover { border-color: #87909d; }
button:disabled { opacity: .45; cursor: default; }
#start-button, #next-button, #resume-button { background: var(--accent); border-color: var(--accent); color: #fff; }
#start-button { margin-top: 5px; width: 100%; }
.study-layout { height: 100%; grid-template-columns: minmax(0, 7fr) minmax(480px, 3fr); gap: 12px; }
.study-layout:not([hidden]) { display: grid; }
.image-workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 42fr) minmax(0, 58fr); gap: 10px; }
.image-section { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 6px; }
.image-section h2 { padding-left: 2px; font-size: 14px; }
.demonstration-grid, .evaluation-grid { min-height: 0; display: grid; justify-content: center; gap: 8px; }
.demonstration-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.evaluation-section { padding-top: 8px; border-top: 1px solid var(--line); }
.evaluation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
figure { height: 100%; margin: 0; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
figure.output { border: 2px solid var(--accent); }
figcaption { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 750; text-align: center; }
.caption-badge { display: inline-grid; place-items: center; min-width: 27px; min-height: 23px; padding: 3px 8px; border-radius: 3px; background: var(--accent); color: #fff; font-size: 11px; line-height: 1; font-weight: 800; }
figure img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; background: #e9edf1; }
.rating-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.rating-panel-header { display: flex; align-items: center; padding: 11px 13px; background: var(--accent); color: #fff; }
.rating-panel-header h2 { font-size: 16px; font-weight: 800; }
.unclear-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 9px 12px; background: #f8f9fa; border-bottom: 1px solid var(--line); }
.unclear-row label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.2; font-weight: 700; }
.unclear-row input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
#rating-form { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; }
.questions { min-height: 0; display: grid; grid-template-rows: repeat(7, minmax(min-content, 1fr)); overflow-y: auto; overscroll-behavior: contain; padding: 0 12px; scrollbar-gutter: stable; }
.question { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(240px, 1.2fr); gap: 16px; align-items: center; padding: clamp(7px, 1vh, 14px) 2px; border-bottom: 1px solid var(--line); }
.question-title { font-size: 13px; font-weight: 750; }
.question-text { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.scale { display: grid; grid-template-columns: repeat(5, minmax(30px, 1fr)); gap: 4px; }
.scale label { position: relative; margin: 0; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span { display: grid; place-items: center; min-height: 40px; padding: 4px; border: 1px solid var(--line); background: #fff; text-align: center; font-size: 14px; font-weight: 750; }
.scale input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: #0f523f; }
.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.anchors { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.2; }
.anchors span { flex: 1; }
.anchors span:nth-child(2) { text-align: center; }
.anchors span:last-child { text-align: right; }
.question.disabled { opacity: .5; }
.comment-section { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(240px, 1.2fr); gap: 16px; align-items: start; padding: 10px 14px; background: #f8f9fa; border-top: 1px solid var(--line); }
.comment-section label { margin: 7px 0 0; font-size: 13px; font-weight: 750; }
.comment-section textarea { min-height: 62px; max-height: 120px; margin: 0; padding: 8px 9px; resize: vertical; line-height: 1.35; }
.form-footer { padding: 9px 11px 11px; background: var(--bg); border-top: 1px solid var(--line); }
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.actions button { width: 100%; min-height: 40px; padding: 6px 8px; font-size: 12px; }
.error { min-height: 17px; margin: 0 0 5px; color: var(--warning); font-size: 11px; line-height: 1.25; font-weight: 650; }
.error:empty { display: none; }
.tour-overlay { position: fixed; inset: 0; z-index: 100; overflow: hidden; }
.tour-spotlight { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tour-popover { position: fixed; z-index: 2; width: min(380px, calc(100vw - 28px)); padding: 18px; border: 1px solid #bfc6cf; border-radius: 6px; background: #fff; box-shadow: 0 16px 42px rgba(0,0,0,.28); transition: left .18s ease, top .18s ease; }
.tour-popover:focus { outline: none; }
.tour-progress { margin-bottom: 7px; color: var(--accent); font-size: 11px; line-height: 1; font-weight: 800; text-transform: uppercase; }
.tour-popover h2 { margin: 0; font-size: 20px; }
.tour-description { margin-top: 9px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.tour-description > p { margin: 0; color: inherit; }
.tour-callouts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.tour-callout { padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; background: #f8f9fa; }
.tour-callout strong { display: block; margin-bottom: 3px; color: var(--ink); font-size: 12px; }
.tour-callout span { display: block; color: var(--muted); font-size: 11px; line-height: 1.35; }
.tour-error { min-height: 16px; margin: 8px 0 0; color: var(--warning); font-size: 11px; line-height: 1.3; }
.tour-error:empty { display: none; }
.tour-footer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.tour-footer button { min-height: 36px; }
.tour-primary { min-width: 92px; background: var(--accent); border-color: var(--accent); color: #fff; }
.tour-close-button { width: 36px; padding: 0; font-size: 22px; line-height: 1; }
body.tour-open { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .tour-popover { transition: none; }
}
@media (max-width: 1100px) and (min-width: 901px) {
  main { padding: 8px; }
  .study-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 8px; }
  .question { grid-template-columns: minmax(110px, .85fr) minmax(178px, 1.15fr); gap: 8px; }
  .scale { grid-template-columns: repeat(5, minmax(32px, 1fr)); }
}
@media (max-height: 800px) and (min-width: 901px) {
  .start-view { padding: 8px 0; }
  .start-view > .start-panel { padding: 18px 26px; }
  .start-panel h1 { margin-bottom: 8px; font-size: 22px; }
  .start-lead { margin-bottom: 9px; font-size: 13px; }
  .scale-guide { margin-top: 9px; }
  .scale-guide > div { padding: 6px 10px; }
  .scale-help { margin-bottom: 8px; }
  .tour-intro { padding: 7px 9px; }
  .participation-note { margin-top: 7px; }
  .participant-form { margin-top: 8px; padding-top: 8px; }
  .participant-help { margin-top: 4px; }
  .participant-status { min-height: 13px; }
  .rating-panel-header { padding: 8px 11px; }
  .unclear-row { padding: 7px 10px; }
  .questions { padding: 0 9px; }
  .question { gap: 9px; padding: 5px 2px; }
  .question-title { font-size: 12px; }
  .question-text { margin-top: 1px; font-size: 10.5px; line-height: 1.18; }
  .scale span { min-height: 30px; font-size: 12px; }
  .anchors { gap: 4px; margin-top: 3px; font-size: 8.5px; line-height: 1.12; }
  .comment-section { grid-template-columns: minmax(110px, .85fr) minmax(178px, 1.15fr); gap: 9px; padding: 7px 10px; }
  .comment-section label { margin-top: 4px; font-size: 12px; }
  .comment-section textarea { min-height: 42px; max-height: 64px; padding: 5px 7px; font-size: 11px; }
  .form-footer { padding: 7px 9px 9px; }
  .actions button { min-height: 34px; padding: 5px 6px; }
}
@media (max-width: 900px) {
  body { height: auto; min-height: 100%; overflow: auto; }
  body.tour-open { overflow: auto; }
  main { height: auto; min-height: calc(100dvh - var(--header-height)); overflow: visible; }
  .study-layout:not([hidden]) { display: grid; grid-template-columns: 1fr; }
  .image-workspace { display: block; }
  .image-section { display: block; }
  .image-section h2 { margin-bottom: 6px; }
  .evaluation-section { margin-top: 10px; }
  figure img { height: auto; aspect-ratio: 1; }
  .rating-panel { margin-top: 2px; overflow: visible; }
  #rating-form { display: block; }
  .questions { overflow: visible; }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto auto; gap: 8px; }
  .topbar #save-status { display: none; }
  main { padding: 8px; }
  .demonstration-grid, .evaluation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .question { grid-template-columns: 1fr; gap: 8px; }
  .unclear-row { grid-template-columns: 1fr; gap: 8px; }
  .scale { grid-template-columns: repeat(5, minmax(38px, 1fr)); }
  .comment-section { grid-template-columns: 1fr; gap: 6px; }
  .comment-section label { margin-top: 0; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .start-view > .start-panel { padding: 20px 18px; }
  .scale-guide { grid-template-columns: 1fr; }
  .scale-guide > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .participant-code-row { grid-template-columns: 1fr; }
  .tour-popover { padding: 15px; }
  .tour-callouts { grid-template-columns: 1fr; }
}
