:root {
  color-scheme: light;
  --ink: #0f1111;
  --ink-soft: #565959;
  --paper: #e3e6e6;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --line: #d5d9d9;
  --line-dark: #879596;
  --accent: #ff9900;
  --accent-dark: #e47911;
  --link: #007185;
  --nav: #131921;
  --nav-muted: #d6d6d6;
  --signal: #ff9900;
  --success: #176246;
  --success-bg: #e2f0e8;
  --danger: #9b352e;
  --danger-bg: #f9e5e0;
  --focus: #c45500;
  --radius: 4px;
  --shadow: 0 2px 8px rgba(15, 17, 17, 0.16);
  --serif: var(--sans);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scrollbar-color: var(--line-dark) var(--paper);
}

::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  background: var(--line-dark);
  border: 3px solid var(--paper);
  border-radius: 10px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

::selection {
  color: var(--ink);
  background: var(--accent);
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: #004e55;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--surface);
  background: var(--nav);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.wrap {
  width: min(1320px, calc(100% - 3rem));
  margin-inline: auto;
}

.topbar {
  color: var(--surface);
  background: var(--nav);
  border-bottom: 4px solid var(--accent);
}

.topbar-inner {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  align-items: center;
  min-height: 64px;
  gap: 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  color: var(--surface);
  font-family: var(--sans);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  text-decoration: none;
}

.brand::before {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  content: "SB";
  color: var(--ink);
  background: var(--accent);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 850;
}

.brand:hover {
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 0.2rem;
}

.nav a {
  display: grid;
  align-items: center;
  padding: 0 0.8rem;
  color: var(--nav-muted);
  border-bottom: 3px solid transparent;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"],
.page-dashboard .nav a[href="/dashboard"],
.page-account .nav a[href="/account"],
.page-shop .nav a[href="/shop"],
.page-product .nav a[href="/shop"],
.page-basket .nav a[href="/basket"] {
  color: var(--surface);
  border-bottom-color: var(--accent);
}

.page-stage-admin .nav a[href="/admin"] {
  color: var(--surface);
  border-bottom-color: var(--accent);
}

.inline-form {
  margin: 0;
}

.inline-form button {
  color: var(--surface);
  background: transparent;
  border-color: #718086;
}

.inline-form button:hover {
  color: var(--nav);
  background: var(--surface);
  border-color: var(--surface);
}

.main-content {
  min-height: calc(100vh - 80px);
  padding-block: clamp(1.5rem, 3vw, 2.75rem) 4rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  max-width: 18ch;
  margin-bottom: 1rem;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.15;
}

h3 {
  margin-bottom: 0.6rem;
  font-size: 1.2rem;
}

p {
  max-width: 70ch;
  margin-bottom: 1rem;
  color: var(--ink-soft);
}

strong {
  color: var(--ink);
  font-weight: 750;
}

.panel {
  margin-bottom: 2.5rem;
  padding-block: 0 1.7rem;
  border-bottom: 1px solid var(--line);
}

.panel > p:first-of-type {
  max-width: 54ch;
  font-size: 1.08rem;
}

.page-shop .main-content > .panel:first-child {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--ink);
  background: linear-gradient(100deg, #fff 0 62%, #fff1db 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-shop .main-content > .panel:first-child::after {
  content: none;
}

.page-shop .main-content > .panel:first-child h1 {
  max-width: 18ch;
  color: var(--ink);
}

.page-shop .main-content > .panel:first-child p {
  color: var(--ink-soft);
}

.narrow {
  max-width: 570px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.card {
  grid-column: span 6;
  min-width: 0;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card > :last-child {
  margin-bottom: 0;
}

.card-grid > .card:only-child,
[data-role="commands-card"] {
  grid-column: 1 / -1;
}

.product-card {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: var(--surface-strong);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.product-card:hover {
  border-color: var(--line-dark);
  box-shadow: var(--shadow);
}

.product-card > :not(.product-image) {
  margin-inline: 1.35rem;
}

.product-card .product-image + h2 {
  margin-top: 1.35rem;
  font-size: 1.12rem;
  line-height: 1.25;
}

.product-card p strong {
  font-size: 1.3rem;
}

.product-card form {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) 1.3fr;
  align-items: end;
  gap: 0.75rem;
  margin: auto 1.35rem 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.product-card .product-action {
  margin: auto 1.35rem 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-weight: 700;
}

.product-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f7f7f7;
  border-bottom: 1px solid var(--line);
}

.product-detail {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
}

.product-detail .product-image {
  border: 1px solid var(--line);
  border-radius: 10px;
}

.product-detail form {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 2fr;
  align-items: end;
  gap: 0.75rem;
  max-width: 420px;
}

.product-comments {
  max-width: 800px;
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--line);
}

.comments-summary {
  color: var(--ink);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.comment-list {
  border-top: 1px solid var(--line);
}

.comment {
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.comment-meta {
  margin-bottom: 0.35rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.comment-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comments-more {
  margin-top: 1rem;
  color: var(--link);
  background: transparent;
}

.comments-more:hover {
  color: var(--surface);
}

.comment-form {
  max-width: 700px;
  margin-top: 3rem;
}

.comment-form h3 {
  margin-bottom: 0;
}

.stack-form,
.flash-stack,
.basket-list {
  display: grid;
  gap: 1rem;
}

[hidden] {
  display: none !important;
}

.stack-form label,
.product-card label,
.product-detail label {
  display: grid;
  gap: 0.4rem;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.035em;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.68rem 0.8rem;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  caret-color: var(--accent);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ink-soft);
}

input::placeholder,
textarea::placeholder {
  color: #68767a;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

button {
  min-height: 44px;
  padding: 0.68rem 1rem;
  color: var(--ink);
  background: var(--accent);
  border: 1px solid #ff8f00;
  border-radius: 999px;
  font-weight: 750;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  color: #6a7476;
  background: #dedbd3;
  border-color: #dedbd3;
  cursor: not-allowed;
}

.flash {
  max-width: 720px;
  padding: 1rem 1.15rem;
  border: 1px solid currentColor;
  border-radius: 10px;
}

.flash:empty {
  display: none;
}

.flash-success {
  color: var(--success);
  background: var(--success-bg);
}

.flash-error {
  color: var(--danger);
  background: var(--danger-bg);
}

.callout {
  max-width: 70ch;
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  color: var(--ink);
  background: #e5efed;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}

.account-grid p {
  display: grid;
  gap: 0.15rem;
  margin: 0;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.account-grid p:nth-child(odd) {
  padding-right: 1rem;
}

.account-status,
[data-role="card-status"],
[data-role="coupon-query-status"] {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

[data-role="card-details"] {
  margin-top: 1rem;
  padding: 1rem;
  color: var(--surface);
  background: var(--nav);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

[data-role="commands-card"] {
  margin-top: 1.25rem;
}

[data-role="commands-list"] .basket-item {
  display: block;
  padding-block: 1.25rem;
}

[data-role="commands-list"] .basket-item p {
  margin-bottom: 0.35rem;
}

.empty-state {
  padding: 1.25rem 0;
  color: var(--ink-soft);
  border-block: 1px solid var(--line);
}

.basket-list {
  margin-top: 1.5rem;
}

.basket-item {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(220px, 2fr) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.basket-item:first-child {
  border-top: 1px solid var(--line);
}

.basket-item h2 {
  margin: 0;
  font-size: 1.22rem;
}

.basket-item p {
  margin: 0;
}

.basket-product {
  width: 112px;
}

.basket-image {
  display: block;
  width: 112px;
  height: 82px;
  object-fit: cover;
  background: #e7efed;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.basket-meta {
  display: grid;
  gap: 0.15rem;
  justify-items: end;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.page-login .main-content,
.page-reset-password .main-content,
.page-create-account .main-content {
  display: grid;
  align-content: center;
}

.page-login .narrow,
.page-reset-password .narrow,
.page-create-account .narrow {
  width: min(100%, 570px);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-login .narrow h1,
.page-reset-password .narrow h1,
.page-create-account .narrow h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
}

.page-login .narrow button,
.page-reset-password .narrow button,
.page-create-account .narrow button {
  margin-top: 0.35rem;
}

.page-login .flash-stack {
  margin-bottom: 1rem;
}

.page-login .panel:not(.narrow) form {
  display: inline-block;
  margin: 0 0.5rem 0.5rem 0;
}

.auth-switch {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.admin-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.environment-badge {
  flex: 0 0 auto;
  padding: 0.45rem 0.7rem;
  color: #3f2d00;
  background: #ffd978;
  border: 1px solid #b67b00;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.06em;
}

.feature-panel {
  max-width: 800px;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.feature-panel fieldset {
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
}

.feature-panel legend {
  margin-bottom: 0.4rem;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 750;
}

.feature-list {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.feature-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 76px;
  padding-block: 0.85rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.feature-row span {
  display: grid;
  gap: 0.15rem;
}

.feature-row small {
  color: var(--ink-soft);
}

.feature-row input[type="checkbox"] {
  width: 1.35rem;
  min-height: 1.35rem;
  accent-color: var(--success);
}

.has-stage-toolbar {
  padding-bottom: 48px;
}

.stage-toolbar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 48px;
  padding: 0.55rem max(1rem, calc((100% - 1320px) / 2));
  color: #f7f7f7;
  background: #20262d;
  border-top: 3px solid #f2b134;
  box-shadow: 0 -3px 12px rgba(15, 17, 17, 0.2);
  font-size: 0.82rem;
}

.stage-toolbar > strong {
  color: #241b08;
  padding: 0.2rem 0.45rem;
  background: #f2b134;
  border-radius: 3px;
  letter-spacing: 0.08em;
}

.stage-toolbar span {
  color: #e5e9eb;
}

.stage-toolbar code {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.stage-toolbar a {
  margin-left: auto;
  color: #ffe0a3;
  font-weight: 750;
}

.stage-status {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.35rem;
  background: #46c37b;
  border-radius: 50%;
}

@media (max-width: 900px) {
  .topbar-inner {
    grid-template-columns: 1fr auto;
    gap: 0.75rem 1rem;
    padding-block: 0.8rem;
  }

  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 44px;
    overflow-x: auto;
  }

  .nav a {
    flex: 0 0 auto;
    padding-inline: 0.6rem;
  }

  .product-card {
    grid-column: span 6;
  }
}

@media (max-width: 640px) {
  .wrap {
    width: min(100% - 1.5rem, 1320px);
  }

  .main-content {
    padding-block: 2.25rem 3.5rem;
  }

  .topbar-inner {
    min-height: 66px;
  }

  .brand {
    font-size: 1.1rem;
  }

  .inline-form button {
    min-height: 40px;
    padding-inline: 0.75rem;
  }

  h1 {
    font-size: clamp(2.2rem, 13vw, 3.5rem);
  }

  .page-shop .main-content > .panel:first-child h1 {
    font-size: clamp(2rem, 11vw, 2.6rem);
  }

  .card,
  .product-card {
    grid-column: 1 / -1;
  }

  .product-detail,
  .product-detail form {
    grid-template-columns: 1fr;
  }

  .product-card form {
    grid-template-columns: 1fr;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .account-grid p:nth-child(odd) {
    padding-right: 0;
  }

  .basket-item {
    grid-template-columns: 1fr auto;
  }

  .basket-item p {
    grid-column: 1 / -1;
  }

  .basket-meta {
    justify-items: start;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .admin-heading {
    display: grid;
    gap: 0.75rem;
  }

  .environment-badge {
    width: fit-content;
  }

  .has-stage-toolbar {
    padding-bottom: 82px;
  }

  .stage-toolbar {
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    min-height: 72px;
  }

  .stage-toolbar a {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
