/* AI Agents at Work: built for a projector. Large type, high contrast. */
:root {
  --ink: #1D2433;
  --ink-2: #3D4452;
  --muted: #5A6070;
  --ground: #F7F7F4;
  --card: #FFFFFF;
  --line: #E4E4DE;
  --good: #1E6B3A;
  --good-bg: #E1F4E7;
  --warn: #8A4B08;
  --warn-bg: #FCEFD9;
  --bad: #A3271A;
  --bad-bg: #FBE4E0;
  --work: #1F4FBF;
  --work-bg: #E3ECFD;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 18px/1.45 Inter, system-ui, sans-serif; }
h1, h2 { font-family: "Space Grotesk", Inter, sans-serif; margin: 0; }
a { color: var(--work); }
a:hover { color: #163a8c; }

.top { max-width: 1760px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end;
       padding: 28px 48px 12px; }
.top h1 { font-size: 40px; line-height: 1.1; }
.eyebrow { margin: 0 0 6px; font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.top nav { display: flex; gap: 20px; font-weight: 600; }
main { padding: 8px 48px 48px; max-width: 1760px; margin: 0 auto; }

.statusbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pill { display: inline-block; padding: 6px 16px; border-radius: 999px; font-weight: 600; font-size: 16px;
        background: #EEEEEA; color: var(--ink-2); }
.pill.open { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--bad-bg); color: var(--bad); }
.hidden { display: none !important; }

/* Agent cards */
.flow { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: stretch; gap: 10px; }
.row .spacer { flex: 1 1 0; min-width: 0; }
.row .spacer.half { flex: 0.5 1 0; }
.row .gap { flex: none; width: 64px; }
.agent { flex: 1 1 0; min-width: 0; display: flex; gap: 16px; align-items: center; background: var(--card);
         border: 1px solid var(--line); border-top: 6px solid var(--accent); border-radius: 18px; padding: 18px; }
.agent img { flex: none; }
.agent-text { min-width: 0; }
.agent-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.agent h2 { font-size: 26px; }
.role { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.action { margin: 6px 0 0; font-size: 17px; color: var(--ink-2); min-height: 2.9em; }
.status { padding: 3px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; background: #EEEEEA; color: var(--ink-2); }
.status.Working, .status.Open { background: var(--work-bg); color: var(--work); }
.status.Done { background: var(--good-bg); color: var(--good); }
.status.Paused, .status.Closed { background: var(--warn-bg); color: var(--warn); }
.agent.working { box-shadow: 0 0 0 3px var(--accent); }
.agent.later { opacity: .55; }
.agent.later .status { background: transparent; border: 1px dashed var(--muted); }

.arrow { flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center;
         gap: 4px; color: #8A909B; }
.queue { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.2; }
.queue.busy { color: var(--warn); }

/* Totals */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin: 26px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px;
        display: flex; flex-direction: column; gap: 2px; }
.tile .label { font-size: 15px; font-weight: 600; color: var(--muted); }
.tile .value { font-family: "Space Grotesk", Inter, sans-serif; font-size: 34px; font-weight: 700; }
.tile .sub { font-size: 14px; color: var(--muted); }
.tile.books.ok .value { color: var(--good); }
.tile.books.bad .value { color: var(--bad); }

/* Activity log */
.log { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; }
.log h2 { font-size: 22px; margin-bottom: 8px; }
.log ol { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 120px 96px 1fr; gap: 12px; padding: 7px 0; border-top: 1px solid #F0F0EC; font-size: 17px; }
.log li:first-child { border-top: 0; }
.log .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .who { font-weight: 700; color: var(--agent, var(--ink)); }
.log li.warn .msg { color: var(--warn); font-weight: 600; }
.log li.error .msg { color: var(--bad); font-weight: 600; }
.log li.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: #FFF6D6; } to { background: transparent; } }

/* Panels, forms, books, presenter */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 18px; }
.panel h2 { font-size: 24px; margin-bottom: 12px; }
.panel.narrow { max-width: 440px; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=password] { width: 100%; font-size: 18px; padding: 10px 12px; border: 1px solid #C9CCD2; border-radius: 10px; }
input[type=range] { width: 100%; }
button { font: inherit; font-weight: 600; min-height: 48px; padding: 10px 18px; border-radius: 12px;
         border: 1px solid #C9CCD2; background: #FFFFFF; color: var(--ink); cursor: pointer; }
button:hover { background: #F3F3EF; }
button.primary { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
button.primary:hover { background: #2E3748; }
button.danger { background: var(--bad-bg); color: var(--bad); border-color: #E8B4AC; }
button[aria-pressed=true] { background: var(--warn-bg); color: var(--warn); border-color: #E9C48C; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #2F6FED; outline-offset: 2px; }
.buttons { display: flex; flex-wrap: wrap; gap: 12px; }
form button { margin-top: 16px; }
.error { color: var(--bad); font-weight: 600; }
.toast { min-height: 1.5em; font-weight: 600; color: var(--good); }
.toast.bad { color: var(--bad); }
.logout { margin-top: 8px; }
body.presenter main { max-width: 760px; }

.books-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
table.money { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.money th, table.money td { padding: 8px 10px; border-bottom: 1px solid #F0F0EC; text-align: right; }
table.money th:first-child, table.money td:first-child { text-align: left; }
table.money tfoot th { border-top: 2px solid var(--ink); }
.check { font-weight: 700; font-size: 20px; }
.check.ok { color: var(--good); }
.check.bad { color: var(--bad); }
.entry { border-top: 1px solid var(--line); padding: 10px 0; }
.entry:first-child { border-top: 0; }
.entry h3 { margin: 0; font-size: 17px; }
.entry .meta { color: var(--muted); font-size: 14px; }

@media (max-width: 1100px) {
  .row { flex-direction: column; gap: 10px; }
  .row .spacer, .row .gap { display: none; }
  .arrow { width: 100%; flex-direction: row; transform: none; }
  .arrow svg { transform: rotate(90deg); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .books-grid { grid-template-columns: 1fr; }
  .top, main { padding-left: 18px; padding-right: 18px; }
  .log li { grid-template-columns: 1fr; gap: 0; }
}

/* Agent colors (kept here, not inline, so the Content Security Policy can block inline styles) */
.agent[data-agent="Store"]    { --accent: #5A6070; }
.agent[data-agent="Mario"]    { --accent: #2F6FED; }
.agent[data-agent="Yoshi"]    { --accent: #3E9B2F; }
.agent[data-agent="Luigi"]    { --accent: #E0912B; }
.agent[data-agent="Kong"]     { --accent: #7C4DDB; }
.agent[data-agent="Princess"] { --accent: #E2553F; }
.agent[data-agent="Toad"]     { --accent: #0F9A8A; }
.agent[data-agent="Daisy"]    { --accent: #C2387B; }

/* Dashboard (Kong) */
.dash-tiles .tile.bump { animation: bump 1.2s ease-out; }
@keyframes bump { from { background: #EEF4FD; } to { background: var(--card); } }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h2 { margin-bottom: 4px; }
.chart-sub { margin: 0 0 10px; font-size: 15px; color: var(--muted); }
.chart { width: 100%; }
.chart svg { display: block; overflow: visible; font-family: Inter, system-ui, sans-serif; }
.chart .axis { font-size: 13px; fill: var(--muted); }
.chart .axis.small { font-size: 12px; font-style: italic; }
.chart .label { font-size: 16px; fill: var(--ink); }
.chart .value { font-size: 15px; font-weight: 600; fill: var(--ink); }
.chart .inside { font-size: 14px; font-weight: 700; fill: #FFFFFF; }
.chart .mark { cursor: default; outline: none; }
.chart .mark:hover .fill, .chart .mark:focus .fill { opacity: .78; }
.chart .mark:focus-visible .fill { stroke: var(--ink); stroke-width: 2; }
.legend { display: flex; gap: 18px; margin: 4px 0 10px; font-size: 15px; color: var(--ink-2); }
.legend .key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }
.legend .key.s1 { background: #2a78d6; }
.legend .key.s2 { background: #eb6834; }
details { margin-top: 10px; font-size: 15px; }
details summary { cursor: pointer; color: var(--work); font-weight: 600; }
table.carriers { font-size: 18px; }
.tooltip { position: absolute; z-index: 10; pointer-events: none; background: #FFFFFF; border: 1px solid var(--line);
           box-shadow: 0 4px 14px rgba(29, 36, 51, .12); border-radius: 10px; padding: 8px 12px;
           display: flex; flex-direction: column; gap: 2px; max-width: 260px; }
.tooltip strong { font-size: 18px; color: var(--ink); }
.tooltip span { font-size: 14px; color: var(--muted); }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* Princess's report and Toad's outbox */
.report .headline { font-family: "Space Grotesk", Inter, sans-serif; font-size: 28px; font-weight: 700; margin: 0 0 14px; }
.report .findings { margin: 0 0 14px; padding-left: 26px; display: flex; flex-direction: column; gap: 10px; font-size: 19px; }
.report .action { font-size: 19px; background: #FCEFD9; border-radius: 12px; padding: 12px 16px; margin: 0; }
pre { white-space: pre-wrap; word-break: break-word; background: #F3F3EF; border-radius: 10px; padding: 14px; font-size: 14px; max-height: 480px; overflow: auto; }
.email-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.email-head h2 { font-size: 22px; margin: 0; }
.email .meta { color: var(--muted); font-size: 15px; margin: 6px 0 12px; }
.email-body { border-top: 1px solid var(--line); padding-top: 12px; font-size: 18px; }
.email-body ul { padding-left: 24px; }

/* Asking Princess a question, and the steps she took */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
form.ask { display: flex; gap: 12px; align-items: stretch; margin-bottom: 12px; }
form.ask input { flex: 1; min-width: 0; font-size: 18px; padding: 10px 12px; border: 1px solid #C9CCD2; border-radius: 12px; }
form.ask button { margin-top: 0; }
.ideas { gap: 8px; }
button.idea { min-height: 40px; padding: 6px 12px; font-weight: 500; font-size: 15px; border-radius: 999px; }
.report .question { color: var(--muted); font-size: 18px; margin: 0 0 6px; }
.trail { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.trail li { border-left: 4px solid var(--line); padding: 4px 0 4px 14px; font-size: 17px; }
.trail li.thought { border-left-color: #E2553F; font-style: italic; }
.trail li.lookup { border-left-color: var(--work); }
.trail li.lookup.failed .label { color: var(--warn); }
.trail li.check { border-left-color: var(--warn); color: var(--warn); font-weight: 600; }
.trail .label { font-weight: 600; }
.trail details { margin-top: 4px; }
@media (max-width: 700px) { form.ask { flex-direction: column; } }

/* Yoshi: five agents in the first row, the approval banner, backorders */
.stats.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tile.backorders.warn .value { color: var(--warn); }
.banner { margin: 0 0 16px; padding: 14px 20px; border-radius: 14px; background: var(--warn-bg); color: var(--warn);
          font-weight: 700; font-size: 20px; border: 2px solid #E9C48C; animation: fresh 1.6s ease-out; }
@media (max-width: 1100px) { .stats.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Yoshi's warehouse page */
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 16px; }
table.grid th, table.grid td { padding: 7px 10px; border-bottom: 1px solid #F0F0EC; text-align: left; vertical-align: top; }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid tr.low td { background: #FFF8EC; }
table.grid tr.out td { background: var(--bad-bg); }
.po { border-top: 1px solid var(--line); padding: 14px 0; }
.po:first-of-type { border-top: 0; }
.po h3 { margin: 0 0 4px; font-size: 19px; }
.po .why { margin: 6px 0; font-size: 17px; }
.po .meta { color: var(--muted); font-size: 14px; }
.approve { border: 2px solid #E9C48C; background: var(--warn-bg); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.approve h3 { margin: 0 0 6px; }
.approve p { margin: 0 0 10px; }
.warehouse-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .warehouse-grid { grid-template-columns: 1fr; } }
.stats.stock-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 6px 0 14px; }

/* ---------- The 3D board ---------- */
.flow { perspective: 1500px; perspective-origin: 50% 0; position: relative; padding: 6px 0 22px; }
.flow::before { content: ""; position: absolute; left: 2%; right: 2%; bottom: -6px; height: 62%; z-index: -1; border-radius: 50%;
                background: radial-gradient(ellipse at 50% 40%, rgba(29, 36, 51, .10), rgba(29, 36, 51, 0) 70%); }
.flow .row { transform-style: preserve-3d; transform: rotateX(7deg); transform-origin: 50% 100%; }
.flow .row.second { transform: rotateX(7deg); }
.agent { position: relative; cursor: pointer; transform: translateZ(0);
         background: linear-gradient(180deg, #FFFFFF 0%, #FBFBF8 100%);
         box-shadow: 0 1px 0 #FFFFFF inset, 0 2px 3px rgba(29, 36, 51, .06), 0 12px 24px -10px rgba(29, 36, 51, .22),
                     0 6px 0 -1px #E9E8E1, 0 7px 0 -1px #D9D7CE;
         transition: box-shadow .3s ease, background-color .3s ease; }
.agent:hover, .agent:focus-visible { box-shadow: 0 0 0 2px var(--line), 0 12px 24px -10px rgba(29, 36, 51, .22),
                                                0 6px 0 -1px #E9E8E1, 0 7px 0 -1px #D9D7CE; }
.agent img { filter: drop-shadow(0 6px 6px rgba(29, 36, 51, .18)); }
/* Working: the card stays put and is highlighted in the agent's color. */
.agent.working { background: linear-gradient(180deg, #FFFFFF 0%, color-mix(in srgb, var(--accent) 7%, #FFFFFF) 100%);
                 box-shadow: 0 0 0 3px var(--accent), 0 14px 30px -14px var(--accent), 0 6px 0 -1px #E9E8E1, 0 7px 0 -1px #D9D7CE; }
/* A parcel just arrived: a short ring, no movement. */
.agent.caught { box-shadow: 0 0 0 3px var(--accent), 0 12px 24px -10px rgba(29, 36, 51, .22), 0 6px 0 -1px #E9E8E1, 0 7px 0 -1px #D9D7CE; }
.agent.chosen { box-shadow: 0 0 0 4px var(--accent), 0 18px 30px -12px rgba(29, 36, 51, .3); }
.arrow { transform: translateZ(4px); }
.arrow svg { filter: drop-shadow(0 2px 2px rgba(29, 36, 51, .15)); }

/* A parcel flying between agents (moved by board.js with the Web Animations API) */
.parcel { position: absolute; left: 0; top: 0; z-index: 50; width: 26px; height: 22px; border-radius: 5px; pointer-events: none;
          background: var(--c); box-shadow: 0 8px 14px -4px rgba(29, 36, 51, .45), inset 0 -4px 0 rgba(0, 0, 0, .18); }
.parcel::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 4px; background: rgba(255, 255, 255, .75); }
.parcel::after { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 3px; background: rgba(255, 255, 255, .45); }

@media (prefers-reduced-motion: reduce) {
  .flow .row, .flow .row.second { transform: none; }
  .agent { transition: none; }
}
@media (max-width: 1100px) { .flow .row, .flow .row.second { transform: none; } }

/* ---------- Focus mode, the "Why?" panel, held orders ---------- */
.pill-button { min-height: 0; padding: 6px 16px; border-radius: 999px; font-size: 16px; background: #EEEEEA; border: 1px solid transparent; }
.pill-button[aria-pressed=true] { background: var(--work-bg); color: var(--work); border-color: #BFD2FA; }
.statusbar .hint { align-self: center; color: var(--muted); font-size: 15px; }
.log ol.focus li:not(.key) { display: none; }
.why { position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(560px, 92vw); overflow-y: auto;
       background: var(--card); border-left: 8px solid var(--agent, var(--ink)); padding: 28px 30px;
       box-shadow: -24px 0 48px -20px rgba(29, 36, 51, .35); animation: slide-in .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.why h2 { font-size: 30px; margin: 0 0 6px; }
.why h3 { font-size: 19px; margin: 18px 0 6px; }
.why .why-job { color: var(--ink-2); margin: 0 0 8px; }
.why .why-item { border-top: 1px solid var(--line); padding-top: 4px; }
.why .why-item p { margin: 4px 0 8px; font-size: 17px; }
.why ul { padding-left: 22px; font-size: 16px; }
.why .trail li { font-size: 16px; }
.why-recent { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.why-recent li { display: grid; grid-template-columns: 104px 1fr; gap: 8px; padding: 5px 0; border-top: 1px solid #F0F0EC; }
.why-recent li.warn { color: var(--warn); }
.why-recent .t { color: var(--muted); }
.why-bar { position: sticky; top: -28px; z-index: 2; display: flex; justify-content: flex-end; margin: -28px -30px 4px;
           padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.why-close { min-height: 40px; padding: 6px 16px; font-size: 18px; }
.approve.held { border-color: #E8B4AC; background: var(--bad-bg); }

/* Daisy's studio */
.ad { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 26px; align-items: start; }
.ad-video video, .ad-placeholder { width: 300px; aspect-ratio: 9 / 16; border-radius: 16px; background: #1D2433; display: block; }
.ad-placeholder { display: flex; align-items: center; justify-content: center; color: #E9E8E2; text-align: center; padding: 20px; }
.ad h2 { font-size: 30px; margin: 10px 0 6px; }
.ad .caption { font-size: 19px; color: var(--ink-2); }
@media (max-width: 800px) { .ad { grid-template-columns: 1fr; } }

/* ---------- Same-size cards: 4 per row; the second row runs right to left ---------- */
.flow { --gap: 10px; --arrow: 56px; }
.flow .row { justify-content: space-between; gap: var(--gap); }
.flow .row .agent { flex: 0 0 calc((100% - 3 * var(--arrow) - 6 * var(--gap)) / 4); height: 158px; min-width: 0; }
.flow .row .arrow { width: var(--arrow); }
.flow .row.reverse { flex-direction: row-reverse; }
.flow .row.reverse .arrow svg { transform: scaleX(-1); }
.flow .arrow.quiet .queue { visibility: hidden; }
.flow .agent .action { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 0; }
.flow .agent .agent-text { flex: 1; min-width: 0; }
.flow .agent h2 { font-size: 25px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #8A909B;
        width: calc((100% - 3 * var(--arrow) - 6 * var(--gap)) / 4); margin: -6px 0 -6px auto; }
.drop svg { filter: drop-shadow(0 2px 2px rgba(29, 36, 51, .15)); }
@media (max-width: 1100px) {
  .flow .row .agent { flex: 1 1 auto; height: auto; }
  .flow .row.reverse { flex-direction: column; }
  .drop { width: 100%; }
}
