/* Shared design system: warm "lab glass" look (sage → cream → peach, frosted cards). */

:root {
  --bg-1: #c9d3c3;
  --bg-2: #ebe7dd;
  --bg-3: #f2ece3;
  --bg-4: #ead6c5;
  --shaft: rgba(255, 255, 255, 0.42);

  /* Frosted, fairly solid cards: the background only tints them. */
  --glass: linear-gradient(160deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.48));
  --glass-strong: rgba(255, 255, 255, 0.66);
  --glass-border: rgba(255, 255, 255, 0.92);
  --glass-blur: blur(18px) saturate(130%);
  --glass-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 14px 34px -16px rgba(60, 48, 36, 0.26),
    0 2px 6px -2px rgba(60, 48, 36, 0.08);
  /* Window light: subtle bands with fairly crisp edges. */
  --beam: rgba(255, 255, 255, 0.42);
  --beam-shadow: rgba(96, 116, 92, 0.17);
  --hairline: rgba(52, 42, 30, 0.1);

  --text: #24201c;
  --text-2: #5f584f;
  --text-3: #8b8378;
  --heading: #1f1c19;

  --blue: #1a6fe8;
  --blue-600: #155ed0;
  --blue-soft: rgba(26, 111, 232, 0.1);
  --navy: #22345c;
  --sage: #6f8f63;
  --green: #138a4c;
  --green-soft: rgba(19, 138, 76, 0.12);
  --amber: #c27a12;
  --amber-soft: rgba(255, 236, 205, 0.7);
  --red: #c8372d;
  --red-soft: rgba(200, 55, 45, 0.1);

  --input-bg: rgba(255, 255, 255, 0.82);
  --input-border: rgba(52, 42, 30, 0.12);
  --focus: 0 0 0 3px rgba(26, 111, 232, 0.28);

  --radius-lg: 16px;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg-1: #121916;
  --bg-2: #161a1f;
  --bg-3: #191c22;
  --bg-4: #1f1a17;
  --shaft: rgba(255, 255, 255, 0.035);
  --glass: rgba(32, 36, 44, 0.55);
  --beam: rgba(255, 255, 255, 0.05);
  --beam-shadow: rgba(0, 0, 0, 0.18);
  --glass-strong: rgba(38, 43, 52, 0.9);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 60px -28px rgba(0, 0, 0, 0.7);
  --hairline: rgba(255, 255, 255, 0.08);
  --text: #e9e6e1;
  --text-2: #b4ada4;
  --text-3: #857f77;
  --heading: #f5f2ee;
  --blue: #4a8ff2;
  --blue-600: #3a7ee4;
  --blue-soft: rgba(74, 143, 242, 0.16);
  --navy: #9db4e6;
  --green: #3fbf7a;
  --green-soft: rgba(63, 191, 122, 0.14);
  --amber: #e2a447;
  --amber-soft: rgba(226, 164, 71, 0.12);
  --red: #ef6b60;
  --red-soft: rgba(239, 107, 96, 0.14);
  --input-bg: rgba(20, 23, 29, 0.7);
  --input-border: rgba(255, 255, 255, 0.12);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-3);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Fixed backdrop: soft colour field + diagonal light shafts */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}
body::before {
  background:
    radial-gradient(1200px 700px at -10% 10%, var(--bg-1) 0%, transparent 60%),
    radial-gradient(900px 700px at 110% 90%, var(--bg-4) 0%, transparent 60%),
    linear-gradient(100deg, var(--bg-1) 0%, var(--bg-2) 32%, var(--bg-3) 62%, var(--bg-4) 100%);
}
/* Window light in an inverted "V" / "A": two groups of crisp light bands
   hinged above the top centre and swung outwards, plus a sage shadow band. */
