:root {
  color-scheme: dark;
  --red: #ef6a6a;
  --button-bg: #b4232d;
  --body-glow: #18232d;
  --accent-wash: rgba(215, 70, 70, .09);
  --card-sheen: rgba(255, 255, 255, .025);
  --input-bg: #0a1016;
  --track: #26313a;
  --ghost-bg: transparent;
  --success-bg: #153327;
  --success-text: #98e1bd;
  --error-bg: #391a1a;
  --error-text: #ffb0b0;
  --row-border: rgba(36, 48, 59, .58);
  --green-border: rgba(75, 201, 144, .52);
  --red-border: rgba(215, 70, 70, .7);
  --focus-ring: rgba(215, 70, 70, .18);
  --inline-error: #ff8c8c;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --line: #ccd5df;
  --text: #18212a;
  --muted: #586979;
  --red: #b4232d;
  --button-bg: #b4232d;
  --green: #087a4d;
  --amber: #8a5a00;
  --body-glow: #e4ebf2;
  --accent-wash: rgba(180, 35, 45, .07);
  --card-sheen: rgba(24, 33, 42, .018);
  --input-bg: #f8fafc;
  --track: #d8e0e7;
  --ghost-bg: rgba(255, 255, 255, .66);
  --success-bg: #e7f6ee;
  --success-text: #146c43;
  --error-bg: #fdecec;
  --error-text: #a61b1b;
  --row-border: rgba(24, 33, 42, .11);
  --green-border: rgba(8, 122, 77, .5);
  --red-border: rgba(180, 35, 45, .55);
  --focus-ring: rgba(180, 35, 45, .16);
  --inline-error: #a61b1b;
}

body {
  background: radial-gradient(circle at 80% 0, var(--body-glow) 0, transparent 38%), var(--bg);
}

header {
  background: linear-gradient(90deg, var(--accent-wash), transparent 45%);
}

.card {
  background: linear-gradient(145deg, var(--card-sheen), transparent), var(--panel);
}

input,
.item-price-field input {
  background: var(--input-bg);
  color: var(--text);
}

input::placeholder {
  color: var(--muted);
  opacity: .78;
}

button:not(.ghost) {
  background: var(--button-bg);
}

.ghost {
  background: var(--ghost-bg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.site-header-inner {
  display: flex;
  max-width: 1400px;
  height: 48px;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  padding: 6px 24px;
}

.site-header a {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.site-header a:hover {
  border-color: var(--line);
  color: var(--text);
}

.site-header a.active {
  border-color: var(--button-bg);
  background: var(--button-bg);
  color: #fff;
}

.notice.ok {
  background: var(--success-bg);
  color: var(--success-text);
}

.notice.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.bar {
  background: var(--track);
}

.items .item-row {
  border-bottom-color: var(--row-border);
}

.auto-refresh-toggle.active {
  border-color: var(--green-border);
}

.item-price-field input:focus {
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.item-row.bazaar-cheaper .item-price-field input {
  border-color: var(--green-border);
}

.item-row.bazaar-higher .item-price-field input,
.item-row.bazaar-invalid .item-price-field input {
  border-color: var(--red-border);
}

.item-row.bazaar-higher .item-price-field small,
.item-row.bazaar-invalid .item-price-field small {
  color: var(--inline-error);
}

.theme-toggle {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 11px;
  white-space: nowrap;
}

.standalone-theme {
  display: flex;
  max-width: 1180px;
  justify-content: flex-end;
  margin: 14px auto 0;
  padding: 0 24px;
}

.standalone-theme .theme-toggle {
  background: var(--panel);
  box-shadow: 0 7px 24px rgba(0, 0, 0, .16);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

.theme-switch-track {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex: 0 0 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--track);
}

.theme-switch-track span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .18s ease;
}

.theme-toggle[aria-checked="true"] .theme-switch-track {
  border-color: var(--amber);
  background: var(--amber);
}

.theme-toggle[aria-checked="true"] .theme-switch-track span {
  transform: translateX(18px);
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-track span {
    transition: none;
  }
}

@media (max-width: 780px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar form,
  .toolbar form button {
    width: 100%;
  }

  .theme-toggle {
    width: 100%;
  }
}
