:root {
  color-scheme: light;
  --bg: #eef2ed;
  --surface: #ffffff;
  --surface-soft: #f6f8f5;
  --text: #17211d;
  --muted: #65716b;
  --border: #d9e0da;
  --primary: #20382f;
  --primary-strong: #14271f;
  --accent: #b46d3b;
  --blue: #dfeef5;
  --blue-text: #15516b;
  --amber: #fff0cf;
  --amber-text: #76500b;
  --red: #f8dddd;
  --red-text: #812c2c;
  --green: #dcefe2;
  --green-text: #285e39;
  --shadow: 0 16px 40px rgba(31, 55, 46, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(180, 109, 59, 0.11), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0.6rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  font-size: 1.25rem;
  font-weight: 900;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -0.025em; }
.brand small { margin-top: 0.05rem; color: var(--muted); font-size: 0.72rem; }

.main-nav {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}

.main-nav a {
  padding: 0.6rem 0.8rem;
  border-radius: 11px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.main-nav a.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 6px 20px rgba(31, 55, 46, 0.09);
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.card {
  margin-top: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-block: 0.9rem;
}

.home-toolbar strong { display: block; margin-top: 0.1rem; }
.context-note { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.78rem; }
.forecast-freshness { font-weight: 650; }
.forecast-freshness.stale { color: var(--red-text); }

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 900;
}

.icon-button:disabled { cursor: wait; opacity: 0.5; }


.period-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
}

.period-button {
  display: grid;
  gap: 0.18rem;
  min-height: 66px;
  padding: 0.75rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.period-button strong { color: var(--text); font-size: 0.95rem; }
.period-button span { font-size: 0.75rem; }
.period-button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 22px rgba(31, 55, 46, 0.18);
}
.period-button.active strong { color: white; }
.period-note {
  min-height: 1.2em;
  margin: 0.45rem 0 0;
  padding-inline: 0.45rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.settings-card { padding-block: 0.8rem; }
.settings-card summary, .result-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 850;
}

.settings-card[open] summary { margin-bottom: 1rem; }
.settings-help { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.8rem; }

.form-grid { display: grid; gap: 1rem; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manual-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

label {
  display: grid;
  gap: 0.4rem;
  color: #33433c;
  font-size: 0.88rem;
  font-weight: 750;
}

label small {
  min-height: 2.3em;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.3;
}

input, select {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.75rem;
  border: 1px solid #cbd5cd;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
}

input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(180, 109, 59, 0.25);
  outline-offset: 2px;
}

.primary-button, .secondary-button {
  min-height: 42px;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding-block: 1rem;
}

.loading-card p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.86rem; }
.loading-card.error { border-color: #e6b8b8; background: var(--red); color: var(--red-text); }
.loading-card.error .spinner { display: none; }

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #dbe2dc;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.current-weather {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
}

.current-weather strong { display: block; margin-top: 0.15rem; font-size: 1.65rem; }
.current-details { display: grid; align-content: center; gap: 0.2rem; color: var(--muted); text-align: right; font-size: 0.8rem; }

.recommendation-header, .section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.section-heading.compact { align-items: center; }
.recommendation-header h1, .recommendation-header h2, .section-heading h2, .page-heading h1 {
  margin: 0.15rem 0 0;
  letter-spacing: -0.035em;
}

.recommendation-header h1 { font-size: clamp(2rem, 7vw, 3.4rem); }
.recommendation-header h2 { font-size: clamp(1.65rem, 4vw, 2.25rem); }
.section-heading h2 { font-size: 1.2rem; }

.muted { color: var(--muted); }
.recommendation-subtitle { margin-bottom: 0; }

.target-box {
  min-width: 140px;
  padding: 0.75rem 0.95rem;
  border-radius: 15px;
  background: var(--primary);
  color: white;
  text-align: right;
}

.target-box span { display: block; opacity: 0.72; font-size: 0.72rem; }
.target-box strong { font-size: 1.25rem; }

