.sw-picker {
  --sp-ink: #17332e;
  --sp-muted: #536b64;
  --sp-paper: #f8faf7;
  --sp-line: #dce7de;
  --sp-green: #216e52;
  --sp-green-dark: #15543c;
  --sp-tint: #eaf3ec;
  --sp-radius: 22px;
  color: var(--sp-ink);
  padding-bottom: 1.5rem;
}

.sw-picker [hidden] { display: none !important; }
.sw-picker :focus-visible { outline: 3px solid #688e3c; outline-offset: 3px; }
.sw-picker h1, .sw-picker h2, .sw-picker h3 { color: inherit; }
.sw-picker h2 { margin: 0; font-size: clamp(1.28rem, 2.3vw, 1.65rem); font-weight: 750; letter-spacing: -.025em; }
.sw-picker h3 { margin: 0; font-size: 1.05rem; font-weight: 720; }
.sw-picker p { margin: 0; }
.sw-picker .sp-muted { color: var(--sp-muted); font-size: .88rem; line-height: 1.55; }
.sw-picker .sp-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sp-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 290px) auto;
  gap: clamp(.9rem, 2.5vw, 2rem);
  align-items: center;
  min-height: 11.25rem;
  padding: clamp(1.15rem, 2vw, 1.8rem) clamp(1rem, 3.5vw, 3.25rem);
  border-radius: 24px;
  color: #f7fcf6;
  background: radial-gradient(ellipse at 88% 11%, #38795e 0, transparent 57%), linear-gradient(125deg, #112c27, #235343);
  box-shadow: 0 20px 40px #193b291a;
  animation: sp-in 420ms ease-out both;
}

.sp-hero::before,
.sp-hero::after {
  position: absolute;
  z-index: -1;
  inset: -56% -6% auto auto;
  width: clamp(280px, 56vw, 690px);
  aspect-ratio: 1;
  border: 1px solid #c3e1c231;
  border-radius: 50%;
  transform: rotate(-28deg) scaleY(.56);
  content: '';
}

