:root {
  --cream: #f6f0e7;
  --paper: #fffdf9;
  --ink: #2d312f;
  --muted: #716f69;
  --sage: #7c9585;
  --sage-dark: #496354;
  --sage-soft: #dfe9e2;
  --peach: #e7b39c;
  --peach-soft: #f6ded2;
  --line: #ded7cc;
  --shadow: 0 18px 50px rgba(75, 65, 50, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background:
  radial-gradient(circle at 10% 0%, rgba(255,255,255,.9), transparent 28rem),
  var(--cream); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(73, 99, 84, .28);
  outline-offset: 2px;
}

.topbar {
  max-width: 1180px; margin: 0 auto; padding: 54px 28px 28px;
  display: flex; align-items: end; justify-content: space-between; gap: 28px;
}
.eyebrow {
  margin: 0 0 8px; color: var(--sage-dark); font-size: .72rem;
  font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
}
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: Georgia, serif; font-size: clamp(2.25rem, 5vw, 4.3rem); line-height: .96; letter-spacing: -.045em; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 1rem; }

.summary {
  display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 18px;
  background: rgba(255,255,255,.55); box-shadow: 0 8px 24px rgba(75,65,50,.05);
}
.summary div { min-width: 92px; padding: 14px 16px; text-align: center; border-left: 1px solid var(--line); }
.summary div:first-child { border-left: 0; }
.summary strong { display: block; font-family: Georgia, serif; font-size: 1.5rem; }
.summary span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

.layout {
  max-width: 1180px; margin: 0 auto 60px; padding: 0 28px;
  display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 28px; align-items: start;
}
.panel {
  border: 1px solid rgba(222,215,204,.95); border-radius: 24px; background: rgba(255,253,249,.92);
  box-shadow: var(--shadow);
}
.add-panel { padding: 24px; position: sticky; top: 20px; }
.panel-heading h2, .shelf-intro h2 { margin-bottom: 8px; font-family: Georgia, serif; font-size: 1.8rem; letter-spacing: -.025em; }
.panel-heading > p:last-child, .shelf-intro > p { color: var(--muted); line-height: 1.55; font-size: .9rem; }

