@font-face {
  font-family: "Space Grotesk";
  src: url("/display/static/fonts/space-grotesk-latin.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 300 700;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/display/static/fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400 700;
}

:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #f0f3ef;
  --ink: #171b19;
  --ink-soft: #39423e;
  --muted: #68736d;
  --faint: #929c96;
  --line: #dde3de;
  --line-strong: #cbd4ce;
  --accent: #16775b;
  --accent-hover: #0f624a;
  --accent-soft: #e4f2ec;
  --accent-line: #acd4c4;
  --danger: #b13b31;
  --danger-soft: #fbeceb;
  --warning: #8b6914;
  --warning-soft: #faf4df;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 1px 2px rgba(18, 32, 25, .04), 0 6px 18px rgba(18, 32, 25, .035);
  --shadow-md: 0 16px 42px rgba(18, 32, 25, .09);
  --shell: 1160px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 7%, rgba(41, 137, 101, .07), transparent 25rem),
    var(--bg);
  font-family: "Space Grotesk", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.admin-page {
  background: #f4f6f3;
}

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

img {
  object-fit: cover;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

h1,
h2,
h3,
p,
dl,
dd,
figure {
  margin: 0;
}

h1,
h2,
h3,
strong {
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(calc(100% - 48px), var(--shell));
  margin-inline: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 11px 16px;
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius-sm);
  transform: translateY(-180%);
  transition: transform .2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgba(22, 119, 91, .34);
  outline-offset: 3px;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  border-bottom: 1px solid rgba(203, 212, 206, .74);
  background: rgba(247, 248, 245, .88);
  backdrop-filter: blur(18px);
}

.admin-header {
  background: rgba(244, 246, 243, .9);
}

.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 11px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.05em;
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: -.01em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: .14em;
}

.primary-nav,
.admin-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
}

.primary-nav a,
.back-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color .2s ease;
}

.primary-nav a:hover,
.back-link:hover {
  color: var(--ink);
}

.availability,
.admin-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.availability i,
.admin-identity i,
.detail-meta i,
.interactive-badge i {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 119, 91, .1);
}

.primary-btn,
.secondary-btn {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1;
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s var(--ease), box-shadow .2s ease;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(22, 119, 91, .18);
}

.primary-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 11px 26px rgba(22, 119, 91, .24);
  transform: translateY(-1px);
}

.secondary-btn {
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.secondary-btn:hover {
  color: var(--ink);
  border-color: #adb9b1;
  background: #fbfcfa;
}

.small-btn {
  min-height: 40px;
  padding-inline: 14px;
  border-radius: 10px;
  font-size: 13px;
}

.site-footer {
  margin-top: 112px;
  border-top: 1px solid var(--line);
}

.footer-inner {
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner strong {
  color: var(--ink-soft);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .09em;
}

.footer-inner p {
  margin-top: 5px;
}

.footer-inner a:hover {
  color: var(--ink);
}

/* Home */

.hero {
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr);
  align-items: center;
  gap: clamp(48px, 8vw, 104px);
  padding-block: 88px 96px;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero h1 {
  max-width: 760px;
  font-size: clamp(48px, 6.1vw, 82px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -.055em;
}

.hero-lead {
  max-width: 610px;
  margin-top: 28px;
  color: var(--muted);
  font-size: clamp(17px, 1.7vw, 20px);
  line-height: 1.8;
}

.hero-search {
  min-height: 62px;
  max-width: 650px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding: 0 14px 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.hero-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 119, 91, .09), var(--shadow-sm);
}

.search-icon {
  flex: 0 0 auto;
  color: var(--muted);
}

.search-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
}

.hero-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
}

.hero-search input::placeholder {
  color: #98a19c;
}

.hero-search input::-webkit-search-cancel-button {
  display: none;
}

.hero-search kbd {
  min-width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--faint);
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  box-shadow: 0 1px 0 #fff inset;
}

.clear-search {
  min-height: 44px;
  padding: 0 9px;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 36px;
}

.hero-stats div {
  min-width: 112px;
  padding-right: 28px;
}

