:root {
  --ink: #151515;
  --muted: #676767;
  --line: #d8d8d8;
  --soft-line: #e9e9e9;
  --surface: #ffffff;
  --soft: #f5f5f3;
  --accent: #202020;
  --danger: #9f2d24;
  --radius: 4px;
  font-family: Inter, "Helvetica Neue", Arial, "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", sans-serif;
  color: var(--ink);
  background: #f2f2f0;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f2f2f0;
  color: var(--ink);
}

body.participant-mode .app-header { display: none; }
body.participant-mode main { padding-top: 28px; }

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px max(24px, calc((100vw - 1320px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.96);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(20px, 2.4vw, 28px); letter-spacing: -0.02em; }
h2 { margin-bottom: 10px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.03em; }
h3 { margin-bottom: 0; font-size: 18px; }

.eyebrow, .step-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.mode-nav { display: flex; gap: 4px; }
.nav-button, .text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.nav-button { padding: 9px 13px; border-radius: 3px; }
.nav-button:hover, .nav-button.is-active { background: var(--ink); color: white; }

main { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 40px 0 72px; }
.view.is-hidden, .is-hidden { display: none !important; }

.section-heading, .panel-heading, .progress-row, .button-row, .field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.section-heading { align-items: flex-end; margin-bottom: 24px; }
.section-heading h2 { margin-bottom: 0; }
.section-note, .muted, .measure-note { color: var(--muted); font-size: 13px; }
.section-note { max-width: 420px; margin-bottom: 2px; text-align: right; }
.muted { margin: 6px 0 0; }

.research-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; }
.summary-grid { display: grid; grid-template-columns: minmax(300px, 0.75fr) minmax(440px, 1.25fr); gap: 18px; margin-bottom: 18px; }

