/* =========================================================================
   hosted·ai TokenFactory — user panel
   Design tokens lifted from hostedai-user-ui (Plus Jakarta Sans, #305eff,
   #f5f5f5 canvas, card-shadow 2px 4px 18px rgba(0,0,0,.05)).
   ========================================================================= */
:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --ink: #222222;
  --muted: #555555;
  --muted-2: #808080;
  --line: #e5e7eb;
  --line-soft: #eef0f3;

  --primary: #305eff;
  --primary-700: #2243b6;
  --primary-600: #2950da;
  --primary-050: #e1e8ff;
  --primary-025: #edf0fd;
  --primary-015: #f6f7fe;
  --lavender: #7493ff;

  --green: #209144;   --green-bg: #e2ffeb;
  --amber: #b8821b;   --amber-bg: #fff6e6;
  --red: #d23b22;     --red-bg: #ffe7e2;
  --purple: #7c52ff;  --purple-bg: #f6e6ff;
  --cyan: #1597b8;    --cyan-bg: #e3fbff;
  --orange: #e07b1a;  --orange-bg: #fdeed3;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-card: 2px 4px 18px rgba(0, 0, 0, .05);
  --shadow-pop: 1px 4px 34px -1px rgba(0, 0, 0, .12);
  --shadow-btn: 0 2px 10px rgba(48, 94, 255, .25);

  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--primary-050); }

/* ---- App shell layout ---------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app--auth { grid-template-columns: 1fr; }
.app--auth .sidebar { display: none; }

/* ---- Sidebar ------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar-top { padding: 0 6px; }
.brand { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.brand-mark { flex: none; color: inherit; display: block; overflow: visible; }
.brand-img { object-fit: contain; }
.brand-word { font-weight: 800; font-size: 18px; letter-spacing: -.01em; color: var(--ink); }
.brand-dot { color: var(--primary); }
.brand-tag {
  margin-left: 2px; align-self: flex-start;
  font: 600 9.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-050);
  padding: 4px 6px; border-radius: 5px;
}
.acct-switch {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 10px; margin-bottom: 8px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-xs);
  color: var(--ink); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.acct-switch:hover { background: var(--primary-015); }
.acct-switch svg { color: var(--muted-2); }
.acct-team { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sidebar-top { position: relative; }
.team-menu {
  position: absolute; left: 6px; right: 6px; top: 100%; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-pop); padding: 6px;
}
.tm-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 7px; font-size: 13px; border: 0; background: none; text-align: left; color: var(--ink); }
.tm-row.current { justify-content: space-between; }
.tm-row.current svg { color: var(--green); flex: none; }
.tm-ns { font: 500 10.5px/1 var(--mono); color: var(--muted-2); margin-left: 7px; }
.tm-sep { height: 1px; background: var(--line-soft); margin: 5px 4px; }
.tm-row.tm-disabled { color: var(--muted-2); cursor: not-allowed; font-weight: 600; }
.tm-row.tm-disabled svg { color: var(--muted-2); flex: none; }
.tm-soon { margin-left: auto; font: 600 9.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--amber); background: var(--amber-bg); padding: 3px 6px; border-radius: 5px; }
.acct-ns {
  font: 500 10.5px/1 var(--mono); color: var(--primary-700);
  background: var(--primary-050); padding: 3px 7px; border-radius: 999px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.nav.nav-secondary { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.nav-spacer { flex: 1 1 auto; }

.nav-label {
  font: 700 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: #b3b9c9; padding: 6px 10px 7px;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-xs);
  color: var(--muted); font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer; transition: background .12s, color .12s;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 22%; height: 56%; width: 3px;
  border-radius: 3px; background: var(--primary);
}
.nav-item svg { flex: none; color: var(--muted-2); }
.nav-item:hover { background: var(--primary-015); color: var(--ink); }
.nav-item:hover svg { color: var(--muted); }
.nav-item.active {
  background: var(--primary-050); color: var(--primary-700);
  border-color: #d3ddff;
}
.nav-item.active svg { color: var(--primary); }

/* Account block (bottom) */
.acct { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 6px; }
.acct-name { font-weight: 700; font-size: 13px; color: var(--ink); padding: 0 8px; }
.acct-email { font-size: 12px; color: var(--muted-2); padding: 1px 8px 8px; word-break: break-all; }
.acct-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border: 0; background: transparent; border-radius: var(--radius-xs);
  color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.acct-link svg { color: var(--muted-2); }
