.agent-library-dialog,
.agent-launch-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  color: var(--ink, #241d19);
  background: transparent;
}

.agent-library-dialog::backdrop,
.agent-launch-dialog::backdrop {
  background: rgba(31, 24, 20, .32);
  backdrop-filter: blur(2px);
}

.agent-library-shell {
  display: flex;
  width: min(1240px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 32px));
  margin: 16px auto;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line, #ead9cb);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 90px -42px rgba(52, 31, 20, .58);
}

.agent-library-topbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line, #ead9cb);
  padding: 0 16px 0 20px;
}

.agent-library-topbar > div,
.agent-launch-identity {
  display: flex;
  align-items: center;
  gap: 11px;
}

.agent-library-brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: var(--accent, #ff5f1f);
  font: 800 14px/1 Inter, system-ui, sans-serif;
}

.agent-library-icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ink-soft, #5f554f);
  background: transparent;
  font: 400 25px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

.agent-library-icon-button:hover,
.agent-library-icon-button:focus-visible {
  border-color: var(--line, #ead9cb);
  background: var(--surface, #fff8f2);
  outline: 0;
}

.agent-library-layout {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 224px minmax(0, 1fr);
}

.agent-library-sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line, #ead9cb);
  padding: 18px 14px;
  background: #fcfaf8;
}

.agent-library-search {
  display: flex;
  height: 39px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line, #ead9cb);
  border-radius: 10px;
  padding: 0 11px;
  background: #fff;
}

.agent-library-search:focus-within {
  border-color: var(--accent, #ff5f1f);
  box-shadow: 0 0 0 3px rgba(255, 95, 31, .09);
}

.agent-library-search span { color: var(--muted, #97877c); font-size: 20px; }
.agent-library-search input { width: 100%; border: 0; outline: 0; color: inherit; background: transparent; font: 500 13px/1.2 Inter, system-ui, sans-serif; }
.agent-library-sidebar nav { display: grid; gap: 5px; }
.agent-library-sidebar nav button {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  padding: 0 11px;
  color: var(--ink-soft, #5f554f);
  background: transparent;
  text-align: left;
  font: 650 12px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}
.agent-library-sidebar nav button:hover,
.agent-library-sidebar nav button.active { color: var(--accent-dark, #d84b1c); background: var(--accent-soft, #fff0e7); }
.agent-library-note { display: grid; gap: 7px; margin-top: auto; border: 1px solid var(--line, #ead9cb); border-radius: 12px; padding: 13px; background: #fff; }
.agent-library-note b { font-size: 11px; }
.agent-library-note span { color: var(--muted, #97877c); font-size: 10px; line-height: 1.5; }

.agent-library-main { min-width: 0; overflow-y: auto; background: #fff; }
.agent-library-hero {
  display: flex;
  min-height: 190px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 34px 44px;
  background: #f7e9df;
}
.agent-library-hero p { margin: 0 0 7px; color: var(--accent-dark, #d84b1c); font: 750 10px/1.2 Inter, system-ui, sans-serif; letter-spacing: .12em; }
.agent-library-hero h2 { margin: 0 0 9px; font: 500 clamp(30px, 4vw, 45px)/1.03 Georgia, serif; }
.agent-library-hero span { display: block; max-width: 590px; color: var(--ink-soft, #5f554f); font-size: 14px; line-height: 1.55; }
.agent-library-hero-art { position: relative; width: 160px; height: 110px; flex: none; }
.agent-library-hero-art i { position: absolute; display: block; border: 2px solid rgba(216, 75, 28, .55); border-radius: 13px; background: rgba(255,255,255,.42); transform: rotate(-4deg); }
.agent-library-hero-art i:nth-child(1) { top: 4px; right: 25px; width: 82px; height: 96px; }
.agent-library-hero-art i:nth-child(2) { top: 24px; right: 2px; width: 62px; height: 70px; transform: rotate(5deg); }
.agent-library-hero-art i:nth-child(3) { top: 34px; right: 74px; width: 72px; height: 50px; transform: rotate(-9deg); }
.agent-library-content { padding: 34px 44px 44px; }
.agent-library-section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.agent-library-section-head h3 { margin: 0 0 5px; font-size: 18px; }
.agent-library-section-head p { margin: 0; color: var(--muted, #97877c); font-size: 11px; line-height: 1.45; }
.agent-library-section-head > span { color: var(--muted, #97877c); font-size: 11px; white-space: nowrap; }
.agent-library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.agent-library-card {
  position: relative;
  display: flex;
  min-height: 190px;
  flex-direction: column;
  border: 1px solid var(--line, #ead9cb);
  border-radius: 15px;
  padding: 18px;
  background: #fff;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.agent-library-card:hover,
.agent-library-card:focus-visible { border-color: #d8c0ae; outline: 0; box-shadow: 0 22px 46px -34px rgba(55, 32, 19, .55); transform: translateY(-2px); }
.agent-library-card.selected { border-color: rgba(255, 95, 31, .48); box-shadow: inset 0 0 0 1px rgba(255, 95, 31, .08); }
.agent-library-card-top { display: flex; align-items: center; justify-content: space-between; }
.agent-library-card-top em { border-radius: 999px; padding: 4px 7px; color: #197d74; background: #e4f5f1; font: 750 9px/1 Inter, system-ui, sans-serif; font-style: normal; }
.agent-library-agent-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; color: #d84b1c; background: #ffe8da; }
.agent-library-agent-icon.blue { color: #366db8; background: #e6f0ff; }
.agent-library-agent-icon.violet { color: #744bc4; background: #eee7ff; }
.agent-library-agent-icon.teal { color: #197d74; background: #dff3ef; }
.agent-library-agent-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.agent-library-card h4 { margin: 17px 0 6px; font-size: 15px; }
.agent-library-card p { display: -webkit-box; margin: 0 0 15px; overflow: hidden; color: var(--muted, #97877c); font-size: 11px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.agent-library-use {
  align-self: flex-start;
  margin-top: auto;
  border: 0;
  border-radius: 8px;
  padding: 8px 15px;
  color: #fff;
  background: var(--accent, #ff5f1f);
  opacity: 0;
  transform: translateY(4px);
  font: 750 11px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  transition: opacity .14s ease, transform .14s ease, background .14s ease;
}
.agent-library-card:hover .agent-library-use,
.agent-library-card:focus-within .agent-library-use,
.agent-library-use:focus-visible { opacity: 1; transform: translateY(0); }
.agent-library-use:hover { background: var(--accent-dark, #d84b1c); }
.agent-library-empty { display: grid; min-height: 200px; grid-column: 1 / -1; place-content: center; gap: 7px; color: var(--muted, #97877c); text-align: center; }
.agent-library-empty b { color: var(--ink, #241d19); }

.agent-launch-dialog { display: none; justify-content: flex-end; }
.agent-launch-dialog[open] { display: flex; }
.agent-launch-panel {
  display: flex;
  width: min(560px, 100vw);
  height: 100vh;
  flex-direction: column;
  background: #fff;
  box-shadow: -24px 0 80px -45px rgba(35, 24, 18, .7);
}
.agent-launch-head { display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line, #ead9cb); padding: 12px 18px; }
.agent-launch-identity p { margin: 0 0 3px; color: var(--muted, #97877c); font: 750 9px/1.2 Inter, system-ui, sans-serif; letter-spacing: .1em; }
.agent-launch-identity h2 { margin: 0; font: 500 22px/1.1 Georgia, serif; }
.agent-launch-identity small { display: block; max-width: 390px; margin-top: 3px; overflow: hidden; color: var(--muted, #97877c); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.agent-launch-scroll { min-height: 0; flex: 1; overflow-y: auto; padding: 26px 22px 38px; }
.agent-launch-intro { border-radius: 13px; padding: 16px; background: #faf6f2; }
.agent-launch-intro h3 { margin: 0 0 6px; font-size: 15px; }
.agent-launch-intro p { margin: 0; color: var(--muted, #97877c); font-size: 11px; line-height: 1.5; }
.agent-launch-fields { display: grid; gap: 24px; margin-top: 28px; }
.agent-launch-field { display: grid; gap: 8px; }
.agent-launch-field > span { color: var(--ink, #241d19); font: 700 13px/1.4 Inter, system-ui, sans-serif; }
.agent-launch-field input,
.agent-launch-field textarea,
.agent-launch-field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d9d4d0;
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--ink, #241d19);
  background: #fff;
  outline: 0;
  font: 500 12px/1.5 Inter, system-ui, sans-serif;
}
.agent-launch-field textarea { min-height: 96px; resize: vertical; }
.agent-launch-field input:focus,
.agent-launch-field textarea:focus,
.agent-launch-field select:focus { border-color: var(--accent, #ff5f1f); box-shadow: 0 0 0 3px rgba(255, 95, 31, .09); }
.agent-launch-field small { justify-self: end; color: var(--muted, #97877c); font-size: 9px; }
.agent-launch-field small i { font-style: normal; }
.agent-launch-footer { border-top: 1px solid var(--line, #ead9cb); padding: 13px 18px; background: rgba(255,255,255,.97); }
.agent-launch-generate { width: 100%; min-height: 44px; border: 0; border-radius: 9px; color: #fff; background: var(--accent, #ff5f1f); font: 750 13px/1 Inter, system-ui, sans-serif; cursor: pointer; }
.agent-launch-generate:hover:not(:disabled) { background: var(--accent-dark, #d84b1c); }
.agent-launch-generate:disabled { opacity: .55; cursor: wait; }

.agent-generation-preview {
  position: absolute;
  z-index: 20;
  top: 50%;
  left: 58%;
  width: min(520px, calc(100% - 40px));
  min-height: 430px;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border: 1px solid var(--line, #ead9cb);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 28px 75px -46px rgba(45, 29, 18, .6);
  transition: opacity .18s ease, transform .18s ease;
}
.agent-generation-preview.leaving { opacity: 0; transform: translate(-50%, -48%); }
.agent-generation-preview > header { display: flex; min-height: 64px; align-items: center; gap: 11px; border-bottom: 1px solid var(--line, #ead9cb); padding: 0 18px; }
.agent-generation-preview > header small { display: block; margin-bottom: 3px; color: var(--muted, #97877c); font-size: 9px; }
.agent-generation-preview > header b { font-size: 13px; }
.agent-generation-paper { display: grid; gap: 13px; padding: 30px 34px; }
.agent-generation-paper i { position: relative; display: block; height: 13px; overflow: hidden; border-radius: 4px; background: #f1eeeb; }
.agent-generation-paper i::after { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.92) 48%, transparent 76%); content: ""; transform: translateX(-100%); animation: agent-library-shimmer 1.35s ease-in-out infinite; }
.agent-generation-paper i:nth-child(1) { width: 44%; height: 21px; margin-bottom: 9px; }
.agent-generation-paper i:nth-child(2) { width: 100%; }
.agent-generation-paper i:nth-child(3) { width: 92%; }
.agent-generation-paper i:nth-child(4) { width: 97%; }
.agent-generation-paper i:nth-child(5) { width: 68%; margin-bottom: 15px; }
.agent-generation-paper i:nth-child(6) { width: 83%; height: 18px; }
.agent-generation-preview > footer { position: absolute; right: 18px; bottom: 15px; left: 18px; color: var(--muted, #97877c); font-size: 10px; }
.agent-generation-preview.failed { border-color: #e4a295; }
.agent-generation-preview.failed .agent-generation-paper i::after { animation: none; }
.agent-generation-preview.failed > footer { color: #a23b2b; }

@keyframes agent-library-shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  .agent-library-card,
  .agent-library-use,
  .agent-generation-preview { transition: none; }
  .agent-generation-paper i::after { animation: none; opacity: .55; }
}

@media (max-width: 760px) {
  .agent-library-shell { width: 100vw; height: 100vh; margin: 0; border: 0; border-radius: 0; }
  .agent-library-layout { display: block; overflow-y: auto; }
  .agent-library-sidebar { position: sticky; z-index: 2; top: 0; display: block; border: 0; border-bottom: 1px solid var(--line, #ead9cb); padding: 10px 14px; }
  .agent-library-sidebar nav { display: none; }
  .agent-library-note { display: none; }
  .agent-library-main { overflow: visible; }
  .agent-library-hero { min-height: 145px; padding: 25px 22px; }
  .agent-library-hero-art { display: none; }
  .agent-library-content { padding: 24px 18px 36px; }
  .agent-library-section-head { align-items: start; }
  .agent-library-grid { grid-template-columns: 1fr; }
  .agent-library-card { min-height: 165px; }
  .agent-library-use { opacity: 1; transform: none; }
  .agent-launch-panel { width: 100vw; }
  .agent-generation-preview { left: 50%; width: calc(100% - 24px); min-height: 390px; }
}
