:root {
  color-scheme: light;
  --ink: #172b3c;
  --muted: #4c6171;
  --teal: #0b645d;
  --line: #d9e4e6;
  --surface: #fff;
  font-family: "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: #f2f7f7;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
h1, h2, h3, p { margin: 0; }
.top { background: #103d40; color: #f3ffff; }
.top-inner { max-width: 1440px; margin: 0 auto; padding: 16px clamp(16px, 4vw, 48px); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: .98rem; font-weight: 700; }
.top-note { color: #c3e0dd; font-size: .83rem; }
.mark, .empty-icon { display: inline-flex; align-items: flex-end; justify-content: center; gap: 4px; }
.mark { width: 34px; height: 33px; padding: 7px; border-radius: 9px; background: #b3e4d5; }
.mark i, .empty-icon i { display: block; width: 4px; border-radius: 2px; background: #126c65; }
.mark i:nth-child(1), .empty-icon i:nth-child(1) { height: 45%; }
.mark i:nth-child(2), .empty-icon i:nth-child(2) { height: 74%; }
.mark i:nth-child(3), .empty-icon i:nth-child(3) { height: 100%; }
main { max-width: 1440px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 12px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 2px 0 24px; }
.intro h1 { font-size: clamp(1.85rem, 4vw, 2.65rem); letter-spacing: -.04em; line-height: 1.25; }
.intro p { color: var(--muted); margin-top: 8px; line-height: 1.65; }
.intro-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
#jump-check { padding: 7px 10px; border: 1px solid #b9d4d1; background: #fff; border-radius: 7px; font-size: .83rem; font-weight: 700; white-space: nowrap; }
.badge, .tag { display: inline-block; background: #e3f3ee; color: #155750; border-radius: 999px; padding: 4px 11px; font-size: .78rem; white-space: nowrap; font-weight: 700; }
.badge { padding: 8px 14px; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 2px 5px #16414608; min-width: 0; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.section-title :is(h2, h3) { font-size: 1.08rem; }
.step { display: inline-flex; min-width: 32px; min-height: 28px; align-items: center; justify-content: center; background: #e1f2ed; color: #135d54; border-radius: 7px; font-size: .78rem; font-weight: 800; }
.data-grid { display: grid; grid-template-columns: 1.28fr repeat(3, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; font-weight: 650; min-width: 0; }
button, input, select { font: inherit; }
input:not([type="checkbox"], [type="color"]), select {
  width: 100%; min-width: 0; min-height: 41px; padding: 8px 10px; background: #fff; color: var(--ink);
  border: 1px solid #b6c9cd; border-radius: 7px;
}
input[type="file"] { font-size: .82rem; text-overflow: ellipsis; }
input[type="file"]::file-selector-button { font: inherit; color: #14574f; background: #e5f3ef; border: 0; padding: 4px 8px; margin-right: 7px; border-radius: 4px; cursor: pointer; }
input:disabled, select:disabled { opacity: .66; background: #f3f7f7; }
:focus-visible { outline: 3px solid #087e70; outline-offset: 2px; }
button { cursor: pointer; min-height: 36px; border-radius: 8px; border: 1px solid transparent; padding: 6px 11px; font-size: .84rem; font-weight: 700; }
button:disabled { cursor: default; opacity: .52; }
.primary { background: #b9ebd8; color: #0c3a36; min-height: 48px; padding: 10px 18px; white-space: nowrap; }
.primary:hover:not(:disabled) { background: #d1f6e7; }
.secondary { background: #edf7f4; color: #145b52; border-color: #cce5df; }
.secondary:hover:not(:disabled) { background: #d9f0e8; }
.plain { color: #145b52; background: transparent; text-decoration: underline; text-underline-offset: 3px; padding-inline: 0; justify-self: start; }
.message, .hint { color: var(--muted); font-size: .82rem; line-height: 1.6; overflow-wrap: anywhere; }
.message { margin-top: 10px; }
.warning { color: #9a3b14; }
details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; font-size: .87rem; font-weight: 700; color: #205650; line-height: 1.7; }
summary .tag { margin-left: 5px; }
details > div, details > p, details > label { margin-top: 9px; }
#read-check-note { margin: 16px 0 0; padding: 9px 10px; border-radius: 7px; background: #edf5f3; }
#guide-spotlight { position: fixed; z-index: 10; pointer-events: none; border: 2px solid #9cdbca; border-radius: 10px; box-shadow: 0 0 0 200vmax #102b3680; }
#guide-popover { position: fixed; z-index: 11; width: min(330px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: 12px 14px; background: #fff; border: 1px solid #b9d4d1; border-radius: 10px; box-shadow: 0 5px 24px #102b3640; }
.guide-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 6px; }
.guide-heading button { min-height: 28px; font-size: .78rem; }
#guide-title { margin-bottom: 5px; font-size: 1rem; }
#guide-action { margin-top: 9px; }
#questions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.group-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: 6px; }
.group { display: flex; align-items: center; justify-content: space-between; gap: 4px; background: #f2f7f7; padding: 5px 7px; border-radius: 6px; font-size: .76rem; }
.group.major { background: #def0eb; }
.layout-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.layout-controls .field { max-width: 135px; }
.layout-controls .question-row-field { max-width: none; }
.layout-controls .mapping-filter { max-width: 320px; }
.inline-check { display: inline-flex; align-items: center; gap: 5px; min-height: 41px; font-size: .84rem; }
.duplicate-setting .inline-check { min-height: 28px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 330px); gap: 16px; align-items: start; margin-top: 16px; }
.preview-select { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preview-area { display: grid; place-items: center; min-height: 225px; margin-top: 14px; padding: 12px; border: 1px solid #cfdddf; border-radius: 10px; background: #f0f5f5; }
.preview-area canvas { display: block; max-width: 100%; max-height: 440px; width: auto; height: auto; background: white; border-radius: 5px; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px; color: #344e61; font-size: .9rem; }
.empty span:last-child { color: var(--muted); font-size: .84rem; }
.empty-icon { width: 51px; height: 50px; padding: 13px; margin-bottom: 5px; border-radius: 13px; background: #deedea; }
.empty-icon i { width: 5px; }
.preview-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.settings-body { display: grid; gap: 11px; }
.settings-body details { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 5px; font-size: .82rem; }
.checks label { display: flex; align-items: center; gap: 4px; }
.checks .wide { grid-column: 1 / -1; }
input[type="checkbox"] { accent-color: var(--teal); width: 15px; height: 15px; }
.swatches { display: flex; gap: 3px; height: 10px; }
.swatches span { flex: 1; border-radius: 3px; }
.item-settings { display: grid; gap: 4px; max-height: 235px; overflow: auto; padding: 1px 3px 4px 1px; }
.item-setting { display: grid; grid-template-columns: 34px minmax(0, 1fr) 27px 27px; align-items: center; gap: 5px; font-size: .79rem; }
.item-setting span { overflow-wrap: anywhere; }
.item-setting input { width: 32px; height: 30px; cursor: pointer; border: 1px solid #bfccce; border-radius: 5px; background: white; }
.icon { min-height: 28px; padding: 1px; background: #edf7f4; color: #145b52; }
#reset-items { margin-top: 6px; }
.table-wrap { overflow: auto; }
.rules-wrap { max-height: 320px; }
.mapping-filter { max-width: 290px; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; overflow-wrap: anywhere; }
th { background: #edf5f4; color: #284a4d; }
td:nth-child(2) { text-align: right; }
table input:not([type="checkbox"], [type="color"]) { min-height: 34px; }
.export-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; padding: 18px 22px; border-radius: 14px; background: #103d40; color: #f3ffff; }
.export-card .section-title { margin-bottom: 6px; }
.export-card p { color: #d5eeec; font-size: .86rem; line-height: 1.55; }
.export-card .warning { color: #ffcfaa; }
.export-card summary { color: #e5f5f1; }
.export-card ul { padding-inline-start: 1.25rem; margin: 8px 0 2px; color: #e5f5f1; font-size: .82rem; }
.export-card :focus-visible { outline-color: #e5f5f1; }
.export-actions { display: flex; justify-content: end; flex-wrap: wrap; gap: 7px; flex-shrink: 0; }
progress { width: 100%; accent-color: #b9ebd8; }
footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 7px; padding: 16px 1px 6px; font-size: .8rem; color: var(--muted); }
a { color: #145b52; }
@media (max-width: 900px) {
  .data-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(245px, 290px); }
  .export-actions { flex-shrink: 1; }
}
@media (max-width: 680px) {
  main { padding-top: 23px; }
  .workspace { grid-template-columns: 1fr; }
  .card, .export-card { padding: 15px; }
  .intro, .export-card { align-items: start; flex-direction: column; }
  .export-actions { justify-content: start; }
  #questions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-area { min-height: 170px; }
  .preview-meta { align-items: start; flex-direction: column; }
}
@media (max-width: 420px) {
  .data-card > .data-grid, #questions, .preview-select { grid-template-columns: 1fr; }
  .top-note { display: none; }
}

.data-card > .data-grid { grid-template-columns: 1.35fr 1fr; }
.workspace { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.output-stack { display: grid; gap: 16px; min-width: 0; }
.output-stack .export-card { display: grid; margin-top: 0; }
.output-stack .export-actions { justify-content: start; }
.output-stack #save-zip { flex: 1 0 100%; }
#scope-equation { margin-bottom: 5px; font-size: 1rem; font-weight: 750; }
.preview-picker { margin-top: 0; padding-top: 0; border: 0; }
.preview-area { min-height: 150px; }
.image-design { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.image-design h3 { font-size: .91rem; }
.image-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.image-background input { width: 44px; height: 34px; border: 1px solid #b6c9cd; border-radius: 5px; background: #fff; }
.settings-card summary { margin-bottom: 9px; }
.scope-key { margin-bottom: 4px; }
.scope-connection { display: flex; align-items: center; justify-content: space-between; gap: 5px 10px; margin-bottom: 9px; }
.scope-network { display: grid; grid-template-columns: clamp(105px, 28%, 155px) minmax(18px, 1fr) minmax(105px, 1.6fr); gap: 5px 0; }
.scope-heading { grid-area: 1 / 1; display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 2px 7px; color: var(--muted); font-size: .79rem; }
.scope-heading:nth-child(2) { grid-column: 3; }
.scope-heading label { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.scope-nodes { grid-area: 2 / 1; display: grid; align-content: start; gap: 4px; z-index: 1; min-width: 0; }
.scope-questions { grid-column: 3; gap: 13px; padding-top: 3px; }
.scope-node { display: flex; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; font-size: .82rem; }
.scope-node[data-included="false"] { background: #f4f8f8; color: var(--muted); }
.scope-node[data-active="true"] { background: #e5f4ee; border-color: var(--teal); font-weight: 700; }
.scope-node label { display: flex; align-items: center; justify-content: space-between; gap: 3px; flex: 1; min-width: 0; padding: 4px 3px 4px 7px; }
.scope-node input { flex: none; margin: 0; }
.scope-pick { min-height: 29px; min-width: 28px; padding: 2px 5px; color: var(--teal); background: transparent; }
.scope-pick:hover:not(:disabled) { background: #d9efe7; }
.scope-questions .scope-pick { flex: 1; min-width: 0; min-height: 35px; text-align: start; overflow-wrap: anywhere; }
.scope-questions label { flex: 0 0 26px; justify-content: center; padding: 3px; }
.scope-links { grid-area: 2 / 2; position: relative; }
.scope-links svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.scope-wire { fill: none; stroke: #649a90; stroke-width: 1.5; pointer-events: none; }
.scope-wire.active { stroke: var(--teal); stroke-width: 2.5; }
.scope-wire.outside { stroke: #677e7d; stroke-dasharray: 4 3; }
.scope-wire-hit { fill: none; stroke: transparent; stroke-width: 13; pointer-events: stroke; cursor: pointer; }
#scope-preview-link { display: none; }

.review-step { margin-top: 16px; }
.review-step .section-title { margin-bottom: 10px; }
.review-panel { --review-border: #e7c98e; --review-bg: #fff4df; --review-ink: #74490a; margin: 0; padding: 0; border: 1px solid var(--review-border); border-radius: 12px; background: #fff; }
.review-panel[data-resolved="true"] { --review-border: #c6dfd8; --review-bg: #e7f4ee; --review-ink: #145b52; }
.review-panel > summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px 12px; padding: 11px 15px; list-style: none; background: var(--review-bg); color: var(--review-ink); border-radius: 11px; }
.review-panel[open] > summary { border-radius: 11px 11px 0 0; border-bottom: 1px solid var(--review-border); }
.review-panel summary::-webkit-details-marker { display: none; }
.review-panel summary strong, .review-panel summary small { display: block; }
.review-action { padding: 3px 9px; border: 1px solid var(--review-border); border-radius: 6px; background: #fff; font-size: .8rem; }
.review-close, .review-panel[open] #review-action { display: none; }
.review-panel[open] .review-close { display: inline; }
.review-body { margin: 0; padding: 0 15px 11px; }
.review-body > .hint { margin-top: 8px; }
.review-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; align-items: center; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.review-source { display: grid; gap: 2px; min-width: 0; }
.review-raw { max-height: 8rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
#review-pages { margin-top: 8px; align-items: center; }

@media (max-width: 680px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  #scope-preview-link { display: inline-block; white-space: nowrap; font-size: .82rem; }
  .review-row { grid-template-columns: minmax(0, 1fr); }
  .review-row button { justify-self: start; }
}
@media (max-width: 420px) {
  .data-card > .data-grid, .column-demographics { grid-template-columns: minmax(0, 1fr); }
  .scope-network { grid-template-columns: minmax(125px, .95fr) minmax(16px, .55fr) minmax(99px, 1.3fr); }
  #scope-groups .scope-node { font-size: .76rem; }
  #scope-groups label { padding-inline-start: 5px; }
}
@media (pointer: coarse) {
  .scope-pick, .scope-node { min-height: 44px; }
  .scope-pick { min-width: 35px; }
}