.hero-stats div + div {
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.hero-stats dt {
  color: var(--faint);
  font-size: 12px;
}

.hero-stats dd {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 17px;
  font-weight: 600;
}

.hero-visual {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(203, 212, 206, .78);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 72% 24%, rgba(22, 119, 91, .12), transparent 11rem),
    linear-gradient(145deg, #f5f8f5, #eaf1ed);
}

.hero-visual::after {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 22px;
  pointer-events: none;
}

.algorithm-trace {
  position: absolute;
  inset: 44px 24px 46px;
  width: calc(100% - 48px);
  height: calc(100% - 90px);
  overflow: visible;
}

.algorithm-trace path {
  fill: none;
  stroke-linecap: round;
}

.trace-shadow {
  stroke: rgba(255, 255, 255, .86);
  stroke-width: 11;
}

.trace-path {
  stroke: var(--accent);
  stroke-width: 2.5;
}

.algorithm-trace circle {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2.5;
}

.algorithm-trace .trace-terminal {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 5;
}

.trace-label,
.trace-note {
  position: absolute;
  z-index: 2;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .08em;
}

.trace-start {
  left: 42px;
  bottom: 54px;
}

.trace-end {
  top: 68px;
  right: 36px;
  color: var(--accent);
}

.trace-note {
  right: 38px;
  bottom: 30px;
  color: var(--faint);
  letter-spacing: 0;
}

.library {
  padding-top: 62px;
  border-top: 1px solid var(--line);
}

.library-heading,
.section-title-row,
.admin-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
}

.library-heading h2,
.section-title-row h2,
.admin-section-heading h2 {
  font-size: clamp(34px, 4vw, 48px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.04em;
}

.result-status,
.admin-section-heading > span {
  color: var(--muted);
  font-size: 14px;
}

.filter-rail {
  display: flex;
  gap: 9px;
  margin-top: 36px;
  padding-bottom: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.filter-chip,
.status-tabs a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .68);
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}

.filter-chip span,
.status-tabs span {
  color: var(--faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.filter-chip:hover,
.filter-chip.is-active,
.status-tabs a:hover,
.status-tabs a.is-active {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.filter-chip.is-active span,
.status-tabs a.is-active span {
  color: rgba(255, 255, 255, .65);
}

.catalog {
  margin-top: 54px;
}

.category-section + .category-section {
  margin-top: 70px;
}

.category-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.category-heading h3 {
  font-size: 18px;
  letter-spacing: -.02em;
}

.category-heading span {
  color: var(--faint);
  font-size: 12px;
}

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

.project-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
  transition: transform .25s var(--ease), border-color .25s ease, box-shadow .25s ease;
}

.project-card:hover {
  z-index: 1;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.project-card:focus-within {
  outline: 3px solid rgba(22, 119, 91, .25);
  outline-offset: 3px;
}

.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  margin: 8px 8px 0;
  border-radius: 17px;
  background: var(--surface-soft);
}

.card-media img {
  width: 100%;
  height: 100%;
  filter: saturate(.83) contrast(.98);
  transition: transform .4s var(--ease), filter .3s ease;
}

.project-card:hover .card-media img {
  filter: saturate(.96) contrast(1);
  transform: scale(1.025);
}

.interactive-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  color: var(--ink-soft);
  border: 1px solid rgba(255, 255, 255, .76);
  border-radius: 999px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 600;
}

.interactive-badge i {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.card-content {
  padding: 22px 22px 20px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--faint);
  font-size: 11px;
}

.card-meta span:last-child {
  font-family: "JetBrains Mono", monospace;
}

.card-content h3 {
  margin-top: 12px;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: -.025em;
}

.card-content h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card-content p {
  min-height: 52px;
  margin-top: 10px;
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  line-height: 1.75;
}

.card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.card-action span:last-child {
  color: var(--accent);
  font-size: 18px;
  transition: transform .2s ease;
}

.project-card:hover .card-action span:last-child {
  transform: translateX(4px);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .54);
}

.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  color: var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 22px;
}

.empty-state h2,
.empty-state h3 {
  font-size: 21px;
}

.empty-state p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

/* Detail */

.detail-shell {
  padding-top: 32px;
}

