/* Archive only. Account behavior and the other screens keep their own styles. */
html:has(.agent-home) { min-width: 0; }
body:has(.agent-home) .topbar {
  gap: 24px;
  min-height: 88px;
  padding-block: 16px;
}
body:has(.agent-home) .brand { min-width: 0; min-height: 44px; }
body:has(.agent-home) .brand-mark { flex-shrink: 0; }
body:has(.agent-home) .brand-copy strong { letter-spacing: .015em; }
body:has(.agent-home) .brand-copy small { margin-top: 3px; font-size: .68rem; }
body:has(.agent-home) .header-actions:empty { display: none; }
body:has(.agent-home) .header-account-area { min-width: 0; max-width: 50%; }
body:has(.agent-home) .account-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 16px;
  align-items: center;
}
body:has(.agent-home) .account-name { grid-column: 1; text-align: right; }
body:has(.agent-home) .account-name:empty { display: none; }
body:has(.agent-home) .account-status { grid-column: 1; text-align: right; font-size: .75rem; }
body:has(.agent-home) .account-controls .button {
  grid-column: 2;
  grid-row: 1 / 3;
  min-height: 44px;
  border-color: #41454a;
  background: #141619;
  white-space: nowrap;
}
body:has(.agent-home) .account-controls .button:last-child:not([hidden]) { grid-row: 3; }
body:has(.agent-home) .account-controls .button:disabled { opacity: .55; cursor: wait; transform: none; }
body:has(.agent-home) #app { padding-top: 44px; }

