:root {
  color-scheme: light;
  --ink: #372e29;
  --muted: #69594b;
  --accent: #963e30;
  --paper: #fffdf7;
  --page: #fff7e8;
  --rule: #e8dac3;
  --warm: #cb654f;
  --cool: #268875;
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid #914e80;
  outline-offset: 3px;
}
h1, h2, p, figure { margin: 0; }
.height-tool { max-width: 1152px; margin: 34px auto 50px; padding: 0 24px; }
h1 { margin-bottom: 24px; line-height: 1.15; font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -.032em; }
.workspace { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; }
.people h2 { font-size: .94rem; margin: 10px 0 12px; font-weight: 800; }
.person { padding: 12px; background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; margin-bottom: 10px; }
.name-row { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0 2px 6px; }
.swatch { width: 10px; height: 10px; background: var(--warm); border-radius: 50%; flex: none; }
.person[data-person="1"] .swatch { background: var(--cool); }
.name-row > span:nth-child(2) { white-space: nowrap; color: var(--muted); font-size: .74rem; }
.name { min-width: 0; width: 100%; min-height: 32px; background: #fffefb; border: 1px solid var(--rule); padding: 4px 8px; border-radius: 7px; font-size: .9rem; font-weight: 700; }
.name::placeholder { color: var(--muted); opacity: 1; }
.character-settings { border-top: 1px solid #ead9bf; margin-top: 8px; font-size: .78rem; }
.character-settings summary { cursor: pointer; padding: 7px 2px 0; color: var(--accent); font-weight: 750; min-height: 29px; }
.character-fields { display: grid; gap: 5px; margin-top: 5px; }
.character-fields label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; font-weight: 650; }
.character-fields select { width: 100%; min-width: 0; min-height: 32px; padding: 3px; border: 1px solid var(--rule); border-radius: 7px; background: #fffafb; font-size: .79rem; }
.stepper { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 2px; align-items: center; }
.stepper button { min-height: 44px; border: 0; border-radius: 10px; background: #ffe3ce; color: var(--accent); font-size: 1.2rem; line-height: 1; }
.stepper button:disabled { opacity: .42; cursor: default; }
.height-field { display: flex; gap: 2px; align-items: baseline; justify-content: center; min-width: 0; }
.height { appearance: textfield; border: 0; border-radius: 4px; padding: 6px 0; width: 2.6em; min-width: 0; background: transparent; text-align: center; font-size: clamp(1.18rem, 4vw, 1.67rem); font-weight: 850; letter-spacing: -.04em; }
.height::-webkit-outer-spin-button, .height::-webkit-inner-spin-button { appearance: none; margin: 0; }
.height-field span, .input-note { font-size: .75rem; color: var(--muted); }
.input-note { margin-top: 3px; }
.appearance { margin-top: 19px; display: grid; gap: 14px; }
.appearance fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.appearance legend { padding: 0; margin-bottom: 6px; font-size: .79rem; font-weight: 800; }
.choices { display: flex; gap: 4px; }
.choices label { position: relative; cursor: pointer; flex: 1 1 auto; min-width: 0; }
.choices input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.choices span { display: grid; height: 44px; place-items: center; padding: 0 7px; border: 1px solid var(--rule); border-radius: 9px; background: var(--paper); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.choices input:checked + span { background:#ffdbbd; color:#7a3922; border-color:#c78c69; }
.choices input:focus-visible + span { outline: 3px solid #914e80; outline-offset: 2px; }
.reset-settings { justify-self: start; min-height: 34px; padding: 0 2px; background: transparent; border: 0; color: var(--muted); font-size: .76rem; text-decoration: underline; text-underline-offset: .18em; }
.model-credits { margin-top: 28px; color: var(--muted); font-size: .75rem; }
.model-credits a { color: inherit; text-underline-offset: .18em; }
.scene-header { display: flex; align-items: center; justify-content: space-between; min-width: 0; gap: 10px; margin-bottom: 12px; }
.tabs { display: flex; gap: 3px; border-radius: 13px; padding: 3px; background: #fff0ce; min-width: 0; }
.tabs button { border: 0; border-radius: 10px; white-space: nowrap; padding: 0 clamp(7px, 1.4vw, 17px); min-height: 44px; background: transparent; color: #634c35; font-size: .88rem; font-weight: 750; }
.tabs button[aria-selected="true"] { background: var(--paper); color: var(--accent); box-shadow: 0 1px 4px #57415622; }
.difference { flex: none; color: var(--accent); font-weight: 850; font-size: .88rem; white-space: nowrap; }
.difference strong { font-size: 1.4em; }
.scene-art { position: relative; }
.model-status { position:absolute; z-index:4; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; padding:18px; border-radius:17px; background:#f7eef3e8; color:var(--accent); font-size:.87rem; font-weight:750; text-align:center; }
.model-status button { border:1px solid #d8bfd1; background:var(--paper); border-radius:10px; padding:0 15px; min-height:40px; font-size:.84rem; font-weight:750; }
.stage { position: relative; isolation: isolate; width: 100%; height: clamp(350px, 45vw, 482px); overflow: hidden; border: 1px solid var(--rule); border-radius: 17px; background: radial-gradient(ellipse at 50% 44%, #fffdfa, #f0e8ed 100%); }
.stage canvas, .ruler-surface, .stage-labels { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.stage-labels { pointer-events: none; }
.stage-label { position: absolute; display: flex; align-items: baseline; justify-content: center; gap: 5px; max-width: 42%; min-width: 0; white-space: nowrap; font-size: .78rem; transform: translate(-50%, -50%); }
.stage-label b { overflow: hidden; text-overflow: ellipsis; }
.stage-label span { color: #605044; white-space: nowrap; }
.stage-label:first-child b { color: #763b36; }
.stage-label:last-child b { color: #285c54; }
.pov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.view { position: relative; border-radius: 17px; overflow: hidden; isolation: isolate; border: 1px solid var(--rule); background: var(--tint); }
.view-warm { --tint: #ffdfc9; --view-color: #753731; }
.view-cool { --tint: #d5f3e9; --view-color: #2d5c55; }
.portrait { position: relative; isolation: isolate; overflow: hidden; background: linear-gradient(165deg, #fffdf999, transparent 70%); }
.portrait canvas { position: relative; display: block; width: 100%; height: clamp(244px, 31vw, 360px); }
.eye-level { position: absolute; left: 0; right: 0; top: var(--eye-level); border-top: 1px dashed #63506366; }
.eye-level span { position: absolute; top: 3px; left: 6px; font-size: .64rem; color: #5d4f59; }
.view figcaption { padding: 9px 8px 5px; text-align: center; }
.view figcaption b, .view figcaption span, .subject { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.view figcaption b { margin: 0 auto; width: max-content; max-width: 100%; padding: 6px 11px; background: #fffdf7; border-radius: 20px; color: var(--view-color); font-weight: 850; font-size: .84rem; }
.angle { width: max-content; max-width: 100%; margin: 4px auto 0; padding: 3px 7px; border-radius: 6px; background: var(--tint); color: var(--ink); font-size: .73rem; font-weight: 750; }
.subject { padding: 8px 10px 10px; color: var(--ink); text-align: center; font-size: .82rem; font-weight: 750; }
.distance { display: flex; align-items: center; gap: 10px; padding: 5px 0 0; min-height: 49px; }
.distance label { font-size: .79rem; font-weight: 760; flex: none; }
.distance-slider { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.distance-slider span { font-size: .68rem; white-space: nowrap; color: var(--muted); }
.distance input { flex: 1; min-width: 20px; width: 0; height: 34px; accent-color: var(--accent); }
.distance output { font-size: .8rem; font-weight: 800; white-space: nowrap; flex: none; width: 44px; text-align: right; }
.framing { min-height: 38px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--accent); font-size: .74rem; font-weight: 750; white-space: nowrap; }
.framing[aria-pressed="true"] { background: #ffdbbd; border-color: #c78c69; }
.scene-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.scene-footer p { color: var(--muted); font-size: .76rem; }
.save { padding: 0 18px; min-height: 44px; border: 0; border-radius: 12px; background: var(--accent); color: #fff9fd; font-size: .86rem; font-weight: 800; white-space: nowrap; }
.save:disabled { opacity:.55; cursor:default; }
.download-icon { padding-right: 6px; font-size: 1rem; }
.error { padding: 16px; border: 1px solid #9d4b41; background: #fae9e4; border-radius: 12px; color: #752f28; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 720px) {
  .height-tool { margin-top: 20px; padding: 0 14px; }
  h1 { margin-bottom: 14px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; column-gap: 8px; }
  .people h2, .input-note { grid-column: 1 / -1; }
  .appearance { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) auto; align-items: end; margin-top: 12px; gap: 10px; }
  .choices { gap: 3px; }
  .choices span { font-size: .73rem; padding: 0 4px; }
  .people h2 { margin: 0 0 7px; font-size: .82rem; }
  .person { padding: 6px; margin-bottom: 4px; }
  .name-row { margin-bottom: 3px; }
  .name { min-height: 32px; }
  .character-settings { margin-top: 4px; }
  .character-fields label { gap: 5px; }
  .stepper { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .tabs button { font-size: .78rem; }
  .scene-header { gap: 5px; margin-bottom: 8px; }
  .difference { font-size: .74rem; }
  .stage { height: 342px; }
  .view canvas { height: clamp(210px, 62vw, 314px); }
  .pov-grid { gap: 6px; }
  .view figcaption { padding: 6px 4px 4px; }
  .view figcaption b { padding: 4px 7px; font-size: .72rem; }
  .angle { font-size: .66rem; }
  .distance { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px; }
  .distance label { font-size: .72rem; }
  .framing { grid-column: 1 / -1; justify-self: end; }
}
@media (max-width: 360px) {
  .stepper { grid-template-columns: 36px minmax(0, 1fr) 36px; }
  .height-field { flex-direction: column; align-items: center; gap: 0; }
  .height { width: 100%; padding: 0; font-size: 1.15rem; }
  .height-field span { font-size: .65rem; line-height: 1; }
  .appearance { gap: 7px; }
  .choices span { font-size:.68rem; padding:0 3px; }
}

/* Comparison workspace */
.height-tool { max-width: 1120px; }
h1 { font-size: clamp(1.55rem, 3vw, 2.1rem); margin-bottom: 4px; }
.tool-subtitle { color:var(--muted); font-size:.92rem; margin-bottom:18px; }
.mode-switch { display:flex; width:min(100%, 390px); padding:4px; margin:0 auto 18px; border-radius:13px; background:#fff0cc; }
.mode-switch button { flex:1; min-height:43px; border:0; border-radius:10px; background:transparent; color:#715937; font-weight:800; }
.mode-switch button[aria-pressed="true"] { background:#fff; color:var(--accent); box-shadow:0 2px 6px #513e4a1a; }
.workspace { grid-template-columns:minmax(0, 1fr) 310px; grid-template-rows:auto 1fr; gap:16px 24px; }
.comparison { grid-column:1; grid-row:1 / span 2; min-width:0; }
#pair-panel { grid-column:2; grid-row:1; }
.controls { grid-column:2; grid-row:2; }
.controls:has(#group-panel:not([hidden])) { grid-row:1 / span 2; }
.scene-header:has(.tabs[hidden]) { display:none; }
.scene-header { flex-wrap:wrap; }
.tabs { flex:1; overflow-x:auto; }
.tabs button { flex:1; display:inline-flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; min-height:48px; padding:4px 8px; font-size:.74rem; line-height:1.2; }
.tabs button svg { width:18px; height:18px; flex:none; }
.stage { height:clamp(330px, 44dvh, 470px); background:#fffafc; }
.secondary-button, .reset-settings, .save { display:inline-flex; align-items:center; justify-content:center; gap:6px; }
.secondary-button svg, .reset-settings svg, .save svg { width:16px; height:16px; flex:none; }
.scene-footer-actions { display:flex; align-items:center; gap:8px; }
.save-dialog-actions { display:flex; gap:8px; }
.save-dialog-actions > button { flex:1; }
.tool-guide { box-sizing:border-box; width:min(100%, 900px); margin:32px auto 0; padding:20px 0 36px; border-top:1px solid var(--rule); color:#1f1d1b; font-size:14px; line-height:1.85; }
.tool-guide h2 { font-size:18px; margin:20px 0 8px; }
.tool-guide h3 { font-size:15px; margin:14px 0 6px; }
.tool-guide p { margin:0 0 10px; color:var(--muted); }
.controls { display:grid; gap:16px; }
.control-panel, .appearance { padding:18px; border:1px solid var(--rule); border-radius:16px; background:#fff; }
.section-heading { display:flex; justify-content:space-between; align-items:start; gap:8px; margin-bottom:14px; }
.section-heading h2 { font-size:1rem; }
.section-heading p, .dialog-content > p { margin-top:5px; font-size:.76rem; color:var(--muted); }
.group-roster { display:grid; gap:8px; }
.roster-row { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px; }
.roster-row-actions { display:flex; gap:4px; }
.roster-row-actions .secondary-button { min-width:44px; min-height:44px; padding-inline:5px; white-space:nowrap; }
.roster-move:disabled { opacity:.45; cursor:default; }
.roster-card { width:100%; display:flex; align-items:center; gap:10px; min-height:58px; padding:8px 12px; border:1px solid var(--rule); border-radius:11px; background:#fffaf0; text-align:left; }
.roster-card b { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.roster-card > span:last-child { color:var(--muted); font-size:.82rem; white-space:nowrap; }
.avatar { display:grid; place-items:center; width:36px; height:36px; flex:none; border-radius:50%; background:#ffdfbb; color:var(--accent); font-weight:800; }
.add-person, .secondary-button { min-height:42px; border:1px solid #d8bea4; border-radius:10px; background:#fff; color:var(--accent); font-size:.8rem; font-weight:750; }
.add-person { width:100%; margin-top:10px; border-style:dashed; }
.secondary-button { padding:0 10px; }
#choose-pair { width:100%; }
#reselect-pair + .people { margin-top:8px; }
.people .person { margin-bottom:8px; }
.appearance { margin:0; gap:12px; }
.background-control { display:flex; align-items:center; gap:10px; margin-top:14px; color:var(--muted); font-weight:750; font-size:.8rem; }
.background-control select { flex:1; max-width:240px; min-height:42px; padding:0 12px; border:1px solid var(--rule); border-radius:10px; background:#fff; }
.scene-footer { margin-top:12px; }
.save-dialog, .picker-dialog { width:min(440px, calc(100% - 28px)); max-height:90dvh; padding:0; border:0; border-radius:18px; background:#fff; color:var(--ink); box-shadow:0 18px 60px #2b192d55; }
.save-dialog::backdrop, .picker-dialog::backdrop { background:#21132299; }
.save-dialog-content, .dialog-content { display:grid; gap:15px; padding:20px; }
.dialog-heading { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.dialog-heading h2 { font-size:1.1rem; }
.dialog-close { width:38px; height:38px; border:0; border-radius:50%; background:#fff0d9; color:var(--accent); font-size:1.4rem; }
#save-preview { display:block; max-width:100%; max-height:46dvh; width:auto; height:auto; margin:auto; border:1px solid var(--rule); border-radius:8px; background:repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 / 16px 16px; }
.save-formats { display:flex; gap:8px; padding:0; margin:0; border:0; }
.save-formats legend { margin-bottom:8px; font-size:.8rem; font-weight:800; }
.save-formats label { position:relative; flex:1; }
.save-formats input { position:absolute; opacity:0; }
.save-formats span { display:grid; place-items:center; min-height:42px; border:1px solid var(--rule); border-radius:9px; font-size:.82rem; font-weight:700; }
.save-formats input:checked + span { border-color:#aa7c9c; background:#f4e8f0; color:var(--accent); }
.save-formats input:focus-visible + span { outline:3px solid #914e80; outline-offset:2px; }
.save-options { display:grid; gap:10px; font-size:.84rem; }
.save-options input { accent-color:var(--accent); }
.pair-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.pair-options button { min-height:52px; border:1px solid var(--rule); border-radius:10px; background:#fff; }
.pair-options button[aria-pressed="true"] { border-color:#a16b93; background:#f3e6ef; color:var(--accent); }
.roster-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.roster-fields label { display:grid; gap:5px; font-size:.8rem; font-weight:750; }
.roster-fields input, .roster-fields select { width:100%; min-width:0; min-height:42px; padding:6px 9px; border:1px solid var(--rule); border-radius:9px; background:#fff; }
.roster-actions { display:flex; justify-content:space-between; gap:10px; }
@media (max-width:720px) {
  .height-tool { margin-top:12px; padding:0 14px; }
  .tool-subtitle, .mode-switch { margin-bottom:10px; }
  .workspace { display:flex; flex-direction:column; gap:12px; }
  .comparison { order:-1; width:100%; }
  .controls, #pair-panel { width:100%; }
  .stage { height:clamp(300px, 84vw, 410px); }
  .control-panel, .appearance { padding:14px; }
  .people { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .people .input-note { grid-column:1 / -1; }
  #pair-panel { padding:10px; }
  #pair-panel .section-heading { align-items:center; margin-bottom:0; }
  .appearance { display:grid; grid-template-columns:1fr; }
  .scene-header { margin-bottom:8px; }
  .tabs { width:100%; }
  .tabs button { flex:1 1 auto; padding:0 3px; font-size:.72rem; }
}
#reselect-pair { width:100%; }
.choices span { font-size:.72rem; padding:0 4px; }
.choose-pair { width:100%; margin-top:10px; }
.portrait { background-size:cover; background-position:center; }
#save-preview { object-fit:contain; max-width:100%; max-height:min(46dvh, 380px); }
.stage-label { max-width:23%; font-size:clamp(.62rem, 1.2vw, .78rem); gap:3px; }
@media (max-width:720px) { .stage-label { font-size:.64rem; } }

.difference { position:absolute; z-index:2; top:10px; right:10px; padding:5px 10px; background:#fffdf7f2; border:1px solid var(--rule); border-radius:11px; pointer-events:none; }
.height-tool:has(#mode-pair[aria-pressed="true"]) #save,
.height-tool:has(#mode-pair[aria-pressed="true"]) #save-download { background:#ac4038; }
.tabs button[aria-selected="true"], .height-tool:has(#mode-pair[aria-pressed="true"]) .difference { color:#8c3039; background:#ffe9e5; border-color:#edb6af; }
#scene[data-view="eyes"] .difference { position:static; display:block; width:max-content; margin:0 0 7px auto; }
.add-person:disabled { border-color:transparent; background:transparent; color:var(--muted); cursor:default; }
.save-status { color:var(--muted); font-size:.78rem; }
.save-status:not(:empty) { margin-top:6px; }
.save-error { color:#8c3039; font-size:.85rem; }
@media (max-width:720px) {
  .roster-card { min-height:44px; padding:6px 7px; gap:5px; }
  .roster-card .avatar { width:24px; height:24px; font-size:.68rem; }
  .roster-card b { font-size:.83rem; }
  .roster-card > span:last-child { font-size:.74rem; }
  #group-panel { display:grid; grid-template-columns:1fr 1.6fr; column-gap:8px; }
  #group-panel .section-heading, #group-panel .group-roster { grid-column:1/-1; }
}
@media (max-width:360px) {
  #pair-scenes { gap:1px; }
  #pair-scenes button { padding-inline:1px; }
}

.height-tool { padding-block:18px; }
.height-tool h1 { color:#463327; }
.mode-switch { background:#fae9bd; box-shadow:inset 0 0 0 1px #e6c990; }
.mode-switch button[aria-pressed="true"] { background:#874135; color:white; }
.tabs { background:#fff2d8; border:1px solid #e9cea2; }
.tabs button[aria-selected="true"] { background:#ab4339; color:#fff; }
.stage { border-color:#dbbf91; }
.height-tool:has(#mode-pair[aria-pressed="true"]) .difference {
  background:#fff0ad; color:#743d1e; border:2px solid white;
  box-shadow:0 2px 6px #59351338; border-radius:18px 18px 4px 18px;
}
.person { --person-ink:#954732; --person-wash:#ffefdf; --person-edge:#e59774;
  background:var(--person-wash); border-color:transparent; border-inline-start:4px solid var(--person-edge);
}
.person[data-person="1"] { --person-ink:#20675d; --person-wash:#e7f7ef; --person-edge:#72b7a2; }
.person .stepper button { background:white; color:var(--person-ink); }
.person .height, .person summary { color:var(--person-ink); }
.person .character-settings { border-color:var(--person-edge); }
.stage-label { background:#fffdf3ed; border-radius:8px; padding-inline:6px; }
