/* ============================================================
   A-GET — styles
   Light consumer-store look: warm neutral background, indigo accent,
   amber for ratings. Instrument Serif for display, Plus Jakarta Sans for UI.
   ============================================================ */
:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-2: #F4F1EC;
  --ink: #1B1916;
  --ink-2: #45413A;
  --muted: #7A746A;
  --line: #EAE4DA;
  --line-2: #DCD4C7;

  --accent: #4F46E5;
  --accent: oklch(0.55 0.17 268);
  --accent-deep: #3F37C9;
  --accent-deep: oklch(0.46 0.17 268);
  --accent-soft: #EEF0FF;
  --accent-soft: oklch(0.96 0.025 268);
  --accent-line: oklch(0.86 0.06 268);

  --amber: #C27C0E;
  --amber-soft: #FDF3DE;
  --green: #1C7F54;
  --green-soft: #E4F4EA;
  --red: #B93A33;
  --red-soft: #FCE9E7;

  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(27, 25, 22, .06);
  --shadow: 0 1px 2px rgba(27, 25, 22, .05), 0 10px 30px -14px rgba(27, 25, 22, .22);
  --shadow-lg: 0 30px 80px -20px rgba(27, 25, 22, .35);

  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
:not(pre) > code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; color: var(--ink-2); }
mark { background: #FFE9A8; color: inherit; border-radius: 3px; padding: 0 1px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.wrap.wide { max-width: 1440px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px;
  border: 1px solid transparent; background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn.big { height: 52px; padding: 0 28px; font-size: 16px; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-deep); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--ink); }
