:root {
  color-scheme: dark;
  --background: #071019;
  --panel: #0d1923;
  --panel-raised: #12232d;
  --ink: #eef8fb;
  --muted: #93aab4;
  --line: rgba(191, 221, 232, .14);
  --cyan: #65e6e3;
  --blue: #17c9ff;
  --lime: #c0ee96;
  --red: #ff9288;
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: radial-gradient(ellipse at 77% 2%, rgba(4, 87, 111, .22), transparent 36rem), var(--background); }
button, input, select, textarea { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }
.page-shell { width: min(1280px, calc(100% - 44px)); margin: 0 auto; padding-bottom: 70px; }
.topbar { display: flex; min-height: 82px; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.brand img { display: block; width: min(210px, 45vw); height: auto; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.quiet-link, .subtle { color: var(--muted); font-size: 12px; }
.welcome-row { display: flex; align-items: end; justify-content: space-between; gap: 22px; padding: 45px 0 25px; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: 'Avenir Next', 'Segoe UI', sans-serif; letter-spacing: -.035em; }
h1 { margin-bottom: 9px; font-size: clamp(31px, 4vw, 44px); }
h2 { margin-bottom: 0; font-size: 22px; }
.muted { max-width: 680px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.eyebrow { margin-bottom: 9px; color: var(--cyan); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 17px; }
.metric, .panel, .login-card { border: 1px solid var(--line); background: rgba(13, 25, 35, .86); box-shadow: 0 16px 40px rgba(0, 0, 0, .12); }
.metric { display: grid; min-height: 94px; align-content: space-between; padding: 15px; border-radius: 10px; }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { font: 600 25px 'Avenir Next', 'Segoe UI', sans-serif; }
.panel { padding: 20px; border-radius: 12px; }
.agent-panel { margin-bottom: 17px; }
.chat-panel { margin-bottom: 17px; }
.chat-transcript { display: grid; max-height: 390px; gap: 12px; overflow-y: auto; margin-top: 17px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: #07131c; }
.chat-empty { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.chat-message { width: fit-content; max-width: min(850px, 94%); padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message[data-role="user"] { justify-self: end; border-color: rgba(23, 201, 255, .28); background: rgba(23, 201, 255, .09); }
.chat-message[data-role="assistant"] { justify-self: start; background: var(--panel-raised); }
.chat-prompts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.chat-form { display: flex; align-items: end; gap: 9px; margin-top: 11px; }
.chat-form textarea { min-height: 48px; max-height: 160px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading .eyebrow { margin-bottom: 5px; }
.mode-badge, .status-badge { padding: 5px 9px; border: 1px solid rgba(101, 230, 227, .23); border-radius: 30px; color: var(--cyan); font-size: 10px; white-space: nowrap; }
.url-form { display: flex; gap: 10px; margin-top: 17px; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: #07131c; }
input, select { min-height: 43px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; }
input::placeholder { color: #627a85; }
.button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 12px; padding: 0 14px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; }
.button:disabled { cursor: wait; opacity: .6; }
.button-primary { background: var(--blue); color: #03151c; }
.button-primary:hover:not(:disabled) { background: #72e4ff; }
.button-secondary { border-color: rgba(101, 230, 227, .35); background: rgba(21, 54, 62, .65); color: var(--cyan); }
.button-quiet { border-color: var(--line); background: transparent; color: var(--muted); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(285px, .8fr); align-items: start; gap: 17px; }
.side-column { display: grid; gap: 17px; }
.toolbar { display: flex; gap: 9px; margin: 17px 0 9px; }
.toolbar select { width: auto; }
.game-list, .job-list, .activity-list { display: grid; }
.game-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 15px; padding: 14px 0; border-top: 1px solid var(--line); }
.game-title { overflow: hidden; margin: 0 0 4px; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.game-meta { color: var(--muted); font-size: 11px; }
.game-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.small-button { min-height: 31px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; }
.small-button:hover { border-color: var(--cyan); color: var(--cyan); }
.small-button.is-published { color: var(--lime); }
.job-item, .activity-item { padding: 12px 0; border-top: 1px solid var(--line); }
.job-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-name { font-size: 12px; font-weight: 700; }
.job-status { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.job-status[data-status="failed"] { color: var(--red); }
.job-status[data-status="completed"] { color: var(--lime); }
.job-message, .activity-item { color: var(--muted); font-size: 11px; line-height: 1.55; }
.job-message { margin: 6px 0 0; }
.job-details { margin-top: 7px; color: var(--muted); font-size: 10px; }
.job-details summary { cursor: pointer; color: var(--cyan); }
.job-details pre { overflow-x: auto; white-space: pre-wrap; }
.login-card { width: min(430px, 100%); margin: clamp(65px, 13vh, 130px) auto; padding: 28px; border-radius: 12px; }
.login-card .muted { margin-bottom: 22px; }
form label { display: block; margin: 13px 0 7px; color: var(--muted); font-size: 11px; }
.login-card form .button { width: 100%; margin-top: 14px; }
.notice { margin: 12px 0 0; color: var(--red); font-size: 12px; line-height: 1.5; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.edit-dialog { width: min(540px, calc(100% - 28px)); max-height: min(88vh, 780px); padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #0d1923; color: var(--ink); }
.edit-dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(4px); }
.edit-dialog form > label:not(.check-label) { margin-top: 15px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 21px; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 16px; min-height: 16px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 5; max-width: min(380px, calc(100% - 44px)); padding: 12px 16px; transform: translateY(20px); border: 1px solid var(--line); border-radius: 8px; background: #12232d; color: var(--ink); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 600px) {
  .page-shell { width: min(100% - 28px, 1280px); }
  .topbar { min-height: 68px; }
  .header-actions { gap: 10px; }
  .quiet-link { font-size: 10px; }
  .welcome-row { align-items: start; flex-direction: column; padding-top: 30px; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric { min-height: 78px; padding: 11px; }
  .metric strong { font-size: 22px; }
  .panel { padding: 15px; }
  .url-form { flex-direction: column; }
  .chat-form { align-items: stretch; flex-direction: column; }
  .chat-form .button { align-self: end; }
  .side-column { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar select { width: 100%; }
  .game-row { grid-template-columns: 1fr; }
  .game-actions { justify-content: start; }
}
