:root {
  color-scheme: light;
  --ink: #173b34;
  --ink-soft: #31554d;
  --canvas: #f1f2ea;
  --paper: #fbfbf6;
  --line: #d7ddd2;
  --muted: #6b7973;
  --accent: #d1a64e;
  --accent-pale: #f8efd9;
  --danger: #a84437;
  --danger-pale: #fae9e4;
  --shadow: 0 22px 50px rgba(31, 59, 51, 0.09);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background-color: var(--canvas);
  background-image: linear-gradient(rgba(23, 59, 52, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(23, 59, 52, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 36px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 42px; }
.topbar > p { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; font-weight: 740; letter-spacing: 0.02em; text-decoration: none; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 2px; width: 16px; height: 16px; padding: 1px; border: 1px solid var(--ink); }
.brand-mark i { background: var(--ink); }
.brand-mark i:last-child { background: var(--accent); }
.back-link { color: var(--ink-soft); font-size: 13px; font-weight: 700; text-decoration: none; }
.back-link:hover, .back-link:focus-visible { color: var(--ink); text-decoration: underline; }

.intro { display: flex; align-items: end; justify-content: space-between; gap: 48px; padding: 0 2px 38px; }
.eyebrow, .section-label { margin: 0; color: var(--ink-soft); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.intro h1 { margin: 12px 0 0; font-size: clamp(34px, 5vw, 60px); line-height: 1.08; letter-spacing: -0.06em; font-weight: 760; }
.intro-copy { width: min(310px, 100%); margin: 0 0 3px; color: var(--muted); font-size: 15px; line-height: 1.75; }

.workbench { display: grid; grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr); gap: 18px; align-items: stretch; }
.parameter-panel, .result-panel { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.parameter-panel { padding: clamp(22px, 3vw, 34px); }
.result-panel { display: flex; flex-direction: column; padding: clamp(22px, 3vw, 34px); overflow: hidden; background: var(--ink); color: #f8faef; }

.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.panel-heading h2 { margin: 7px 0 0; font-size: 22px; letter-spacing: -0.035em; }
.result-heading .section-label { color: #b7c9bd; }
.unit-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f2f4ec; }
.result-heading .unit-switch { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); }
.unit-button { min-width: 38px; border: 0; border-radius: 6px; padding: 5px 8px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 760; line-height: 1; }
.unit-button.is-active { color: var(--paper); background: var(--ink); }
.result-heading .unit-button { color: #b7c9bd; }
.result-heading .unit-button.is-active { color: var(--ink); background: var(--accent); }
.unit-button:focus-visible, input:focus-visible { outline: 3px solid rgba(209, 166, 78, 0.45); outline-offset: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px 14px; margin-top: 31px; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.input-wrap { position: relative; }
.input-wrap input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 9px; padding: 0 48px 0 13px; color: var(--ink); background: #fffefa; font-size: 16px; font-weight: 650; transition: border-color 160ms ease, box-shadow 160ms ease; }
.input-wrap input:hover { border-color: #aebbb2; }
.input-wrap input:focus { border-color: var(--ink-soft); box-shadow: 0 0 0 3px rgba(23, 59, 52, 0.09); outline: 0; }
.input-wrap input::placeholder { color: #abb4ad; font-weight: 500; opacity: 0.78; }
.input-unit { position: absolute; top: 50%; right: 13px; transform: translateY(-50%); color: var(--muted); font-size: 12px; font-weight: 750; }
.field-hint { min-height: 18px; margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.rotation-control { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 28px; padding: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; }
.rotation-control strong, .rotation-control small { display: block; }
.rotation-control strong { font-size: 13px; }
.rotation-control small { max-width: 290px; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.rotation-control input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.switch { position: relative; width: 40px; height: 23px; flex: 0 0 auto; border-radius: 99px; background: #bdc8c0; transition: background 160ms ease; }
.switch span { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 160ms ease; }
.rotation-control input:checked + .switch { background: var(--ink); }
.rotation-control input:checked + .switch span { transform: translateX(17px); }
.rotation-control input:focus-visible + .switch { outline: 3px solid rgba(209, 166, 78, 0.45); outline-offset: 3px; }
.form-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.action-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border-radius: 9px; padding: 10px 14px; font-size: 13px; font-weight: 750; text-decoration: none; transition: transform 160ms ease, background 160ms ease, border-color 160ms ease; }
.action-button:hover { transform: translateY(-1px); }
.action-button:focus-visible { outline: 3px solid rgba(209, 166, 78, 0.45); outline-offset: 2px; }
.action-button-secondary { border: 1px solid var(--line); color: var(--ink); background: #fffefa; }
.action-button-secondary:hover { border-color: var(--ink-soft); background: var(--accent-pale); }
.action-button-primary { border: 1px solid var(--ink); color: var(--paper); background: var(--ink); }
.action-button-primary:hover { background: var(--ink-soft); }
.form-status { min-height: 20px; margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.empty-state, .error-state { display: grid; place-content: center; flex: 1; min-height: 400px; text-align: center; }
.empty-index, .state-index { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.16em; }
.empty-state h3, .error-state h3 { margin: 14px 0 10px; font-size: 25px; letter-spacing: -0.04em; }
.empty-state p, .error-state p { max-width: 290px; margin: 0; color: #b7c9bd; font-size: 13px; line-height: 1.7; }
.error-state { padding: 20px; border: 1px solid rgba(220, 102, 85, 0.45); border-radius: 12px; background: rgba(168, 68, 55, 0.13); }
.error-state .state-index { color: #f2ac9e; }
.empty-state[hidden], .error-state[hidden], .result-state[hidden] { display: none !important; }

.result-state { display: flex; flex: 1; flex-direction: column; padding-top: 32px; }
.recommendation { padding: 24px; border: 1px solid rgba(255,255,255,0.2); border-radius: 13px; background: linear-gradient(135deg, rgba(255,255,255,0.13), rgba(255,255,255,0.04)); }
.recommendation p { margin: 0 0 9px; color: #d3dfd5; font-size: 13px; font-weight: 680; }
.recommendation div { display: flex; align-items: baseline; gap: 8px; }
.recommendation strong { color: var(--accent); font-size: clamp(55px, 7vw, 79px); letter-spacing: -0.085em; line-height: 0.93; }
.recommendation span { color: #f8faef; font-size: 20px; font-weight: 750; }
.recommendation small { display: block; margin-top: 13px; color: #b7c9bd; font-size: 11px; }
.result-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.result-summary > div { padding: 14px 0; border-top: 1px solid rgba(255,255,255,0.16); }
.result-summary span, .breakdown-list dt { display: block; color: #b7c9bd; font-size: 11px; }
.result-summary strong { display: block; margin-top: 5px; font-size: 18px; letter-spacing: -0.025em; }
.cut-layout { display: grid; grid-template-columns: 62px 1fr; gap: 15px; align-items: center; margin-top: 16px; padding: 16px 0; border-top: 1px solid rgba(255,255,255,0.16); border-bottom: 1px solid rgba(255,255,255,0.16); }
.layout-visual { position: relative; width: 56px; height: 75px; overflow: hidden; border: 1px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.07); }
.fabric-edge { position: absolute; top: 0; bottom: 0; left: 8px; border-left: 1px dashed var(--accent); }
.cut-piece { position: absolute; top: 13px; right: 7px; bottom: 13px; left: 15px; border: 1px solid var(--accent); background: rgba(209,166,78,0.22); }
.cut-layout strong { display: block; margin: 5px 0 4px; font-size: 15px; }
.cut-layout p { margin: 0; color: #b7c9bd; font-size: 11px; line-height: 1.55; }
.breakdown-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; margin: auto 0 0; }
.breakdown-list > div { display: flex; justify-content: space-between; gap: 8px; padding: 12px 0 8px; border-bottom: 1px solid rgba(255,255,255,0.16); }
.breakdown-list dd { margin: 0; font-size: 12px; font-weight: 700; }

footer { margin: 27px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 28px, 620px); padding-top: 20px; }
  .topbar { padding-bottom: 32px; }
  .topbar > p { display: none; }
  .intro { display: block; padding-bottom: 28px; }
  .intro h1 { font-size: clamp(35px, 11vw, 49px); }
  .intro-copy { margin-top: 19px; }
  .workbench { grid-template-columns: 1fr; }
  .parameter-panel, .result-panel { border-radius: 13px; }
  .result-panel { min-height: 490px; }
  .empty-state, .error-state { min-height: 330px; }
}

@media (max-width: 420px) {
  .form-grid, .result-summary, .breakdown-list, .form-actions { grid-template-columns: 1fr; }
  .rotation-control small { max-width: 220px; }
  .result-state { padding-top: 24px; }
  .recommendation strong { font-size: 63px; }
}
