:root {
  --bg: #0b0f14;
  --fg: #e7edf3;
  --muted: #6b7785;
  --brand: #4b8dea;
  --panel: #131a22;
  --border: #1e2834;
  --anim-fast: 150ms;
  --anim-med: 250ms;
}
/* Synthwave */
[data-theme='synthwave'] {
  --bg: #0b1026;
  --fg: #f6e8ff;
  --muted: #caa4ff;
  --brand: #ff2bd6;
  --panel: #1a103d;
  --border: #2a1b4b;
}
/* Purple */
[data-theme='purple'] {
  --bg: #0f0a1f;
  --fg: #ede9fe;
  --muted: #b6a6e4;
  --brand: #7c3aed;
  --panel: #18102d;
  --border: #2a2245;
}
/* Retro (light) */
[data-theme='retro'] {
  --bg: #f5ecd7;
  --fg: #2b2b2b;
  --muted: #7a6f5a;
  --brand: #d2691e;
  --panel: #fff9ec;
  --border: #c8bba0;
}
/* Game Boy Pocket */
[data-theme='gameboy'] {
  --bg: #e0f8cf;
  --fg: #0f380f;
  --muted: #306230;
  --brand: #8bac0f;
  --panel: #d0f0ba;
  --border: #9bbc0f;
}
/* Nord (dark) */
[data-theme='nord'] {
  --bg: #2e3440;
  --fg: #eceff4;
  --muted: #d8dee9;
  --brand: #5e81ac;
  --panel: #3b4252;
  --border: #434c5e;
}
/* Solarized (dark) */
[data-theme='solarized'] {
  --bg: #002b36;
  --fg: #eee8d5;
  --muted: #93a1a1;
  --brand: #268bd2;
  --panel: #073642;
  --border: #586e75;
}
/* Nekos (logo-inspired) */
[data-theme='nekos'] {
  --bg: #0e1a2b; /* deep navy */
  --fg: #eaf2ff; /* soft light */
  --muted: #7aa0c5; /* desaturated blue */
  --brand: #ff7a00; /* orange accent */
  --panel: #132338; /* dark panel */
  --border: #1e3653; /* panel border */
}
/* Synthwave */
[data-theme='synthwave'] {
  --bg: #0b1026;
  --fg: #f6e8ff;
  --muted: #caa4ff;
  --brand: #ff2bd6;
  --panel: #1a103d;
  --border: #2a1b4b;
}
/* Purple */
[data-theme='purple'] {
  --bg: #0f0a1f;
  --fg: #ede9fe;
  --muted: #b6a6e4;
  --brand: #7c3aed;
  --panel: #18102d;
  --border: #2a2245;
}
/* Retro (light) */
[data-theme='retro'] {
  --bg: #f5ecd7;
  --fg: #2b2b2b;
  --muted: #7a6f5a;
  --brand: #d2691e;
  --panel: #fff9ec;
  --border: #c8bba0;
}
/* Game Boy Pocket */
[data-theme='gameboy'] {
  --bg: #e0f8cf;
  --fg: #0f380f;
  --muted: #306230;
  --brand: #8bac0f;
  --panel: #d0f0ba;
  --border: #9bbc0f;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    14px/1.4 -apple-system,
    BlinkMacSystemFont,
    Segoe UI,
    Inter,
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 1rem auto;
}
.topbar .container .spacer {
  flex: 1 1 auto;
}
.topbar .container .right {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
}
.topbar .logo img {
  height: 4rem;
  max-height: 4rem;
  width: auto;
  display: block;
}
.topbar .logo {
  padding-top: 0.75rem;
}
.container {
  max-width: 880px;
  margin: 2rem auto;
  padding: 0 1rem;
}
h1 {
  font-size: 22px;
  margin: 0 0 16px;
}
h2 {
  font-size: 16px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 600;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  animation: fade-up var(--anim-med) ease both;
}
.row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}
.row.actions + .row.options {
  margin-top: 1rem;
}
.row.options + .row.options {
  margin-top: 0.75rem;
}
.row .chk {
  padding: 0.25rem 0;
}

