:root {
  color-scheme: light;
  --page: #f2f6fd;
  --surface: #ffffff;
  --surface-soft: #f6f7fa;
  --ink: #202329;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #356b9a;
  --accent-dark: #285577;
  --brand-gradient: linear-gradient(90deg, #17b3a6 0%, #58cec4 38%, #665bed 68%, #776af3 100%);
  --card-accent: #ebe8e1;
  --danger: #a44343;
  --shadow: 0 16px 38px rgba(48, 48, 42, 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: 100svh;
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button, .button { min-height: 44px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.site-header { width: min(1320px, calc(100% - 48px)); margin: 0 auto; min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.site-identity { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.site-identity strong { font-size: 1.9rem; letter-spacing: -.025em; }
.identity-mark { width: 46px; height: 46px; margin-left: -4px; display: block; object-fit: contain; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-actions form, .product-admin form { margin: 0; }
.welcome { color: var(--muted); font-size: .84rem; }
.header-divider { width: 100%; height: 4px; background: var(--brand-gradient); }

.page-shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 72px; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.auth-card h1, .editor-header h1 { margin: 10px 0 12px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.08; letter-spacing: -.045em; }
.add-panel p, .auth-card > p, .editor-header p { margin: 0; color: var(--muted); font-size: 1rem; }
.item-count { flex: 0 0 auto; border-radius: 999px; color: var(--accent-dark); background: #fff; padding: 10px 16px; font-size: .82rem; font-weight: 800; }
.item-summary { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 24px; }

.add-panel { margin-top: 24px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(260px, .72fr) minmax(360px, 1.28fr); align-items: center; gap: 32px; padding: 28px; }
.add-panel h2 { margin: 4px 0; font-size: 1.35rem; }
.url-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }

input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #f9fafc; padding: 12px 14px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(53, 107, 154, .12); }
textarea { resize: vertical; }
.button {
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(105deg, #534ae6 0%, #665bed 50%, #776af3 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  box-shadow: 0 10px 25px rgba(91, 76, 230, .3), 0 5px 12px rgba(91, 76, 230, .18);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 200ms ease, filter 200ms ease, box-shadow 200ms ease;
}
.button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 14px 32px rgba(91, 76, 230, .38), 0 7px 16px rgba(91, 76, 230, .22);
}
.button:active { transform: translateY(0); }
.button:focus-visible { outline: 3px solid rgba(83, 74, 230, .38); outline-offset: 3px; }
.button-muted { border: 1px solid var(--line); color: #343840; background: #f2f3f6; box-shadow: none; }
.button-muted:hover { background: #e9ebf0; transform: translateY(-1px); filter: none; box-shadow: 0 6px 14px rgba(48, 48, 42, .1); }
.button-muted:active { transform: translateY(0); }
.owner-sign-in { gap: 8px; color: #4f5962; background: #ebe9e3; box-shadow: none; }
.owner-sign-in svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.owner-sign-in:hover { color: #414950; background: #dfdcd3; transform: translateY(-1px); filter: none; box-shadow: 0 6px 14px rgba(48, 48, 42, .1); }
.owner-sign-in:active { transform: translateY(0); }

.product-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 24px; }
.item-summary + .product-grid { margin-top: 16px; }
.product-card { min-width: 0; border-radius: 20px; background: #fcf7e7; box-shadow: 0 10px 28px rgba(48, 48, 42, .06); overflow: hidden; isolation: isolate; display: flex; flex-direction: column; transition: transform 600ms ease, box-shadow 600ms ease; }
.product-card:hover,
.product-card:focus-within,
.product-card.is-highlighted { transform: translateY(-2px); box-shadow: var(--shadow); }
.product-link:focus-visible { outline: 3px solid rgba(105, 85, 245, .42); outline-offset: -4px; }
.product-link { display: flex; flex: 1 1 auto; flex-direction: column; color: inherit; text-decoration: none; }
.product-image-wrap { position: relative; aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; overflow: hidden; }
.product-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; padding: 22px; transition: transform 240ms ease; }
.product-card:hover .product-image { transform: scale(1.025); }
.product-placeholder, .image-unavailable::after { color: #a5a098; font-size: 3rem; content: "♡"; }
.product-copy { min-height: 220px; flex: 1 1 auto; background: linear-gradient(to bottom, #fcf7e7 0%, #fff 100%); display: flex; flex-direction: column; align-items: flex-start; padding: 22px; }
.retailer-badge, .visibility-badge { border-radius: 999px; color: #5c6268; background: #eeece7; padding: 5px 9px; font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.product-copy h2 { margin: 14px 0 8px; font-size: 1.05rem; line-height: 1.35; }
.product-price { margin-bottom: 8px; font-size: 1.22rem; }
.product-copy p { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; margin: 0 0 16px; color: var(--muted); font-size: .84rem; }
.product-admin { background: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; padding: 12px 16px; }
.visibility-private { color: #59616c; background: #eceff3; }
.text-action { min-height: 36px; border: 0; color: var(--accent-dark); background: none; display: inline-flex; align-items: center; padding: 0; font-size: .75rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.text-danger { color: var(--danger); }
.purchase-action { color: #39715a; gap: 4px; }

.purchased-header { min-height: 190px; border-radius: 24px; background: var(--surface-soft); display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: clamp(28px, 5vw, 56px); }
.purchased-header h1 { margin: 7px 0 5px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.05; letter-spacing: -.045em; }
.purchased-header p { margin: 0; color: var(--muted); }
.purchased-list { margin-top: 24px; display: grid; gap: 12px; }
.purchased-item { border-radius: 18px; background: var(--surface); box-shadow: 0 8px 22px rgba(48, 48, 42, .07); display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 24px; padding: 16px; }
.purchased-product { min-width: 0; display: flex; align-items: center; gap: 18px; color: inherit; text-decoration: none; }
.purchased-image { width: 88px; height: 72px; border-radius: 12px; background: var(--surface-soft); display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; color: #9aa1ab; font-size: 1.8rem; }
.purchased-image img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.purchased-copy { min-width: 0; display: grid; justify-items: start; gap: 5px; }
.purchased-copy strong { overflow: hidden; max-width: 55ch; text-overflow: ellipsis; white-space: nowrap; }
.purchased-copy > span:last-child:not(.retailer-badge) { color: var(--muted); font-size: .82rem; }
.purchase-date { display: grid; gap: 2px; min-width: 120px; }
.purchase-date span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.purchase-date strong { font-size: .88rem; }

.flash { width: min(1320px, calc(100% - 48px)); margin: 24px auto 18px; border-radius: 12px; padding: 12px 16px; font-size: .86rem; }
.flash-success { color: #315f4a; background: #e2f0e8; }
.flash-error, .inline-error { color: #843c3c; background: #f7e7e7; }
.inline-error { margin: 16px 0; border-radius: 10px; padding: 11px 13px; font-size: .85rem; }
.empty-state { margin-top: 32px; border-radius: 22px; background: var(--surface); display: grid; place-items: center; padding: 80px 24px; text-align: center; }
.empty-state > span { color: #9aa1ab; font-size: 3rem; }
.empty-state h2 { margin: 12px 0 2px; }
.empty-state p { margin: 0; color: var(--muted); }

.auth-page .page-shell { display: grid; place-items: center; min-height: calc(100svh - 180px); }
.auth-card { width: min(100%, 480px); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); padding: clamp(28px, 5vw, 48px); }
.auth-card h1 { font-size: 2.2rem; }
.stack-form { margin-top: 26px; display: grid; gap: 10px; }
.stack-form label, .field label { font-size: .78rem; font-weight: 800; }
.stack-form .button { margin-top: 10px; }
.editor-header { max-width: 760px; padding: 42px 0 26px; }
.editor-header h1 { font-size: clamp(2rem, 4vw, 3.4rem); }
.item-form { border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: clamp(24px, 4vw, 42px); }
.field { display: grid; gap: 7px; }
.field label span { color: var(--muted); font-weight: 500; }
.field-wide { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 10px; font-size: .85rem; font-weight: 700; }
.check-field input { width: 20px; height: 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.site-footer { width: min(1320px, calc(100% - 48px)); margin: 0 auto; border-top: 1px solid var(--line); color: var(--muted); display: flex; justify-content: space-between; padding: 24px 0 40px; font-size: .75rem; }

@media (max-width: 760px) {
  .site-header, .page-shell, .site-footer, .flash { width: min(100% - 32px, 1320px); }
  .site-header { min-height: 78px; }
  .site-identity strong { font-size: 1.55rem; }
  .welcome { display: none; }
  .add-panel { grid-template-columns: 1fr; padding: 22px; }
  .url-form { grid-template-columns: 1fr; }
  .url-form .button { width: 100%; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .product-copy { min-height: 200px; padding: 17px; }
  .item-form { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .purchased-header { align-items: flex-start; flex-direction: column; }
  .purchased-item { grid-template-columns: 1fr auto; }
  .purchased-product { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .product-grid { grid-template-columns: 1fr; }
  .product-image-wrap { aspect-ratio: 16 / 11; }
  .product-copy { min-height: 190px; }
  .header-actions .button { padding-inline: 12px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .purchased-item { grid-template-columns: 1fr; }
  .purchased-product { grid-column: auto; }
  .purchased-copy strong { max-width: 30ch; }
  .purchased-item > form .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .product-card:hover, .product-card:focus-within { transform: none; }
}
