:root {
  color-scheme: light dark;
  --bg: #f4f1eb;
  --surface: #fffefa;
  --surface-raised: #ffffff;
  --text: #171818;
  --muted: #676963;
  --line: #d6d2c9;
  --line-strong: #a6a49e;
  --ink: #121416;
  --accent: #e6542f;
  --accent-soft: #fbe8e1;
  --success: #176b4a;
  --success-soft: #e1f0e8;
  --danger: #b12f2f;
  --danger-soft: #fbe7e5;
  --focus: #2b6de0;
  --shadow: 0 18px 50px rgba(31, 29, 24, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(rgba(23, 24, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 24, 24, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 40px 40px;
  color: var(--text);
  font-family: Inter, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select, input[type="range"] { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, transparent);
  outline-offset: 3px;
}

.site-header, main, footer { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }

.site-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.site-header > p, footer > p { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.04em; }

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 800; font-size: 0.82rem; letter-spacing: 0.14em; }

.brand-mark { position: relative; width: 28px; height: 20px; border: 2px solid currentColor; border-radius: 4px; display: inline-grid; place-items: center; }
.brand-mark::before { content: ""; position: absolute; width: 9px; height: 3px; left: 3px; top: -5px; border-radius: 2px 2px 0 0; background: currentColor; }
.brand-mark span { width: 8px; aspect-ratio: 1; border: 2px solid currentColor; border-radius: 50%; }

.hero { padding: 80px 0 64px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 0.48fr); align-items: end; column-gap: 64px; }
.eyebrow, .step-label { color: var(--accent); font-weight: 800; font-size: 0.7rem; letter-spacing: 0.2em; margin: 0 0 10px; }
.hero h1 { grid-row: span 2; margin: 0; font-size: clamp(3rem, 7.2vw, 6.25rem); line-height: 0.98; letter-spacing: -0.075em; font-weight: 850; }
.hero h1 span { color: var(--accent); }
.hero-copy { margin: 0 0 24px; color: var(--muted); font-size: 1rem; line-height: 1.9; }
.hero-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-meta span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.68rem; font-weight: 700; color: var(--muted); background: color-mix(in srgb, var(--surface) 70%, transparent); }

.app-shell { display: grid; grid-template-columns: minmax(360px, 0.86fr) minmax(440px, 1.14fr); align-items: start; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.control-panel { padding: 30px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.section-heading h2 { margin: 0; font-size: 1.7rem; line-height: 1.15; letter-spacing: -0.04em; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 5px; text-decoration: underline; text-underline-offset: 4px; font-size: 0.75rem; }

.field-group { margin: 0 0 25px; min-width: 0; }
.field-group > label, .field-group legend, .label-row > label, .reverse-input-block > label { display: block; margin: 0 0 9px; font-weight: 750; font-size: 0.82rem; }
.field-group legend { padding: 0; }
fieldset.field-group { border: 0; padding: 0; }
select, .unit-input { width: 100%; min-height: 50px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-raised); color: var(--text); }
select { padding: 0 42px 0 14px; }
.unit-input { display: flex; align-items: center; overflow: hidden; }
.unit-input input { width: 100%; min-width: 0; height: 48px; border: 0; background: transparent; color: var(--text); padding: 0 5px 0 14px; cursor: text; }
.unit-input input:focus { outline: 0; }
.unit-input:focus-within, select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.unit-input > span { padding: 0 14px 0 8px; color: var(--muted); font-size: 0.78rem; font-weight: 750; }
.field-help { margin: 6px 0 0; color: var(--muted); font-size: 0.68rem; }
.field-error { min-height: 0; margin: 6px 0 0; color: var(--danger); font-size: 0.72rem; font-weight: 700; }
.field-error:empty { display: none; }
.has-error { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent) !important; }

