/* ExtraWorker UI — same visual system as ExtraDrive, so the Extra properties
   read as one product. Dark by default, light via `body.light`. */

:root {
  --bg: #0a0a0a;
  --panel: #111113;
  --panel-2: #17171a;
  --border: #232328;
  --fg: #f5f5f5;
  --muted: #8a8a8a;
  --faint: #5a5a5a;
  --accent: #ff2d6f;
  --accent-dim: rgba(255, 45, 111, 0.12);
  --ok: #3ecf8e;
  --warn: #f5a623;
  --busy: #4a9eff;
}

body.light {
  --bg: #f6f6f7;
  --panel: #ffffff;
  --panel-2: #efeff1;
  --border: #e0e0e4;
  --fg: #17171a;
  --muted: #6b6b74;
  --faint: #9b9ba3;
  --accent: #e40058;
  --accent-dim: rgba(228, 0, 88, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

button {
  font: inherit;
  color: var(--fg);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:disabled:hover { border-color: var(--border); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.danger:hover { border-color: #ff4d4d; color: #ff6b6b; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 0.3rem 0.5rem; }
button.ghost:hover { color: var(--fg); border-color: var(--border); }

input, textarea, select {
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---- login ---- */

.login-wrap { height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
}
.login h1 { margin: 0 0 0.35rem; font-size: 1.5rem; letter-spacing: -0.02em; }
.login .tagline { margin: 0 0 1.5rem; color: var(--muted); }
.login label { display: block; margin-bottom: 0.4rem; color: var(--muted); font-size: 13px; }
.login input { width: 100%; margin-bottom: 1rem; }
.login button { width: 100%; }
.login .hint { margin-top: 1rem; color: var(--faint); font-size: 12.5px; line-height: 1.5; }

/* ---- shell ---- */

.shell { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.brand img { width: 22px; height: 22px; }
.brand .name { font-weight: 650; letter-spacing: -0.01em; }
.brand .spacer { flex: 1; }

.sidebar-actions { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.sidebar-actions button { width: 100%; }

.session-list { flex: 1; overflow-y: auto; padding: 0.5rem; }
.session-list .empty { color: var(--faint); padding: 2rem 1rem; text-align: center; line-height: 1.6; }

.session-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.15rem;
  cursor: pointer;
}
.session-item:hover { background: var(--panel-2); border-color: transparent; }
.session-item.active { background: var(--accent-dim); border-color: var(--accent); }
.session-item .title {
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}
.session-item .sub { display: flex; align-items: center; gap: 0.4rem; color: var(--faint); font-size: 12px; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.working { background: var(--busy); animation: pulse 1.4s ease-in-out infinite; }
.dot.waiting { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.dot.idle { background: var(--ok); }
.dot.starting { background: var(--busy); animation: pulse 1.4s ease-in-out infinite; }
.dot.hibernated { background: var(--faint); }
.dot.error { background: #ff4d4d; }
.dot.closed { background: var(--border); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- main ---- */

.main { display: flex; flex-direction: column; min-width: 0; }

.main-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.main-header .title { font-weight: 600; letter-spacing: -0.01em; }
.main-header .meta { color: var(--faint); font-size: 12px; }
.main-header .spacer { flex: 1; }

.placeholder { flex: 1; display: grid; place-items: center; color: var(--faint); text-align: center; line-height: 1.7; }

.transcript { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; }

.msg { max-width: 780px; }
.msg .role { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.msg.user { align-self: flex-end; }
.msg.user .body {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 12px 12px 2px 12px;
  padding: 0.65rem 0.85rem;
}
.msg.assistant .body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 2px;
  padding: 0.65rem 0.85rem;
}
.msg.system .body { color: var(--muted); font-size: 12.5px; font-style: italic; }

.tool {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 12px;
  color: var(--muted);
  margin: 0.15rem 0.3rem 0.15rem 0;
}
.tool .name { color: var(--fg); font-family: ui-monospace, monospace; font-size: 11.5px; }

/* Cards the agent is blocked on — the one thing that must not be missable. */
.card {
  border: 1px solid var(--warn);
  background: rgba(245, 166, 35, 0.07);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  max-width: 780px;
}
.card h4 { margin: 0 0 0.5rem; font-size: 13px; }
.card .q { margin-bottom: 0.75rem; }
.card .q .text { margin-bottom: 0.45rem; }
.card .opts { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.card .opts button { font-size: 13px; padding: 0.35rem 0.7rem; }

.composer { border-top: 1px solid var(--border); padding: 0.85rem 1.25rem; background: var(--panel); }
.composer form { display: flex; gap: 0.6rem; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 200px; line-height: 1.5; }

/* ---- toasts ---- */

#toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; }
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  max-width: 380px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: slide-in 0.18s ease-out;
}
.toast.err { border-left-color: #ff4d4d; }
.toast.ok { border-left-color: var(--ok); }
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- modal ---- */

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 40; padding: 1.5rem; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; width: min(520px, 100%); }
.modal h3 { margin: 0 0 1rem; font-size: 1.05rem; }
.modal label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 0.35rem; }
.modal input, .modal textarea, .modal select { width: 100%; margin-bottom: 0.9rem; }
.modal textarea { min-height: 90px; resize: vertical; }
.modal .row { display: flex; gap: 0.6rem; justify-content: flex-end; }
.modal .note { color: var(--faint); font-size: 12.5px; line-height: 1.5; margin: -0.4rem 0 1rem; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .shell.show-list .sidebar { display: flex; }
  .shell.show-list .main { display: none; }
}

/* Where extra-auth's org widget mounts. It renders in a shadow root, so the
   only things reachable from here are the box it sits in and the variables it
   reads. A session belongs to an ID, so the ID sits above the session list. */
.orgslot {
  padding: 10px 12px 0;
  --xo-line: var(--line, #232328);
  --xo-card: var(--panel, #141417);
  --xo-row: var(--panel-2, #17171a);
  --xo-ink: var(--text, #f5f5f5);
  --xo-dim: var(--muted, #8a8a8a);
  --xo-accent: var(--accent, #ff2d6f);
}
.orgslot > * { max-width: 100%; }
.profile-link {
  display: block; padding: 10px 12px; font-size: 12px;
  color: var(--muted, #8a8a8a); text-decoration: none; word-break: break-all;
  border-top: 1px solid var(--line, #232328);
}
.profile-link:hover { color: var(--text, #f5f5f5); }

/* Budget meter: always on, so a limit is never news. The bar follows whichever
   window is closer to its ceiling — the one that will actually stop you. */
.spend {
  padding: 10px 12px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.spend .row { display: flex; align-items: baseline; gap: 6px; }
.spend .row .spacer { flex: 1; }
.spend .row b { color: var(--fg); font-weight: 600; }
.spend .mo { color: var(--faint); }
.spend .bar {
  margin-top: 6px; height: 3px; border-radius: 2px;
  background: var(--panel-2); overflow: hidden;
}
.spend .bar i { display: block; height: 100%; background: var(--ok); transition: width 0.3s; }
.spend.near .bar i { background: var(--warn); }
.spend.over .bar i { background: var(--accent); }
.spend .note { margin-top: 6px; color: var(--accent); line-height: 1.4; }
