/*
 * Laid out and colored like the Windows 11 Settings app: WinUI theme resources, the system accent
 * color (set by settings.js; Windows' default blue until then) and the apps' light/dark mode.
 */
:root {
  --accent-light: #005fb8;
  --accent-dark: #60cdff;
  --accent: var(--accent-light);
  --on-accent: #fff;
  --bg: #f3f3f3;                                 /* Mica, SolidBackgroundFillColorBase */
  --text: rgba(0, 0, 0, 0.896);
  --dim: rgba(0, 0, 0, 0.62);
  --faint: rgba(0, 0, 0, 0.446);
  --card: rgba(255, 255, 255, 0.7);              /* CardBackgroundFillColorDefault */
  --card-stroke: rgba(0, 0, 0, 0.0578);          /* CardStrokeColorDefault */
  --line: rgba(0, 0, 0, 0.0803);                 /* DividerStrokeColorDefault */
  --subtle-hover: rgba(0, 0, 0, 0.0373);         /* SubtleFillColorSecondary */
  --subtle-press: rgba(0, 0, 0, 0.0241);
  --control: rgba(255, 255, 255, 0.7);           /* ControlFillColorDefault */
  --control-hover: rgba(249, 249, 249, 0.5);
  --control-press: rgba(249, 249, 249, 0.3);
  --control-stroke: rgba(0, 0, 0, 0.0578);       /* ControlElevationBorder */
  --control-stroke-bottom: rgba(0, 0, 0, 0.1622);
  --strong: rgba(0, 0, 0, 0.446);                /* ControlStrongFillColorDefault */
  --strong-stroke: rgba(0, 0, 0, 0.446);         /* ControlStrongStrokeColorDefault */
  --track: rgba(0, 0, 0, 0.0578);                /* ControlAltFillColorTertiary */
  --ok: #0f7b0f;
  --warn: #9d5d00;
  --bad: #c42b1c;
  --ease: cubic-bezier(0, 0, 0, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: var(--accent-dark);
    --on-accent: #000;
    --bg: #202020;
    --text: #fff;
    --dim: rgba(255, 255, 255, 0.786);
    --faint: rgba(255, 255, 255, 0.545);
    --card: rgba(255, 255, 255, 0.0512);
    --card-stroke: rgba(0, 0, 0, 0.1);
    --line: rgba(255, 255, 255, 0.0837);
    --subtle-hover: rgba(255, 255, 255, 0.0605);
    --subtle-press: rgba(255, 255, 255, 0.0419);
    --control: rgba(255, 255, 255, 0.0605);
    --control-hover: rgba(255, 255, 255, 0.0837);
    --control-press: rgba(255, 255, 255, 0.0326);
    --control-stroke: rgba(255, 255, 255, 0.0698);
    --control-stroke-bottom: rgba(255, 255, 255, 0.0698);
    --control-stroke-top: rgba(255, 255, 255, 0.093);
    --strong: rgba(255, 255, 255, 0.545);
    --strong-stroke: rgba(255, 255, 255, 0.545);
    --track: rgba(255, 255, 255, 0.0419);
    --ok: #6ccb5f;
    --warn: #fce100;
    --bad: #ff99a4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 14px/20px "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  user-select: none; cursor: default;
}
button { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
/* ScrollBar: a thin rail that widens when hovered. */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-thumb { border: 5px solid transparent; border-radius: 6px; background: var(--strong) padding-box; }
::-webkit-scrollbar-thumb:hover { border-width: 3px; }

/* On Windows 11 the window's Mica shows through; it falls back to --bg by itself when inactive. */
html.mica body { background: transparent; }

/* Title bar: icon and caption on the Mica, and the close button of WinUI's caption buttons. */
.titlebar { flex: none; display: flex; align-items: center; gap: 12px; height: 48px; padding-left: 16px; }
.titlebar span { font-size: 12px; line-height: 16px; }
body.inactive .titlebar span, body.inactive .caption { color: var(--faint); }
.caption {
  align-self: flex-start; margin-left: auto; width: 46px; height: 32px; border: 0; background: transparent;
  font: 10px "Segoe Fluent Icons", "Segoe MDL2 Assets"; color: var(--text);
}
.caption:hover { background: #c42b1c; color: #fff; }
.caption:active { background: rgba(196, 43, 28, 0.9); color: rgba(255, 255, 255, 0.7); }
.shell { flex: 1; display: flex; min-height: 0; }

/* Navigation pane */
.sidebar { width: 240px; flex: none; display: flex; flex-direction: column; gap: 4px; padding: 4px 8px 12px; }
.nav {
  position: relative; display: flex; align-items: center; gap: 16px; width: 100%; height: 36px; padding: 0 12px;
  border: 0; border-radius: 4px; background: transparent; text-align: left; color: var(--text);
}
.nav svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.nav:hover, .nav.active { background: var(--subtle-hover); }
.nav:active { background: var(--subtle-press); color: var(--dim); }
/* The selection pill, which grows in from the middle. */
.nav::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 16px; margin-top: -8px;
  border-radius: 2px; background: var(--accent); transform: scaleY(0); transition: transform 0.2s var(--ease);
}
.nav.active::before { transform: scaleY(1); }
.version { margin-top: auto; padding: 0 12px; font-size: 12px; color: var(--faint); }

/* Content */
main { flex: 1; overflow-y: auto; padding: 4px 40px 40px 12px; }
.page { display: none; max-width: 1000px; }
.page.active { display: block; animation: page-in 0.3s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(20px); } }
.page header { margin-bottom: 24px; }
h1 { font-size: 28px; line-height: 36px; font-weight: 600; }
.page header p { color: var(--dim); margin-top: 4px; }
h2 { font-size: 14px; font-weight: 600; margin: 28px 0 8px 1px; }
.page > header + h2 { margin-top: 0; }
.hint { color: var(--dim); font-size: 12px; line-height: 16px; margin: 12px 1px 0; }
/* InfoBar (informational) */
.hint.notice {
  color: var(--text); font-size: 14px; line-height: 20px; padding: 14px 16px; margin-top: 12px;
  background: var(--card); border: 1px solid var(--card-stroke); border-radius: 4px;
}

/* Setting cards: each row is its own card, a few pixels apart. */
.group { display: flex; flex-direction: column; gap: 4px; }
.group + .group { margin-top: 4px; }
.row, .account, .group > .empty {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--card-stroke); border-radius: 4px;
}
.disabled { opacity: 0.4; pointer-events: none; }

