/* Agent Forge admin panel — "drafting paper" workshop.
   Quiet paper and ink; each agent's own colour is the one bold element. */

:root {
  --paper: #EEF1EC;
  --panel: #F8FAF6;
  --ink: #1F2A44;
  --muted: #5B6478;
  --rule: #CDD3CB;
  --moss: #4E7D4B;
  --ochre: #B7862B;
  --brick: #A2412F;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2.125rem;
  --radius: 5px;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; font: var(--step-0)/1.55 var(--sans); }
a { color: var(--ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); margin-top: 1.6em; }
h3 { font-size: var(--step-1); margin-top: 1.2em; }
p { max-width: 75ch; margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
pre { white-space: pre-wrap; word-break: break-word; background: var(--panel); border: 1px solid var(--rule);
      padding: .75rem 1rem; border-radius: var(--radius); font-size: var(--step--1); max-height: 28rem; overflow: auto; }

/* ---------- frame ---------- */
.frame { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); min-height: 100vh; }
.frame > * { min-width: 0; }
.rail { background: var(--ink); color: var(--paper); padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: .2rem; }
.rail .brand { font-family: var(--serif); font-size: var(--step-2); color: var(--paper); text-decoration: none; margin: 0 .5rem 1.2rem; }
.rail a.nav { color: var(--paper); text-decoration: none; padding: .45rem .6rem; border-radius: var(--radius); display: flex; justify-content: space-between; }
.rail a.nav:hover, .rail a.nav[aria-current="page"] { background: rgba(238, 241, 236, .13); }
.rail .count { background: var(--ochre); color: var(--ink); border-radius: 999px; padding: 0 .5rem; font-size: var(--step--1); font-weight: 600; }
.rail form { margin-top: auto; }
.rail .linkish { color: var(--paper); opacity: .75; }
main { padding: 2rem clamp(1rem, 3vw, 3rem) 4rem; max-width: 76rem; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.page-head p { margin: 0; color: var(--muted); }

@media (max-width: 760px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .rail { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; align-items: center; padding: .5rem; gap: .1rem;
          position: sticky; top: 0; z-index: 2; }
  .rail a.nav { white-space: nowrap; gap: .4rem; }
  .rail .brand { font-size: var(--step-1); margin: .3rem .6rem .3rem .3rem; white-space: nowrap; }
  .rail form { margin-top: 0; }
  main { padding: 1.2rem 1rem 3rem; }
}

/* ---------- agent tokens: the signature element ---------- */
.token { --c: var(--ink); display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; color: var(--ink); vertical-align: middle; }
.token .mark { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center;
               font-size: .85rem; flex: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.token .name { font-family: var(--serif); font-weight: 600; }
.token.big .mark { width: 3.4rem; height: 3.4rem; font-size: 1.6rem; }
.token.big .name { font-size: var(--step-3); }

.roster { display: flex; gap: 1rem; overflow-x: auto; padding: .4rem .2rem 1rem; margin: 0 -.2rem 1.5rem; scroll-snap-type: x proximity; }
.seat { --c: var(--ink); flex: 0 0 11rem; scroll-snap-align: start; border-top: 6px solid var(--c); background: var(--panel); padding: .8rem .9rem;
        text-decoration: none; color: var(--ink); border-radius: 0 0 var(--radius) var(--radius); }
.seat .mark { font-size: 1.6rem; line-height: 1; }
.seat .name { font-family: var(--serif); font-size: var(--step-1); font-weight: 600; display: block; margin-top: .3rem; }
.seat .line { display: block; font-size: var(--step--1); color: var(--muted); }
.seat:hover { outline: 2px solid var(--c); }
.seat.add { border-top-style: dashed; border-top-color: var(--rule); display: grid; place-items: center; color: var(--muted); min-height: 7.5rem; }

/* ---------- status ---------- */
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--step--1); }
.status::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); }
.status.working::before, .status.active::before, .status.done::before, .status.finished::before, .status.verified::before, .status.approved::before { background: var(--moss); }
.status.working::before { animation: pulse 1.6s ease-in-out infinite; }
.status.waiting::before, .status.waiting_approval::before, .status.waiting_input::before, .status.queued::before, .status.pending::before, .status.paused::before, .status.proposed::before, .status.scheduled::before, .status.in_progress::before { background: var(--ochre); }
.status.failed::before, .status.limit::before, .status.rejected::before, .status.denied::before, .status.cancelled::before, .status.blocked::before, .status.archived::before { background: var(--brick); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status.working::before { animation: none; } }

