:root {
  color-scheme: light;
  --bg: #f5f3ed;
  --surface: #fffdf8;
  --surface-strong: #181817;
  --ink: #181817;
  --muted: #66645d;
  --line: #d7d1c3;
  --accent: #315f4c;
  --accent-2: #5d43d8;
  --accent-3: #c25b35;
  --mint: #c8dcc3;
  --cream: #fff6dc;
  --shadow: 0 18px 45px rgba(31, 28, 21, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(49, 95, 76, 0.13), transparent 34rem),
    linear-gradient(315deg, rgba(194, 91, 53, 0.1), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

a {
  color: inherit;
}

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(24, 24, 23, 0.11);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 12px 35px rgba(27, 24, 19, 0.08);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: #fffdf8;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.search-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.search-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.topbar-actions,
.toolbar-controls,
.stack-card-title {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button,
.primary-link,
.secondary-button,
.text-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: var(--ink);
  color: #fffdf8;
  letter-spacing: 0;
}

.icon-button span {
  font-size: 0.75rem;
}

.primary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.workspace {
  min-width: 0;
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 430px);
  gap: 28px;
  align-items: stretch;
  min-height: 330px;
  padding: 32px;
  border: 1px solid rgba(24, 24, 23, 0.12);
  border-radius: var(--radius);
  background:
    linear-gradient(110deg, rgba(24, 24, 23, 0.96), rgba(32, 40, 32, 0.94)),
    var(--surface-strong);
  color: #fffdf8;
  overflow: hidden;
}

.intro-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent-3);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.intro-panel .eyebrow {
  color: #c8dcc3;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 16px;
  font-size: clamp(2.6rem, 5vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.3rem, 2vw, 2rem);
  letter-spacing: 0;
}

.intro-panel p:last-child {
  max-width: 760px;
  margin-bottom: 0;
  color: rgba(255, 253, 248, 0.78);
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.48;
}

.skill-map {
  width: 100%;
  height: 100%;
  min-height: 270px;
  object-fit: contain;
  align-self: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stats-grid article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stats-grid strong {
  display: block;
  font-size: 1.5rem;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.86rem;
}

.category-tabs {
  display: flex;
  gap: 10px;
  margin: 22px 0 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.category-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
}

.category-tabs button[aria-selected="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffdf8;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

.toolbar-controls label,
.goal-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 700;
}

.secondary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tool-card {
  display: grid;
  gap: 16px;
  min-height: 330px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 25px rgba(39, 35, 28, 0.05);
}

.tool-card.is-selected {
  border-color: rgba(49, 95, 76, 0.7);
  box-shadow: 0 0 0 3px rgba(49, 95, 76, 0.12);
}

.tool-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tool-title {
  min-width: 0;
}

.tool-title h3 {
  margin: 0 0 5px;
  font-size: 1.1rem;
  line-height: 1.18;
  letter-spacing: 0;
}

.tool-title a {
  overflow-wrap: anywhere;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.select-toggle {
  display: inline-grid;
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e9e3d7;
  cursor: pointer;
  padding: 2px;
}

.select-toggle span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
  box-shadow: 0 2px 8px rgba(24, 24, 23, 0.2);
}

.select-toggle[aria-pressed="true"] {
  background: var(--accent);
}

.select-toggle[aria-pressed="true"] span {
  transform: translateX(18px);
}

.tool-description {
  color: var(--muted);
  line-height: 1.48;
}

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

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(24, 24, 23, 0.11);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 10px;
}

.pill.strong {
  background: var(--mint);
  color: var(--ink);
}

.capability-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.capability-list li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.35;
}

.capability-list li::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent-2);
}

.tool-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-self: end;
}

.tool-actions a,
.tool-actions button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.tool-actions a:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.skill-browser {
  display: grid;
  gap: 14px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.skill-toolbar {
  align-items: center;
  margin-bottom: 0;
}

.skill-toolbar p:last-child {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.skill-search {
  width: min(360px, 100%);
}

.source-audit {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.audit-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.audit-card span,
.audit-card small {
  color: var(--muted);
}

.skill-list {
  display: grid;
  gap: 8px;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1fr) minmax(160px, 0.8fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.skill-row h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  line-height: 1.25;
}

.skill-row p {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.skill-row-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.skill-row-actions a,
.skill-row-actions button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
  padding: 0 10px;
  white-space: nowrap;
}

.skill-row-actions a:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.stack-panel {
  position: sticky;
  top: 94px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(24, 24, 23, 0.12);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stack-header p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.goal-field select {
  width: 100%;
}

.stack-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.stack-card-title {
  justify-content: space-between;
  font-weight: 900;
}

.stack-card-title span {
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.text-button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  padding: 0 10px;
}

.selected-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.selected-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.selected-list strong {
  color: var(--ink);
  font-weight: 900;
}

pre,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #181817;
  color: #fffdf8;
  line-height: 1.45;
  white-space: pre-wrap;
}

pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  font-size: 0.82rem;
}

textarea {
  resize: vertical;
  min-height: 220px;
  padding: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 40px));
  transform: translateY(20px);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1180px) {
  main {
    grid-template-columns: 1fr;
  }

  .stack-panel {
    position: static;
    max-height: none;
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-audit {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .skill-row-actions {
    justify-content: stretch;
  }

  .skill-row-actions a,
  .skill-row-actions button {
    flex: 1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .intro-panel {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  h1 {
    font-size: clamp(2.35rem, 14vw, 3.5rem);
  }

  .stats-grid,
  .tool-grid {
    grid-template-columns: 1fr;
  }

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

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-controls {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .toolbar-controls label {
    flex: 1 1 180px;
  }

  .toolbar-controls button {
    flex: 1 1 120px;
  }
}