/* Fog drifts; the seal itself now turns almost imperceptibly and breathes with a slow glow, like something ancient still watching. */
body:has(.agent-home) {
  isolation: isolate;
  background:
    radial-gradient(ellipse at 5% 8%, #641a2424, transparent 48rem),
    repeating-linear-gradient(0deg, #ffffff02 0 1px, transparent 1px 4px),
    #09090b;
}
body:has(.agent-home)::before {
  inset: -2%;
  background:
    radial-gradient(ellipse at 8% 45%, #80384426, transparent 52%),
    radial-gradient(ellipse at 88% 68%, #55505620, transparent 44%),
    radial-gradient(ellipse at 42% 88%, #68283120, transparent 48%);
  mask-image: none;
  opacity: .7;
  animation: archive-mist 28s ease-in-out infinite alternate;
}
body:has(.agent-home)::after {
  width: min(52vw, 620px);
  height: auto;
  aspect-ratio: 1;
  top: auto;
  right: -110px;
  bottom: -140px;
  border: 0;
  border-radius: 0;
  background: url("assets/archive-seal.svg") center / contain no-repeat;
  box-shadow: none;
  transform-origin: 50% 50%;
  animation: archive-seal-turn 240s linear infinite, archive-seal-breathe 16s ease-in-out infinite;
}

@keyframes archive-seal-turn {
  from { transform: rotate(-14deg); }
  to { transform: rotate(346deg); }
}

@keyframes archive-seal-breathe {
  0%, 100% { opacity: .13; filter: drop-shadow(0 0 0 transparent); }
  50% { opacity: .22; filter: drop-shadow(0 0 40px rgba(217, 35, 50, 0.14)); }
}
body:has(.agent-home) .topbar {
  background: linear-gradient(110deg, #100d0ff5, #0b0c0df5);
  box-shadow: 0 6px 24px #0004;
}
body:has(.agent-home) .topbar::after { background: linear-gradient(90deg, transparent, #bf4651 25%, #6c252f 65%, transparent); }
body:has(.agent-home) .brand-mark { box-shadow: 0 0 0 4px #a8313c0d, inset 0 0 18px #a8313c18; }
body:has(.agent-home) .site-footer { background: #09090b9c; }

.agent-home { --home-border: rgba(174, 180, 183, .19); }
.agent-home .home-heading { gap: 32px; align-items: center; padding: 0 0 32px; margin-bottom: 30px; }
.agent-home .home-heading .eyebrow { margin-bottom: 14px; font-size: .7rem; letter-spacing: .2em; }
.agent-home h1 { font-size: clamp(1.9rem, 3.5vw, 2.75rem); margin-bottom: 14px; }
.agent-home .home-heading .muted { font-size: .96rem; }
.agent-home .home-create { flex-shrink: 0; min-height: 48px; padding-inline: 22px; }
.agent-home .home-create > span { font-size: 1.35rem; line-height: 1; font-weight: 400; }
.archive-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.archive-section-heading h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1rem; }
.archive-count { display: grid; place-items: center; min-width: 26px; height: 26px; padding-inline: 7px; border: 1px solid var(--home-border); border-radius: 6px; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.archive-section-heading p { margin: 0; color: var(--muted); font-size: .8rem; }

.agent-home .empty-state {
  overflow: hidden;
  min-height: 385px;
  padding: 48px 24px 40px;
  border-color: var(--home-border);
  background: radial-gradient(ellipse at 50% 0, rgba(160, 25, 38, .085), transparent 65%), linear-gradient(145deg, #101214, #0b0d0f);
  box-shadow: 0 16px 44px #0003;
}
.agent-home .empty-state::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-top: 1px solid #cc283438; border-radius: inherit; }
.agent-home .empty-state-inner { max-width: 480px; }
.agent-home .empty-sigil { width: 76px; height: 76px; margin-bottom: 28px; color: #f35a66; }
.agent-home .empty-sigil svg { width: 40px; height: 40px; }
.agent-home .empty-state .eyebrow { font-size: .62rem; letter-spacing: .15em; margin-bottom: 10px; color: #b88387; }
.agent-home .empty-state h2 { font-size: clamp(1.2rem, 2.4vw, 1.5rem); margin-bottom: 12px; line-height: 1.3; }
.agent-home .empty-state .muted { max-width: 350px; margin: 0 auto 24px; font-size: .92rem; }
.agent-home .empty-save-note { margin: 16px 0 0; font-size: .72rem; color: var(--muted); }

.agent-home .character-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.agent-home .character-card { display: flex; flex-direction: column; min-width: 0; padding: 24px 20px 18px; border-color: var(--home-border); }
.agent-home .character-card:hover { transform: translateY(-2px); }
.agent-home .character-card:focus-within { border-color: #cb414b; }
.agent-home .character-card-head { align-items: flex-start; margin-bottom: 22px; }
.agent-home .character-card-head > div:last-child { min-width: 0; }
.agent-home .character-card h3 { font-size: 1.13rem; line-height: 1.3; margin: 0 0 5px; overflow-wrap: anywhere; }
.agent-home .character-card-head .small { display: block; font-size: .77rem; overflow-wrap: anywhere; }
.agent-home .avatar { border-radius: 10px; font-size: .94rem; }
.agent-home .character-meta { margin-bottom: 24px; gap: 6px; }
.agent-home .badge { max-width: 100%; overflow-wrap: anywhere; border-radius: 5px; font-size: .71rem; font-weight: 600; }
.agent-home .badge.red { font-weight: 750; }
.agent-home .card-actions { align-items: center; gap: 7px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--home-border); }
.agent-home .card-actions .button { min-height: 44px; }
.agent-home .card-open { justify-content: space-between; padding-inline: 13px; border: 1px solid #42464b; background: #202328; }
.agent-home .card-open:hover { border-color: #de535e; background: #2a2024; }
.agent-home .card-delete { width: 44px; flex: 0 0 44px; padding: 10px; border-color: transparent; color: var(--muted); }
.agent-home .card-delete svg { width: 19px; height: 19px; }
.agent-home .card-delete:hover { background: var(--red-soft); border-color: #b73a46; color: #ff9ca4; }
.agent-home .button:focus-visible, body:has(.agent-home) .topbar button:focus-visible { outline: 2px solid #f5848d; outline-offset: 4px; }
.agent-home .button:active { transform: translateY(1px); }

/* Small details echo an investigation file without covering the content. */
.agent-home .home-heading .eyebrow { display: flex; align-items: center; gap: 10px; }
.agent-home .home-heading .eyebrow::before { content: ""; width: 6px; height: 6px; border: 1px solid #b7525c; transform: rotate(45deg); }
.agent-home .home-heading::after { width: min(280px, 55%); box-shadow: none; }
.agent-home .empty-state {
  background: radial-gradient(ellipse at 50% 0, #7c283114, transparent 70%), linear-gradient(145deg, #131113, #0c0e10);
}
.agent-home .empty-state::before {
  content: "";
  position: absolute;
  width: 270px;
  height: 270px;
  left: -100px;
  bottom: -76px;
  background: url("assets/archive-seal.svg") center / contain no-repeat;
  opacity: .14;
  transform: rotate(19deg);
  pointer-events: none;
}
.agent-home .empty-state-inner { position: relative; z-index: 1; }
.agent-home .empty-sigil { box-shadow: 0 0 0 7px #9c31390a, inset 0 0 24px #0005; }
.agent-home .empty-sigil::before { animation: none; }
.agent-home .character-card { background: linear-gradient(135deg, #ffffff03, transparent 42%), linear-gradient(165deg, #171416, #0e1012); }
.agent-home .character-card::before { box-shadow: none; opacity: .8; }
.agent-home .character-card::after { border-color: #a9546059; }
.agent-home .character-card:hover { box-shadow: 0 12px 28px #0005; border-color: #9c4a54; }
.agent-home .button.primary { border-color: #cf4a57; background: linear-gradient(#cf2d3d, #a9202e); box-shadow: 0 5px 18px #98172626; }
.agent-home .button.primary:hover { background: linear-gradient(#dd3747, #b82433); border-color: #e46a74; }

@keyframes archive-mist {
  from { transform: translate3d(-.7%, .6%, 0); opacity: .55; }
  to { transform: translate3d(1%, -.5%, 0); opacity: .8; }
}

@media (max-width: 760px) {
  body:has(.agent-home)::before { animation: none; transform: none; opacity: .6; }
  body:has(.agent-home)::after { width: 280px; right: -120px; bottom: 16%; opacity: .12; }
  .agent-home .empty-state::before { width: 200px; height: 200px; left: -112px; bottom: -62px; opacity: .1; }
  body:has(.agent-home) .topbar { position: relative; flex-wrap: wrap; padding: 18px 20px 14px; gap: 16px; }
  body:has(.agent-home) .brand { width: 100%; }
  body:has(.agent-home) .brand-copy strong { font-size: .84rem; }
  body:has(.agent-home) .brand-copy small { display: block; }
  body:has(.agent-home) .header-account-area { width: 100%; max-width: none; padding-top: 13px; border-top: 1px solid #ffffff12; }
  body:has(.agent-home) .account-controls { width: 100%; max-width: none; gap: 3px 12px; }
  body:has(.agent-home) .account-name, body:has(.agent-home) .account-status { text-align: left; }
  body:has(.agent-home) .account-status { font-size: .72rem; }
  body:has(.agent-home) #app { width: calc(100% - 32px); padding-top: 30px; }
  .agent-home .home-heading { flex-direction: column; align-items: stretch; gap: 22px; padding-bottom: 26px; margin-bottom: 24px; }
  .agent-home .home-heading .muted { font-size: .88rem; }
  .agent-home .home-create { width: 100%; }
  .archive-section-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .archive-section-heading p { font-size: .76rem; }
  .agent-home .empty-state { min-height: 350px; padding: 32px 20px; }
  .agent-home .empty-state .eyebrow { max-width: 230px; margin-inline: auto; }
  .agent-home .empty-state .home-create { max-width: 280px; }
  .agent-home .character-card { padding: 22px 16px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  body:has(.agent-home)::before { animation: none; transform: none; opacity: .65; }
  body:has(.agent-home)::after { animation: none; transform: rotate(-14deg); opacity: .17; }
  body:has(.agent-home) .brand:hover .brand-mark { transform: none; }
  .agent-home .character-card:hover, .agent-home .button:hover, .agent-home .button:active { transform: none; }
}
