:root {
  --ink: #211a1f;
  --muted: #6e6068;
  --paper: #fffaf7;
  --panel: #ffffff;
  --line: #eaded7;
  --rose: #9b375d;
  --berry: #6e2144;
  --champagne: #f4d7bd;
  --shadow: 0 18px 45px rgba(70, 42, 50, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(145deg, #fffaf7 0%, #fff1ed 45%, #f7eef2 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  padding: 20px 0 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--rose);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  max-width: 790px;
  margin: 0;
  font-size: 4.2rem;
  line-height: 0.96;
  letter-spacing: 0;
}

.intro {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.65;
}

.counter-card {
  min-width: 150px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow);
  text-align: right;
}

.counter-card span {
  display: block;
  font-size: 2rem;
  font-weight: 900;
  color: var(--berry);
}

.counter-card small {
  color: var(--muted);
}

.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr minmax(240px, 1.35fr);
  gap: 12px;
  margin: 18px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 247, 0.92);
  backdrop-filter: blur(18px);
}

.station-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.station-chip {
  display: grid;
  gap: 5px;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  padding: 12px;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.station-chip:hover {
  transform: translateY(-2px);
  border-color: rgba(155, 55, 93, 0.34);
}

.station-chip.is-active {
  background: #fff;
  border-color: var(--rose);
  box-shadow: 0 10px 24px rgba(155, 55, 93, 0.12);
}

.station-chip span {
  font-size: 0.95rem;
  font-weight: 850;
}

.station-chip small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #dbc9c1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(155, 55, 93, 0.14);
}

.season-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 16px;
  align-items: stretch;
  margin: 18px 0;
}

.season-summary,
.palette-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  padding: 18px;
}

.season-summary h2 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

.season-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.season-kicker {
  margin: 0 0 6px;
  color: var(--rose);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.contrast-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #f6e8ed;
  color: var(--berry);
  font-size: 0.78rem;
  font-weight: 850;
  padding: 7px 10px;
}

.season-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.season-summary .avoid {
  margin-top: 10px;
  color: #5c4d55;
}

.tone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tone-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 10px 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.tone-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.complexion-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.complexion-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.complexion-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.complexion-card strong {
  color: var(--berry);
  font-size: 1.6rem;
  line-height: 1;
}

.complexion-card small {
  color: #4d4148;
  font-size: 0.88rem;
  line-height: 1.35;
}

.season-summary .complexion-note {
  margin-top: 10px;
  color: #5c4d55;
  font-size: 0.92rem;
}

.palette-box h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.guides {
  display: grid;
  gap: 10px;
}