body::after,
html::before,
html::after {
  content: "";
  position: fixed;
  pointer-events: none;
  inset: auto;
  top: -30vh;
  height: 190vh;
  transform-origin: 50% 0;
  z-index: -1;
}
body::after {
  /* left leg "/": a wide band and a thinner one beside it, sloping well down-left */
  left: calc(58% - 13vw);
  width: 26vw;
  min-width: 220px;
  transform: rotate(42deg);
  background: linear-gradient(
    90deg,
    transparent 0 5%,
    var(--beam) 10% 46%,
    transparent 51% 60%,
    var(--beam) 64% 74%,
    transparent 79% 100%
  );
  filter: blur(9px);
}
html::before {
  /* right leg "\": steeper */
  left: calc(58% - 8vw);
  width: 16vw;
  min-width: 140px;
  transform: rotate(-17deg);
  background: linear-gradient(
    90deg,
    transparent 0 8%,
    var(--beam) 14% 52%,
    transparent 58% 66%,
    var(--beam) 70% 80%,
    transparent 86% 100%
  );
  filter: blur(9px);
  opacity: 0.8;
}
html::after {
  /* sage shadow just outside the left leg */
  left: calc(58% - 36vw);
  width: 22vw;
  transform: rotate(42deg);
  background: linear-gradient(90deg, transparent, var(--beam-shadow) 30% 70%, transparent);
  filter: blur(16px);
}

h1,
h2,
h3,
h4 {
  color: var(--heading);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- glass surfaces ---------- */

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-lg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.card {
  padding: 24px;
}

.eyebrow {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
}

.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}

/* ---------- top bar (floating pill, like the store) ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 13px 14px 13px 24px;
  border-radius: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--heading);
  text-decoration: none !important;
}
.brand img {
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}
.brand-name {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-tag {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------- pills & badges ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 6px 18px -10px rgba(60, 50, 40, 0.35);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--heading);
  white-space: nowrap;
}
.pill .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--blue-soft);
  color: var(--blue);
  white-space: nowrap;
}
.badge.green {
  background: var(--green-soft);
  color: var(--green);
}
.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.badge.red {
  background: var(--red-soft);
  color: var(--red);
}
.badge.grey {
  background: var(--hairline);
  color: var(--text-2);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none !important;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled],
.btn[aria-busy="true"] {
  opacity: 0.65;
  cursor: progress;
}
.btn-primary {
  color: #fff;
  background: linear-gradient(100deg, #1a6fe8 0%, #2a74e0 60%, #4b80c9 100%);
  box-shadow: 0 14px 28px -12px rgba(26, 111, 232, 0.7);
}
.btn-primary:hover {
  background: linear-gradient(100deg, #155ed0 0%, #2468d0 60%, #3f74bf 100%);
}
.btn-accent {
  color: #fff;
  background: linear-gradient(100deg, #1a6fe8 0%, #3a78cc 55%, #6f8f63 100%);
  box-shadow: 0 14px 28px -12px rgba(26, 111, 232, 0.6);
}
.btn-ghost {
  color: var(--heading);
  background: var(--glass-strong);
  border-color: var(--glass-border);
  box-shadow: 0 8px 22px -14px rgba(60, 50, 40, 0.4);
}
.btn-ghost:hover {
  background: var(--input-bg);
}
.btn-danger {
  color: var(--red);
  background: var(--red-soft);
}
.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
  border-radius: 11px;
  gap: 7px;
}
.btn-block {
  width: 100%;
}
.btn-lg {
  min-height: 56px;
  font-size: 16.5px;
  border-radius: 16px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--glass-strong);
  color: var(--heading);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > label,
.label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.field .hint {
  font-size: 12.5px;
  color: var(--text-3);
}
.optional {
  font-weight: 500;
  color: var(--text-3);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}
.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}
.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b8378' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--focus);
}
.field.invalid .input,
.field.invalid .select,
.field.invalid .textarea {
  border-color: var(--red);
  background-color: var(--red-soft);
}
.field-error {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
}
.field-error .icon {
  width: 15px;
  height: 15px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.switch input {
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--hairline);
  border: 1px solid var(--input-border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  margin: 0;
  flex: none;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch input:checked {
  background: var(--blue);
}
.switch input:checked::after {
  transform: translateX(18px);
}

/* ---------- alerts ---------- */

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.alert .icon {
  margin-top: 1px;
}
.alert-error {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(200, 55, 45, 0.2);
}
.alert-warn {
  background: var(--amber-soft);
  color: #7a4f0c;
  border-color: rgba(194, 122, 18, 0.28);
}
:root[data-theme="dark"] .alert-warn {
  color: var(--amber);
}
.alert-info {
  background: var(--blue-soft);
  color: var(--navy);
  border-color: rgba(26, 111, 232, 0.18);
}
.alert-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(19, 138, 76, 0.2);
}
.alert strong {
  display: block;
  margin-bottom: 2px;
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: 14px;
  background: #1f2430;
  color: #fff;
  font-weight: 550;
  font-size: 14px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.2s ease;
}
.toast.error {
  background: var(--red);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

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