:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171717;
  background: #ececec;
  line-height: 1.5;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
a { color: inherit; }

.hero { padding: 24px clamp(20px, 5vw, 72px) 88px; background: #171717; color: #fff; }
.nav { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto 76px; }
.brand { display: inline-flex; align-items: baseline; gap: 10px; color: inherit; text-decoration: none; font-weight: 850; letter-spacing: -.03em; border-radius: 12px; padding: 6px 9px; margin-left: -9px; }
.brand:hover, .brand:focus-visible { background: rgba(255,255,255,.1); outline: none; }
.brand__name { font-size: 1.2rem; }
.brand__version { font-size: .74rem; color: #bdbdbd; letter-spacing: .02em; font-weight: 700; }
.language-button { border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; padding: 8px 16px; }
.hero__content { max-width: 1180px; margin: 0 auto; }
.eyebrow, .section-kicker { text-transform: uppercase; letter-spacing: .13em; font-size: .76rem; font-weight: 800; opacity: .68; }
h1 { max-width: 920px; margin: 8px 0 20px; font-size: clamp(2.5rem, 7vw, 6rem); line-height: .94; letter-spacing: -.055em; }
.hero__content > p:last-child { max-width: 790px; font-size: 1.13rem; color: #d7d7d7; }

.workspace { width: min(1180px, calc(100% - 32px)); margin: -48px auto 64px; display: grid; gap: 22px; }
.panel { background: #fff; border: 1px solid #b7b7b7; border-radius: 20px; padding: clamp(22px, 4vw, 42px); box-shadow: 0 14px 40px rgba(0,0,0,.08); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.section-heading h2 { margin: 2px 0 0; font-size: clamp(1.65rem, 3vw, 2.5rem); }
.section-kicker { margin: 0; }
.status-chip { display: inline-flex; align-items: center; min-height: 32px; border: 1px solid #b7b7b7; border-radius: 999px; padding: 5px 12px; font-size: .82rem; background: #f4f4f4; }

.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.result-grid--capacity { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric { border: 1px solid #c8c8c8; border-radius: 14px; padding: 18px; min-height: 126px; display: flex; flex-direction: column; justify-content: space-between; background: #fafafa; }
.metric span { color: #626262; font-size: .9rem; }
.metric strong { font-size: clamp(1.35rem, 3vw, 2.1rem); letter-spacing: -.03em; }
.metric--accent { background: #171717; color: #fff; border-color: #171717; }
.metric--accent span { color: #cfcfcf; }
.formula-card { margin-top: 18px; border-left: 4px solid #171717; background: #f1f1f1; padding: 15px 18px; }
.formula-card p { margin: 0; }

.settings-panel { position: fixed; z-index: 20; right: 18px; top: 18px; width: min(360px, calc(100vw - 36px)); max-height: calc(100vh - 36px); overflow: auto; border: 1px solid #8f8f8f; border-radius: 16px; background: rgba(255,255,255,.97); box-shadow: 0 16px 48px rgba(0,0,0,.24); backdrop-filter: blur(12px); }
.settings-toggle { width: 100%; min-height: 48px; border: 0; border-bottom: 1px solid #d4d4d4; background: #fff; display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-weight: 800; text-align: left; }
.settings-panel__content { padding: 16px; display: grid; gap: 14px; }
.settings-panel.is-collapsed { width: auto; overflow: hidden; }
.settings-panel.is-collapsed .settings-panel__content, .settings-panel.is-collapsed .settings-toggle__text { display: none; }
.settings-panel.is-collapsed .settings-toggle { border-bottom: 0; width: 50px; justify-content: center; }
.settings-section-title { margin: 0; font-size: 1rem; letter-spacing: .02em; }
.settings-divider { height: 1px; background: #cfcfcf; margin: 4px 0; }

.field { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select, textarea { width: 100%; border: 1px solid #a6a6a6; border-radius: 9px; background: #fff; color: #171717; padding: 10px 11px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(23,23,23,.15); border-color: #171717; }
input:disabled { background: #ededed; color: #777; cursor: not-allowed; }
textarea { resize: vertical; min-height: 210px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.55; }
textarea[aria-invalid="true"] { border-color: #a90000; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: .9rem; }
.check-row input { width: 18px; height: 18px; }
.hint { margin: -8px 0 0; color: #666; font-size: .8rem; }
details { border-top: 1px solid #e0e0e0; padding-top: 10px; }
summary { cursor: pointer; font-weight: 750; font-size: .9rem; }
.four-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.four-sides label { display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: 4px; }

.button-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.button { border: 1px solid #171717; border-radius: 9px; background: #171717; color: #fff; padding: 9px 13px; }
.button--quiet { background: #fff; color: #171717; }
.error-box { margin: 14px 0 0; border: 1px solid #a90000; border-radius: 9px; background: #fff0f0; color: #7a0000; padding: 12px 14px; white-space: pre-wrap; }
.has-error .metric { opacity: .55; }
.result-grid--orders { margin-top: 18px; }
.orders-panel .metric { min-height: 100px; }

.candidate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.candidate-card { border: 1px solid #bcbcbc; border-radius: 14px; padding: 18px; background: #f8f8f8; }
.candidate-card.is-best { border: 3px solid #171717; padding: 16px; }
.candidate-card > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.candidate-card strong { font-size: 1.7rem; }
.candidate-card p { margin: 12px 0 4px; font-weight: 800; }
.candidate-card small { color: #666; }
.candidate-card__label { font-weight: 850; }

.placement-preview-wrap { margin-top: 24px; }
.preview-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.preview-heading h3 { margin: 0 0 12px; }
.preview-heading p { margin: 0 0 12px; color: #666; font-size: .84rem; }
.placement-preview { --grid-columns: 4; --cell-ratio: 1; display: grid; grid-template-columns: repeat(var(--grid-columns), minmax(32px, 1fr)); gap: 5px; width: min(100%, 860px); border: 2px solid #171717; padding: 8px; background: #ececec; overflow: auto; }
.placement-cell { aspect-ratio: var(--cell-ratio); min-height: 42px; border: 1px solid #171717; background: #fff; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: clamp(.72rem, 1.4vw, .95rem); }
.placement-cell strong { font-size: 1.18em; }

.page-pairs-panel > p { max-width: 850px; }
.table-wrap { overflow-x: auto; border: 1px solid #bcbcbc; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #dedede; text-align: left; }
th { background: #171717; color: #fff; font-size: .84rem; }
tbody tr:nth-child(even) { background: #f5f5f5; }
tbody tr:last-child td { border-bottom: 0; }
.empty-state { margin: 16px 0 0; color: #666; }

.roadmap-panel { border-style: dashed; }
.roadmap-panel h2 { margin-top: 0; }
.two-column-copy { max-width: 850px; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 22px; transform: translateX(-50%); border-radius: 999px; background: #171717; color: #fff; padding: 10px 18px; box-shadow: 0 12px 32px rgba(0,0,0,.24); }
footer { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 0 0 48px; color: #555; display: flex; justify-content: space-between; gap: 16px; }
.footer-brand { font-weight: 800; text-decoration: none; }

@media (max-width: 1080px) { .result-grid--capacity { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .settings-panel { position: relative; top: auto; right: auto; width: min(760px, calc(100% - 32px)); max-height: none; margin: -54px auto 72px; }
  .workspace { margin-top: 0; }
}
@media (max-width: 700px) {
  .nav { margin-bottom: 52px; }
  .result-grid, .result-grid--capacity { grid-template-columns: 1fr; }
  .section-heading, .preview-heading { flex-direction: column; }
  .button-row { justify-content: flex-start; }
  .field-grid, .four-sides, .candidate-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
  .metric { min-height: 104px; }
  .placement-preview { grid-template-columns: repeat(var(--grid-columns), minmax(28px, 1fr)); }
}
