:root {
  color-scheme: dark;

  --bg: #14120f;
  --panel: #1b1814;
  --panel-raised: #211d18;
  --border: rgba(243, 237, 228, 0.14);
  --border-strong: rgba(243, 237, 228, 0.28);
  --text: #f3ede3;
  --text-dim: #a79d8d;
  --text-faint: #938a78;
  --accent: #e2662c;
  --accent-ink: #1b0f06;
  --gold: #d9b35a;

  --font-display: ui-sans-serif, -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --radius-sm: 3px;
  --radius-md: 4px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

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

button {
  font-family: inherit;
  touch-action: manipulation;
}

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

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 18px;
  font-weight: 700;
  border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
  left: 0;
}

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

dialog:focus-visible {
  outline: none;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-mark {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}

.brand-tag {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  max-width: 34ch;
}

.sidebar-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
}

.field select {
  background-color: var(--panel-raised);
  color: var(--text);
}

.field input::placeholder {
  color: var(--text-faint);
}

.field input:hover,
.field select:hover {
  border-color: var(--text-dim);
}

.saved-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.saved-toggle .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.saved-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.saved-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.saved-toggle[aria-pressed="true"] .icon path {
  fill: currentColor;
  stroke: currentColor;
}

.result-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.main {
  padding: 36px 32px 60px;
  min-width: 0;
}

.main-head h1 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 34px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.main-head p {
  margin: 0 0 28px;
  color: var(--text-dim);
  max-width: 56ch;
}

/* Empty state */
.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 28px;
}

.empty-state p {
  margin: 0 0 16px;
}

.empty-state button {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

.empty-state button:hover {
  filter: brightness(1.08);
}

/* Grid of items */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.grid[hidden] {
  display: none;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--panel-raised);
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saved-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(20, 18, 15, 0.85);
  color: var(--gold);
  border: 1px solid rgba(217, 179, 90, 0.5);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-category {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0;
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1.25;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.card-instructor {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.card-meta {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.card-footer {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  min-width: 0;
}

.card-price {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.view-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.view-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Detail dialog */
.detail {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(460px, 100%);
  height: 100%;
  max-height: 100%;
  border: none;
  border-left: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  padding: 0;
  overscroll-behavior: contain;
}

.detail[open] {
  display: flex;
  flex-direction: column;
  animation: slide-in 0.22s ease-out;
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail[open] {
    animation: none;
  }
  .card,
  .saved-toggle,
  .view-btn,
  .empty-state button {
    transition: none;
  }
}

.detail::backdrop {
  background: rgba(10, 8, 6, 0.6);
}

.close-btn {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  z-index: 2;
}

.close-btn svg {
  width: 16px;
  height: 16px;
}

.close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 64px calc(28px + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.detail-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.detail-category {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0;
}

.detail-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.detail-instructor {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 0;
  padding: 16px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.detail-facts div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-facts dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.detail-facts dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.detail-body {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

.save-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: auto;
}

.save-toggle[aria-pressed="true"] {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}

.save-toggle:hover {
  filter: brightness(1.05);
}

.save-toggle svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-photo {
    height: 120px;
  }

  .main {
    padding: 24px 18px 48px;
  }

  .main-head h1 {
    font-size: 26px;
  }

  .detail {
    width: 100%;
  }

  .detail-facts {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .sidebar {
    padding: 20px 16px 18px;
  }

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