.sp-hero::after { inset: -42% -10% auto auto; transform: rotate(-28deg) scaleY(.69); }
.sp-hero h1 {
  margin: 0 0 .32rem;
  font-size: clamp(1.8rem, 3.05vw, 3rem);
  line-height: 1.08;
  font-weight: 780;
  letter-spacing: -.045em;
}
.sp-hero-content > p { max-width: 56ch; color: #e1eee4; font-size: clamp(.88rem, 1.24vw, 1rem); line-height: 1.45; }
.sp-hero-link {
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .42rem .7rem;
  border-radius: 11px;
  background: #e1efc6;
  color: #25433a;
  font-size: .82rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  transition: background 160ms ease, transform 160ms ease;
}
.sp-hero-link:hover { transform: translateY(-2px); background: #f0f7dc; color: #132e27; }
.sp-hero-stats {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  gap: clamp(.45rem, 1.1vw, .8rem);
  padding: clamp(.5rem, 1.25vw, .95rem);
  border: 1px solid #d9eed950;
  border-radius: 14px;
  background: #ffffff13;
  backdrop-filter: blur(11px);
}
.sp-hero-stat { display: grid; align-content: center; gap: .18rem; }
.sp-hero-stat + .sp-hero-stat { padding-left: clamp(.45rem, 1.1vw, .8rem); border-left: 1px solid #d9eed94d; }
.sp-hero-stat strong { color: #e6f1cf; font-size: clamp(1.3rem, 2.5vw, 2.2rem); letter-spacing: -.04em; line-height: 1; }
.sp-hero-stat span { color: #e0eee3; font-size: .78rem; line-height: 1.3; overflow-wrap: anywhere; }

.sp-workspace {
  --sp-sidebar-width: clamp(232px, 25vw, 290px);
  --sp-column-gap: clamp(1.1rem, 2.6vw, 2rem);
  --sp-row-gap: .8rem;
  margin: clamp(1rem, 2.1vw, 1.7rem) 0 0;
}
.sp-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.24fr);
  width: min(100%, var(--sp-sidebar-width));
  gap: .22rem;
  padding: .26rem;
  margin: 0 0 var(--sp-row-gap);
  border: 1px solid var(--sp-line);
  border-radius: 15px;
  background: var(--sp-tint);
}
.sp-tabs button {
  display: inline-flex;
  gap: .32rem;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .45rem .32rem;
  border: 0;
  border-radius: 11px;
  color: var(--sp-muted);
  background: transparent;
  font-size: .9rem;
  font-weight: 720;
  transition: color 150ms, background 150ms, box-shadow 150ms;
}
.sp-tabs button[aria-selected='true'] { color: var(--sp-ink); background: #fff; box-shadow: 0 2px 5px #22443516; }
.sp-tab-count { min-width: 1.5rem; padding: .06rem .35rem; border-radius: 99px; background: #d6e9dc; color: #214d3a; font-size: .76rem; }
.sp-match-layout {
  display: grid;
  grid-template-columns: var(--sp-sidebar-width) minmax(0, 1fr);
  gap: var(--sp-column-gap);
  align-items: start;
}
.sp-surface { border: 1px solid var(--sp-line); border-radius: var(--sp-radius); background: #fff; box-shadow: 0 6px 18px #17332806; }
.sp-goals { padding: clamp(1rem, 2vw, 1.3rem); }
.sp-goal-head, .sp-results-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem 1.1rem; }
.sp-goals > .sp-muted, .sp-results-head .sp-muted { margin-top: .27rem; }
.sp-quick-goals { display: flex; flex-wrap: wrap; gap: .38rem; margin-top: .85rem; }
.sp-quick-goals:empty { display: none; }
.sp-chip, .sp-text-button {
  border: 0;
  background: transparent;
  color: var(--sp-green-dark);
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
}
.sp-chip { padding: .37rem .68rem; border-radius: 99px; background: var(--sp-tint); transition: background 150ms; }
.sp-chip:hover { background: #d8eade; }
.sp-text-button { padding: .13rem 0; text-align: left; }
.sp-text-button:hover { color: var(--sp-green-dark); text-decoration: underline; text-underline-offset: .2em; }
.sp-text-button:disabled { color: var(--sp-muted); opacity: .65; text-decoration: none; }
.sp-goal-rows { display: grid; gap: .65rem; margin-top: .8rem; }
.sp-goal-rows:empty { display: none; }
.sp-goal {
  display: grid;
  gap: .48rem;
  padding: .75rem;
  border: 1px solid var(--sp-line);
  border-radius: 14px;
  background: var(--sp-paper);
  animation: sp-in 190ms ease-out both;
}
.sp-goal-top, .sp-goal-quantity { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .42rem; align-items: end; }
.sp-goal-quantity { grid-template-columns: minmax(0, 1fr) minmax(68px, .66fr); }
.sp-field { display: grid; gap: .24rem; min-width: 0; color: var(--sp-muted); font-size: .79rem; font-weight: 680; }
.sp-field input, .sp-field select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .5rem .62rem;
  border: 1px solid #cbd9ce;
  border-radius: 10px;
  background-color: #fff;
  color: var(--sp-ink);
  font-size: .9rem;
  font-weight: 550;
  line-height: 1.3;
}
.sp-field input::placeholder { color: #637772; }
.sp-field :disabled { opacity: .65; cursor: default; }
.sp-field [aria-invalid='true'] { border-color: #a74436; }
.sp-add-goal { width: 100%; margin-top: .85rem; }
.sp-match-field { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--sp-line); }
.sp-search { margin: .85rem 0; }
.sp-mode-field { flex-shrink: 0; }

.sp-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .42rem;
  min-height: 41px;
  padding: .48rem .78rem;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: .85rem;
  font-weight: 720;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: background 150ms, border-color 150ms, transform 150ms;
}
.sp-button-primary { color: #fff; background: var(--sp-green); }
.sp-button-primary:hover { color: #fff; background: var(--sp-green-dark); transform: translateY(-1px); }
.sp-button-soft { color: var(--sp-green-dark); background: var(--sp-tint); }
.sp-button-soft:hover { color: #153e2e; background: #d9eade; }
.sp-button-outline { color: var(--sp-green-dark); border-color: #bfcfc4; background: #fff; }
.sp-button-outline:hover, .sp-button-outline[aria-pressed='true'] { color: #174633; border-color: #7aa98d; background: #e8f4eb; }
.sp-button:disabled { opacity: .56; cursor: default; transform: none; }
.sp-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 39px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--sp-tint);
  color: var(--sp-green-dark);
  font-size: 1.36rem;
  line-height: 1;
}
.sp-icon-button:hover { background: #d8e9dd; }

.sp-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .82rem; }
.sp-card {
  display: flex;
  flex-direction: column;
  gap: .72rem;
  min-width: 0;
  padding: .95rem;
  transition: border-color 170ms, box-shadow 170ms, transform 170ms;
  animation: sp-in 225ms ease-out both;
}
.sp-card:hover { transform: translateY(-2px); border-color: #abc9b4; box-shadow: 0 13px 25px #17332813; }
.sp-card-top { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: .68rem; align-items: center; }
.sp-photo {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e5eee6;
  border-radius: 13px;
  width: 74px;
  aspect-ratio: 1;
  background: radial-gradient(circle at 70% 18%, #ffffff, #eaf2ec 85%);
}
.sp-photo img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.sp-card .sp-card-meta { margin-bottom: .16rem; font-size: .72rem; }
.sp-card h3 { overflow-wrap: anywhere; line-height: 1.24; }
.sp-card .sp-card-dose { color: var(--sp-muted); font-size: .81rem; line-height: 1.4; }
.sp-card-values { display: grid; gap: .24rem; margin: 0; padding: .5rem .6rem; border-radius: 12px; background: var(--sp-paper); list-style: none; }
.sp-card-values li { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .8rem; }
.sp-card-values li span { min-width: 0; overflow-wrap: anywhere; }
.sp-card-values strong { text-align: right; white-space: nowrap; }
.sp-goal-met strong { color: #146340; }
.sp-goal-possible strong { color: #86510b; }
.sp-goal-under strong { color: #984d38; }
.sp-goal-missing { color: var(--sp-muted); }
.sp-card-actions { display: flex; flex-wrap: wrap; gap: .42rem; margin-top: auto; }
.sp-card-actions .sp-button { flex: 1 0 auto; }
.sp-show-more { margin-top: .85rem; }
.sp-empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: start;
  gap: .7rem;
  padding: clamp(1rem, 3vw, 1.8rem);
  border: 1px dashed #b8d0bf;
  border-radius: var(--sp-radius);
  background: var(--sp-paper);
  color: var(--sp-muted);
}

.sp-compare-panel { animation: sp-in 235ms ease-out both; }
.sp-compare-toolbar { display: flex; flex-wrap: wrap; gap: .65rem; }
.sp-compare-panel .sp-results-head { margin-bottom: .95rem; }
.sp-table-wrap { overflow-x: auto; }
.sp-compare-table, .sp-detail-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .87rem; }
.sp-compare-table th, .sp-compare-table td, .sp-detail-table th, .sp-detail-table td {
  padding: .66rem .84rem;
  border-bottom: 1px solid #e8eee9;
  vertical-align: top;
  text-align: left;
}
.sp-compare-table thead th, .sp-detail-table thead th { background: var(--sp-tint); color: var(--sp-ink); font-weight: 700; }
.sp-compare-table tbody tr:nth-child(even) > *, .sp-detail-table tbody tr:nth-child(even) > * { background: var(--sp-paper); }
.sp-compare-table tbody tr:last-child > *, .sp-detail-table tbody tr:last-child > * { border-bottom: 0; }
.sp-compare-sticky { position: sticky; z-index: 1; left: 0; min-width: 150px; background: #fff; box-shadow: 1px 0 0 var(--sp-line); }
.sp-compare-table .sp-compare-col { min-width: 170px; }
.sp-compare-photo { width: 58px; margin: 0 0 .4rem; }
.sp-compare-col strong, .sp-compare-col > span { display: block; }
.sp-compare-col strong { max-width: 24ch; line-height: 1.25; }
.sp-compare-col > span { margin-top: .28rem; font-size: .76rem; }
.sp-compare-actions { display: flex; justify-content: space-between; align-items: center; gap: .45rem; margin-top: .42rem; }
.sp-compare-actions .sp-icon-button { width: 30px; height: 30px; }
.sp-compare-meter { display: block; height: 4px; width: min(100%, 100px); margin-top: .32rem; overflow: hidden; border-radius: 99px; background: #e5eee5; }
.sp-compare-meter > span { display: block; height: 100%; border-radius: inherit; background: #69a481; animation: sp-meter 280ms ease-out both; transform-origin: left; }
.sp-compare-panel .sp-empty { margin-top: .7rem; }

.sp-tray {
  position: sticky;
  z-index: 20;
  bottom: max(.75rem, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
  margin: 1rem 0 0;
  padding: .75rem .95rem;
  border: 1px solid #a6c6b0;
  border-radius: 16px;
  background: #f6fcf7f7;
  box-shadow: 0 9px 25px #193b2924;
  backdrop-filter: blur(9px);
  animation: sp-in 210ms ease-out both;
}
.sp-tray-items { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; }
.sp-tray-chip { display: inline-flex; gap: .35rem; align-items: center; max-width: 18rem; padding: .16rem .44rem; border-radius: 8px; background: var(--sp-tint); color: var(--sp-green-dark); font-size: .75rem; }
.sp-tray-chip > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sp-tray-chip button { padding: 0 .16rem; border: 0; background: transparent; color: inherit; font-size: 1rem; line-height: 1; }

.sp-dialog {
  position: fixed;
  inset: 0;
  width: min(870px, calc(100% - 1.6rem));
  max-height: min(88dvh, 900px);
  max-width: none;
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #c4d8cb;
  border-radius: 23px;
  background: #fff;
  color: var(--sp-ink);
  box-shadow: 0 25px 80px #14251a50;
}
.sp-dialog[open] .sp-dialog-inner { animation: sp-in 220ms ease-out both; }
.sp-dialog::backdrop { background: #142a23a0; backdrop-filter: blur(3px); }
.sp-dialog-inner { position: relative; padding: clamp(.9rem, 3vw, 1.8rem); }
.sp-dialog-close { position: absolute; top: .8rem; right: .9rem; }
.sp-detail-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .75rem; margin: 0 2.5rem .95rem 0; }
.sp-detail-photo { width: 78px; }
.sp-detail-head h2 { margin-top: .12rem; }
.sp-dose-panel { display: grid; grid-template-columns: 1fr 1fr; gap: .72rem; margin-bottom: 1rem; }
.sp-dose-instruction, .sp-dose-custom { display: grid; align-content: start; gap: .42rem; padding: .85rem .95rem; border: 1px solid var(--sp-line); border-radius: 15px; background: var(--sp-paper); }
.sp-dose-custom { background: #edf6ee; }
.sp-dose-panel h3 { font-size: .98rem; }
.sp-dose-instruction > p:nth-child(2) { font-weight: 720; }
.sp-detail-form { margin-top: .9rem; }
.sp-detail-form h3 { margin: 0 0 .4rem; }
.sp-detail-form .sp-table-wrap { border: 1px solid var(--sp-line); border-radius: 13px; }
.sp-detail-table small { display: block; margin-top: .18rem; font-size: .73rem; font-weight: 500; }
.sp-detail-table .sp-own-value { color: var(--sp-green-dark); font-weight: 760; }
.sp-detail-footer { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1rem; }
.sp-detail-footer .sp-button-outline { margin-left: auto; }

@keyframes sp-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sp-meter { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (min-width: 1250px) {
  .sp-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
  .sp-card-grid { grid-template-columns: minmax(0, 1fr); }
}
@supports (grid-template-rows: subgrid) {
  @media (min-width: 768px) {
    .sp-workspace {
      display: grid;
      grid-template-columns: var(--sp-sidebar-width) minmax(0, 1fr);
      grid-template-rows: auto minmax(0, 1fr);
      gap: var(--sp-row-gap) var(--sp-column-gap);
    }
    .sp-tabs { z-index: 1; grid-area: 1 / 1; width: auto; margin: 0; }
    .sp-match-layout {
      grid-area: 1 / 1 / 3 / -1;
      grid-template-columns: subgrid;
      grid-template-rows: subgrid;
      gap: inherit;
    }
    .sp-goals { grid-area: 2 / 1; }
    .sp-results { grid-area: 1 / 2 / 3; }
    .sp-compare-panel { grid-area: 2 / 1 / 3 / -1; }
    .sp-tray { grid-area: 3 / 1 / auto / -1; }
  }
}
@media (max-width: 767px) {
  .sp-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: start;
    gap: .65rem .55rem;
    min-height: 0;
    padding: 1rem;
    border-radius: 20px;
  }
  .sp-hero-content { grid-column: 1 / -1; }
  .sp-tabs { width: 100%; }
  .sp-match-layout { grid-template-columns: minmax(0, 1fr); }
  .sp-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-compare-panel .sp-results-head { flex-wrap: wrap; }
}
@media (max-width: 535px) {
  .sp-card-grid, .sp-dose-panel { grid-template-columns: minmax(0, 1fr); }
  .sp-results-head { flex-wrap: wrap; }
  .sp-mode-field { width: 100%; }
  .sp-tray { flex-wrap: wrap; }
  .sp-tray > .sp-button { width: 100%; }
  .sp-tray-items { display: none; }
  .sp-field input, .sp-field select { font-size: 1rem; }
  .sp-detail-table { min-width: 0; table-layout: fixed; }
  .sp-detail-table th, .sp-detail-table td { padding: .5rem .38rem; font-size: .74rem; overflow-wrap: anywhere; }
  .sp-detail-table th:first-child { width: 32%; }
  .sp-detail-table thead th { font-size: .71rem; line-height: 1.3; }
  .sp-detail-photo { width: 57px; }
  .sp-compare-sticky { min-width: 125px; }
  .sp-compare-table .sp-compare-col { min-width: 147px; }
}
@media (prefers-reduced-motion: reduce) {
  .sw-picker *, .sw-picker *::before, .sw-picker *::after { animation: none !important; transition: none !important; }
}