form { display: grid; gap: 16px; margin-top: 24px; }
form > label { display: grid; gap: 7px; font-size: .8rem; font-weight: 750; }
input, select {
  width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink);
}
input::placeholder { color: #aaa39a; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 8px; font-size: .8rem; font-weight: 750; }
fieldset small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.35; }
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid var(--line);
  border-radius: 13px; background: #f3eee7;
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid; place-items: center; min-height: 40px; border-radius: 9px;
  color: var(--muted); font-size: .82rem; font-weight: 700;
}
.segmented input:checked + span { background: #fff; color: var(--sage-dark); box-shadow: 0 2px 8px rgba(75,65,50,.08); }
.segmented input:focus-visible + span { outline: 3px solid rgba(73,99,84,.28); }

.primary {
  min-height: 48px; border: 0; border-radius: 13px; padding: 0 16px;
  background: var(--sage-dark); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 10px 20px rgba(73,99,84,.18);
}
.primary:hover { transform: translateY(-1px); }

.shelf-area { min-width: 0; display: grid; gap: 20px; }
.shelf-intro {
  padding: 4px 4px 8px; display: flex; align-items: end; justify-content: space-between; gap: 22px;
}
.shelf-intro > p { max-width: 390px; margin-bottom: 2px; text-align: right; }

.routine {
  position: relative; overflow: hidden; padding: 22px 22px 28px;
  border: 1px solid var(--line); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow);
}
.routine::before {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  right: -80px; top: -90px; opacity: .6; pointer-events: none;
}
.morning::before { background: var(--peach-soft); }
.evening::before { background: var(--sage-soft); }
.routine-title { position: relative; display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.routine-title p { margin: 0 0 2px; color: var(--muted); font-size: .69rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.routine-title h3 { margin: 0; font-family: Georgia, serif; font-size: 1.45rem; }
.orb { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%; position: relative; }
.sun { background: #f5c7a9; box-shadow: inset -7px -7px 0 rgba(255,255,255,.25); }
.moon { background: #b9c9bf; }
.moon::after { content: ""; position: absolute; width: 32px; height: 32px; left: -3px; top: 1px; border-radius: 50%; background: var(--paper); }
.count-pill {
  margin-left: auto; min-width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 999px; background: #f2eee8; color: var(--muted); font-size: .82rem; font-weight: 800;
}

.product-grid { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; z-index: 1; }
.product-card {
  min-width: 0; padding: 15px; border: 1px solid #e6dfd5; border-radius: 18px;
  background: rgba(255,255,255,.9); transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 12px 22px rgba(75,65,50,.08); }
.product-card.paused { background: #f6f3ee; border-color: #d8cec3; }
.product-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bottle {
  width: 44px; height: 58px; flex: 0 0 auto; position: relative; border: 1px solid #cfd8d2;
  border-radius: 9px 9px 13px 13px; background: linear-gradient(150deg, #eef4ef, #d6e2da);
  box-shadow: inset 8px 0 rgba(255,255,255,.34);
}
.bottle::before { content: ""; position: absolute; width: 22px; height: 9px; left: 10px; top: -7px; border-radius: 4px 4px 1px 1px; background: #8aa093; }
.bottle span { position: absolute; width: 26px; height: 16px; left: 8px; top: 23px; border-radius: 4px; background: rgba(255,255,255,.8); }
.product-meta { min-width: 0; }
.state-dot { color: var(--sage-dark); font-size: .69rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.paused .state-dot { color: #947365; }
.product-meta h4 { margin: 3px 0 2px; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; white-space: nowrap; }
.product-meta p { margin: 0; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.product-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.product-tags span { padding: 5px 8px; border-radius: 999px; background: #f3eee8; color: #655f58; font-size: .7rem; }
.paused .product-tags span { background: #ece5dc; color: #71665d; }
.product-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.product-actions button {
  min-height: 42px; padding: 0 9px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--sage-dark); font-size: .76rem; font-weight: 800;
}
.product-actions button:hover { border-color: var(--sage); background: #f4f8f5; }
.product-actions .danger { color: #8b5749; }
.product-actions .danger:hover { border-color: #d5a08f; background: #fff6f2; }

.empty {
  grid-column: 1 / -1; min-height: 154px; padding: 26px; border: 1px dashed #d8d0c5; border-radius: 18px;
  display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted);
}
.empty-icon { margin-bottom: 5px; font-family: Georgia, serif; font-size: 1.5rem; color: var(--sage-dark); }
.empty strong { color: var(--ink); font-family: Georgia, serif; font-size: 1.05rem; font-weight: 600; }
.empty span:last-child { margin-top: 4px; font-size: .78rem; }
.shelf-line { height: 9px; margin: 20px -8px -19px; border-radius: 999px; background: linear-gradient(90deg, #d8cbbb, #eee7de 60%, #d8cbbb); box-shadow: 0 7px 12px rgba(75,65,50,.10); }

.toast {
  position: fixed; z-index: 10; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 999px; background: #2f4036;
  color: #fff; font-size: .82rem; font-weight: 700; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; box-shadow: 0 10px 30px rgba(45,49,47,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: #8b5749; }

@media (max-width: 820px) {
  .topbar { align-items: start; flex-direction: column; padding-top: 36px; }
  .summary { width: 100%; }
  .summary div { flex: 1; min-width: 0; }
  .layout { grid-template-columns: 1fr; }
  .add-panel { position: static; }
  .shelf-intro { align-items: start; flex-direction: column; }
  .shelf-intro > p { text-align: left; }
}
@media (max-width: 560px) {
  .topbar, .layout { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-top: 28px; }
  .layout { gap: 20px; }
  .summary div { padding: 11px 8px; }
  .summary strong { font-size: 1.3rem; }
  .panel, .routine { border-radius: 20px; }
  .add-panel, .routine { padding: 18px; }
  .product-grid { grid-template-columns: 1fr; }
  .product-actions button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
