:root {
  --navy: #14263d;
  --navy-soft: #263c55;
  --paper: #f4eee4;
  --paper-deep: #e5d4bb;
  --kraft: #c49b69;
  --brass: #b47a32;
  --metal: #d5d9dc;
  --metal-dark: #7d8791;
  --ink: #1e2a35;
  --muted: #66727c;
  --line: #cec5b8;
  --red: #b84d37;
  --green: #31735b;
  --shadow: 0 18px 40px rgba(20, 38, 61, .12);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); overflow-x: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; min-height: 44px; }
button:disabled { cursor: not-allowed; opacity: .45; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 10; background: var(--navy); color: #fff; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }

.hero { min-height: 390px; position: relative; isolation: isolate; display: flex; align-items: end; overflow: hidden; color: #fff; background: var(--navy); }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -2; background: url("/assets/workbench-hero.jpg") center / cover no-repeat; transform: scale(1.015); }
.hero__veil { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(11, 27, 46, .93) 0%, rgba(11, 27, 46, .67) 44%, rgba(11, 27, 46, .18) 100%), linear-gradient(0deg, rgba(11, 27, 46, .68), transparent 55%); }
.hero__content { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 92px 0 58px; }
.eyebrow, .section-kicker, .panel-index { margin: 0 0 .8rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; letter-spacing: .16em; }
.eyebrow { color: #e0b978; }
.hero h1 { max-width: 720px; margin: 0; font-size: clamp(2.8rem, 7vw, 5.8rem); line-height: .98; letter-spacing: -.07em; font-weight: 800; }
.hero__lead { max-width: 580px; margin: 1.5rem 0 1.8rem; color: #e4ebef; font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.8; }
.hero__quickstart { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; color: #f0d7ac; font-size: .84rem; }
.text-chip { border: 1px solid rgba(255,255,255,.38); color: #fff; background: rgba(15, 31, 51, .52); padding: .55rem .8rem; border-radius: 999px; min-height: 44px; }
.text-chip:hover, .text-chip:focus-visible { background: #fff; color: var(--navy); }
.hero__example-result { display: flex; align-items: baseline; flex-wrap: wrap; gap: .6rem 1.1rem; width: fit-content; margin-top: 1.65rem; padding: .7rem .9rem; border-left: 2px solid #e0b978; background: rgba(15, 31, 51, .45); }
.hero__example-result span { color: #e0b978; font: .64rem ui-monospace, monospace; letter-spacing: .13em; }
.hero__example-result strong { color: #fff; font: 700 1rem ui-monospace, monospace; letter-spacing: .03em; }
.hero__example-result strong i { color: #e0b978; font-style: normal; }
.hero__example-result small { color: #c3d0d6; font-size: .75rem; }
.hero__mark { position: absolute; right: max(32px, calc((100% - 1180px) / 2)); top: 48px; color: rgba(255, 255, 255, .7); display: grid; gap: .5rem; justify-items: end; font: .76rem ui-monospace, monospace; letter-spacing: .12em; }
.hero__mark i { width: 96px; height: 1px; display: block; background: #e0b978; box-shadow: 0 7px 0 rgba(224, 185, 120, .4), 0 14px 0 rgba(224, 185, 120, .18); }

.workbench { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 80px 0 92px; }
.workbench__intro { display: grid; grid-template-columns: minmax(220px, .65fr) minmax(0, 1.35fr); gap: 2rem; align-items: end; margin-bottom: 2.5rem; }
.section-kicker { color: var(--brass); }
.workbench h2, .how-to h2 { margin: 0; color: var(--navy); font-size: clamp(1.7rem, 3vw, 2.65rem); letter-spacing: -.045em; line-height: 1.16; }
.workbench__intro > p:last-child { margin: 0; max-width: 650px; color: var(--muted); line-height: 1.8; }
.workbench-grid { display: grid; grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); gap: 22px; align-items: start; }
.measure-panel, .result-panel { position: relative; min-width: 0; border: 1px solid rgba(20, 38, 61, .15); box-shadow: var(--shadow); }
.measure-panel { padding: 28px; background: linear-gradient(145deg, #e0c49f, #d2b186); }
.measure-panel::after { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(20, 38, 61, .15); pointer-events: none; }
.measure-panel > * { position: relative; z-index: 1; }
.result-panel { padding: 28px; background: #fffdfa; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.7rem; }
.panel-heading h3, .parts-heading h3 { margin: 0; color: var(--navy); font-size: 1.28rem; letter-spacing: -.03em; }
.panel-index { margin-bottom: .45rem; color: rgba(20, 38, 61, .58); }
.steel-dot { width: 13px; height: 13px; flex: 0 0 auto; border: 1px solid #fff; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #8b969d 55%, #43505a); box-shadow: 0 0 0 4px rgba(255,255,255,.25); }
.field-grid { display: grid; gap: 12px; }
.field-grid--conditions { grid-template-columns: .9fr 1fr 1fr; }
.field-grid--dimensions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; color: var(--navy); font-weight: 700; font-size: .85rem; }
.field > span { display: flex; justify-content: space-between; gap: .4rem; }
.field small { color: var(--muted); font-size: .7rem; font-weight: 500; }
.field input, .field select { width: 100%; min-height: 46px; border: 1px solid rgba(20, 38, 61, .24); border-radius: 2px; color: var(--ink); background: rgba(255, 255, 255, .72); padding: .65rem .7rem; font-size: 16px; }
.field input:focus, .field select:focus, button:focus-visible { outline: 3px solid rgba(180, 122, 50, .4); outline-offset: 2px; }
.field-hint { margin-top: -2px; }
.parts-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin: 2rem 0 .9rem; padding-top: 1.2rem; border-top: 1px solid rgba(20, 38, 61, .22); }
.parts-heading h3 span { color: rgba(20, 38, 61, .6); font-size: .72rem; font-weight: 600; letter-spacing: .06em; }
.parts-list { display: grid; gap: 10px; }
.part-row { padding: 13px; border: 1px solid rgba(20, 38, 61, .2); background: rgba(255,255,255,.42); }
.part-row__top { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-bottom: 10px; }
.part-number { padding-bottom: 13px; color: rgba(20,38,61,.6); font: .72rem ui-monospace, monospace; }
.remove-part { min-height: 44px; border: 0; color: var(--red); background: transparent; padding: .4rem; font-size: .8rem; }
.parts-note { margin: .8rem 0 0; color: rgba(20,38,61,.7); font-size: .76rem; line-height: 1.5; }
.button { min-height: 44px; border: 1px solid transparent; border-radius: 2px; padding: .62rem .8rem; font-weight: 800; font-size: .78rem; letter-spacing: .02em; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button--small { min-height: 44px; padding: .48rem .72rem; }
.button--outline { border-color: rgba(20, 38, 61, .36); color: var(--navy); background: rgba(255,255,255,.35); }
.button--outline:hover:not(:disabled) { background: #fff; }
.button--navy { color: #fff; background: var(--navy); }
.button--brass { color: #fff; background: var(--brass); }
.button--quiet { border-color: transparent; color: var(--muted); background: transparent; }
.formula-strip { display: flex; align-items: center; justify-content: center; gap: .65rem; margin-top: 1.5rem; padding: .9rem; color: var(--navy); border-top: 1px solid rgba(20, 38, 61, .18); border-bottom: 1px solid rgba(20, 38, 61, .18); font-size: .84rem; }
.formula-strip b { color: var(--brass); }
.formula-strip strong { color: var(--red); }
.form-message { display: grid; gap: .2rem; margin: 1rem 0 0; padding: .75rem; font-size: .8rem; line-height: 1.5; }
.form-message--error { color: #7c2f21; border-left: 3px solid var(--red); background: rgba(255,255,255,.42); }

.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: .25rem .55rem; color: var(--muted); background: var(--metal); font-size: .68rem; font-weight: 800; white-space: nowrap; }
.status-badge--ok { color: #225b46; background: #dbece4; }
.status-badge--warn { color: #7c2f21; background: #f4dcd6; }
.result-summary { min-height: 152px; }
.empty-state { display: grid; place-items: center; min-height: 136px; margin: 0; padding: 1.5rem; color: var(--muted); border: 1px dashed var(--line); text-align: center; line-height: 1.7; }
.empty-state--error { color: #7c2f21; background: #fff7f4; }
.result-equation { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; min-height: 42px; margin-bottom: 1rem; color: var(--muted); font-size: .78rem; }
.result-equation b { color: var(--brass); }
.result-equation strong { color: var(--navy); font-size: 1rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); }
.result-table { width: 100%; min-width: 530px; border-collapse: collapse; font-size: .78rem; }
.result-table th, .result-table td { padding: .64rem .55rem; border-bottom: 1px solid #e8e1d7; text-align: right; white-space: nowrap; }
.result-table thead th { color: var(--navy); background: #eef0ef; font-size: .7rem; }
.result-table thead tr:first-child th:not(:first-child) { text-align: center; }
.result-table th:first-child, .result-table td:first-child { text-align: left; }
.result-table tbody th { font-weight: 800; }
.result-table td small { color: var(--muted); font-size: .68rem; }
.muted { color: #9ba2a5; }
.ruler-frame { margin-top: 1.3rem; padding: 12px; background: #e8ebeb; border: 1px solid #c3c9ca; box-shadow: inset 0 0 0 1px rgba(255,255,255,.65); }
.ruler-frame__label { display: flex; justify-content: space-between; margin-bottom: .55rem; color: #647078; font: .63rem ui-monospace, monospace; letter-spacing: .08em; }
.ruler-preview { min-height: 120px; display: grid; place-items: center; overflow-x: auto; background: #cbd0d1; }
.ruler-preview svg { display: block; width: 100%; min-width: 390px; height: auto; }
.print-note { margin: .9rem 0 0; color: var(--muted); font-size: .76rem; line-height: 1.65; }
.print-note strong { color: var(--navy); }
.action-area { display: grid; gap: .55rem; margin-top: 1.15rem; }
.action-group { display: flex; flex-wrap: wrap; gap: .45rem; }
.app-status { min-height: 1.3em; margin: .8rem 0 0; color: var(--green); font-size: .78rem; line-height: 1.5; }
.app-status--error { color: var(--red); }
.app-status--success { color: var(--green); }

.how-to { display: grid; grid-template-columns: minmax(220px, .65fr) minmax(0, 1.35fr); gap: 2rem; width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 55px 0 92px; border-top: 1px solid var(--line); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.step { min-height: 190px; padding: 1.25rem; border-left: 2px solid var(--brass); background: rgba(255,255,255,.36); }
.step span { color: var(--brass); font: .72rem ui-monospace, monospace; }
.step h3 { margin: 1rem 0 .6rem; color: var(--navy); font-size: 1rem; }
.step p { margin: 0; color: var(--muted); font-size: .83rem; line-height: 1.7; }
.site-footer { display: flex; justify-content: space-between; gap: 2rem; padding: 22px max(24px, calc((100% - 1180px) / 2)); color: #dfe7eb; background: var(--navy); font-size: .76rem; line-height: 1.6; }
.site-footer div { display: flex; flex-wrap: wrap; gap: .8rem 1rem; }
.site-footer span, .site-footer p { color: #aebdca; }
.site-footer p { margin: 0; }

@media (max-width: 860px) {
  .workbench-grid { grid-template-columns: 1fr; }
  .workbench__intro, .how-to { grid-template-columns: 1fr; }
  .hero__mark { display: none; }
}
@media (max-width: 560px) {
  .hero__content, .workbench, .how-to { width: min(100% - 28px, 1180px); }
  .hero { min-height: 430px; }
  .hero__content { padding: 70px 0 38px; }
  .measure-panel, .result-panel { padding: 20px 16px; }
  .field-grid--conditions { grid-template-columns: 1fr 1fr; }
  .field-grid--conditions .field:first-child { grid-column: 1 / -1; }
  .parts-heading { align-items: start; flex-direction: column; }
  .steps { grid-template-columns: 1fr; }
  .step { min-height: auto; }
  .site-footer { display: block; padding: 22px 14px; }
  .site-footer p { margin-top: .8rem; }
}
@media (max-width: 320px) {
  .hero__content, .workbench, .how-to { width: calc(100% - 20px); }
  .hero h1 { font-size: 2.55rem; }
  .hero__lead { font-size: .92rem; }
  .field-grid--conditions, .field-grid--dimensions { grid-template-columns: 1fr; }
  .field-grid--conditions .field:first-child { grid-column: auto; }
  .action-group .button { flex: 1 1 auto; }
  .formula-strip { gap: .35rem; font-size: .72rem; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .hero, .workbench__intro, .measure-panel, .how-to, .site-footer, .action-area, .app-status, .print-note, .panel-heading, .result-equation, .result-summary { display: none !important; }
  .workbench, .workbench-grid, .result-panel, .ruler-frame { width: 100%; margin: 0; padding: 0; border: 0; box-shadow: none; display: block; }
  .ruler-frame__label { display: none; }
  .ruler-preview { display: block; background: #fff; }
  .ruler-preview svg { width: 210mm; min-width: 0; }
}