.panel {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel-heading { align-items: flex-start; margin-bottom: 20px; }

.status-chip {
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.range-control { display: block; margin-bottom: 20px; }
.range-control > span { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.range-control output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--ink); }

label > span { display: block; margin-bottom: 7px; color: #444; font-size: 12px; font-weight: 700; }
input[type="text"], input[type="number"], select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #bdbdbd;
  border-radius: 2px;
  background: white;
  color: var(--ink);
}
input:focus, select:focus, button:focus-visible { outline: 2px solid #707070; outline-offset: 2px; }
.field-row > label { flex: 1; }
.level-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 14px; }
details { margin: 18px 0; border-top: 1px solid var(--soft-line); border-bottom: 1px solid var(--soft-line); padding: 13px 0; }
summary { cursor: pointer; font-size: 13px; font-weight: 700; }
hr { margin: 22px 0; border: 0; border-top: 1px solid var(--soft-line); }

.primary-button, .secondary-button, .danger-button, .file-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 2px;
  font-weight: 700;
  text-decoration: none;
}
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; }
.primary-button:hover { background: #383838; }
.secondary-button, .file-button { border: 1px solid #9d9d9d; background: white; color: var(--ink); }
.secondary-button:hover, .file-button:hover { background: var(--soft); }
.danger-button { border: 1px solid #d2a29d; background: white; color: var(--danger); }
.full-width { width: 100%; }
.wide-button { min-width: 220px; }
.button-row { justify-content: flex-start; }
.button-row.centered { justify-content: center; }
.file-button { cursor: pointer; font-size: 13px; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.text-button { padding: 8px; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--ink); }

.inline-message { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }
.inline-message.is-success { color: #22613c; }

.stimulus-frame {
  width: 100%;
  height: 500px;
  overflow: hidden;
  border: 1px solid #cfcfcf;
  background: #fff;
  color: #161616;
  font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans CJK JP", sans-serif;
  font-size: 18px;
  font-weight: 400;
  text-align: justify;
  text-justify: inter-character;
  writing-mode: horizontal-tb;
}
.stimulus-inner { padding: 34px 40px; }
.stimulus-inner p { margin: 0; }
.preview-frame { background-image: linear-gradient(#fafafa 1px, transparent 1px); background-size: 100% 50px; }
.participant-frame { width: min(760px, 100%); height: 650px; margin: 0 auto 28px; }

.condition-panel { margin-top: 18px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--soft-line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; letter-spacing: 0.05em; }
td input[type="number"] { width: 90px; min-height: 34px; }
.empty-cell { padding: 34px 10px; color: var(--muted); text-align: center; }

.participant-intro, .trial-ready, .completion-screen {
  width: min(620px, 100%);
  margin: 8vh auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  background: white;
  text-align: center;
}
.participant-intro > p, .trial-ready > p, .completion-screen > p { line-height: 1.7; }
.participant-back { display: block; margin: 12px auto 0; }
.instruction-box { margin: 24px 0; padding: 14px 16px; background: var(--soft); color: #444; font-size: 13px; text-align: left; }
.instruction-box p { margin: 0; }
.participant-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0 14px; text-align: left; }

.trial-screen { width: min(980px, 100%); margin: 0 auto; }
.progress-row { width: min(760px, 100%); margin: 0 auto 16px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.progress-track { flex: 1; height: 3px; background: #dedede; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--ink); transition: width 180ms ease; }

.rating-panel { width: min(760px, 100%); margin: 0 auto; padding: 22px 26px 26px; border: 1px solid var(--line); background: white; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 16px; font-size: 14px; font-weight: 700; }
.rating-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; padding: 14px 0; border-top: 1px solid var(--soft-line); }
.rating-label { font-size: 14px; font-weight: 700; }
.scale-options { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.scale-option { display: flex; align-items: center; justify-content: center; }
.scale-option input { position: absolute; opacity: 0; }
.scale-option span { display: flex; width: 34px; height: 34px; align-items: center; justify-content: center; border: 1px solid #aaa; border-radius: 50%; font-size: 12px; }
.scale-option input:checked + span { border-color: var(--ink); background: var(--ink); color: white; }
.scale-option input:focus-visible + span { outline: 2px solid #777; outline-offset: 2px; }
.scale-endpoints { grid-column: 2; display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 10px; }

.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.summary-card { padding: 18px; border: 1px solid var(--line); background: white; }
.summary-card span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.summary-card strong { font-size: 28px; font-variant-numeric: tabular-nums; }
.metric-list { display: grid; gap: 10px; }
.metric-line { display: grid; grid-template-columns: 92px 1fr 38px; align-items: center; gap: 10px; font-size: 13px; }
.metric-bar { height: 8px; background: #e6e6e6; }
.metric-bar span { display: block; height: 100%; background: #333; }
.metric-value { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .app-header { position: static; align-items: flex-start; flex-direction: column; }
  main { width: min(100% - 28px, 720px); padding-top: 24px; }
  .research-grid, .summary-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-note { text-align: left; }
  .participant-frame { height: 650px; }
}

@media (max-width: 620px) {
  .app-header { padding: 18px 14px; }
  .mode-nav { width: 100%; }
  .nav-button { flex: 1; }
  .panel { padding: 16px; }
  .level-fields, .participant-fields, .summary-cards { grid-template-columns: 1fr; }
  .rating-panel { padding: 16px 12px 20px; }
  .rating-row { grid-template-columns: 1fr; }
  .scale-options { grid-column: 1; margin-top: 10px; }
  .scale-endpoints { grid-column: 1; }
  .scale-option span { width: 32px; height: 32px; }
  .stimulus-inner { padding: 26px 24px; }
  .button-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

body,button,input,select{font-family:"Portfolio Sans SC","Portfolio Sans JP",sans-serif}html[lang="ja"] body,html[lang="ja"] button,html[lang="ja"] input,html[lang="ja"] select{font-family:"Portfolio Sans JP","Portfolio Sans SC",sans-serif}.stimulus-frame,.stimulus-inner:lang(ja){font-family:"Portfolio Sans JP",sans-serif}.stimulus-inner:lang(zh){font-family:"Portfolio Sans SC",sans-serif}.stimulus-inner{font-weight:400;font-synthesis:none}
