:root {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --card-foreground: #fafafa;
  --popover: #09090b;
  --popover-foreground: #fafafa;
  --primary: #d6f249;
  --primary-foreground: #09090b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --border: #27272a;
  --input: #27272a;
  --ring: #d6f249;
  --radius: 0.5rem;
  --hover-border: #3f3f46;
  --ring-offset: #09090b;
  --transition-fast: 150ms ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
}

a {
  color: var(--primary);
}

a,
button,
input,
select,
.chip,
.skill-pill {
  transition: all var(--transition-fast);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(9, 9, 11, 0.88);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--foreground);
  text-decoration: none;
  font-weight: 700;
}

.brand-logo {
  flex-shrink: 0;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
}

.menu-toggle:hover {
  background: var(--accent);
}

.topnav {
  position: absolute;
  top: 52px;
  right: 16px;
  display: none;
  flex-direction: column;
  min-width: 150px;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.topnav.open {
  display: flex;
}

.topnav a {
  color: var(--muted-foreground);
  text-decoration: none;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.topnav a:last-child {
  border-bottom: 0;
}

.topnav a:hover {
  color: var(--foreground);
  background: var(--accent);
}

.topnav a.active {
  color: var(--foreground);
  box-shadow: inset 0 -2px 0 var(--primary);
}

.app-shell {
  width: min(1200px, calc(100% - 24px));
  margin: 16px auto 40px;
  position: relative;
}

.card-surface {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: none;
  transition: border-color var(--transition-fast);
}

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

.hero h1 {
  margin: 0;
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.hero-sub {
  margin: 12px 0 0;
  color: var(--muted-foreground);
  line-height: 1.6;
  max-width: 760px;
}

.hero-sub strong {
  color: var(--foreground);
}

.hero-sub code {
  background: var(--secondary);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--primary);
}
.hero-count {
  margin: 8px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
}

.controls {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.search-wrap {
  display: grid;
  gap: 8px;
}

input[type="search"],
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--foreground);
  font-size: 14px;
  line-height: 20px;
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-color: var(--input);
  padding-right: 36px;
}

input[type="search"]::placeholder {
  color: var(--muted-foreground);
}

input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px var(--ring-offset);
}

.filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-label {
  font-size: 12px;
  color: var(--muted-foreground);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  cursor: pointer;
  text-transform: capitalize;
}

.chip:hover {
  border-color: var(--ring);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.skill-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
}

.ghost-btn {
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--foreground);
  font-size: 14px;
  font-weight: 500;
  padding: 0 16px;
  cursor: pointer;
}

.ghost-btn:hover {
  background: var(--accent);
}

.results-head {
  margin-top: 14px;
}

#countLabel {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 12px;
}
.count-highlight {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.plays-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  grid-auto-rows: 1fr;
}

.play-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 12px;
  height: 100%;
  transition: border-color var(--transition-fast);
}

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

