:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #171717;
  --muted: #62615c;
  --line: #dfd9cf;
  --teal: #0f766e;
  --blue: #2563eb;
  --rose: #c02659;
  --gold: #b7791f;
  --shadow: 0 16px 40px rgba(24, 24, 27, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 330px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.36);
  outline-offset: 3px;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2.4rem;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 1.42rem;
  line-height: 1.2;
}

h3 {
  font-size: 1rem;
  line-height: 1.28;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(23, 23, 23, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.stats strong {
  color: var(--ink);
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.controls,
.content-band {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 28px rgba(24, 24, 27, 0.06);
}

.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px;
  backdrop-filter: blur(18px);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-box span {
  color: var(--teal);
  font-size: 1.25rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-box input::placeholder {
  color: #908b82;
}

.icon-button,
.chip,
.detail-button,
.copy-button,
.favorite-button,
.drawer-close {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.icon-button:hover,
.chip:hover,
.detail-button:hover,
.copy-button:hover,
.favorite-button:hover,
.drawer-close:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 10px 22px rgba(24, 24, 27, 0.08);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 98px;
  min-height: 46px;
  padding: 0 14px;
  font-weight: 800;
}

.icon-button[aria-pressed="true"] {
  border-color: rgba(183, 121, 31, 0.48);
  background: #fff7e6;
  color: #8a4b00;
}

.filter-row {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-top: 12px;
  scrollbar-color: rgba(15, 118, 110, 0.55) transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  flex: 0 0 auto;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.chip::before {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chip-color, var(--teal));
  content: "";
}

.chip.is-active {
  border-color: var(--chip-color, var(--teal));
  background: color-mix(in srgb, var(--chip-color, var(--teal)) 12%, #ffffff);
  color: var(--ink);
}

.content-band {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.sort-control select {
  min-height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
  gap: 14px;
  min-width: 0;
}

.role-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 490px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(24, 24, 27, 0.06);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.role-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--agent-color, var(--teal)) 44%, var(--line));
  box-shadow: var(--shadow);
}

.role-image {
  position: relative;
  aspect-ratio: 16 / 10.5;
  min-width: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #ece7dc;
}

.role-image img {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  object-fit: cover;
}

.category-pill {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #111827;
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.card-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.card-title-row h3 {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.english-name {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.favorite-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  color: var(--gold);
  font-size: 1.05rem;
  line-height: 1;
}

.favorite-button.is-active {
  border-color: rgba(183, 121, 31, 0.5);
  background: #fff7e6;
}

.description {
  display: -webkit-box;
  min-height: 64px;
  margin-bottom: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.skill-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-tag {
  max-width: 100%;
  padding: 5px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--agent-color, var(--teal)) 10%, #ffffff);
  color: color-mix(in srgb, var(--agent-color, var(--teal)) 62%, #111827);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: grid;
  padding: 0 14px 14px;
}

.detail-button {
  min-height: 42px;
  padding: 0 14px;
  background: #171717;
  color: #ffffff;
  font-weight: 900;
}

.detail-button:hover {
  border-color: #171717;
  background: color-mix(in srgb, var(--agent-color, var(--teal)) 72%, #111827);
  color: #ffffff;
}

.empty-state {
  padding: 56px 20px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 16, 18, 0.42);
  backdrop-filter: blur(4px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(720px, 100%);
  height: 100dvh;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -26px 0 70px rgba(15, 23, 42, 0.24);
}

.drawer-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 18px;
}

.drawer-close {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.92);
  font-size: 1.6rem;
  line-height: 1;
}

.drawer-hero {
  display: grid;
  grid-template-columns: minmax(180px, 270px) 1fr;
  gap: 18px;
  align-items: stretch;
  margin-top: 8px;
}

.drawer-hero img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f3ec;
  object-fit: contain;
}

.drawer-title {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.drawer-title h2 {
  font-size: 1.7rem;
  overflow-wrap: anywhere;
}

.drawer-title p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.meta-line span,
.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--agent-color, var(--teal)) 10%, #ffffff);
  color: color-mix(in srgb, var(--agent-color, var(--teal)) 64%, #111827);
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
}

.drawer-section {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.drawer-section h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.drawer-section ul,
.drawer-section ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: #343434;
  line-height: 1.58;
}

.drawer-section li {
  overflow-wrap: anywhere;
}

.prompt-box {
  display: grid;
  gap: 12px;
}

.prompt-box pre {
  max-height: 240px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #151515;
  color: #f6f1e8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.copy-button {
  justify-self: start;
  min-height: 40px;
  padding: 0 13px;
  background: #0f766e;
  color: #ffffff;
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 60;
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #171717;
  color: #ffffff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

[hidden] {
  display: none !important;
}

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

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    justify-content: flex-start;
  }

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

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

  .drawer-hero img {
    min-height: auto;
    aspect-ratio: 16 / 10.5;
  }
}

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

  h1 {
    font-size: 1.95rem;
  }

  .content-band,
  .controls,
  .drawer-scroll {
    padding: 12px;
  }

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

  .role-card {
    min-height: auto;
  }

  .stats span {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
