:root {
  --void: #07050b;
  --workspace: #0e0a14;
  --panel: #15101d;
  --panel-raised: #1e1628;
  --panel-hover: #281d35;
  --stroke: #382747;
  --stroke-soft: #261b31;
  --primary: #9d7cff;
  --primary-bright: #cbbcff;
  --primary-deep: #6d43e6;
  --text: #f5f1fa;
  --muted: #b3a7bf;
  --faint: #7e7289;
  --success: #65d6ad;
  --warning: #f0b96a;
  --danger: #ff718b;
  --shadow: 0 18px 54px rgba(0, 0, 0, .34);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--void); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.65rem; letter-spacing: -.025em; }
h2 { margin-bottom: .35rem; font-size: 1.05rem; }
p { color: var(--muted); font-size: .875rem; line-height: 1.6; }
code { color: var(--primary-bright); }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  background: radial-gradient(circle at 44% 10%, #171020 0, var(--workspace) 38%, var(--void) 100%);
}

.topbar {
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  gap: 1rem;
  padding: 0 1.15rem;
  border-bottom: 1px solid var(--stroke);
  background: rgba(21, 16, 29, .96);
  box-shadow: 0 5px 24px rgba(0, 0, 0, .2);
}

.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brandmark {
  width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 11px; color: #100918; font-weight: 850; font-size: 1.3rem;
  background: linear-gradient(145deg, var(--primary-bright), var(--primary-deep));
  box-shadow: 0 0 24px rgba(157, 124, 255, .24);
}
.brandcopy { min-width: 0; }
.eyebrow { color: var(--primary-bright); font-size: .75rem; font-weight: 760; letter-spacing: .12em; text-transform: uppercase; }
.project-name { margin-top: .15rem; overflow: hidden; color: var(--muted); font-size: .8rem; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }

.workspace-tabs { display: flex; gap: .25rem; padding: .25rem; border: 1px solid var(--stroke-soft); border-radius: 10px; background: var(--workspace); }
.workspace-tab {
  min-width: 92px; padding: .5rem .9rem; border: 0; border-radius: 7px;
  color: var(--muted); background: transparent; cursor: pointer; font-size: .875rem; font-weight: 650;
}
.workspace-tab:hover { color: var(--text); background: var(--panel-raised); }
.workspace-tab.active { color: #100918; background: linear-gradient(135deg, var(--primary-bright), var(--primary)); }

.status { display: flex; justify-content: flex-end; align-items: center; gap: .55rem; min-width: 0; color: var(--muted); font-size: .8rem; }
.status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px rgba(101, 214, 173, .45); }
.status-dot.busy { background: var(--warning); animation: pulse 1.1s infinite; }
.status-dot.error { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.82); } }

.btn {
  min-height: 36px; padding: .48rem .8rem; border: 1px solid var(--stroke); border-radius: 8px;
  color: var(--text); background: var(--panel-raised); cursor: pointer; font-size: .82rem;
  transition: border-color .15s, background .15s, transform .12s;
}
.btn:hover:not(:disabled) { border-color: #654a79; background: var(--panel-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { border-color: transparent; color: #100918; background: linear-gradient(135deg, var(--primary-bright), var(--primary)); font-weight: 720; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #ddd4ff, #a98dff); }
.btn.danger { color: var(--danger); }
.btn.compact { min-height: 30px; padding: .32rem .6rem; font-size: .78rem; }
.btn.full { width: 100%; }
.btn.grow { flex: 1; }
.file-input { display: none; }
.button-row { display: flex; gap: .5rem; }
.button-column { display: grid; gap: .55rem; }

input, select {
  width: 100%; min-width: 0; height: 34px; padding: .4rem .55rem;
  border: 1px solid var(--stroke); border-radius: 7px; outline: none;
  color: var(--text); background: var(--workspace); font-size: .82rem;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(157, 124, 255, .1); }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }
input[type="range"] { height: 4px; padding: 0; border: 0; accent-color: var(--primary); }

.field { display: grid; grid-template-columns: minmax(0, 1fr) 108px; align-items: center; gap: .75rem; font-size: .82rem; }
.field label { color: var(--muted); }
.check { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .8rem; }
.hint { margin: 0; color: var(--faint); font-size: .75rem; line-height: 1.5; }
.warn { color: var(--warning); }
.subtle { color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: center; }

.toast-stack { position: fixed; right: 1rem; top: 4.8rem; z-index: 100; display: grid; gap: .5rem; width: min(360px, calc(100vw - 2rem)); }
.toast { padding: .75rem .85rem; border: 1px solid var(--stroke); border-radius: 8px; color: var(--text); background: #23192e; box-shadow: var(--shadow); font-size: .82rem; animation: toastIn .18s ease-out; }
.toast.error { border-color: rgba(255, 113, 139, .55); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

dialog { width: min(640px, calc(100vw - 2rem)); border: 1px solid var(--stroke); border-radius: 13px; color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(3, 2, 5, .72); backdrop-filter: blur(3px); }
.dialog-inner { padding: .75rem; }
.dialog-inner h2 { margin: .4rem 0 .8rem; font-size: 1.2rem; }
.dialog-inner li, .dialog-inner p { color: var(--muted); font-size: .875rem; line-height: 1.65; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 950px) {
  .topbar { grid-template-columns: 1fr auto; }
  .status { display: none; }
  .workspace-tab { min-width: 75px; }
}

/* Tracker Xtreme brand integration */
.brandmark-image {
  object-fit: cover;
  border: 1px solid rgba(196, 171, 255, .62);
  background: #090510;
  box-shadow: 0 0 24px rgba(157, 124, 255, .30);
}
.brand-meta { display: flex; align-items: center; gap: .55rem; min-width: 0; margin-top: .12rem; }
.brand-meta .project-name { margin-top: 0; }
.homepage-link {
  flex: 0 0 auto;
  color: #9f91ae;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .025em;
  text-decoration: none;
  opacity: .78;
  transition: color .15s ease, opacity .15s ease;
}
.homepage-link:hover, .homepage-link:focus-visible { color: var(--primary-bright); opacity: 1; text-decoration: underline; text-underline-offset: 3px; }

/* Automatic browser recovery */
.autosave-indicator {
  flex: 0 0 auto;
  margin-left: .25rem;
  padding-left: .7rem;
  border-left: 1px solid var(--stroke-soft);
  color: var(--faint);
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.autosave-indicator[data-kind="saving"] { color: var(--warning); }
.autosave-indicator[data-kind="recovered"] { color: var(--primary-bright); }
.autosave-indicator[data-kind="error"] { color: var(--danger); }
.recovery-card { border-color: rgba(101, 214, 173, .22); }
.browser-recovery-status { margin: .1rem 0 0; color: var(--success); font-size: .78rem; font-weight: 700; }
.recovery-dialog-inner { display: grid; gap: .35rem; }
.recovery-dialog-inner h2 { margin-bottom: .25rem; }
.recovery-explainer { margin-bottom: 0; }
#recoveryDialog .dialog-actions { gap: .55rem; }
.status #statusText { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