.play-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.play-title {
  margin: 0;
  color: var(--foreground);
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

.play-title a {
  color: var(--foreground);
  text-decoration: none;
}

.play-title a:hover {
  color: var(--primary);
}

.source-link {
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 16px;
}

.source-link:hover {
  color: var(--foreground);
}

.play-desc {
  margin: 0;
  color: var(--muted-foreground);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  font-size: 13px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
  border-radius: 9999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.4;
}

.skill-pill:hover {
  border-color: var(--ring);
}

.skill-pill.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-foreground);
  border-radius: 9999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
  line-height: 1.4;
}
.badge[class*="effort-low"] { border-color: #22c55e40; color: #4ade80; }
.badge[class*="effort-medium"] { border-color: #eab30840; color: #facc15; }
.badge[class*="effort-high"] { border-color: #ef444440; color: #f87171; }
.badge[class*="value-low"] { border-color: var(--border); color: var(--muted-foreground); }
.badge[class*="value-medium"] { border-color: #3b82f640; color: #60a5fa; }
.badge[class*="value-high"] { border-color: #D6F24940; color: #D6F249; }

.empty {
  margin-top: 16px;
  color: var(--muted-foreground);
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.hidden {
  display: none !important;
}

.view {
  display: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.detail-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.permalink {
  color: var(--muted-foreground);
  text-decoration: none;
}

.permalink:hover {
  color: var(--foreground);
}

.detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-title {
  margin: 0;
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-text {
  color: var(--muted-foreground);
  line-height: 1.6;
  white-space: pre-wrap;
}

.detail-gotcha {
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius);
  background: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
}

.detail-meta {
  margin-top: 0;
}

.replication-count {
  font-size: 12px;
}

.comments-wrap {
  margin-top: 12px;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h3 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

.comments-wrap h2 {
  margin-bottom: 12px;
}

.comments-list {
  display: grid;
  gap: 10px;
}

.comment-item {
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.comment-author {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--muted-foreground);
  font-size: 12px;
}

.comment-time {
  color: var(--muted-foreground);
  font-size: 12px;
}

.comment-body {
  margin: 0;
  color: var(--foreground);
  white-space: pre-wrap;
  line-height: 1.6;
}

.comment-children {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.comments-howto {
  margin-top: 16px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.comments-howto summary {
  padding: 12px 16px;
  cursor: pointer;
  color: var(--muted-foreground);
  font-size: 13px;
  user-select: none;
  list-style: none;
}
.comments-howto summary::-webkit-details-marker { display: none; }
.comments-howto summary::before { content: '▸ '; }
.comments-howto[open] summary::before { content: '▾ '; }
.comments-howto summary:hover { color: var(--foreground); }
.comments-howto-inner {
  padding: 0 16px 16px;
}
.comments-howto p {
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
.comments-howto code {
  display: block;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 10px 0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--primary);
  user-select: all;
}
.comments-howto-sub {
  margin-top: 8px !important;
  font-size: 12px !important;
  color: var(--muted-foreground);
}
.comments-howto-sub code {
  display: inline;
  padding: 2px 6px;
  margin: 0;
  font-size: 12px;
}

.graph-head {
  margin-bottom: 10px;
}

.graph-head h2,
.graph-head p {
  margin: 0;
}

.graph-head p {
  margin-top: 6px;
  color: var(--muted-foreground);
}

.graph-mount {
  height: 70vh;
  min-height: 420px;
  position: relative;
  overflow: hidden;
  padding: 0;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stat-card h3 {
  margin-top: 0;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 500;
}

.stat-value {
  margin: 0;
  font-size: 30px;
  line-height: 36px;
  color: var(--foreground);
  font-weight: 700;
  letter-spacing: -0.02em;
}

#view-about section {
  margin-top: 12px;
}

.top-skills {
  display: grid;
  gap: 8px;
}

.skill-bar {
  display: grid;
  grid-template-columns: minmax(100px, 210px) 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.skill-bar-name {
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-bar-track {
  background: var(--secondary);
  border: 1px solid var(--border);
  height: 8px;
  border-radius: 9999px;
  overflow: hidden;
}

.skill-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a2bc33, var(--primary));
}

.skill-bar-count {
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

.about-content h3 {
  margin: 20px 0 8px;
}

.about-content h3:first-child {
  margin-top: 0;
}

.about-content p {
  color: var(--muted-foreground);
  line-height: 1.6;
}

.about-content code {
  background: var(--secondary);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius);
  color: var(--foreground);
}

.loading-screen {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.92);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  color: var(--muted-foreground);
}

.loading-screen::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  border: 2px solid var(--muted);
  border-top-color: var(--ring);
  animation: spin 0.9s linear infinite;
}

#errorState::before {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 640px) {
  .plays-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .plays-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 740px) {
  .topbar {
    padding: 0 24px;
  }

  .menu-toggle {
    display: none;
  }

  .topnav {
    position: static;
    display: flex;
    flex-direction: row;
    background: transparent;
    border: 0;
    min-width: 0;
    height: 100%;
    align-items: center;
  }

  .topnav a {
    border: 0;
    padding: 0 10px;
    height: 100%;
    display: inline-flex;
    align-items: center;
  }

  .search-wrap {
    grid-template-columns: 1fr auto;
  }

  #sortSelect {
    min-width: 220px;
  }

  .skill-row {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
  }

  .about-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 739px) {
  button,
  .chip,
  .skill-pill,
  .ghost-btn,
  input[type="search"],
  select,
  .topnav a {
    min-height: 44px;
  }

  .chip,
  .skill-pill,
  .badge {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card-surface,
  .play-card {
    padding: 16px;
  }

  .detail-title,
  .hero h1 {
    font-size: 26px;
    line-height: 32px;
  }
}
