/* Flexible layouts, readable content, and comfortable touch controls. */
:root { color-scheme: light; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 20px; }
button { touch-action: manipulation; }
img, svg { max-width: 100%; }
.main-shell, main, .view, .builder-grid > *, .prediction-grid > *, .summary-column > *,
.stat-card > div, .forecast-metrics > div, .heading-row > div, .panel-heading > div,
.saved-card, .guide-card, .hero-copy { min-width: 0; }
.sidebar { overflow-y: auto; }
.nav-label { min-width: 0; }
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card strong { font-size: clamp(17px, 1.45vw, 22px); overflow-wrap: anywhere; }
.stat-card > div > span { font-size: 11px; line-height: 1.5; }
.stat-card small { font-size: 10px; line-height: 1.5; }
.heading-row { flex-wrap: wrap; }
.subtitle { font-size: 14px; }
.hero-copy p { font-size: 13px; }
.hero-pc { flex-shrink: 0; max-width: 42%; }
.hero-copy h2 { font-size: clamp(21px, 2vw, 28px); }
.button { min-height: 44px; font-size: 12px; white-space: normal; line-height: 1.5; }
.icon-button, .part-edit { min-width: 44px; min-height: 44px; }
.small { min-height: 40px; }
.section-kicker, .eyebrow { font-size: 10px; }
.preset-tabs button { min-height: 44px; font-size: 11px; white-space: normal; line-height: 1.5; }
.part-info .part-category { font-size: 10px; }
.part-name { font-size: 13px; }
.part-spec { font-size: 11px; line-height: 1.6; }
.part-price { font-size: 13px; min-height: 44px; }
.part-price small { font-size: 9px; line-height: 1.5; }
.part-edit svg { width: 16px; height: 16px; }
.compatibility { font-size: 11px; }
.component-foot { font-size: 10px; line-height: 1.6; }
.cost-line, .total-line { font-size: 12px; }
.cost-line small { font-size: 10px; }
.extra-field input { font-size: 12px; width: 85px; min-height: 40px; }
.budget-input input { min-width: 0; }
.budget-meta { font-size: 11px; flex-wrap: wrap; }
.budget-meta strong { font-size: 10px; }
.micro-note, .budget-panel .micro-note { font-size: 11px; }
.budget-panel .button { font-size: 11px; }
.forecast-card p { font-size: 12px; }
.forecast-card > button { font-size: 12px; min-height: 44px; }
.forecast-change { font-size: 11px; line-height: 1.7; }
.notice strong, .notice p { font-size: 12px; }
.forecast-metrics span { font-size: 11px; line-height: 1.5; }
.forecast-metrics strong { font-size: clamp(17px, 1.7vw, 23px); overflow-wrap: anywhere; }
.forecast-metrics > div { gap: 9px; }
.scenario-tabs { flex-wrap: wrap; }
.scenario-tabs button { min-height: 44px; font-size: 12px; }
.chart-legend { flex-wrap: wrap; font-size: 11px; row-gap: 10px; }
.forecast-foot { font-size: 11px; }
.projection-table { max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.projection-table table { font-size: 12px; }
.projection-table th { font-size: 11px; }
.table-scroll-hint { display: none; }
.slider-label { font-size: 12px; line-height: 1.6; }
.range-ends { font-size: 10px; }
input[type=range] { min-height: 44px; margin-block: 0; }
.insight { font-size: 12px; }
.controls-panel > .button { font-size: 12px; }
.guide-card p { font-size: 14px; }
.source-links { font-size: 12px; overflow-wrap: anywhere; }
.source-links a { padding-block: 8px; line-height: 1.6; }
.saved-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.saved-card h2 { overflow-wrap: anywhere; }
.saved-card p { font-size: 12px; }
.saved-date { font-size: 11px; }
footer { flex-wrap: wrap; column-gap: 15px; row-gap: 8px; }
footer button { min-height: 44px; }
dialog { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.modal-header h2 { overflow-wrap: anywhere; }
.search-box input { font-size: 14px; min-width: 0; }
.search-row select { min-height: 44px; font-size: 12px; }
.checkbox-label { min-height: 44px; font-size: 12px; line-height: 1.5; }
.checkbox-label input { width: 20px; height: 20px; flex-shrink: 0; }
.catalog-item .part-name { font-size: 14px; white-space: normal; line-height: 1.5; }
.catalog-item .part-spec { font-size: 12px; }
.catalog-item .catalog-status { font-size: 11px; line-height: 1.6; }
.catalog-item .part-price { font-size: 13px; }
.catalog-item .button { min-height: 44px; font-size: 12px; flex-shrink: 0; }
.field-label, .compact-modal p { font-size: 13px; }
.text-input { min-height: 48px; }

@media (min-width: 1600px) {
  main { padding-inline: 50px; }
  .builder-grid, .prediction-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .hero-banner { min-height: 275px; }
  .hero-pc { width: 390px; }
  .hero-pc svg { max-height: 250px; }
  .component-row { padding-block: 20px; }
}

@media (max-width: 1200px) {
  .sidebar { width: 205px; padding-inline: 15px; }
  .main-shell { margin-left: 205px; }
  .topbar { padding-inline: 26px; }
  main { padding-inline: 26px; }
  .builder-grid, .prediction-grid { grid-template-columns: minmax(0, 1fr); }
  .summary-column { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .forecast-card { align-self: stretch; }
  .forecast-card > svg { height: 100px; }
  .controls-panel { max-width: none; }
  .stat-card { padding: 16px 12px; gap: 10px; }
  .stat-icon { width: 35px; height: 35px; }
  .stat-card strong { font-size: 18px; }
  .saved-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { left: calc(50% + 102px); }
}

@media (max-width: 980px) and (min-width: 761px) {
  .sidebar { width: 76px; padding: 28px 12px; align-items: center; }
  .brand { font-size: 0; padding: 0; }
  .brand > span:not(.brand-icon), .brand i { display: none; }
  .brand-icon { margin: 0; }
  .brand-icon svg { width: 28px; height: 28px; }
  .workspace-label { display: none; }
  .sidebar nav { width: 100%; margin-top: 38px; }
  .nav-link { justify-content: center; padding: 15px 0; min-height: 48px; gap: 0; }
  .nav-label, .nav-count, .nav-dot { display: none; }
  .nav-link svg { width: 22px; height: 22px; }
  .sidebar-tip { display: none; }
  .sidebar-bottom { font-size: 0; margin-top: auto; }
  .sidebar-bottom .online-dot { display: none; }
  .sidebar-bottom button { margin: 0; min-width: 44px; min-height: 44px; }
  .sidebar-bottom svg { width: 20px; height: 20px; }
  .main-shell { margin-left: 76px; }
  .toast { left: calc(50% + 38px); }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 82px; }
  .sidebar { position: sticky; inset: auto; top: 0; width: 100%; height: auto; min-height: 62px; padding: 13px max(18px, env(safe-area-inset-left)); overflow: visible; flex-direction: row; align-items: center; border-bottom: 1px solid #344a3b; }
  .brand { padding: 0; font-size: 25px; }
  .brand-icon { margin-right: 10px; }
  .brand-icon svg { width: 25px; height: 25px; }
  .workspace-label, .sidebar-tip, .sidebar-bottom { display: none; }
  .sidebar nav { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; width: 100%; padding: 8px max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); background: var(--forest); border-top: 1px solid #344a3b; box-shadow: 0 -5px 24px #182c2015; }
  .nav-link { min-height: 58px; padding: 8px 4px; margin: 0; border-radius: 8px; font-size: 11px; flex-direction: column; gap: 5px; justify-content: center; white-space: normal; text-align: center; line-height: 1.3; }
  .nav-link svg { width: 21px; height: 21px; }
  .nav-label { display: block; }
  .nav-dot, .nav-count { display: none; }
  .main-shell { margin-left: 0; }
  .topbar { height: auto; min-height: 56px; padding: 9px 18px; gap: 8px; }
  .breadcrumb { font-size: 11px; gap: 7px; flex-wrap: wrap; }
  .top-actions { gap: 4px; }
  .avatar { display: none; }
  .demo-label { font-size: 9px; padding: 6px; white-space: nowrap; }
  main { padding: 25px max(18px, env(safe-area-inset-left)) calc(95px + env(safe-area-inset-bottom)); }
  .heading-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .heading-row > .button { margin: 0; font-size: 12px; padding: 10px 14px; }
  h1 { font-size: clamp(27px, 5vw, 36px); letter-spacing: -1.1px; overflow-wrap: anywhere; }
  h1 span { display: block; }
  .eyebrow { font-size: 10px; letter-spacing: 1.5px; }
  .subtitle { font-size: 14px; }
  .hero-banner { padding: 24px; min-height: 250px; gap: 5px; }
  .hero-copy h2 { font-size: 22px; }
  .hero-copy p { font-size: 13px; }
  .hero-pc { width: 230px; margin: 0 -20px 0 0; max-width: 40%; }
  .hero-outline { font-size: 110px; }
  .stats-grid { gap: 12px; }
  .stat-card { display: block; padding: 16px; }
  .stat-icon { margin-bottom: 10px; }
  .stat-card strong { font-size: 20px; white-space: normal; }
  .panel { padding: 22px; }
  .components-panel { padding: 0; }
  .components-panel .panel-heading { padding: 22px 18px 15px; }
  .panel-heading { flex-wrap: wrap; }
  .panel-heading h2 { line-height: 1.5; }
  .preset-tabs { margin-inline: 18px; }
  .preset-tabs button { font-size: 12px; }
  .builder-grid, .prediction-grid { gap: 18px; }
  .summary-column { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .budget-input input { font-size: 26px; }
  .budget-panel .button, .forecast-card > button { font-size: 13px; }
  .cost-line { gap: 14px; font-size: 13px; }
  .extra-field input { font-size: 16px; width: 100px; }
  .total-line strong { font-size: 24px; }
  .forecast-card { padding: 24px; }
  .forecast-card h3 { font-size: 20px; }
  .forecast-card p { font-size: 14px; }
  .forecast-price { font-size: 28px; }
  .forecast-change { font-size: 12px; }
  .notice { padding: 18px; }
  .notice strong, .notice p { font-size: 13px; }
  .controls-panel { display: block; }
  .slider-label { font-size: 14px; }
  .range-ends { font-size: 12px; }
  .forecast-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .forecast-metrics strong { font-size: 18px; }
  .saved-grid, .guide-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-card { padding: 24px; }
  .saved-card p { font-size: 14px; }
  .saved-card .button { font-size: 13px; }
  .source-links { font-size: 14px; }
  .toast { left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); width: max-content; font-size: 12px; }
  footer { margin-top: 26px; padding-bottom: 0; font-size: 11px; }
  footer > span:nth-child(2) { margin-left: 0; }
  footer button { font-size: 11px; }
  .search-box input, .text-input { font-size: 16px; }
}

@media (max-width: 600px) {
  .hero-banner { flex-direction: column; align-items: stretch; padding: 24px 22px 14px; }
  .hero-copy .pill { white-space: normal; font-size: 9px; line-height: 1.6; }
  .hero-copy h2 { font-size: 23px; line-height: 1.5; }
  .hero-copy p { max-width: none; }
  .hero-copy .button { margin-top: 18px; font-size: 13px; }
  .hero-pc { position: relative; width: 240px; max-width: 85%; align-self: center; margin: 4px 0 0; }
  .hero-pc svg { max-height: 170px; }
  .pc-caption { font-size: 6px; padding-bottom: 8px; }
  .hero-outline { top: auto; bottom: 42px; right: 25px; }
  .stats-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 18px 0; }
  .stat-card { display: flex; align-items: center; padding: 17px 18px; gap: 16px; }
  .stat-icon { margin: 0; width: 44px; height: 44px; }
  .stat-card strong { font-size: 23px; margin: 5px 0; }
  .stat-card > div > span { font-size: 12px; }
  .stat-card small { font-size: 11px; }
  .section-kicker { font-size: 10px; }
  .components-panel .panel-heading { padding: 20px 16px 14px; gap: 10px; }
  .panel-heading h2 { font-size: 20px; }
  .count-badge { font-size: 11px; }
  .build-tools { gap: 4px; }
  .build-tools .button { font-size: 12px; min-height: 44px; }
  .preset-tabs { margin: 0 16px 16px; flex-wrap: wrap; gap: 6px; }
  .preset-tabs button { flex: 1 1 100%; min-height: 44px; padding: 10px 8px; font-size: 13px; }
  .table-labels { padding: 12px 16px; font-size: 10px; }
  .table-labels span:last-child { display: none; }
  .component-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 5px 11px; padding: 18px 16px; }
  .part-art { width: 44px; height: 44px; align-self: start; grid-column: 1; grid-row: 1; }
  .part-art svg { width: 26px; height: 26px; }
  .part-info { grid-column: 2; grid-row: 1; }
  .part-info .part-category { font-size: 10px; line-height: 1.5; }
  .part-name { white-space: normal; overflow: visible; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
  .part-spec { font-size: 12px; line-height: 1.6; }
  .part-price { grid-column: 2; grid-row: 2; min-height: 44px; font-size: 14px; text-align: left; justify-self: start; max-width: 100%; white-space: normal; }
  .part-price small { font-size: 10px; line-height: 1.6; margin-top: 3px; }
  .part-edit { grid-column: 3; grid-row: 1 / span 2; margin: 0; align-self: center; width: 44px; height: 44px; }
  .part-edit svg { width: 18px; height: 18px; }
  .empty-part { font-size: 13px; line-height: 1.5; }
  .component-row > .button { grid-column: 2; grid-row: 2; justify-self: start; }
  .compatibility { margin-inline: 16px; font-size: 12px; padding: 14px; }
  .compatibility strong { align-items: flex-start; }
  .compatibility svg { width: 18px; height: 18px; margin-top: 2px; }
  .component-foot { align-items: flex-start; font-size: 11px; padding: 16px; }
  .component-foot svg { width: 16px; height: 16px; margin-top: 2px; }
  .forecast-metrics { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .forecast-metrics > div { padding-bottom: 13px; border-bottom: 1px solid var(--line); gap: 6px; }
  .forecast-metrics span { font-size: 12px; }
  .forecast-metrics strong { font-size: 25px; }
  .scenario-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .scenario-tabs button { font-size: 13px; min-width: 0; padding-inline: 6px; }
  .chart-legend { justify-content: flex-start; font-size: 11px; gap: 12px; }
  .forecast-foot { font-size: 12px; }
  .table-scroll-hint { display: block; font-size: 11px; line-height: 1.7; margin: 14px 0 8px; color: #70855e; }
  .projection-table { border: 1px solid var(--line); border-radius: 6px; }
  .projection-table table { min-width: 450px; }
  .projection-table td, .projection-table th { padding: 12px; }
  .projection-table caption { padding: 12px !important; }
  .insight, .micro-note { font-size: 12px; }
  .guide-card p { font-size: 14px; }
  dialog:not(.compact-modal) { position: fixed; inset: 0; margin: 0; width: 100%; max-width: none; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
  .compact-modal { padding: 20px; width: calc(100% - 28px); max-width: 410px; max-height: calc(100dvh - 28px); }
  .modal-header { align-items: flex-start; }
  .modal-header h2 { font-size: 21px; line-height: 1.5; }
  .modal-header .icon-button { flex-shrink: 0; }
  .search-row { flex-wrap: wrap; }
  .search-box { flex: 1 1 100%; }
  .search-row select { width: 100%; max-width: none; font-size: 14px; }
  .checkbox-label { font-size: 13px; }
  .catalog-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 18px 0; }
  .catalog-item .part-art { display: none; }
  .catalog-item .part-info { grid-column: 1 / -1; margin: 0; }
  .catalog-item .part-name { font-size: 16px; }
  .catalog-item .part-spec { font-size: 13px; }
  .catalog-item .part-price { grid-column: 1; grid-row: 2; font-size: 16px; align-self: center; }
  .catalog-item .button { grid-column: 2; grid-row: 2; min-width: 78px; font-size: 14px; }
  .modal-buttons { flex-wrap: wrap; }
}

@media (max-width: 360px) {
  main { padding-inline: 12px; }
  .topbar { padding-inline: 12px; }
  .top-actions { gap: 0; }
  .demo-label { font-size: 8px; }
  .breadcrumb { font-size: 10px; }
  .nav-link { font-size: 10px; }
  .hero-banner { padding-inline: 18px; }
  .panel { padding: 17px; }
  .components-panel { padding: 0; }
  .components-panel .panel-heading { flex-direction: column; align-items: stretch; }
  .build-tools { justify-content: flex-end; }
  .component-row { padding-inline: 12px; gap: 5px 8px; grid-template-columns: 36px minmax(0, 1fr) 44px; }
  .part-art { width: 36px; height: 36px; }
  .part-art svg { width: 23px; height: 23px; }
  .budget-meta { gap: 6px; }
  .total-line { flex-wrap: wrap; gap: 8px; }
  footer > span:nth-child(2) { flex: 1; }
}

@media (max-height: 620px) and (min-width: 761px) {
  .sidebar-tip { display: none; }
  .sidebar-bottom { margin-top: auto; }
  .workspace-label { margin-top: 30px; }
}

@media (pointer: coarse) {
  .button, .small, .icon-button, .part-edit, .part-price, .nav-link { min-height: 44px; }
  input, select { font-size: max(16px, 1em); }
}

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