:root {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #ebebf0;
  --border: #d9d9e0;
  --text: #1c1c22;
  --muted: #666672;
  --accent: #5b4bd6;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --ok: #1f8a5b;
  --shadow: 0 1px 2px rgba(20, 20, 40, .08), 0 2px 8px rgba(20, 20, 40, .06);
  --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #212127;
    --surface-2: #2b2b33;
    --border: #3a3a44;
    --text: #ececf1;
    --muted: #a0a0ad;
    --accent: #8f82f5;
    --accent-text: #14141a;
    --danger: #ef7a6d;
    --ok: #55c79a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
}
#app { height: 100%; display: flex; flex-direction: column; }
main { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.spacer, .grow { flex: 1; }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 9px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
button {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; cursor: pointer;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button:disabled { opacity: .6; cursor: default; }
.link-btn { border: none; background: none; padding: 2px 4px; color: var(--accent); text-decoration: underline; }
.lang-links { margin: 14px 0 0; text-align: center; font-size: 13px; }
.icon-btn { border: none; background: none; padding: 2px 8px; border-radius: 6px; color: var(--muted); line-height: 1.2; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; flex: 1; min-width: 150px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-error { color: var(--danger); min-height: 1em; margin: 0 0 8px; }
.form-error:empty { display: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 48px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img { width: 24px; height: 24px; border-radius: 5px; }
.tool-nav { display: flex; gap: 4px; }
.tool-nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tool-nav a:hover { background: var(--surface-2); }
.tool-nav a.active { color: var(--text); background: var(--surface-2); }
.user-btn { border: none; background: none; padding: 2px; border-radius: 50%; }

.avatar {
  --size: 24px; width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: calc(var(--size) * .42); font-weight: 700; user-select: none;
}
.avatar.empty { border: 1.5px dashed var(--border); }

/* pages */
.page { width: 100%; max-width: 860px; margin: 0 auto; padding: 28px 16px; }
.page.narrow { max-width: 420px; }
.card, .center-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.center-card { width: min(380px, calc(100% - 32px)); margin: 12vh auto 0; }
.center-card button.primary { width: 100%; }

.launcher { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-card {
  display: flex; gap: 12px; align-items: center; padding: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--accent); }
.tool-card img { width: 40px; height: 40px; }
.tool-card p { margin: 0; }

.people { list-style: none; padding: 0; margin: 0 0 24px; }
.people li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); margin-bottom: -1px;
}
.people li:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.people li:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.people li.inactive > :not(.icon-btn) { opacity: .5; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}

/* menu + toast */
.menu {
  position: absolute; z-index: 100; min-width: 170px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18); display: flex; flex-direction: column;
}
.menu button { border: none; background: none; text-align: left; padding: 7px 10px; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  padding: 10px 16px; border-radius: var(--radius); color: #fff; background: var(--danger);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); max-width: calc(100% - 32px);
}
.toast.ok { background: var(--ok); }
@media (prefers-color-scheme: dark) { .toast { color: #14141a; } }

/* Agent access: a newly created token and the text to hand to an agent */
.token-new { margin-bottom: 24px; border-color: var(--accent); }
.copy-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.copy-row code, .copy-row pre {
  flex: 1; min-width: 0; margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--surface-2);
  font: 13px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
  user-select: all;
}