.btn.ghost:hover { background: var(--surface); border-color: var(--ink-2); }
.btn.danger, .danger { color: var(--red); }
.btn.ghost.danger:hover { border-color: var(--red); background: var(--red-soft); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 20px; height: 66px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font: 26px/1 var(--serif); padding-top: 3px;
  position: relative; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.brand-mark::after {
  content: ''; position: absolute; right: -3px; top: -3px; width: 11px; height: 11px;
  border-radius: 50%; background: #F5B94A; border: 2px solid var(--bg);
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand-name span { color: var(--accent); }
.brand.small .brand-mark { width: 26px; height: 26px; font-size: 20px; border-radius: 8px; }
.brand.small .brand-name { font-size: 15px; }
.badge-backstage {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--ink); color: #fff; border-radius: 6px; padding: 3px 8px; margin-left: 4px;
}
.top-search {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.top-search:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.top-search input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; color: var(--ink); }
body.is-home .top-search { visibility: hidden; }
.topnav { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.mode-banner { background: var(--amber-soft); border-bottom: 1px solid #F1DDB1; font-size: 13px; color: #6B4A0B; }
.mode-banner .wrap { padding-top: 9px; padding-bottom: 9px; }
.mode-banner code { background: rgba(255,255,255,.6); }

/* ---------- hero ---------- */
.hero { padding: 64px 0 40px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ''; position: absolute; inset: -40% -10% auto; height: 620px; z-index: -1;
  background:
    radial-gradient(40% 50% at 30% 40%, oklch(0.93 0.05 268 / .7), transparent 70%),
    radial-gradient(35% 45% at 72% 35%, oklch(0.95 0.06 75 / .7), transparent 70%);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.hero h1 {
  font: 400 clamp(46px, 7.4vw, 88px)/.95 var(--serif); letter-spacing: -.02em; margin: 18px 0 30px;
}
.hero h1 em { color: var(--accent); }
.search {
  max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  height: 64px; padding: 0 12px 0 22px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  color: var(--muted); transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 5px var(--accent-soft); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 17px; color: var(--ink); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd {
  font: 600 12px var(--mono); color: var(--muted); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 6px; padding: 3px 8px; background: var(--bg);
}
.suggest { margin-top: 18px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; font-size: 13px; }
.suggest span { color: var(--muted); margin-right: 2px; }
.suggest button {
  border: 1px solid var(--line); background: rgba(255,255,255,.7); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; color: var(--ink-2); font-weight: 500;
}
.suggest button:hover { border-color: var(--accent-line); color: var(--accent); background: var(--surface); }

/* ---------- chips / filters ---------- */
.results { padding-bottom: 72px; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 -2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--ink-2);
  transition: all .15s;
}
.chip b { font-weight: 600; font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.on b { background: rgba(255,255,255,.18); color: #fff; }
.chip.zero { opacity: .5; }
.chip.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.subs { padding-top: 0; align-items: center; }
.subs-label { flex: none; font-size: 13px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.subs .chip.on { background: var(--accent); border-color: var(--accent); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 26px 0 16px; flex-wrap: wrap; }
.toolbar h2 { font: 400 30px/1.1 var(--serif); }
.tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.select { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.select select, select {
  appearance: none; -webkit-appearance: none;
  height: 36px; padding: 0 34px 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%237A746A' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer;
}
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .2s; flex: none;
}
.toggle span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- icons ---------- */
.icon {
  --tile: #EEF0FF;
  flex: none; display: grid; place-items: center; overflow: hidden;
  background: var(--tile); border-radius: 22%; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(27,25,22,.06);
}
.icon img { width: 100%; height: 100%; object-fit: cover; }
.icon.sm { width: 36px; height: 36px; font-size: 19px; border-radius: 10px; }
.icon.md { width: 56px; height: 56px; font-size: 29px; }
.icon.lg { width: 72px; height: 72px; font-size: 38px; }
.icon.xl { width: 112px; height: 112px; font-size: 60px; border-radius: 26px; }

/* ---------- featured ---------- */
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 26px 0 14px; flex-wrap: wrap; }
.section-head h2 { font: 400 30px/1.1 var(--serif); }
.section-head p { color: var(--muted); font-size: 14px; }
.featured { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feat {
  display: flex; gap: 16px; align-items: flex-start; padding: 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); position: relative;
  text-decoration: none !important; transition: transform .15s, box-shadow .2s, border-color .2s;
}
.feat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.feat .rank { position: absolute; top: 12px; right: 18px; font: 400 44px/1 var(--serif); color: var(--line-2); }
.feat h3 { font-size: 17px; display: flex; align-items: center; gap: 6px; padding-right: 26px; }
.feat p { color: var(--ink-2); font-size: 14px; margin: 5px 0 10px; }
.feat-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.grid.one { grid-template-columns: 1fr; }
.card {
  display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto 1fr auto; gap: 12px 14px;
  padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none !important; min-height: 196px;
  transition: transform .15s, box-shadow .2s, border-color .2s;
}
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.card-main { min-width: 0; align-self: center; }
.card h3 { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.card-pub { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-tag { grid-column: 1 / -1; color: var(--ink-2); font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb i { font-style: normal; color: var(--line-2); margin: 0 2px; }
.card-stats { display: inline-flex; gap: 12px; flex: none; }
.card-stats > span { display: inline-flex; align-items: center; gap: 4px; }
.rating { display: inline-flex; align-items: center; gap: 4px; color: var(--amber); font-weight: 700; }
.verified { color: var(--accent); flex: none; }

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: rgba(255,255,255,.5); }
.empty h2, .empty h3 { font: 400 30px var(--serif); margin-bottom: 8px; }
.empty p { color: var(--muted); margin-bottom: 18px; }
.loading { padding: 80px 24px; text-align: center; color: var(--muted); }

/* ---------- agent page ---------- */
.detail { padding-top: 22px; padding-bottom: 80px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 22px; }
.back:hover { color: var(--ink); text-decoration: none; }
.detail-head { display: grid; grid-template-columns: auto 1fr auto; gap: 28px; align-items: center; }
.detail-title .crumb { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.detail-title .crumb a { color: var(--muted); }
.detail-title .crumb a:hover { color: var(--accent); }
.detail-title h1 { font: 400 clamp(40px, 5.4vw, 60px)/1 var(--serif); margin: 6px 0 8px; }
.lede { font-size: 18px; color: var(--ink-2); max-width: 640px; }
.pub { margin-top: 10px; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.verified-label { color: var(--accent); font-size: 13px; }
.detail-cta { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.stats {
  list-style: none; margin: 30px 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.stats li { padding: 16px 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stats li + li { border-left: 1px solid var(--line); }
.stats b { font-size: 20px; font-weight: 700; text-transform: capitalize; }
.stats span { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.stats li:first-child span svg { color: var(--amber); }

.detail-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 44px; align-items: start; }
.detail-main section { margin-bottom: 42px; }
.detail-main h2 { font: 400 30px/1.1 var(--serif); margin-bottom: 14px; }
.prose p { margin-bottom: 12px; color: var(--ink-2); font-size: 16px; max-width: 70ch; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tags a { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 4px 11px; }
.tags a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.needs { list-style: none; padding: 0; margin: 16px 0 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.needs li { display: flex; gap: 14px; padding: 15px 18px; align-items: flex-start; }
.needs li + li { border-top: 1px solid var(--line); }
.need-ic { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.need-ic.secret { background: var(--amber-soft); color: var(--amber); }
.needs b { font-weight: 700; margin-right: 8px; }
.needs code { font-size: 12px; margin-left: 4px; }
.needs p { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-right: 4px; vertical-align: 1px; }
.pill.req { background: var(--accent-soft); color: var(--accent-deep); }
.pill.ghost { background: transparent; border: 1px solid var(--line); }
.pill.secret { background: var(--amber-soft); color: var(--amber); margin-left: 8px; }
.note-box { background: var(--amber-soft); border: 1px solid #F1DDB1; border-radius: var(--radius-md); padding: 16px 18px; color: #5B420F; }

details.code { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
details.code summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 18px; font-family: var(--mono); font-weight: 600; font-size: 14px;
}
details.code summary::-webkit-details-marker { display: none; }
details.code summary::before { content: '▸'; margin-right: 8px; color: var(--muted); transition: transform .15s; display: inline-block; }
details.code[open] summary::before { transform: rotate(90deg); }
details.code summary span:first-child { display: flex; }
details.code summary .muted { font-family: var(--sans); font-weight: 500; font-size: 13px; }
.code-actions { display: flex; justify-content: flex-end; padding: 0 12px 8px; }
details.code pre { margin: 0; max-height: 460px; overflow: auto; background: #1C1B22; color: #E6E3F5; padding: 18px 20px; font-size: 13px; line-height: 1.6; tab-size: 4; }

.comment-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.comment-form .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.comment-form .row.end { justify-content: flex-end; }
.comment-form input[name=author] { flex: 1; min-width: 160px; max-width: 280px; }
.comment-form textarea { resize: vertical; min-height: 70px; }
.stars-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.stars-input input { position: absolute; opacity: 0; pointer-events: none; }
.stars-input label { font-size: 24px; color: var(--line-2); cursor: pointer; transition: color .1s, transform .1s; line-height: 1; }
.stars-input label:hover, .stars-input label:hover ~ label, .stars-input input:checked ~ label { color: #F2B233; }
.stars-input label:active { transform: scale(.9); }
.stars-input input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
.comments { list-style: none; padding: 0; margin: 0; }
.comments li { padding: 16px 0; border-top: 1px solid var(--line); }
.comments li:first-child { border-top: 0; }
.c-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-deep); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.c-stars { color: #F2B233; letter-spacing: 1px; font-size: 14px; }
.c-stars i { font-style: normal; color: var(--line-2); }
.comments p { color: var(--ink-2); padding-left: 40px; }
.empty-note { padding: 10px 0 !important; }

.detail-side { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 16px; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.side-card.soft { background: var(--accent-soft); border-color: var(--accent-line); }
.side-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 12px; }
.side-card dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; margin: 0; font-size: 14px; }
.side-card dt { color: var(--muted); }
.side-card dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.howto { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); }

/* ---------- forms (shared) ---------- */
input[type=text], input[type=search], input[type=email], input[type=url], input[type=number], input[type=password], input:not([type]), textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface); outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: 0; }
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #A9A297; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.help.block { margin: 0 0 14px; }
.req-star { color: var(--red); margin-left: 3px; }
.opt { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 8px; }

/* ---------- install dialog ---------- */
dialog.install {
  width: min(560px, calc(100vw - 24px)); max-height: min(88vh, 860px); padding: 0;
  border: 0; border-radius: 24px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.install[open] { display: flex; animation: pop .22s cubic-bezier(.2, .9, .3, 1.2); }
dialog::backdrop { background: rgba(27, 25, 22, .42); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.dlg { display: flex; flex-direction: column; width: 100%; max-height: inherit; }
.dlg-head { display: flex; align-items: center; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font: 400 28px/1.1 var(--serif); margin-top: 2px; }
.dlg-head .x { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.dlg-head .x:hover { background: var(--line); color: var(--ink); }
.dlg-body { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.intro { color: var(--ink-2); }
.field label { display: flex; align-items: center; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field.bool .toggle { font-weight: 700; color: var(--ink); }
.field .err-msg { display: none; color: var(--red); font-size: 12.5px; font-weight: 600; margin-top: 5px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.field.invalid .err-msg { display: block; }
.secret-wrap { position: relative; }
.secret-wrap input { padding-right: 46px; font-family: var(--mono); }
.reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.reveal:hover, .reveal.on { color: var(--accent); background: var(--accent-soft); }
.privacy { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #1D5B41; background: var(--green-soft); border-radius: 12px; padding: 11px 14px; }
.privacy svg { flex: none; margin-top: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.dlg-foot { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--bg); }
.dlg-foot > :first-child { margin-right: auto; }
.progress { font-size: 13px; color: var(--muted); font-weight: 600; }
.done-mark { width: 64px; height: 64px; margin: 6px auto 0; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green); animation: pop .35s cubic-bezier(.2, .9, .3, 1.4); }
.done-title { text-align: center; font: 400 30px/1.1 var(--serif); }
.steps { margin: 4px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; color: var(--ink-2); }
.steps b { color: var(--ink); }
.cmd { display: flex; align-items: center; gap: 8px; margin-top: 8px; background: #1C1B22; border-radius: 10px; padding: 6px 6px 6px 14px; }
.cmd code { flex: 1; background: none !important; color: #E6E3F5 !important; padding: 0 !important; overflow-x: auto; white-space: nowrap; }
.cmd .btn.ghost { color: #E6E3F5; border-color: #3A3847; }
.cmd .btn.ghost:hover { background: #2A2833; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: 13px; }
.footer-in { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-in a { margin-left: auto; font-weight: 600; }

/* ============================================================
   Backstage
   ============================================================ */
body.admin .footer { display: none; }
.backstage { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 28px; padding-top: 24px; padding-bottom: 60px; align-items: start; }
.bs-list { position: sticky; top: 90px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; gap: 10px; }
.bs-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 0; }
.bs-list-head h2 { font-size: 16px; }
.bs-list input[type=search] { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.agent-list { list-style: none; padding: 0; margin: 0 -6px; overflow-y: auto; }
.agent-list button {
  width: 100%; display: flex; gap: 10px; align-items: center; padding: 8px; border: 0; background: transparent; border-radius: 12px; text-align: left; cursor: pointer;
}
.agent-list button:hover { background: var(--surface-2); }
.agent-list button.on { background: var(--accent-soft); }
.agent-list button > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agent-list b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-list small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-list .dl { flex: none; font-weight: 600; }
.pad { padding: 10px; }

.editor-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.editor-head h1 { font: 400 44px/1 var(--serif); margin-top: 6px; }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }
.panel { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 20px 22px 22px; margin: 0 0 18px; min-width: 0; }
.panel legend { float: left; width: 100%; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; margin-bottom: 16px; padding: 0; }
.panel legend + * { clear: both; }
.step { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 13px; }
.f { flex: 1; min-width: 0; margin-bottom: 14px; }
.f.sm { flex: 0 0 170px; }
.f.end { display: flex; align-items: flex-end; }
.f > label:not(.toggle):not(.btn) { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.f-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.f-row.tight { gap: 8px; align-items: center; margin-bottom: 8px; }
.check-f { display: flex; align-items: center; padding-top: 30px; }
.bad { border-color: var(--red) !important; box-shadow: 0 0 0 4px var(--red-soft) !important; }
.file-btn { cursor: pointer; }
.code-input { font-family: var(--mono); font-size: 13px; background: #1C1B22; color: #E6E3F5; border-color: #1C1B22; min-height: 260px; tab-size: 4; }
.code-input::placeholder { color: #7B7890; }
.code-input:focus { border-color: var(--accent); }

.icon-edit { display: flex; gap: 16px; align-items: flex-start; }
.icon-controls { flex: 1; min-width: 0; }
.icon-controls input[name=icon] { width: 140px; flex: none; font-size: 18px; }
.color { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.color input { width: 42px; height: 42px; border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; }
.emoji-picks { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.emoji-picks button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
.emoji-picks button:hover { border-color: var(--accent); background: var(--accent-soft); }

.param-head, .param-main { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(140px, 1.4fr) 170px 44px auto; gap: 8px; align-items: center; }
.param-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 2px 6px; }
.param { border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 8px; background: var(--bg); }
.param input { min-height: 38px; padding: 7px 10px; font-size: 14px; }
.param select { height: 38px; width: 100%; font-size: 13px; }
.p-key { font-family: var(--mono); font-size: 13px !important; }
.p-req { display: grid; place-items: center; cursor: pointer; }
.p-req input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); cursor: pointer; }
.p-actions { display: flex; gap: 0; }
.param-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.param-more .wide, .param-more .p-options { grid-column: 1 / -1; }
.param-add { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.param-add .help { margin: 0 0 0 6px; }

.editor-side .sticky { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 12px; }
.side-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
.form-preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow: auto; }
.fp span { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.fp i { color: var(--red); font-style: normal; margin-left: 2px; }
.fp-input { height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; display: flex; align-items: center; font-size: 13px; color: #A9A297; overflow: hidden; white-space: nowrap; }
.fp-input.secret { font-family: var(--mono); letter-spacing: 2px; }
.fp-input.textarea { height: 52px; align-items: flex-start; padding-top: 7px; }
.fp-input.boolean { border: 0; padding: 0; color: var(--ink-2); }
.mini-comments { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.mini-comments li { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; }
#statsBox h3 + dl + h3 { margin-top: 18px; }

.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 240px; z-index: 30; display: flex; flex-direction: column; }
.menu-pop button, .menu-pop label { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; }
.menu-pop button:hover, .menu-pop label:hover { background: var(--surface-2); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side .sticky { position: static; }
}
@media (max-width: 960px) {
  .featured { grid-template-columns: 1fr; }
  .detail-body { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .backstage { grid-template-columns: 1fr; }
  .bs-list { position: static; max-height: 320px; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .topbar-in { gap: 12px; height: 60px; }
  .brand-name { font-size: 17px; }
  .top-search { display: none; }
  body:not(.is-home) .top-search { display: flex; visibility: visible; }
  .topnav .btn { padding: 0 12px; }
  .hero { padding: 40px 0 26px; }
  .search { height: 56px; padding-left: 16px; }
  .search input { font-size: 16px; }
  .search kbd { display: none; }
  .detail-head { grid-template-columns: auto 1fr; gap: 16px 18px; }
  .icon.xl { width: 80px; height: 80px; font-size: 44px; border-radius: 20px; }
  .detail-cta { grid-column: 1 / -1; align-items: stretch; }
  .detail-cta .btn { width: 100%; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stats li:nth-child(4) { border-left: 0; }
  .stats li:nth-child(n+4) { border-top: 1px solid var(--line); }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .param-head { display: none; }
  .param-main { grid-template-columns: 1fr 1fr; }
  .param-main .p-req { justify-content: start; }
  .p-actions { justify-content: flex-end; }
  .param-more { grid-template-columns: 1fr; }
  .editor-head h1 { font-size: 36px; }
  .f.sm { flex-basis: 100%; }
  .check-f { padding-top: 0; }
  .dlg-foot { flex-wrap: wrap; }
  .dlg-foot .progress { width: 100%; }
  .comments p { padding-left: 0; }
}
@media (max-width: 420px) {
  .topnav .btn { font-size: 12px; }
  .brand-mark { width: 30px; height: 30px; font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- fixes ---------- */
.search input, .top-search input { border: 0 !important; box-shadow: none !important; min-height: 0; padding: 0; background: transparent; }
details.code summary { justify-content: flex-start; }
details.code summary .muted { margin-left: auto; }
.param-head, .param-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 138px 30px auto; gap: 6px; }
.p-actions .icon-btn { width: 26px; height: 30px; }
@media (max-width: 760px) {
  .param-head, .param-main { grid-template-columns: 1fr 1fr; }
}

/* ---------- code upload ---------- */
.upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-file { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; padding: 8px 8px 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.upload-file > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.upload-file b { font-family: var(--mono); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file small { color: var(--muted); font-size: 12px; }
.file-ic { width: 36px; height: 36px; border-radius: 9px; background: #1C1B22; color: #E6E3F5; display: grid; place-items: center; font: 700 11px var(--mono); flex: none; }

/* ---------- login ---------- */
body.login { background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 40% at 25% 30%, oklch(0.93 0.05 268 / .8), transparent 70%),
    radial-gradient(35% 40% at 78% 70%, oklch(0.95 0.06 75 / .8), transparent 70%);
}
.login-card { position: relative; z-index: 1; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 34px 30px 28px; }
.login-card .brand { margin-bottom: 26px; }
.login-card h1 { font: 400 40px/1 var(--serif); margin-bottom: 6px; }
.login-card > p { color: var(--muted); margin-bottom: 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-err { display: none; background: var(--red-soft); color: var(--red); font-size: 13.5px; font-weight: 600; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.login-err.show { display: block; }
.login-foot { margin-top: 20px; font-size: 12.5px; color: var(--muted); text-align: center; }
html.auth-pending body { visibility: hidden; }
@media (max-width: 520px) { .topnav .signout { display: none; } }
.upload { clear: both; }

/* ---------- backstage tabs ---------- */
.bs-tabs { display: flex; gap: 4px; margin-left: 12px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.bs-tabs a { padding: 6px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); text-decoration: none !important; white-space: nowrap; }
.bs-tabs a:hover { color: var(--ink); background: rgba(255,255,255,.6); }
.bs-tabs a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.panel select { width: 100%; height: 42px; }
.panel select:disabled { opacity: .6; cursor: not-allowed; }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; background: transparent !important; color: var(--muted) !important; }

.bs-page { padding-top: 28px; padding-bottom: 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font: 400 44px/1 var(--serif); margin-top: 6px; }
.page-head h1 .muted { font-size: 28px; }
.page-head p.muted { max-width: 560px; margin-top: 10px; font-size: 14px; }
.page-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-tools input { width: 260px; min-height: 36px; padding: 6px 12px; font-size: 14px; }

/* ---------- agents table ---------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg); }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]:hover { color: var(--ink); }
table.data th.asc::after { content: ' ↑'; color: var(--accent); }
table.data th.desc::after { content: ' ↓'; color: var(--accent); }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--bg); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .nowrap { white-space: nowrap; }
.tbl-agent { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.tbl-agent > span { display: flex; flex-direction: column; min-width: 0; }
.tbl-agent b { display: inline-flex; align-items: center; gap: 4px; }
.tbl-agent small, .tbl-code small { color: var(--muted); font-size: 12px; }
.tbl-code { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.empty-row { text-align: center; color: var(--muted); padding: 40px 14px !important; }

/* ---------- categories ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.cat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cat-card header, .sub-list li { display: flex; align-items: center; gap: 8px; }
.cat-card .count { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cat-name, .sub-name { border-color: transparent !important; background: transparent !important; min-height: 36px !important; padding: 6px 8px !important; }
.cat-name { font-weight: 800; font-size: 17px; }
.sub-name { font-size: 14px; }
.cat-name:hover, .sub-name:hover { border-color: var(--line-2) !important; }
.cat-name:focus, .sub-name:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
.sub-list { list-style: none; margin: 0; padding: 6px; background: var(--bg); border-radius: 12px; display: flex; flex-direction: column; gap: 2px; }
.sub-list li.none { font-size: 13px; color: var(--muted); padding: 8px; }
.sub-list .count { min-width: 22px; text-align: right; }
.sub-add { display: flex; gap: 8px; }
.sub-add input { min-height: 34px; padding: 5px 10px; font-size: 14px; }

@media (max-width: 1100px) {
  body.admin .topbar-in { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; row-gap: 8px; }
  .bs-tabs { order: 3; margin-left: 0; width: 100%; overflow-x: auto; }
}
@media (max-width: 760px) {
  .page-tools, .page-tools input { width: 100%; }
  .cat-grid { grid-template-columns: 1fr; }
}