.badge-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.9rem 0 1.1rem; }
.badge, .small-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.34rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 850;
}
.badge.neutral, .small-pill { background: #edf0ed; color: #59645f; }
.badge.blue { background: var(--blue); color: var(--blue-text); }
.badge.amber { background: var(--amber); color: var(--amber-text); }
.badge.red { background: var(--red); color: var(--red-text); }

.rug-list { display: grid; gap: 0.55rem; }
.primary-rug-list { margin-bottom: 1rem; }
.rug-choice {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.rug-choice.outer-rug { border-color: #bdd7e4; background: #f4fafc; }
.rug-choice strong, .rug-choice span, .alternative-list strong, .alternative-list span, .inventory-list strong, .inventory-list span { display: block; }
.rug-choice span, .alternative-list span, .inventory-list span { margin-top: 0.14rem; color: var(--muted); font-size: 0.78rem; }

.layer-number, .rug-icon {
  display: grid !important;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: white !important;
  font-weight: 850;
}
.total-line { margin: 0.3rem 0 0; text-align: right; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem; }
.metric { padding: 0.72rem; border-radius: 13px; background: var(--surface-soft); }
.metric span, .metric strong { display: block; }
.metric span { color: var(--muted); font-size: 0.7rem; }
.metric strong { margin-top: 0.14rem; font-size: 0.9rem; }

.result-details { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.result-details[open] summary { margin-bottom: 1rem; }
.result-details h2 { margin: 1.2rem 0 0.5rem; font-size: 1rem; }
.reasoning-list { margin-bottom: 0; padding-left: 1.4rem; color: #39463f; }
.reasoning-list li + li { margin-top: 0.5rem; }

.alternative-list, .inventory-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.alternative-list li, .inventory-list li { padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.alternative-list li:last-child, .inventory-list li:last-child { border-bottom: 0; }

.notice-strip {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid #ead7bd;
  border-radius: 15px;
  background: #fffaf3;
  color: #665039;
  font-size: 0.78rem;
  line-height: 1.45;
}

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
  gap: 1.5rem;
  align-items: end;
  padding-top: 1.5rem;
}
.page-heading h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.5; }

.compact-field { min-width: 190px; }
.subheading { margin: 1.35rem 0 0.65rem; font-size: 0.95rem; }
.scenario-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.scenario-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.52rem 0.75rem;
  background: var(--surface-soft);
  color: #3e4b45;
  font-size: 0.78rem;
  font-weight: 750;
}
.scenario-button:hover, .scenario-button.active { border-color: var(--primary); background: var(--primary); color: white; }

.tools-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.7fr); gap: 1rem; align-items: start; }
.inventory-card { position: sticky; top: 0.5rem; }

.test-result {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 13px;
  font-size: 0.84rem;
}
.test-result.pass { background: var(--green); color: var(--green-text); }
.test-result.fail { background: var(--red); color: var(--red-text); }

.warning-text, .fatal-error { color: var(--red-text); }
.fatal-error { margin-top: 1rem; padding: 1rem; border: 1px solid #e6b8b8; border-radius: 14px; background: var(--red); font-weight: 750; }

code { padding: 0.08rem 0.24rem; border-radius: 4px; background: #edf0ed; }
footer { padding: 1.5rem 1rem 2.5rem; color: var(--muted); text-align: center; font-size: 0.78rem; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .manual-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tools-layout { grid-template-columns: 1fr; }
  .inventory-card { position: static; }
}

@media (max-width: 700px) {
  .app-header { grid-template-columns: 1fr auto; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; justify-content: stretch; }
  .main-nav a { flex: 1; text-align: center; }
  .install-button { grid-column: 2; grid-row: 1; }
  .page-heading { grid-template-columns: 1fr; }
  .page-heading p { max-width: 42rem; }
}

@media (max-width: 620px) {
  .app-header { padding-top: 0.8rem; }
  .app-shell { padding-inline: 0.75rem; }
  .brand small { display: none; }
  .three-columns, .manual-grid, .metric-grid { grid-template-columns: 1fr; }
  .recommendation-header, .section-heading, .current-weather, .test-result { display: grid; }
  .target-box { width: 100%; text-align: left; }
  .current-details { text-align: left; }
  .scenario-list { display: grid; grid-template-columns: 1fr; }
  .scenario-button { text-align: left; }
  .compact-field { min-width: 0; }
}

@media (max-width: 560px) {
  .two-columns { grid-template-columns: 1fr; }
  .period-button { padding-inline: 0.65rem; }
  .period-button strong { font-size: 0.86rem; }
  .period-button span { font-size: 0.7rem; }
}

.extended-comment {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid #d7dfd9;
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  background: #fbf8f3;
}
.extended-comment strong {
  display: block;
  margin-top: 0.22rem;
  color: var(--primary);
}
.extended-comment p:last-child {
  margin: 0.35rem 0 0;
  color: #4d5a54;
  font-size: 0.84rem;
  line-height: 1.5;
}