.breadcrumb {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb a:hover {
  color: var(--ink);
}

.breadcrumb span[aria-hidden] {
  color: var(--line-strong);
}

.project-overview {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(420px, 1.12fr);
  gap: clamp(48px, 7vw, 88px);
  align-items: center;
  padding-block: 72px 64px;
}

.overview-content h1 {
  max-width: 620px;
  margin-top: 18px;
  font-size: clamp(46px, 6vw, 76px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -.055em;
}

.detail-category {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 600;
}

.detail-summary {
  max-width: 590px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.85;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.detail-meta dt,
.preview-meta dt {
  color: var(--faint);
  font-size: 11px;
}

.detail-meta dd,
.preview-meta dd {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.detail-meta dd {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-meta i {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.detail-media {
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.detail-media img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 21px;
  background: var(--surface-soft);
}

.detail-media figcaption {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: 13px;
  color: var(--faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.isolation-note {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}

.note-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: var(--accent);
  font-weight: 700;
}

.isolation-note strong {
  font-size: 14px;
}

.isolation-note p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.related-section {
  margin-top: 100px;
}

.section-title-row > a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.related-card {
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color .2s ease, transform .2s var(--ease), box-shadow .2s ease;
}

.related-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.related-media {
  width: 84px;
  height: 72px;
  overflow: hidden;
  border-radius: 11px;
  background: var(--surface-soft);
}

.related-media img {
  width: 100%;
  height: 100%;
}

.related-card span {
  color: var(--faint);
  font-size: 10px;
}

.related-card h3 {
  margin-top: 3px;
  font-size: 15px;
}

.related-card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.related-card p {
  display: none;
}

.related-arrow {
  padding-right: 8px;
  color: var(--accent) !important;
  font-size: 17px !important;
}

/* Admin */

.admin-page .site-footer {
  display: none;
}

.admin-shell {
  padding-block: 56px 90px;
}

.admin-intro {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 54px;
}

.admin-intro h1,
.edit-intro h1 {
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.045em;
}

.admin-intro > div > p:last-child,
.edit-intro > div > p:last-child {
  max-width: 620px;
  margin-top: 16px;
  color: var(--muted);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.admin-stats div {
  min-width: 92px;
  padding: 15px 18px;
}

.admin-stats div + div {
  border-left: 1px solid var(--line);
}

.admin-stats dt {
  color: var(--faint);
  font-size: 11px;
}

.admin-stats dd {
  margin-top: 3px;
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  line-height: 1.2;
}

.notice-box {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding: 12px 16px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 14px;
}

.notice-box span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}

.notice-box.success {
  color: #125e48;
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.notice-box.success span {
  color: #fff;
  background: var(--accent);
}

.notice-box.error {
  color: #8d2d27;
  border-color: #efc4c0;
  background: var(--danger-soft);
}

.notice-box.error span {
  color: #fff;
  background: var(--danger);
}

.admin-tools {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
  margin-top: 42px;
}

.tool-panel,
.edit-form-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.tool-panel {
  overflow: hidden;
}

.tool-panel summary {
  min-height: 86px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 15px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.tool-panel summary::-webkit-details-marker {
  display: none;
}

.tool-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.tool-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 20px;
}

.tool-panel summary strong,
.tool-panel summary small {
  display: block;
}

.tool-panel summary strong {
  font-size: 15px;
}

.tool-panel summary small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.summary-arrow {
  color: var(--faint);
  font-size: 20px;
  transition: transform .2s ease;
}

.tool-panel[open] .summary-arrow {
  transform: rotate(180deg);
}

.tool-content {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 19px;
}

.span-2 {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field textarea,
.field select,
.inline-category-form input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: #fbfcfa;
  font-weight: 400;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.field textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.65;
}

.field select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 21px, calc(100% - 12px) 21px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.inline-category-form input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(22, 119, 91, .08);
}

.field small {
  color: var(--faint);
  font-size: 11px;
  font-weight: 400;
}

.file-field input[type="file"] {
  padding: 6px;
}

.file-field input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  padding: 0 12px;
  color: var(--ink-soft);
  border: 0;
  border-radius: 7px;
  background: var(--surface-soft);
  cursor: pointer;
  font-weight: 600;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.category-content {
  padding-top: 18px;
}

.category-editor {
  display: grid;
  gap: 9px;
}

.inline-category-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px auto;
  gap: 8px;
}

.inline-category-form input {
  min-height: 40px;
  padding-block: 7px;
  background: #fff;
}

.add-category-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px auto;
  align-items: end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.compact-field input {
  text-align: center;
}

.project-admin-section {
  margin-top: 76px;
}

.admin-section-heading h2 {
  font-size: 34px;
}

.status-tabs {
  display: flex;
  gap: 8px;
  margin-top: 28px;
  padding-bottom: 6px;
  overflow-x: auto;
}

.status-tabs a {
  min-height: 40px;
  padding-inline: 14px;
  font-size: 13px;
}

.admin-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.admin-item {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 22px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.admin-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.admin-thumb {
  min-height: 130px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-soft);
}

.admin-thumb img {
  width: 100%;
  height: 100%;
}

.admin-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 4px 0;
}

.admin-item-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.item-kicker {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.admin-item-title h3 {
  margin-top: 4px;
  font-size: 20px;
  letter-spacing: -.02em;
}

.status-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.live {
  color: #126048;
  background: var(--accent-soft);
}

.status-badge.draft {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-badge.trash {
  color: #922f28;
  background: var(--danger-soft);
}

.admin-item-main > p {
  max-width: 700px;
  margin-top: 10px;
  color: var(--muted);
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 13px;
}

.admin-item-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-top: auto;
  padding-top: 16px;
}

.updated-at {
  color: var(--faint);
  font-size: 11px;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.row-actions form {
  display: inline-flex;
}

.text-action {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.text-action:hover {
  color: var(--accent);
}

.button-action {
  padding: 0;
}

.danger-action {
  color: var(--danger);
}

.admin-empty {
  min-height: 240px;
}

/* Edit */

.edit-shell {
  padding-top: 28px;
}

.edit-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 36px;
  margin-top: 28px;
}

.edit-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  margin-top: 42px;
}

.preview-panel {
  position: sticky;
  top: 104px;
  overflow: hidden;
}

.preview-image {
  aspect-ratio: 16 / 10;
  margin: 8px;
  overflow: hidden;
  border-radius: 17px;
  background: var(--surface-soft);
}

.preview-image img {
  width: 100%;
  height: 100%;
}

.preview-copy {
  padding: 20px 20px 17px;
}

.preview-copy h2 {
  margin-top: 12px;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.preview-copy p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.preview-meta {
  display: grid;
  gap: 13px;
  padding: 17px 20px 20px;
  border-top: 1px solid var(--line);
}

.preview-meta dd {
  overflow-wrap: anywhere;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.edit-form-panel {
  padding: 28px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  font-size: 22px;
  letter-spacing: -.02em;
}

.panel-heading span {
  color: var(--faint);
  font-size: 11px;
}

@media (max-width: 980px) {
  .hero {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 58px;
    padding-block: 72px 84px;
  }

  .hero-content {
    max-width: 760px;
  }

  .hero-visual {
    min-height: 330px;
  }

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

  .project-overview {
    grid-template-columns: 1fr;
    gap: 48px;
    padding-top: 54px;
  }

  .overview-content {
    max-width: 720px;
  }

  .detail-media {
    max-width: 760px;
  }

  .admin-intro {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .admin-stats {
    width: 100%;
  }

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

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

  .preview-panel {
    position: static;
    display: grid;
    grid-template-columns: 300px 1fr;
  }

  .preview-meta {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(calc(100% - 36px), var(--shell));
  }

  .header-inner {
    min-height: 68px;
  }

  .brand-copy small,
  .availability,
  .admin-identity {
    display: none;
  }

  .primary-nav,
  .admin-nav {
    gap: 10px;
  }

  .primary-nav > a:not(.back-link) {
    display: none;
  }

  .hero {
    gap: 44px;
    padding-block: 58px 70px;
  }

  .hero h1 {
    font-size: clamp(44px, 13.4vw, 64px);
  }

  .hero-lead {
    margin-top: 22px;
    font-size: 17px;
  }

  .hero-search {
    min-height: 58px;
    margin-top: 30px;
  }

  .hero-search kbd {
    display: none;
  }

  .hero-stats div {
    min-width: 88px;
    padding-right: 17px;
  }

  .hero-stats div + div {
    padding-left: 17px;
  }

  .hero-visual {
    min-height: 270px;
    border-radius: var(--radius-lg);
  }

  .algorithm-trace {
    inset: 28px 10px 38px;
    width: calc(100% - 20px);
    height: calc(100% - 66px);
  }

  .trace-start {
    left: 27px;
    bottom: 37px;
  }

  .trace-end {
    top: 41px;
    right: 24px;
  }

  .trace-note {
    display: none;
  }

  .library {
    padding-top: 48px;
  }

  .library-heading,
  .section-title-row,
  .admin-section-heading {
    align-items: start;
  }

  .library-heading h2,
  .section-title-row h2 {
    font-size: 36px;
  }

  .result-status {
    padding-top: 25px;
    white-space: nowrap;
  }

  .filter-rail {
    margin-top: 28px;
    margin-right: -18px;
    padding-right: 18px;
  }

  .catalog {
    margin-top: 42px;
  }

  .category-section + .category-section {
    margin-top: 54px;
  }

  .card-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }

  .card-content p {
    min-height: auto;
  }

  .site-footer {
    margin-top: 82px;
  }

  .footer-inner {
    min-height: 140px;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
  }

  .detail-shell {
    padding-top: 18px;
  }

  .project-overview {
    gap: 38px;
    padding-block: 38px 44px;
  }

  .overview-content h1 {
    font-size: clamp(42px, 13vw, 60px);
  }

  .detail-summary {
    font-size: 16px;
  }

  .detail-actions a {
    flex: 1 1 150px;
  }

  .detail-meta {
    gap: 12px;
  }

  .detail-media {
    border-radius: 20px;
  }

  .detail-media img {
    border-radius: 14px;
  }

  .isolation-note {
    align-items: flex-start;
  }

  .related-section {
    margin-top: 72px;
  }

  .section-title-row > a {
    white-space: nowrap;
  }

  .admin-nav .small-btn {
    font-size: 0;
  }

  .admin-nav .small-btn span {
    font-size: 16px;
  }

  .admin-shell {
    padding-block: 40px 64px;
  }

  .admin-intro {
    gap: 30px;
  }

  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-stats div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .admin-stats div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .tool-panel summary {
    min-height: 78px;
  }

  .tool-content,
  .edit-form-panel {
    padding: 20px;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .add-category-form {
    grid-template-columns: 1fr 82px;
  }

  .add-category-form .secondary-btn {
    grid-column: 1 / -1;
  }

  .admin-item {
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 14px;
  }

  .admin-thumb {
    min-height: 96px;
  }

  .admin-item-main {
    padding-top: 3px;
  }

  .admin-item-title {
    gap: 8px;
  }

  .admin-item-title h3 {
    font-size: 17px;
  }

  .admin-item-main > p {
    margin-top: 6px;
    -webkit-line-clamp: 1;
  }

  .admin-item-footer {
    grid-column: 1 / -1;
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .edit-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-panel {
    display: block;
  }

  .preview-image {
    aspect-ratio: 16 / 9;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
}

@media (max-width: 440px) {
  .brand-copy strong {
    font-size: 14px;
  }

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

  .hero-stats div,
  .hero-stats div + div {
    min-width: 0;
    padding-inline: 10px;
  }

  .hero-stats div:first-child {
    padding-left: 0;
  }

  .hero-stats dd {
    font-size: 14px;
  }

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

  .admin-thumb {
    aspect-ratio: 16 / 8;
  }

  .admin-item-main {
    padding: 5px 6px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Minimal home toolbar */
.home-page .header-inner {
  min-height: 64px;
}

.home-page .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
}

.home-page .library {
  padding-top: 48px;
  border-top: 0;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  align-items: end;
  gap: 48px;
}

.library-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.library-title h1 {
  font-size: clamp(36px, 4vw, 48px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.045em;
}

.library-toolbar .hero-search {
  width: 100%;
  min-height: 54px;
  margin-top: 0;
  justify-self: end;
}

.home-page .filter-rail {
  margin-top: 28px;
}

.home-page .catalog {
  margin-top: 36px;
}

@media (max-width: 720px) {
  .home-page .header-inner {
    min-height: 60px;
  }

  .home-page .library {
    padding-top: 28px;
  }

  .library-toolbar {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .library-title {
    justify-content: space-between;
    gap: 24px;
  }

  .library-title h1 {
    font-size: 34px;
  }

  .library-toolbar .hero-search {
    min-height: 56px;
    margin-top: 0;
  }

  .library-title .result-status {
    padding-top: 0;
  }

  .home-page .filter-rail {
    margin-top: 20px;
  }

  .home-page .catalog {
    margin-top: 32px;
  }
}