/* ComboBox */
.select { position: relative; }
.select::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 1px solid var(--dim); border-bottom: 1px solid var(--dim); transform: rotate(45deg); pointer-events: none;
}
select {
  appearance: none; min-width: 200px; height: 32px; padding: 0 36px 0 11px; font: inherit; color: var(--text);
  background: var(--control); border: 1px solid var(--control-stroke); border-bottom-color: var(--control-stroke-bottom);
  border-top-color: var(--control-stroke-top, var(--control-stroke)); border-radius: 4px;
}
select:hover { background: var(--control-hover); }
select:active { background: var(--control-press); }
option { background: var(--bg); color: var(--text); }

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 32px; padding: 0 12px;
  background: var(--control); border: 1px solid var(--control-stroke); border-bottom-color: var(--control-stroke-bottom);
  border-top-color: var(--control-stroke-top, var(--control-stroke)); border-radius: 4px;
}
.btn:hover { background: var(--control-hover); }
.btn:active { background: var(--control-press); color: var(--dim); border-color: var(--control-stroke); }
.btn:disabled { color: var(--faint); background: var(--control-press); }
.btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: rgba(255, 255, 255, 0.08) rgba(255, 255, 255, 0.08) rgba(0, 0, 0, 0.4); }
.btn.accent:hover { background: color-mix(in srgb, var(--accent) 90%, var(--bg)); }
.btn.accent:active { background: color-mix(in srgb, var(--accent) 80%, var(--bg)); color: var(--on-accent); }

