/* Brainpot AI app styles. Palette: light yellow, emerald, pacific cyan, bubblegum pink, amber gold. */
:root {
  --bg: #F8FFE5;
  --paper: #ffffff;
  --ink: #0f2a2d;
  --muted: #4d6663;
  --line: rgba(15, 42, 45, 0.12);
  --soft: rgba(15, 42, 45, 0.05);
  --emerald: #06D6A0;
  --cyan: #1B9AAA;
  --pink: #EF476F;
  --amber: #FFC43D;
  --on-color: #0f2a2d;
  --sans: "Helvetica Neue", Helvetica, Arial, "Nimbus Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1f22;
    --paper: #12292d;
    --ink: #F8FFE5;
    --muted: #a6bdb8;
    --line: rgba(248, 255, 229, 0.12);
    --soft: rgba(248, 255, 229, 0.05);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { letter-spacing: -0.03em; line-height: 1.1; margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.875em; }
[hidden] { display: none !important; }

.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
@media (min-width: 720px) { .wrap { padding-left: max(40px, env(safe-area-inset-left, 0px)); padding-right: max(40px, env(safe-area-inset-right, 0px)); } }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; letter-spacing: -0.03em; text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand .ai { font-weight: 400; color: var(--muted); }

/* Buttons and fields */
.btn { font: inherit; font-weight: 700; font-size: 1rem; border-radius: 12px; padding: 12px 18px; border: 0; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-main { background: var(--emerald); color: var(--on-color); }
.btn-main:hover { filter: brightness(0.94); }
.btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-line:hover { box-shadow: inset 0 0 0 1.5px var(--muted); }
.btn-danger { background: transparent; color: var(--pink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-sm { padding: 7px 12px; font-size: 0.875rem; border-radius: 10px; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: default; }
label { display: block; font-weight: 700; font-size: 0.9375rem; margin-bottom: 6px; }
input[type="text"], input[type="email"], textarea, select {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(27, 154, 170, 0.18); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--emerald); }
.hint { font-size: 0.875rem; color: var(--muted); margin: 8px 0 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1 1 220px; min-width: 0; width: auto; }
.stack { display: grid; gap: 16px; }

/* Flash */
.flash { border-radius: 12px; padding: 12px 16px; font-weight: 700; margin-bottom: 20px; }
.flash.ok { background: rgba(6, 214, 160, 0.16); }
.flash.error { background: rgba(239, 71, 111, 0.14); color: var(--ink); }
.dev { border: 1.5px dashed var(--amber); border-radius: 12px; padding: 12px 16px; font-size: 0.875rem; margin-top: 16px; word-break: break-all; }
.dev b { display: block; margin-bottom: 4px; }

/* Plain (auth) layout */
.plain { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.plain header { padding-block: 22px; }
.plain main { display: grid; place-items: center; padding-block: 24px 64px; }
.card { width: 100%; max-width: 480px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px, 4vw, 36px); }
.card h1 { font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem); margin-bottom: 10px; }
.card p.lead { color: var(--muted); margin: 0 0 22px; }
.card .divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.8125rem; margin: 20px 0; }
.card .divider::before, .card .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.icon-badge { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 18px; background: rgba(6, 214, 160, 0.18); }
.icon-badge svg { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.plain footer { padding-block: 20px 28px; color: var(--muted); font-size: 0.875rem; text-align: center; }

/* App layout */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.topbar .wrap { display: flex; align-items: center; gap: 20px; padding-block: 14px; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 0.9375rem; }
.topbar nav a:hover { color: var(--ink); background: var(--soft); }
.topbar nav a.on { color: var(--ink); background: var(--soft); }
.topbar .spacer { flex: 1; }
.ws-switch { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; }
.ws-switch select { width: auto; padding: 6px 10px; font-size: 0.875rem; border-radius: 10px; }
.plan-chip { font-size: 0.75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--amber); color: var(--on-color); white-space: nowrap; }
.page { padding-block: 32px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(2rem, 1.5rem + 1.8vw, 3rem); }
.page-head .sub { color: var(--muted); margin: 6px 0 0; }
.crumbs { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { text-decoration: none; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: clamp(18px, 2.5vw, 28px); min-width: 0; }
.panel h2 { font-size: 1.25rem; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Pot */
.overview { font-size: 1.125rem; white-space: pre-wrap; margin: 0; }
.facts { list-style: none; margin: 0; padding: 0; }
.fact { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; padding: 14px 4px; border-top: 1px solid var(--line); align-items: start; }
.fact:first-child { border-top: 0; }
.fact .id { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); padding-top: 4px; }
.fact .text { font-size: 1.0625rem; }
.fact .meta { grid-column: 2; font-size: 0.8125rem; color: var(--muted); }
.fact .key { font-family: var(--mono); font-size: 0.75rem; background: var(--soft); padding: 2px 7px; border-radius: 6px; margin-left: 6px; white-space: nowrap; }
.fact .pin { font-size: 0.75rem; font-weight: 700; background: var(--amber); color: var(--on-color); padding: 2px 8px; border-radius: 999px; margin-right: 6px; }
.fact .actions { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 6px; }
.fact details.edit { grid-column: 1 / -1; }
.fact details.edit summary { display: none; }
.fact .edit-form { display: grid; gap: 10px; padding: 12px; margin-top: 8px; background: var(--soft); border-radius: 14px; }
.empty { color: var(--muted); padding: 20px 0; }
.tree { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px solid var(--line); }
.tree a { display: flex; justify-content: space-between; gap: 8px; text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.tree a:hover { background: var(--soft); }
.tree a.on { background: rgba(6, 214, 160, 0.18); font-weight: 700; }
.tree .n { color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; margin: 8px 0 4px; }
.meter span { display: block; height: 100%; background: var(--emerald); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th { text-align: left; font-size: 0.8125rem; color: var(--muted); font-weight: 700; padding: 10px 8px; border-bottom: 1.5px solid var(--line); }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.role { font-size: 0.75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--soft); text-transform: capitalize; }
.role.owner { background: var(--amber); color: var(--on-color); }
.role.admin { background: rgba(27, 154, 170, 0.22); }
.switch { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--line); border: 0; cursor: pointer; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch.on { background: var(--emerald); }
.switch.on::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; cursor: default; }

/* History */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 6px 16px; padding: 14px 0; border-top: 1px solid var(--line); align-items: start; }
.timeline .when { font-size: 0.8125rem; color: var(--muted); }
.timeline .act { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 6px; }
.act.create { background: rgba(6, 214, 160, 0.22); }
.act.update { background: rgba(27, 154, 170, 0.22); }
.act.delete { background: rgba(239, 71, 111, 0.2); }
.act.restore { background: rgba(255, 196, 61, 0.35); }
.diff del { color: var(--pink); text-decoration: line-through; }
.diff ins { text-decoration: none; background: rgba(6, 214, 160, 0.2); }
@media (max-width: 640px) { .timeline li { grid-template-columns: minmax(0, 1fr); } }

/* Connect */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.tool-card { border: 1px solid var(--line); border-radius: 18px; padding: 20px; background: var(--paper); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; min-width: 0; }
@media (min-width: 900px) { .tool-card.wide { grid-column: span 2; } }
.tool-card h3 { font-size: 1.125rem; display: flex; align-items: center; gap: 8px; }
.tool-card h3::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--c, var(--cyan)); }
.tool-card ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 0.9375rem; display: grid; gap: 4px; }
.code { position: relative; min-width: 0; }
.code pre { margin: 0; font-family: var(--mono); font-size: 0.8125rem; line-height: 1.55; background: var(--soft); border-radius: 10px; padding: 12px 84px 12px 14px; overflow-x: auto; white-space: pre; }
.copy { position: absolute; top: 7px; right: 7px; z-index: 1; font: inherit; font-size: 0.8125rem; font-weight: 700; border: 0; border-radius: 8px; padding: 6px 12px; background: var(--ink); color: var(--bg); cursor: pointer; }
.new-token { border: 2px solid var(--emerald); }