.acct-link:hover { background: var(--primary-015); color: var(--ink); }

/* ---- Main / page header -------------------------------------------------- */
.main { min-width: 0; padding: 30px 36px 60px; }
.app--auth .main { padding: 0; }
.upgrade-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto 18px;
  padding: 13px 15px;
  border: 1px solid #b99b39;
  border-radius: 8px;
  background: #fff8df;
  color: #3d3108;
  box-shadow: 0 8px 24px rgba(29, 25, 10, .06);
}
.upgrade-copy { display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.45; }
.upgrade-copy b { font-size: 13.5px; }
.upgrade-dismiss {
  border: 0;
  background: transparent;
  color: #5d4a0b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.upgrade-dismiss:hover { color: #1f1802; }
.page { max-width: 1180px; margin: 0 auto; animation: fade-in .22s ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 7px; margin-bottom: 14px; font-size: 14px; color: var(--muted-2); }
.breadcrumb a { color: var(--primary); font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-title { margin: 0; font-size: 16px; font-weight: 700; }
.card-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1080px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--radius-xs); border: 1px solid transparent;
  font-weight: 700; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .14s, border-color .14s, box-shadow .14s, opacity .14s;
}
.btn svg { flex: none; }
.btn-primary { background: var(--primary-700); color: #fff; }
.btn-primary:hover { background: #1c3a9e; }
.btn-accent { background: var(--primary); color: #fff; box-shadow: var(--shadow-btn); }
.btn-accent:hover { background: var(--primary-600); }
.btn-lavender { background: var(--lavender); color: #fff; }
.btn-lavender:hover { background: #5d7dfb; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: #cfd6e4; background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--primary-015); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 2px 10px rgba(210, 59, 34, .18); }
.btn-danger:hover { background: #b92f1b; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: default; box-shadow: none; }

/* ---- Segmented control / tabs ------------------------------------------- */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 13px; border-radius: 7px; font-weight: 700; font-size: 13px;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--primary-700); color: #fff; }
.seg.seg-soft button.active { background: var(--primary-050); color: var(--primary-700); }

.pilltabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pilltab {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 7px 15px; border-radius: 999px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.pilltab:hover { border-color: #cfd6e4; color: var(--ink); }
.pilltab.active { background: var(--primary-700); color: #fff; border-color: var(--primary-700); }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 0 0 12px; margin-bottom: -1px; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary-700); border-bottom-color: var(--primary-700); }

/* ---- Badges / chips ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px; font-weight: 600; font-size: 11.5px;
  background: #f0f1f4; color: var(--muted);
}
.badge-type { text-transform: capitalize; }
.t-text { background:#eef1f6; color:#475569; }
.t-code { background:#e7f0ff; color:#1e57c7; }
.t-reasoning { background: var(--purple-bg); color: var(--purple); }
.t-multimodal { background:#e9e6ff; color:#5b46d6; }
.t-vision { background: var(--cyan-bg); color: var(--cyan); }
.t-image { background:#ffe9f1; color:#c43168; }
.t-audio { background: var(--amber-bg); color: var(--amber); }
.t-video { background:#e6f7ee; color:#1f8b54; }
.t-embedding { background:#eef1f6; color:#475569; }

.chip { display:inline-flex; align-items:center; padding:4px 10px; border-radius:7px; font-weight:600; font-size:12px; background: var(--primary-025); color: var(--primary-700); }
.chips { display:flex; flex-wrap:wrap; gap:8px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }

/* ---- Fields -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 12.5px; color: var(--muted); }
.input, input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius-xs);
  background: var(--surface); color: var(--ink); font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(48,94,255,.12); }
.input-search { position: relative; }
.input-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.input-search input { padding-left: 40px; }
.input-icon-lg input { height: 52px; font-size: 15px; }

/* ---- Stat / KPI cards ---------------------------------------------------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 18px; }
.kpi-head { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.kpi-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: var(--radius-xs); background: var(--primary-025); color: var(--primary); }
.kpi-ico.green { background: var(--green-bg); color: var(--green); }
.kpi-ico.amber { background: var(--amber-bg); color: var(--amber); }
.kpi-val { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.kpi-val.accent { color: var(--primary-700); }
.kpi-sub { color: var(--muted-2); font-size: 12px; margin-top: 6px; }

/* ---- Progress ------------------------------------------------------------ */
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.green > i { background: var(--green); }
.progress.indeterminate > i { width: 38%; animation: progress-scan 1.2s ease-in-out infinite; }
@keyframes progress-scan { 0% { transform: translateX(-110%); } 100% { transform: translateX(270%); } }

/* ---- Table --------------------------------------------------------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th { text-align: left; padding: 13px 16px; color: var(--muted); font-weight: 700; font-size: 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); color: var(--ink); white-space: nowrap; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--primary-015); }
.td-mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted-2); }
.empty svg { color: #c7ccd6; margin-bottom: 10px; }

/* ---- Code block ---------------------------------------------------------- */
.code {
  background: #0c1020; border: 1px solid #1b2238; border-radius: var(--radius);
  overflow: hidden;
}
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #1b2238; }
.code-tabs { display: flex; gap: 16px; }
.code-tab { background: 0; border: 0; color: #8893b5; font: 600 12.5px var(--font); cursor: pointer; border-bottom: 2px solid transparent; padding-bottom: 6px; }
.code-tab.active { color: #fff; border-bottom-color: var(--primary); }
.code-name { font: 500 12px var(--mono); color: #8893b5; display: flex; align-items: center; gap: 8px; }
.code pre { margin: 0; padding: 18px; overflow-x: auto; }
.code code { font: 13px/1.7 var(--mono); color: #d7def0; white-space: pre; }
.code .k { color: #ff9d6e; } .code .s { color: #8ee6b0; } .code .c { color: #5d6b8f; } .code .f { color: #79b8ff; }
.copy-btn { background: 0; border: 0; color: #8893b5; cursor: pointer; display: inline-flex; }
.copy-btn:hover { color: #fff; }

/* ---- Toast --------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-weight: 600; font-size: 13px; box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Background jobs ----------------------------------------------------- */
.task-tray {
  position: fixed; right: 22px; bottom: 22px; z-index: 55;
  width: min(390px, calc(100vw - 28px)); display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.task-card {
  pointer-events: auto; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 28px;
  gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; box-shadow: var(--shadow-pop);
}
.task-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: var(--primary-700); background: var(--primary-050);
}
.task-success .task-icon { color: var(--green); background: var(--green-bg); }
.task-error .task-icon { color: var(--red); background: var(--red-bg); }
.task-copy { min-width: 0; }
.task-title { font-weight: 800; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-sub { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-link { font-weight: 700; font-size: 12px; color: var(--primary); text-decoration: none; white-space: nowrap; }
.task-link:hover { text-decoration: underline; }
.task-x { border: 0; background: transparent; color: var(--muted-2); font-size: 18px; line-height: 1; cursor: pointer; width: 26px; height: 26px; border-radius: 7px; }
.task-x:hover { background: var(--surface-2); color: var(--ink); }
.task-bar { height: 3px; border-radius: 999px; background: #e9edf7; overflow: hidden; margin-top: 8px; }
.task-bar span { display: block; width: 72%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8aa2ff); }

/* =========================================================================
   Login
   ========================================================================= */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth-aside {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(116,147,255,.55), transparent 60%),
    radial-gradient(700px 600px at 110% 120%, rgba(48,94,255,.65), transparent 55%),
    linear-gradient(160deg, #14235f 0%, #1b3aa8 52%, #305eff 100%);
  padding: 56px 60px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 38px 38px; mask-image: radial-gradient(620px 420px at 70% 30%, #000, transparent 75%); pointer-events: none;
}
.auth-brand { display: flex; align-items: center; gap: 11px; position: relative; z-index: 1; }
.auth-brand .brand-img { filter: invert(1); }
.brand-mobile .brand-img { filter: none; }
.auth-brand .brand-word { color: #fff; font-size: 21px; }
.auth-brand .brand-dot { color: #9fb4ff; }
.auth-brand .brand-tag { background: rgba(255,255,255,.14); color: #fff; }
.auth-copy { position: relative; z-index: 1; max-width: 30ch; }
.auth-copy h2 { font-size: 34px; line-height: 1.12; letter-spacing: -.02em; margin: 0 0 14px; font-weight: 800; }
.auth-copy p { color: #cdd8ff; font-size: 15px; margin: 0; }
.auth-feats { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 12px; }
.auth-feat { display: flex; align-items: center; gap: 11px; color: #e7ecff; font-size: 14px; font-weight: 500; }
.auth-feat svg { color: #9fb4ff; flex: none; }

.auth-main { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.auth-card { width: 100%; max-width: 392px; }
.auth-card .brand-mobile { display: none; }
.auth-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card .lead { color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; }
.auth-row a { color: var(--primary); font-weight: 600; font-size: 13px; }
.auth-row a:hover { text-decoration: underline; }
.auth-divider { display: flex; align-items: center; gap: 14px; color: var(--muted-2); font-size: 12px; margin: 22px 0; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.sso { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sso .btn { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; }
.sso .btn:hover { background: var(--surface-2); }
.auth-foot { margin-top: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-foot a { color: var(--primary); font-weight: 600; }
.auth-legal { margin-top: 30px; text-align: center; color: var(--muted-2); font-size: 11.5px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card .brand-mobile { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 26px; }
}

/* =========================================================================
   Models
   ========================================================================= */
.models-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1240px) { .models-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 980px) { .models-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .models-grid { grid-template-columns: 1fr; } }

.mcard {
  display: flex; flex-direction: column; gap: 12px; min-height: 168px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 16px; cursor: pointer;
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.mcard:hover { border-color: #c4d0f5; box-shadow: 0 8px 26px rgba(48,94,255,.12); transform: translateY(-2px); }
.mcard-top { display: flex; gap: 11px; }
.mcard-body { flex: 1; min-width: 0; }
.mcard-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.mcard-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.mcard-desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mcard-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); }
.mcard-foot .price { font-family: var(--mono); font-size: 11.5px; }
.mcard-foot .sep { color: #c7ccd6; }
.mcard-foot .more { margin-left: auto; color: var(--primary); font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.mcard-foot .soon-tag { margin-left: auto; color: var(--muted-2); font-weight: 700; font-size: 12px; }
.mcard-foot .import-actions { margin-left: auto; display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.mcard-foot .import-actions .soon-tag,
.mcard-foot .import-actions .more { margin-left: 0; }
.mcard-foot .import-del-btn { min-height: 26px; padding: 3px 8px; border-radius: 8px; font-size: 12px; color: var(--danger); }
.mcard-foot .import-del-btn:hover { color: var(--danger); background: rgba(185, 28, 28, .08); }
.mcard.soon { opacity: .62; cursor: default; }
.mcard.soon:hover { border-color: var(--line); box-shadow: var(--shadow-card); transform: none; }
.badge-soon { background: var(--amber-bg); color: var(--amber); }

.avatar {
  width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -.02em;
}
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.avatar.lg { width: 46px; height: 46px; border-radius: 12px; font-size: 19px; }

.commit-rates { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.commit-rates .cr { display: flex; align-items: baseline; gap: 9px; }
.commit-rates .cr b { color: var(--green); font-size: 18px; font-weight: 800; }

/* Model detail */
.detail-head { display: flex; align-items: flex-start; gap: 14px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 22px; }
.detail-id { display: flex; align-items: center; gap: 12px; }
.detail-id .avatar { width: 40px; height: 40px; }
.detail-name { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-slug { font-family: var(--mono); font-size: 13px; color: var(--muted-2); margin-top: 4px; }
.pricing-row { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.pricing-row .pl { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.pricing-row .pv { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.pricing-row .pv small { font-size: 14px; font-weight: 600; color: var(--muted-2); }
.statbox .sl { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.statbox .sv { font-size: 19px; font-weight: 700; }
.statbox .sv.mono { font-family: var(--mono); font-size: 15px; color: var(--primary-700); }

/* =========================================================================
   Playground
   ========================================================================= */
.pg-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pg-modes { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.pg-modes button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 7px 14px; border-radius: 7px; font-weight: 700; font-size: 13px; }
.pg-modes button.active { background: var(--primary-700); color: #fff; }
.pg-model { flex: 1; min-width: 220px; position: relative; }
.pg-model select { appearance: none; padding-right: 38px; font-weight: 600; }
.pg-len { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pg-len select { width: auto; padding: 9px 10px; font-weight: 600; }
.pg-model .chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }

.pg-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); display: flex; flex-direction: column; height: calc(100vh - 250px); min-height: 420px; }
.pg-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.pg-clear { display: inline-flex; align-items: center; gap: 6px; background: 0; border: 0; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.pg-clear:hover { color: var(--ink); }
.pg-modelid { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.pg-log { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.pg-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: var(--muted-2); }
.pg-empty .eicon { width: 46px; height: 46px; color: #c4cbe0; }
.pg-examples { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 720px; }
.pg-ex { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; color: var(--ink); font-size: 13px; cursor: pointer; }
.pg-ex:hover { border-color: var(--primary); color: var(--primary-700); background: var(--primary-015); }

.msg { display: flex; gap: 12px; max-width: 100%; }
.msg .who { width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; }
.msg.user .who { background: #3b4252; }
.msg.bot .who { background: var(--primary); }
.msg .bubble { padding-top: 4px; }
.msg .bubble p { margin: 0 0 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 4px 0 10px; padding-left: 22px; }
.msg .bubble li { margin: 3px 0; }
.msg .bubble li::marker { color: var(--muted-2); }
.msg .bubble strong { font-weight: 700; }
.msg .bubble .md-h { font-weight: 700; margin: 12px 0 4px; }
.msg .bubble code { background: #eef1f6; padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 12.5px; }
.msg .bubble pre code { background: none; padding: 0; font-size: 12.5px; }
.msg .bubble .math-block { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 14px; margin: 8px 0; overflow-x: auto; white-space: pre-wrap; }
.msg .bubble .math { font-family: var(--mono); font-size: 12.5px; background: #eef1f6; padding: 1px 5px; border-radius: 5px; }
.msg .bubble pre { background: #0c1020; color: #d7def0; padding: 14px; border-radius: 10px; overflow-x: auto; font: 12.5px/1.6 var(--mono); margin: 8px 0; }
.msg .meta { margin-top: 8px; display: flex; gap: 14px; color: var(--muted-2); font-size: 11.5px; font-family: var(--mono); flex-wrap: wrap; }
/* wake-tier chips (v1 playground comparison): which path served the reply */
.msg .meta .tier-warm { color: #b45309; background: #fef3c7; border-radius: 5px; padding: 1px 7px; }
.msg .meta .tier-cold { color: #1d4ed8; background: #dbeafe; border-radius: 5px; padding: 1px 7px; }
.pg-tier button.active { background: var(--primary-700); color: #fff; }
.pg-tier-note { flex-basis: 100%; color: var(--muted-2); font-size: 12px; margin: -6px 0 2px 2px; }
.pg-prec button.active { background: #1d4ed8; color: #fff; }
/* before/after evaluation (compare vs base) */
#pg-compare.on { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.pg-cmp-heads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 18px 0; }
.pg-cmp-head { display: flex; align-items: baseline; gap: 8px; padding: 8px 12px; font-size: 12px; color: var(--muted-2); background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 9px; min-width: 0; }
.pg-cmp-head b { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-cmp-head.mine { background: var(--primary-015); border-color: #d3ddff; }
.pg-cmp-head.mine b { color: var(--primary-700); }
.pg-cmp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.pg-cmp-row .msg { min-width: 0; }
.pg-cmp-row .bubble { min-width: 0; overflow-wrap: anywhere; }
.pg-cmp-side { min-width: 0; }
.pg-cmp-mine .msg .who { background: var(--primary-700); }
.pg-cmp-note { padding: 8px 18px 12px; font-size: 11.5px; color: var(--muted-2); border-top: 1px solid var(--line-soft); }
/* side tags only exist visually when the columns stack — otherwise the heads label them */
.pg-side-tag { display: none; }
@media (max-width: 900px) {
  .pg-cmp-row, .pg-cmp-heads { grid-template-columns: 1fr; }
  .pg-cmp-heads { display: none; }
  .pg-side-tag { display: inline-block; font: 600 11px/1 var(--font); color: var(--muted-2); background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 3px 8px; margin: 0 0 6px 42px; }
  .pg-side-tag.mine { color: var(--primary-700); background: var(--primary-015); border-color: #d3ddff; }
}
.cursor::after { content: "▋"; color: var(--primary); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.pg-thinking { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-weight: 600; }
/* late-reveal backstop: invisible unless the wait outlasts ~600ms (a real wake) */
.pg-thinking-late { animation: pg-late .18s ease .6s both; margin-left: 8px; }
@keyframes pg-late { from { opacity: 0; } to { opacity: 1; } }
.pg-thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); animation: pgdot 1.3s infinite ease-in-out both; }
.pg-thinking i:nth-child(2) { animation-delay: .18s; }
.pg-thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes pgdot { 0%, 70%, 100% { opacity: .35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

.pg-input { display: flex; gap: 12px; padding: 16px 18px; border-top: 1px solid var(--line-soft); }
.pg-input input { flex: 1; }
.pg-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted-2); font-size: 12.5px; }
.pg-foot .tag { color: var(--muted); font-weight: 700; }
.pg-foot a { color: var(--primary); font-weight: 600; }

/* image/audio playground */
.pg-gen { flex: 1; display: grid; place-items: center; padding: 30px; }
.pg-gen .frame { width: 320px; height: 320px; border-radius: 14px; border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted-2); background: var(--surface-2); text-align: center; padding: 20px; }

/* ---- misc ---------------------------------------------------------------- */
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.mono { font-family: var(--mono); }
.spark { display: block; width: 100%; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.callout { background: var(--primary-015); border: 1px solid #d8e0ff; border-radius: var(--radius); padding: 16px 18px; color: var(--primary-700); font-size: 13.5px; }
.divider { height: 1px; background: var(--line-soft); margin: 18px 0; }

/* ---- fine-tuning --------------------------------------------------------- */
.stpill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 7px; font-weight: 600; font-size: 11.5px; white-space: nowrap; }
.stpill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-succeeded { background: var(--green-bg); color: var(--green); }
.st-running { background: #e7f0ff; color: var(--primary); }
.st-running::before { animation: stpulse 1s infinite; }
.st-queued { background: #f0f1f4; color: var(--muted); }
.st-failed { background: var(--red-bg); color: var(--red); }
@keyframes stpulse { 50% { opacity: .3; } }
table.tbl tbody tr[data-job] { cursor: pointer; }
.ft-form { display: flex; flex-direction: column; gap: 16px; }
.ft-drop { display: flex; align-items: center; gap: 13px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); padding: 18px; color: var(--muted); background: var(--surface-2); }
.ft-drop.dragover { border-color: var(--primary); background: var(--primary-015); color: var(--primary-700); box-shadow: inset 0 0 0 1px rgba(48,94,255,.18); }
.ft-drop svg { color: var(--muted-2); flex: none; }
.ft-drop.dragover svg { color: var(--primary); }
.ft-drop a { color: var(--primary); font-weight: 600; }
.ft-adv-toggle { align-self: flex-start; background: 0; border: 0; color: var(--primary); font-weight: 700; font-size: 13px; cursor: pointer; padding: 0; }
.ft-cfg { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.ft-cfg:last-child { border-bottom: 0; }
.ft-cfg .l { color: var(--muted); }
.ft-cfg .v { font-weight: 600; text-align: right; }
.ft-logs { background: #0c1020; color: #9fb0d0; border-radius: var(--radius-sm); padding: 14px 16px; font: 12px/1.7 var(--mono); white-space: pre-wrap; margin: 0; max-height: 220px; overflow: auto; }

/* ---- live metrics tiles ------------------------------------------------- */
.mgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 1080px) { .mgrid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .mgrid { grid-template-columns: repeat(2, 1fr); } }
.mtile { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; }
.mtile .ml { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.mtile .mv { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.mtile .ms { color: var(--muted-2); font-size: 11px; margin-top: 3px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { padding: 22px 18px 50px; }
}

/* ---- customization: user-endpoint badges + playground grounding ---- */
.badge-you { background: var(--active-tint, #e1e8ff); color: var(--primary-deep, #2243b6); }
.pg-tag {
  display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; margin-left: 6px;
  font: 600 10px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase;
  background: #eef1f7; color: #5b6472; border: 1px solid #e2e6ee; border-radius: 5px; padding: 3px 6px;
}
.pg-tag-rag { background: #e7f6ef; color: #0e7a4f; border-color: #c9ebd9; }
.pg-sources { margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line, #e5e7eb); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pg-src-h { display: inline-flex; align-items: center; gap: 5px; font: 600 10.5px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; color: #0e7a4f; }
.pg-src { font-size: 12px; color: var(--ink, #222); background: #f5f6f8; border: 1px solid var(--line, #e5e7eb); border-radius: 6px; padding: 3px 8px; }
.st-canceled { background: #eef0f3; color: #6b7280; }
.st-queued { background: #eef0f3; color: #6b7280; }
/* a disabled primary button should read as disabled, not as the page's main CTA */
.btn-accent:disabled, .btn-accent[disabled] { background: #c7d0e6; color: #fff; box-shadow: none; }
tr[role="button"] { cursor: pointer; }
tr[role="button"]:focus-visible { outline: 2px solid var(--primary, #305eff); outline-offset: -2px; }
/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,24,40,.42); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal { background: #fff; border-radius: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.22); width: 100%; max-width: 468px; padding: 24px; }
.modal h3 { margin: 0 0 4px; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.modal .modal-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 6px; }
.modal label { display: block; font-weight: 600; font-size: 12.5px; color: var(--muted); margin: 14px 0 6px; }
.modal input, .modal select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; outline: none; }
.modal input:focus, .modal select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(48,94,255,.12); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal-danger-head { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: start; }
.modal-danger-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--red); background: var(--red-bg); }
.delete-target { margin-top: 14px; padding: 10px 12px; border-radius: 8px; border: 1px solid #f1c4ba; background: #fff7f5; color: var(--red); font: 700 13px/1.35 var(--mono); word-break: break-word; }
.confirm-token { color: var(--ink); font-family: var(--mono); font-weight: 800; }
.key-reveal { display: flex; align-items: center; gap: 8px; background: #0f1220; color: #e7ecff; border-radius: 9px; padding: 11px 12px; font: 13px/1.4 var(--mono); word-break: break-all; margin-top: 8px; }
.key-reveal button { flex: none; }
.key-warn { color: var(--amber); font-size: 12.5px; margin-top: 10px; display: flex; gap: 6px; align-items: center; }
/* new-endpoint chooser + import */
.ne-tiles { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.ne-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; transition: border-color .12s, background .12s; }
.ne-tile:hover { border-color: var(--primary); background: var(--active-tint, #f3f6ff); }
.ne-tile svg { color: var(--primary); margin-bottom: 4px; }
.ne-tile b { font-size: 14.5px; }
.ne-tile span { font-size: 12.5px; color: var(--muted); }
/* collapsed reasoning (<think>) disclosure */
.pg-think { margin: 0 0 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--surface-2); }
.pg-think summary { cursor: pointer; padding: 7px 12px; font: 600 12px/1.2 var(--font); color: var(--muted-2); list-style: none; display: flex; align-items: center; gap: 6px; }
.pg-think summary::before { content: '▸'; font-size: 10px; transition: transform .15s; }
.pg-think[open] summary::before { transform: rotate(90deg); }
.pg-think summary::-webkit-details-marker { display: none; }
.pg-think summary em { margin-left: auto; font-style: normal; font-weight: 600; font-size: 11px; color: var(--muted); }
.pg-think-live { border-color: #c7d2fe; background: #eef2ff; box-shadow: inset 3px 0 0 var(--primary); }
.pg-think-live summary { color: var(--primary-700); }
.pg-think-wait { padding: 8px 12px; color: var(--primary-700); font: 700 12px/1.2 var(--font); }
.pg-think-body { padding: 2px 12px 10px; font-size: 12.5px; color: var(--muted); white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
.pg-think-dots::after { content: '…'; animation: blink 1.2s steps(2) infinite; }

/* endpoint-status API state chips (contract v1) */
.ep-state { font: 600 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 999px; }
.eps-hard-zero { color: var(--primary-700); background: var(--primary-050); }
.eps-running { color: var(--green); background: var(--green-bg); }
.eps-waking, .eps-preparing { color: var(--amber); background: var(--amber-bg); }
.eps-parked { color: var(--muted); background: #eef0f3; }
.eps-failed { color: var(--red); background: var(--red-bg); }
.im-size { font-size: 12.5px; margin: 6px 0 4px; min-height: 18px; }
.im-size .im-ok { color: var(--green); }
.im-size .im-warn { color: var(--amber); }
.im-size .im-block { color: var(--red); font-weight: 600; }
.im-check { display: flex !important; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--ink); margin: 16px 0 0 !important; }
.im-check input { width: auto !important; }

/* standing-tier row on deployed cards (warm/cold experience, spec 2026-07-05) */
.mcard-tier { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 10px 0 2px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: 12.5px; color: var(--muted); }
.mcard-tier b { color: var(--ink); font-weight: 600; }
.tier-btn { padding: 4px 10px; font-size: 12px; border-radius: 8px; flex: none; }
.tier-on { color: var(--green); font-weight: 600; font-size: 12px; flex: none; }