.custom-sensor, .two-column-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.custom-sensor[hidden] { display: none; }
.compact-field { margin-top: -12px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; background: color-mix(in srgb, var(--line) 45%, transparent); padding: 4px; border-radius: 11px; }
.segmented-control label { position: relative; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { min-height: 45px; display: flex; align-items: center; justify-content: center; gap: 9px; border-radius: 8px; color: var(--muted); font-size: 0.8rem; font-weight: 750; cursor: pointer; }
.segmented-control input:checked + span { background: var(--surface-raised); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.segmented-control input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.orientation-icon { display: block; width: 18px; height: 13px; border: 1.5px solid currentColor; border-radius: 2px; }
.portrait-icon { width: 10px; height: 15px; }

.label-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.label-row > label { margin: 0; }
.prominent-input { width: 130px; min-height: 46px; }
.prominent-input input { font-size: 1.4rem; font-weight: 800; text-align: right; }
.range-input { width: 100%; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.range-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.62rem; margin-top: -2px; }
.preset-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.preset-buttons button { min-height: 34px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); font-size: 0.7rem; font-weight: 700; }
.preset-buttons button:hover, .preset-buttons button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.dark-card { background: var(--ink); color: #f4f4ef; border-color: #2d3032; overflow: hidden; }
.preview-panel { min-height: 680px; padding: 30px; display: flex; flex-direction: column; }
.light-heading { margin-bottom: 20px; }
.status-dot { display: flex; align-items: center; gap: 6px; color: #acb0ad; font-size: 0.64rem; font-weight: 800; letter-spacing: 0.12em; }
.status-dot i { width: 6px; height: 6px; border-radius: 50%; background: #ff5b38; box-shadow: 0 0 0 4px rgba(255, 91, 56, 0.14); }
.preview-stage { min-height: 430px; flex: 1; display: grid; place-items: center; padding: 24px 2px; }
.camera-frame { position: relative; width: min(100%, 600px); max-height: 470px; aspect-ratio: 3 / 2; overflow: hidden; border: 1px solid #858987; background: radial-gradient(circle at 50% 70%, #35383a 0%, #222527 42%, #17191b 100%); transition: aspect-ratio 180ms ease; }
.camera-frame::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 33.2%, rgba(255,255,255,0.055) 33.4%, transparent 33.6%, transparent 66.4%, rgba(255,255,255,0.055) 66.6%, transparent 66.8%), linear-gradient(0deg, transparent 33.2%, rgba(255,255,255,0.055) 33.4%, transparent 33.6%, transparent 66.4%, rgba(255,255,255,0.055) 66.6%, transparent 66.8%); pointer-events: none; }
.corner { position: absolute; z-index: 4; width: 18px; height: 18px; border-color: #f2f0e9; }
.top-left { left: 12px; top: 12px; border-left: 2px solid; border-top: 2px solid; }
.top-right { right: 12px; top: 12px; border-right: 2px solid; border-top: 2px solid; }
.bottom-left { left: 12px; bottom: 12px; border-left: 2px solid; border-bottom: 2px solid; }
.bottom-right { right: 12px; bottom: 12px; border-right: 2px solid; border-bottom: 2px solid; }
.center-line { position: absolute; z-index: 1; background: rgba(255,255,255,0.12); }
.center-line.horizontal { height: 1px; left: 47%; right: 47%; top: 50%; }
.center-line.vertical { width: 1px; top: 46%; bottom: 46%; left: 50%; }
.frame-label { position: absolute; z-index: 5; right: 13px; bottom: 10px; color: rgba(255,255,255,0.7); font-variant-numeric: tabular-nums; font-size: 0.62rem; letter-spacing: 0.08em; }

.person { position: absolute; z-index: 2; left: 50%; top: 15.625%; height: 68.75%; width: 20.625%; min-width: 5px; transform: translateX(-50%); transition: height 180ms ease, width 180ms ease, top 180ms ease; filter: drop-shadow(0 12px 12px rgba(0,0,0,0.22)); }
.person span { position: absolute; display: block; background: #d9d8d0; }
.person-head { width: 28%; height: 15%; left: 36%; top: 0; overflow: hidden; border-radius: 48% 48% 43% 43%; background: radial-gradient(ellipse at 50% 5%, #77736d 0 42%, transparent 43%), #d9d8d0; }
.person-head::before { content: ""; position: absolute; width: 52%; height: 18%; left: 24%; top: 43%; background: radial-gradient(circle at 16% 50%, #3f403d 0 14%, transparent 16%), radial-gradient(circle at 84% 50%, #3f403d 0 14%, transparent 16%); }
.person-head::after { content: ""; position: absolute; width: 26%; height: 10%; left: 37%; top: 68%; border-bottom: 1px solid #8b655c; border-radius: 50%; }
.person-neck { width: 12%; height: 5%; left: 44%; top: 13%; }
.person-body { width: 52%; height: 43%; left: 24%; top: 17%; clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%); border-radius: 15% 15% 5% 5%; }
.person-arm { width: 13%; height: 42%; top: 18%; border-radius: 999px; transform-origin: 50% 5%; }
.person-arm.left { left: 16%; transform: rotate(5deg); }
.person-arm.right { right: 16%; transform: rotate(-5deg); }
.person-leg { width: 18%; height: 43%; top: 57%; border-radius: 0 0 999px 999px; }
.person-leg.left { left: 29%; transform: rotate(1deg); }
.person-leg.right { right: 29%; transform: rotate(-1deg); }
.occupancy-readout { border-top: 1px solid #343739; padding-top: 22px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.occupancy-readout > div > span { display: block; color: #9ca09e; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; }
.occupancy-readout strong { display: block; font-size: clamp(2.5rem, 5vw, 4rem); line-height: 1.05; letter-spacing: -0.055em; font-variant-numeric: tabular-nums; }
.occupancy-readout strong small { font-size: 0.42em; margin-left: 4px; color: var(--accent); }
.occupancy-readout > p { margin: 0 0 7px; color: #f1a78f; font-size: 0.86rem; font-weight: 750; text-align: right; }
.preview-note { color: #888d8a; font-size: 0.65rem; margin: 16px 0 0; }

.results-section { padding: 90px 0; }
.results-heading { align-items: end; }
.results-heading h2, .reverse-copy h2, .guide-section h2 { font-size: clamp(2rem, 4vw, 3.4rem); }
.share-button { min-height: 46px; padding: 0 18px; border: 1px solid var(--text); border-radius: 999px; background: var(--text); color: var(--bg); font-size: 0.78rem; font-weight: 750; }
.share-button:hover { transform: translateY(-1px); }
.share-message { min-height: 1.4em; margin: -18px 0 14px; color: var(--success); text-align: right; font-size: 0.75rem; font-weight: 700; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line); }
.result-card { position: relative; min-height: 190px; padding: 26px 22px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 75%, transparent); }
.result-card p { margin: 35px 0 6px; color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.result-card strong { display: block; font-size: clamp(1.45rem, 2.5vw, 2.1rem); line-height: 1.2; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.result-card small { display: block; margin-top: 8px; color: var(--muted); font-size: 0.65rem; }
.result-index { position: absolute; top: 20px; right: 20px; color: var(--line-strong); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.1em; }
.featured-result { background: var(--accent); color: white; border-color: color-mix(in srgb, var(--accent) 70%, black); }
.featured-result p, .featured-result small, .featured-result .result-index { color: rgba(255,255,255,0.72); }
.span-two { grid-column: span 2; }
.span-two strong { display: flex; align-items: center; gap: 14px; font-size: clamp(1.8rem, 3.2vw, 2.8rem); }
.span-two strong i { color: var(--accent); font-style: normal; font-size: 0.7em; font-weight: 400; }
.face-result { border-top: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.face-result strong { color: var(--accent); }
.fit-result.is-not-fit { background: var(--danger-soft); }
.fit-result:not(.is-not-fit) { background: var(--success-soft); }
.fit-result strong { color: var(--success); }
.fit-result.is-not-fit strong { color: var(--danger); }

.reverse-section { display: grid; grid-template-columns: 0.72fr 1.28fr; gap: 70px; align-items: center; padding: 40px 0 110px; }
.reverse-copy h2 { margin: 0 0 24px; line-height: 1.15; letter-spacing: -0.055em; }
.reverse-copy > p:last-child { max-width: 390px; color: var(--muted); font-size: 0.88rem; }
.reverse-calculator { padding: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.reverse-input-block { padding-right: 30px; border-right: 1px solid var(--line); }
.jumbo-input input { height: 66px; font-size: 2.1rem; font-weight: 800; text-align: right; }
.reverse-result > span { color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.reverse-result > strong { display: block; margin: 4px 0 20px; color: var(--accent); font-size: clamp(3rem, 6vw, 5rem); line-height: 1; letter-spacing: -0.07em; }
.reverse-result > strong small { font-size: 0.3em; margin-left: 6px; }
.lens-suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lens-suggestions div { padding: 12px; background: color-mix(in srgb, var(--line) 35%, transparent); border-radius: 8px; }
.lens-suggestions span { display: block; color: var(--muted); font-size: 0.62rem; }
.lens-suggestions b { display: block; margin-top: 2px; font-size: 0.92rem; }

.guide-section { display: grid; grid-template-columns: 1fr 1fr; gap: 70px; border-top: 1px solid var(--line-strong); padding: 90px 0; }
.guide-section h2 { margin: 0 0 36px; line-height: 1.2; letter-spacing: -0.05em; }
.guide-column ol { list-style: none; margin: 0; padding: 0; }
.guide-column li { display: grid; grid-template-columns: 38px 1fr; gap: 15px; padding: 18px 0; border-top: 1px solid var(--line); }
.guide-column li > span { color: var(--accent); font-weight: 800; font-size: 0.72rem; }
.guide-column strong { font-size: 0.9rem; }
.guide-column li p { color: var(--muted); font-size: 0.76rem; margin: 3px 0 0; }
.notes-card { align-self: end; padding: 32px; background: var(--ink); color: #f3f3ed; border-radius: var(--radius); }
.notes-card h2 { font-size: 1.25rem; margin-bottom: 20px; letter-spacing: -0.02em; }
.notes-card ul { padding-left: 1.2em; margin: 0; color: #b4b7b4; font-size: 0.75rem; }
.notes-card li + li { margin-top: 9px; }
.notes-card li::marker { color: var(--accent); }

footer { min-height: 130px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; row-gap: 24px; padding-top: 60px; }
  .hero h1 { grid-row: auto; }
  .hero-copy { max-width: 570px; }
  .app-shell { grid-template-columns: 1fr; }
  .preview-panel { min-height: 620px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .reverse-section { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 640px) {
  .site-header, main, footer { width: min(100% - 24px, 1180px); }
  .site-header { min-height: 66px; }
  .site-header > p { display: none; }
  .hero { padding: 46px 0 42px; }
  .hero h1 { font-size: clamp(2.7rem, 14vw, 4rem); }
  .hero-copy { font-size: 0.88rem; }
  .app-shell { gap: 12px; }
  .control-panel, .preview-panel { padding: 22px 18px; }
  .text-button { min-height: 44px; }
  .section-heading { margin-bottom: 24px; }
  .section-heading h2 { font-size: 1.5rem; }
  .custom-sensor, .two-column-fields { grid-template-columns: 1fr; gap: 0; }
  .compact-field { margin-top: 0; }
  .preset-buttons { grid-template-columns: repeat(5, 1fr); }
  .preset-buttons button { min-height: 40px; }
  .range-input { height: 44px; margin-block: -8px; }
  .preview-panel { min-height: 560px; }
  .preview-stage { min-height: 330px; padding: 16px 0; }
  .camera-frame { width: 100%; }
  .occupancy-readout { align-items: flex-end; }
  .results-section { padding: 64px 0; }
  .results-heading { align-items: flex-end; }
  .share-button { padding-inline: 14px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .result-card { min-height: 160px; padding: 20px 16px; }
  .result-card p { margin-top: 28px; }
  .result-card strong { font-size: 1.3rem; }
  .span-two { grid-column: span 2; }
  .span-two strong { font-size: 1.8rem; }
  .fit-result { grid-column: span 2; }
  .reverse-section { padding-bottom: 72px; }
  .reverse-calculator { padding: 22px 18px; grid-template-columns: 1fr; gap: 25px; }
  .reverse-input-block { padding: 0 0 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .guide-section { grid-template-columns: 1fr; gap: 50px; padding: 64px 0; }
  .notes-card { padding: 24px 20px; }
  footer { flex-direction: column; justify-content: center; gap: 8px; text-align: center; }
  footer p { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #181a1c;
    --surface-raised: #202326;
    --text: #f0f0ea;
    --muted: #a7aaa5;
    --line: #34373a;
    --line-strong: #55595b;
    --ink: #090a0b;
    --accent: #ff704c;
    --accent-soft: #3a211c;
    --success: #79d6a7;
    --success-soft: #173228;
    --danger: #ff9292;
    --danger-soft: #3a2020;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
  }
  body { background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px); }
  .featured-result { background: #d84b2a; }
  .share-button { color: #111315; background: #f0f0ea; border-color: #f0f0ea; }
}