/* ToggleSwitch */
.switch {
  appearance: none; flex: none; position: relative; width: 40px; height: 20px; border-radius: 10px;
  background: var(--control); border: 1px solid var(--strong-stroke); transition: background 0.1s;
}
.switch:hover { background: var(--control-hover); }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--dim); transition: transform 0.2s var(--ease), width 0.1s, height 0.1s, top 0.1s, left 0.1s;
}
.switch:hover::after { top: 2px; left: 2px; width: 14px; height: 14px; }
.switch:active::after { width: 17px; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked:hover { background: color-mix(in srgb, var(--accent) 90%, var(--bg)); }
.switch:checked::after { background: var(--on-accent); transform: translateX(20px); }
.switch:checked:active::after { transform: translateX(17px); }

/* Slider */
input[type="range"] {
  appearance: none; width: 180px; height: 4px; border-radius: 2px; background: transparent;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--strong) var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 5px, transparent 5.5px), var(--bg);
  box-shadow: 0 0 0 1px var(--control-stroke), 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: background-size 0.1s;
}
input[type="range"]:hover::-webkit-slider-thumb { background: radial-gradient(circle, var(--accent) 6px, transparent 6.5px), var(--bg); }
input[type="range"]:active::-webkit-slider-thumb { background: radial-gradient(circle, var(--accent) 4px, transparent 4.5px), var(--bg); }
.range { display: flex; align-items: center; gap: 12px; }
.range output { width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

.with-mark { display: flex; align-items: center; gap: 16px; }
/* Provider logos, white on each brand's color, like app icons in the Settings app. */
.logo { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; color: #fff; }
.logo svg { fill: currentColor; }
.logo.claude { background: #d97757; }
.logo.claude svg { width: 16px; height: 16px; }
.logo.codex { background: #000; }
.logo.codex svg { width: 14px; height: 14px; }
@media (prefers-color-scheme: dark) { .logo.codex { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); } }

/* Accounts */
.provider + .provider { margin-top: 28px; }
.provider-head { display: flex; align-items: center; gap: 12px; margin: 0 0 8px 1px; }
.provider-head h3 { font-size: 14px; font-weight: 600; }
.provider-head .btn { margin-left: auto; }
.account { justify-content: flex-start; }
.avatar {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  font-weight: 600; font-size: 14px; color: #fff;
}
.who { flex: 1; min-width: 0; }
/* TextBox, blending into the card until hovered or focused. */
.who input {
  width: 100%; font: inherit; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: 4px; padding: 1px 6px; margin-left: -7px; outline: none;
}
.who input:hover { background: var(--control-hover); border-color: var(--control-stroke); }
.who input:focus { background: var(--bg); border-color: var(--control-stroke); border-bottom: 2px solid var(--accent); padding-bottom: 0; }
.who input::placeholder { color: var(--text); opacity: 1; }
.who small { display: flex; gap: 6px; align-items: center; color: var(--dim); font-size: 12px; line-height: 16px; overflow: hidden; white-space: nowrap; }
.who small span { overflow: hidden; text-overflow: ellipsis; }
.chip {
  font-style: normal; flex: none; padding: 0 6px; border-radius: 4px; font-size: 12px; line-height: 18px;
  background: var(--control); border: 1px solid var(--control-stroke); color: var(--dim);
}
.chip.live { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.chip.resets.live { background: transparent; border-color: var(--ok); color: var(--ok); }
.meter { flex: none; width: 140px; text-align: right; }
.meter b { font-weight: 600; font-variant-numeric: tabular-nums; }
.meter .track { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; margin-top: 6px; }
.meter .track i { display: block; height: 100%; border-radius: 2px; }
.meter.none b { color: var(--faint); font-weight: 400; }
.meter small { display: block; margin-top: 4px; color: var(--dim); font-size: 12px; line-height: 16px; white-space: nowrap; }
.remove {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 4px;
  background: transparent; color: var(--dim); opacity: 0;
}
.remove svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.account:hover .remove:not(:disabled), .remove:focus-visible { opacity: 1; }
.remove:hover { background: var(--subtle-hover); }
.remove:active { background: var(--subtle-press); }
.remove:disabled { visibility: hidden; }
.group > .empty { color: var(--dim); justify-content: flex-start; }

.balancer { margin-top: 4px; }
.btn.use { flex: none; }

.row .title { display: flex; flex-direction: column; }
.row .title small { color: var(--dim); font-size: 12px; line-height: 16px; }
.row .title small.available { color: var(--accent); font-weight: 600; }