/* No widows or orphans: balance headings, keep the last line of paragraphs from being one word. */
h1, h2, h3, .lead, .sub { text-wrap: balance; }
p, li, td, .hint, .overview, .fact .text { text-wrap: pretty; }

#instr + .copy { top: auto; bottom: 8px; }

/* Client picker and onboarding */
.picker-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.picker-tabs button { font: inherit; font-weight: 700; font-size: 0.9375rem; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.picker-tabs button::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.picker-tabs button:hover { border-color: var(--muted); }
.picker-tabs button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.steps-list { margin: 0; padding-left: 22px; display: grid; gap: 14px; }
.steps-list li { padding-left: 4px; line-height: 1.5; }
.steps-list li .code, .steps-list li form { margin-top: 8px; }
.status { display: flex; gap: 10px; align-items: flex-start; margin-top: 20px; padding: 12px 14px; border-radius: 12px; background: var(--soft); font-size: 0.9375rem; color: var(--muted); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); flex: none; margin-top: 6px; animation: bp-pulse 1.6s ease-in-out infinite; }
.status.ok, .status.done { color: var(--ink); background: rgba(6, 214, 160, 0.12); }
.status.ok .dot, .status.done .dot { background: var(--emerald); animation: none; }
@keyframes bp-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status .dot { animation: none; } }
.onboard { display: grid; gap: 20px; max-width: 860px; }
.step-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.step-head h2 { margin: 2px 0 4px; font-size: 1.375rem; }
.step-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--emerald); color: var(--on-color); flex: none; }

/* User menu */
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1.5px solid var(--line); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { border-color: var(--muted); }
.usermenu .avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--emerald); color: var(--on-color); font-weight: 700; font-size: 0.875rem; }
.usermenu .uname { font-weight: 700; font-size: 0.9375rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .usermenu .uname { display: none; } .usermenu summary { padding: 3px; } }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); z-index: 20; display: grid; }
.usermenu .menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; gap: 2px; min-width: 0; }
.usermenu .menu-head span { font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.usermenu .menu a, .usermenu .menu button { display: block; width: 100%; text-align: left; font: inherit; font-weight: 700; font-size: 0.9375rem; color: var(--ink); background: none; border: 0; padding: 10px 12px; border-radius: 10px; text-decoration: none; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover, .usermenu .menu a.on { background: var(--soft); }
.usermenu .menu form { margin: 0; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