button,
.btn {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition:
    background-color var(--anim-fast),
    box-shadow var(--anim-fast),
    transform var(--anim-fast);
}
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
button:active,
.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.progress-wrap {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  width: 100%;
}
progress {
  width: 100%;
  height: 1rem;
  -webkit-appearance: none;
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
/* WebKit/Blink */
progress::-webkit-progress-bar {
  background: var(--panel);
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: var(--brand);
  border-radius: 999px;
  transition: width var(--anim-med) ease;
}
/* Firefox */
progress::-moz-progress-bar {
  background: var(--brand);
  border-radius: 999px;
  transition: width var(--anim-med) ease;
}
/* Shimmer effect when busy */
progress.busy::-webkit-progress-value {
  background-image:
    linear-gradient(
      120deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.35) 50%,
      rgba(255, 255, 255, 0) 100%
    ),
    linear-gradient(0deg, var(--brand), var(--brand));
  background-size:
    200% 100%,
    100% 100%;
  background-position:
    0 0,
    0 0;
  animation: shimmer 1.4s linear infinite;
}
progress.busy::-moz-progress-bar {
  background-image:
    linear-gradient(
      120deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.35) 50%,
      rgba(255, 255, 255, 0) 100%
    ),
    linear-gradient(0deg, var(--brand), var(--brand));
  background-size:
    200% 100%,
    100% 100%;
  background-position:
    0 0,
    0 0;
  animation: shimmer 1.4s linear infinite;
}
.log {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  height: 25vh; /* Default desktop height */
  overflow: auto;
  color: var(--fg);
  width: 100%;
  transition:
    background-color var(--anim-med),
    border-color var(--anim-med),
    color var(--anim-med);
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}
.links .btn {
  animation: pop var(--anim-fast) ease both;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 0.25rem; /* Reduced space */
}
.chk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.label {
  min-width: 110px;
  color: var(--muted);
}
/* Group label + input vertically as a field */
.field {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
  gap: 0.5rem;
  flex: 1 1 100%;
  width: 100%;
}
/* Text inputs and selects */
input:not([type='checkbox']):not([type='radio']),
select {
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background-color var(--anim-med),
    border-color var(--anim-med),
    color var(--anim-med),
    box-shadow var(--anim-fast);
}
input:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(75, 141, 234, 0.25);
}
/* Checkbox reset + styling */
input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  display: inline-grid;
  place-content: center;
  border: 2px solid var(--border);
  border-radius: 3px;
  background: var(--panel);
  cursor: pointer;
  transition:
    background-color var(--anim-fast),
    border-color var(--anim-fast);
}
input[type='checkbox']::after {
  content: '';
  width: 0.85rem;
  height: 0.85rem;
  display: block;
  transform: scale(0);
  transition: transform 120ms ease-in-out;
  color: white;
}
input[type='checkbox']:checked {
  background: var(--brand);
  border-color: var(--brand);
}
input[type='checkbox']:checked::after {
  content: '✓';
  transform: scale(1);
  line-height: 0.85rem;
  text-align: center;
}
.chk {
  cursor: pointer;
  gap: 0.5rem;
}
/* Responsive stacking for narrow screens */
@media (max-width: 700px) {
  .progress-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  #percent {
    text-align: right;
  }
  .row.actions {
    flex-direction: column;
    align-items: stretch;
  }
  .row.actions > * {
    flex: 1 1 100%;
    width: 100%;
  }
  .row.actions button {
    width: 100%;
  }
  .label {
    min-width: 0;
  }
  .log {
    height: 20vh;
  } /* Taller on mobile */
}

/* Ensure autofill uses dark background/text */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg);
  box-shadow: 0 0 0px 1000px var(--panel) inset;
  border: 1px solid var(--border);
  transition: background-color 99999s ease-in-out 0s;
  caret-color: var(--fg);
}
.topbar,
.panel,
body,
.row,
.progress-wrap {
  transition:
    background-color var(--anim-med),
    color var(--anim-med),
    border-color var(--anim-med);
}

/* Spinner next to status when busy */
#status.is-busy::before {
  content: '';
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--muted);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: -2px;
  animation: spin 850ms linear infinite;
}

/* Keyframes */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes shimmer {
  from {
    background-position:
      200% 0,
      0 0;
  }
  to {
    background-position:
      -200% 0,
      0 0;
  }
}

/* Theme crossfade overlay */
body.theme-transition::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg);
  pointer-events: none;
  animation: themeCross var(--anim-med) ease both;
}
@keyframes themeCross {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.login-card {
  max-width: 420px;
  margin: 80px auto;
}
.login-fields {
  display: grid;
  gap: 10px;
}
.error {
  color: #ff6b6b;
  margin-bottom: 8px;
}
.right {
  text-align: right;
}
input[type='text'],
input[type='password'] {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f141b;
  color: var(--fg);
  appearance: none;
  -webkit-appearance: none;
}
/* Make autofill match dark input styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg);
  box-shadow: 0 0 0px 1000px #0f141b inset;
  border: 1px solid var(--border);
  transition: background-color 99999s ease-in-out 0s;
  caret-color: var(--fg);
}
label {
  color: var(--muted);
  font-size: 13px;
}