.guide {
  display: grid;
  gap: 3px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.guide:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.guide strong {
  font-size: 0.92rem;
}

.guide span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.product-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(70, 42, 50, 0.08);
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.product-card:hover {
  transform: translateY(-3px);
  border-color: rgba(155, 55, 93, 0.42);
  box-shadow: 0 16px 38px rgba(70, 42, 50, 0.15);
}

.product-card-link { display: flex; flex: 1; flex-direction: column; color: inherit; text-decoration: none; }
.edit-product { width: calc(100% - 28px); margin: 0 14px 14px; }
.catalog-tools { display: grid; gap: 12px; margin: 14px 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.catalog-tools[hidden] { display: none; }
.catalog-tools > div:first-child { display: grid; gap: 4px; }
.catalog-tools > div:first-child span { color: var(--muted); }
.catalog-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
button, .import-label { min-height: 42px; border: 1px solid var(--rose); border-radius: 8px; background: var(--rose); color: #fff; padding: 9px 14px; font: inherit; font-weight: 750; cursor: pointer; }
button:hover, .import-label:hover { background: var(--berry); }
button:focus-visible, .import-label:focus-within { outline: 3px solid var(--champagne); outline-offset: 2px; }
.catalog-actions button:not(:first-child), .catalog-actions .import-label, .plain-button, .edit-product { background: #fff; color: var(--berry); }
.catalog-actions button:not(:first-child):hover, .catalog-actions .import-label:hover, .plain-button:hover, .edit-product:hover { background: #f8edf1; }
#catalogStatus, #formStatus { margin: 0; color: var(--berry); }
#catalogStatus:empty, #formStatus:empty { display: none; }
.product-dialog { width: min(720px, calc(100% - 24px)); max-height: min(92vh, 900px); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 22px; color: var(--ink); }
.product-dialog::backdrop { background: rgba(33, 26, 31, .55); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading .plain-button { min-width: 42px; font-size: 1.5rem; padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-wide { grid-column: 1 / -1; }
textarea { width: 100%; border: 1px solid #dbc9c1; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; padding: 10px 12px; resize: vertical; }
textarea:focus { border-color: var(--rose); outline: 3px solid rgba(155, 55, 93, .14); }
.dialog-actions { justify-content: end; margin-top: 18px; }
.source-note { color: var(--muted); line-height: 1.5; }
.product-preview, .refresh-proposal { padding: 14px; margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; background: #fffaf8; }
.product-preview[hidden] { display: none; }
.product-preview img { display: block; max-width: 120px; max-height: 120px; object-fit: contain; margin-top: 10px; }
.refresh-results { max-height: 50vh; overflow: auto; }
.refresh-proposal { display: grid; gap: 8px; }
.refresh-proposal p { margin: 0; color: var(--muted); }
.refresh-proposal button { justify-self: start; }
#refreshStatus { color: var(--berry); }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .field-wide { grid-column: auto; } }

.product-media {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff, #f8eff1);
  padding: 18px;
}

.product-fallback {
  position: absolute;
  inset: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  border: 1px solid rgba(155, 55, 93, 0.12);
  border-radius: 7px;
  background-color: #fffaf8;
  background:
    radial-gradient(circle at 72% 18%, rgba(155, 55, 93, 0.14), transparent 34%),
    linear-gradient(145deg, #fffaf8, #f8edf1);
  color: #4d4148;
  opacity: 1;
  padding: 14px;
  text-align: center;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.fallback-badge {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--berry);
  font-size: 0.72rem;
  font-weight: 850;
  padding: 4px 8px;
}

.fallback-swatch {
  width: 72px;
  height: 72px;
  border: 8px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: var(--product-accent, #b9828e);
  box-shadow: 0 10px 24px rgba(70, 42, 50, 0.16);
}

.product-fallback strong,
.product-fallback small {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.product-fallback strong {
  font-size: 0.88rem;
  line-height: 1.2;
}

.product-fallback small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.product-media img {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity 160ms ease;
}

.product-media.has-product-image .product-fallback {
  opacity: 0;
  visibility: hidden;
}

.product-media.has-product-image img {
  opacity: 1;
}

.product-media.has-image-error img {
  display: none;
}

.product-info {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  background: var(--panel);
  padding: 14px;
}

.shop-link {
  align-self: end;
  color: var(--rose);
  font-size: 0.86rem;
  font-weight: 850;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 999px;
  background: #f8edf1;
  color: var(--berry);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 5px 8px;
}

.product-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.shade {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.purchase-guide {
  margin: 0;
  border-left: 3px solid rgba(155, 55, 93, 0.34);
  border-radius: 6px;
  background: #fff8f5;
  color: #4d4148;
  font-size: 0.86rem;
  line-height: 1.42;
  padding: 9px 10px;
}

.purchase-guide strong {
  color: var(--berry);
  font-weight: 900;
}

.why {
  margin: 0;
  color: #4d4148;
  font-size: 0.9rem;
  line-height: 1.45;
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed #cbb5ad;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.disclaimer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  padding: 18px 0 0;
}

@media (max-width: 860px) {
  .topbar,
  .season-panel,
  .controls {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 3rem;
  }

  .station-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .counter-card {
    text-align: left;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 16px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .controls {
    position: static;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .station-nav {
    grid-template-columns: 1fr;
  }

  .season-heading {
    display: grid;
  }

  .complexion-codes {
    grid-template-columns: 1fr;
  }
}
