:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-muted: #64748b;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --page: #eef2f7;
  --line: #dbe3ec;
  --line-strong: #cbd5e1;
  --brand: #155eef;
  --brand-dark: #0f4fc7;
  --brand-tint: #eff6ff;
  --brand-line: #bfdbfe;
  --focus: #f59e0b;
  --wall: #075985;
  --wall-tint: #f0f9ff;
  --wall-line: #bae6fd;
  --ceiling: #047857;
  --ceiling-tint: #ecfdf5;
  --ceiling-line: #a7f3d0;
  --floor: #b45309;
  --floor-tint: #fffbeb;
  --floor-line: #fde68a;
  --danger: #b91c1c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}

button,
input,
select {
  font: inherit;
}

button,
summary,
input,
select {
  min-height: 44px;
}

button,
summary {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: #bfdbfe;
  color: var(--ink);
}

input::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #e2e8f0;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.page-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.site-header {
  background: var(--ink);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.header-kicker {
  margin: 0 0 6px;
  color: #93c5fd;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.header-subtitle {
  margin: 8px 0 0;
  color: #cbd5e1;
}

.app-layout {
  display: grid;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel h2,
.panel h3 {
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.panel h2 {
  font-size: 1.35rem;
}

.panel h3 {
  font-size: 1.05rem;
}

.panel-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-note {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 96px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: var(--ink-soft);
  color: #ffffff;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--surface-soft);
}

.btn-danger-text {
  color: var(--danger);
}

.field-group {
  margin: 0 0 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.field-group legend {
  padding: 0 8px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-field label {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.94rem;
}

.form-field input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.form-field input:hover {
  border-color: #94a3b8;
}

.privacy-note {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.count-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.room-container {
  display: grid;
  gap: 14px;
}

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  text-align: center;
}

.empty-state p {
  margin: 0;
}

.room {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 16px;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.room-title {
  margin: 0;
  font-size: 1rem;
}

.room-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-size: 0.82rem;
  vertical-align: middle;
}

.remove-room-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: var(--danger);
  font-weight: 700;
}

.remove-room-btn:hover {
  background: #fee2e2;
}

.room-core {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.room-core .form-field label {
  font-size: 0.86rem;
}

.room-core input,
.room-core select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.treatments {
  margin-top: 14px;
}

.treatments-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.treatments-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.treatment-group {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.treatment-group h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.treatment-group h4::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.treatment-group.wall {
  border-color: var(--wall-line);
  background: var(--wall-tint);
  color: var(--wall);
}

.treatment-group.ceiling {
  border-color: var(--ceiling-line);
  background: var(--ceiling-tint);
  color: var(--ceiling);
}

.treatment-group.floor {
  border-color: var(--floor-line);
  background: var(--floor-tint);
  color: var(--floor);
}

.treatment-group h4,
.treatment-group legend,
.treatment-group label {
  color: var(--ink);
}

.treatment-group h4 {
  color: inherit;
}

.option-block {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}

.option-block legend {
  width: 100%;
  padding: 0;
  margin-bottom: 6px;
}

.option-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 700;
}

.option-toggle:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-dark);
}

.option-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  margin-top: 8px;
}

.option-grid[hidden] {
  display: none;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
}

.option-item:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 700;
}

.option-item input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

.room-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.quote-panel {
  position: sticky;
  top: 20px;
}

.quote-result {
  min-height: 170px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.quote-empty {
  margin: 0;
  color: var(--ink-soft);
}

.quote-room + .quote-room {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.quote-room h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.quote-meta {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.quote-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.88rem;
}

.quote-line span:last-child {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quote-subtotal {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  text-align: right;
}

.quote-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-sm);
  background: var(--brand-tint);
}

.quote-total strong {
  color: var(--brand-dark);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.quote-disclaimer {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.action-buttons {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.action-buttons .btn {
  width: 100%;
}

.price-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.price-panel summary {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: var(--brand-dark);
  font-weight: 700;
}

.price-panel-body {
  padding: 0 14px 14px;
}

.price-fields {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 12px;
}

.price-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-field label {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.price-field input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.price-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.price-actions .btn {
  flex: 1 1 140px;
}

.status-region {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--brand-dark);
  font-size: 0.86rem;
  font-weight: 600;
}

.info-panel {
  margin-top: 20px;
}

.info-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 16px;
}

.info-grid h3,
.faq h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.info-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.faq {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.faq details {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.faq summary {
  padding: 0;
  min-height: 0;
  color: var(--ink);
  font-weight: 700;
}

.faq details p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #e2e8f0;
}

.footer-brand {
  display: grid;
  gap: 2px;
}

.footer-brand strong {
  color: #ffffff;
  font-size: 1.05rem;
}

.footer-brand span {
  color: #cbd5e1;
  font-size: 0.86rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.footer-links a {
  color: #bfdbfe;
  text-underline-offset: 3px;
}

.footer-links a:hover {
  color: #ffffff;
}

@media (min-width: 900px) {
  .app-layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(330px, 0.9fr);
  }
}

@media (max-width: 620px) {
  .page-shell {
    padding: 12px 12px 28px;
  }

  .site-header {
    padding: 20px 16px;
  }

  .panel {
    padding: 16px;
  }

  .panel-heading {
    align-items: stretch;
  }

  .panel-heading .btn {
    width: 100%;
  }

  .form-grid,
  .room-core {
    grid-template-columns: 1fr;
  }

  .treatments-row {
    grid-template-columns: 1fr;
  }

  .quote-panel {
    position: static;
  }

  .action-buttons {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding: 18px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .page-shell {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .site-header,
  .panel,
  .site-footer {
    box-shadow: none;
  }

  .site-header,
  .input-panel,
  .info-panel,
  .site-footer,
  .action-buttons,
  .price-panel,
  .status-region,
  .remove-room-btn,
  .room-actions {
    display: none !important;
  }

  .app-layout {
    display: block;
    margin: 0;
  }

  .quote-panel {
    position: static;
    border: 0;
    padding: 0;
  }

  .quote-room,
  .room-quote {
    break-inside: avoid;
  }
}
