:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3fb;
  --surface-strong: #e0e8f4;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d8e1ef;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.14);
  --radius-lg: 28px;
  --radius: 18px;
  --radius-sm: 12px;
  --focus: 0 0 0 4px rgba(37, 99, 235, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #08111f;
    --surface: #101827;
    --surface-soft: #172033;
    --surface-strong: #243048;
    --text: #e5edf7;
    --muted: #99a7bd;
    --border: #26354e;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #08111f;
  --surface: #101827;
  --surface-soft: #172033;
  --surface-strong: #243048;
  --text: #e5edf7;
  --muted: #99a7bd;
  --border: #26354e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 820px;
  min-height: 620px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  box-shadow: var(--focus);
  border-color: var(--primary);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.loading-screen,
.auth-shell,
.app-shell {
  min-height: 100vh;
}

.loading-screen {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  text-align: center;
}

.loading-screen img {
  width: 96px;
  height: 96px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--surface-strong);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(420px, 560px) 1fr;
  gap: 2rem;
  padding: 2rem;
  align-items: stretch;
}

.auth-card,
.auth-hero,
.panel,
.hero-card,
.stat-card,
.project-card,
.list-card,
.dialog {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 2rem;
  display: grid;
  align-content: start;
  gap: 1.4rem;
}

.auth-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-brand img,
.sidebar-brand img {
  width: 54px;
  height: 54px;
}

.auth-brand h1,
.auth-hero h2,
.topbar h1,
.view-header h2,
.hero-card h2 {
  margin: 0;
  letter-spacing: -0.04em;
}

.auth-brand p,
.auth-hero p,
.view-header p,
.hero-card p,
.list-row p,
.empty-state p,
.hint {
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.auth-hero {
  display: grid;
  align-content: center;
  padding: 3rem;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.9), rgba(14, 165, 233, 0.72)),
    var(--surface);
  color: white;
}

.auth-hero p,
.auth-hero .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.auth-hero h2 {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.auth-hero li {
  margin: 1rem 0;
}

.stepper,
.button-row,
.topbar-actions,
.auth-footer,
.panel-head,
.view-header,
.dialog-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stepper {
  padding: 0.4rem;
  background: var(--surface-soft);
  border-radius: 999px;
}

.stepper span {
  flex: 1;
  text-align: center;
  padding: 0.65rem 0.85rem;
  color: var(--muted);
  border-radius: 999px;
}

.stepper .active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.btn,
.sync-pill,
.connection-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  font-weight: 700;
}

.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  color: var(--danger);
}

.btn.small {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}

.message {
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

.message.success {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}

.message.error {
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  color: var(--danger);
}

.diagnostics {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface-soft);
}

.diagnostics pre {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 220px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  padding: 1.5rem;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  margin-bottom: 2rem;
}

.sidebar-brand span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar nav {
  display: grid;
  gap: 0.35rem;
}

.sidebar button {
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 0;
  color: var(--muted);
  background: transparent;
}

.sidebar button.active,
.sidebar button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.workspace {
  min-width: 0;
  padding: 1.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
}

.view-frame {
  min-height: calc(100vh - 126px);
}

.view-stack {
  display: grid;
  gap: 1rem;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, transparent), transparent),
    var(--surface);
}

.hero-card h2 {
  font-size: clamp(2rem, 4vw, 4rem);
}

.stats-grid,
.card-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card,
.project-card,
.panel {
  padding: 1.2rem;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 0.45rem;
  font-size: 2rem;
}

.panel-head,
.view-header,
.dialog-head {
  justify-content: space-between;
}

.panel h3,
.project-card h3 {
  margin: 0;
}

.command-input {
  max-width: 520px;
}

.project-card {
  box-shadow: none;
}

.status-dot {
  display: block;
  width: 12px;
  height: 12px;
  background: var(--success);
  border-radius: 99px;
  margin-bottom: 0.8rem;
}

.list-card {
  overflow: hidden;
  box-shadow: none;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: 0;
}

.empty-state {
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.connection-pill.connected,
.connection-pill.online {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  color: var(--success);
}

.connection-pill.connecting {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  color: var(--warning);
}

.connection-pill.error,
.connection-pill.offline {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  color: var(--danger);
}

.sync-pill {
  color: var(--primary);
}

.theme-switch {
  width: auto;
  display: inline-flex;
  align-items: center;
}

.theme-switch select {
  min-width: 112px;
  padding: 0.65rem 0.8rem;
}

.theme-switch.expanded {
  display: grid;
  width: 100%;
  gap: 0.5rem;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: rgba(8, 17, 31, 0.56);
  z-index: 20;
}

.dialog {
  width: min(560px, 100%);
  padding: 1.4rem;
}

.icon-btn {
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.4rem;
}

.toast {
  position: fixed;
  right: 1.4rem;
  bottom: 1.4rem;
  max-width: 420px;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 30;
}

.toast.success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
}

.toast.error {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

.skeleton-card,
.skeleton-row {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-soft), var(--surface-strong), var(--surface-soft));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-card {
  height: 148px;
}

.skeleton-row {
  height: 64px;
  margin: 0.8rem;
}

@keyframes shimmer {
  to {
    background-position-x: -200%;
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
  }
}