/* ---------- layout pieces ---------- */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.5rem 2.5rem; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.2rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: .2rem; border-bottom: 1px solid var(--rule); margin: 1rem 0 1.4rem; }
.tabs a { padding: .5rem .85rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--c, var(--ink)); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* lists that read like a logbook: time on the left, entry on the right */
.log { list-style: none; padding: 0; margin: 0; }
.log li { display: grid; grid-template-columns: 7.5rem 1fr; gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--rule); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-size: var(--step--1); padding-top: .15rem; }
.log .what { min-width: 0; }
@media (max-width: 520px) { .log li { grid-template-columns: 1fr; gap: .1rem; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: var(--step--1); }
tbody tr:hover { background: rgba(31, 42, 68, .03); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* meters for spend and XP */
.meter { height: .55rem; background: var(--rule); border-radius: 999px; overflow: hidden; margin: .3rem 0 .2rem; }
.meter > span { display: block; height: 100%; background: var(--ink); }
.meter.warn > span { background: var(--ochre); }
.meter.over > span { background: var(--brick); }
.bars { display: grid; gap: .3rem; }
.bars .bar { display: grid; grid-template-columns: 6.5rem 1fr 4.5rem; gap: .6rem; align-items: center; font-size: var(--step--1); }

/* ---------- forms ---------- */
form.stack { display: grid; gap: 1rem; max-width: 46rem; }
label { display: grid; gap: .3rem; font-weight: 600; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: var(--step--1); }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); padding: .5rem .65rem; width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--ink); }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.2rem 1.2rem; margin: 0; background: var(--panel); }
legend { font-family: var(--serif); font-size: var(--step-1); font-weight: 600; padding: 0 .4rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem 1.4rem; align-items: end; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .3rem; }
.slider { display: grid; grid-template-columns: 6rem 1fr 6rem 2rem; gap: .6rem; align-items: center; font-weight: 400;
          font-size: var(--step--1); }
.slider span:last-of-type { text-align: right; }
.slider output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

button, .button { font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius); padding: .5rem 1rem; border: 1px solid var(--ink);
                  background: var(--ink); color: var(--paper); text-decoration: none; display: inline-block; }
button.quiet, .button.quiet { background: transparent; color: var(--ink); }
button.stop { background: var(--brick); border-color: var(--brick); }
button.go { background: var(--moss); border-color: var(--moss); }
button.linkish { background: none; border: 0; padding: 0; text-decoration: underline; font-weight: 400; }
button:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.flash { border-left: 4px solid var(--moss); background: var(--panel); padding: .7rem 1rem; margin-bottom: 1.2rem; border-radius: 0 var(--radius) var(--radius) 0; }
.flash.err { border-left-color: var(--brick); }
.empty { color: var(--muted); padding: 1rem 0; }

/* the one control that can stop everything */
.killswitch { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.killswitch.on { padding: .8rem 1rem; background: rgba(162, 65, 47, .08); border: 1px solid var(--brick); border-radius: var(--radius); }

/* talk */
.bubble { border-left: 4px solid var(--c, var(--rule)); padding: .4rem .9rem; margin: .7rem 0; background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0; }
.bubble .who { font-size: var(--step--1); color: var(--muted); }
.bubble.system { border-left-color: var(--ochre); font-style: italic; }
.map { width: 100%; max-width: 34rem; height: auto; display: block; }
.map text { font: 600 12px var(--serif); fill: var(--ink); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: min(24rem, 100%); }
.login h1 { font-size: var(--step-3); }

/* creator preview */
#preview-out { min-height: 6rem; }

/* backups */
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0 .5rem; }
.actions form { margin: 0; }
#backups { margin-bottom: 2rem; }
