:root {
  /* Palette */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.1);

  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --border: #334155;
  --border-hover: #475569;

  --success: #10b981;
  --warning: #f59e0b;

  /* Spacing & Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Outfit", sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header / Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo::before {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

.auth-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.user-info {
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-weight: 500;
}

/* Main Layout */
main {
  flex: 1;
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center; /* Center content vertically if needed */
}

/* App Grid */
.app {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 2rem;
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.panel-title,
.presets-title {
  font-weight: 600;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title::before,
.presets-title::before {
  content: "";
  width: 4px;
  height: 1.2em;
  background: var(--primary);
  border-radius: 2px;
}

/* Fields */
.field {
  margin-bottom: 1.5rem;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-light);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Range Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--bg-input);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* Switch Row */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.switch-row:hover {
  border-color: var(--border);
}

.switch-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Toggle Switch */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  background: var(--bg-input);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="checkbox"]:checked {
  background: var(--success);
}

input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

/* Select */
.mode-row {
  margin-bottom: 1.5rem;
}

.mode-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
}

.mode-select:focus {
  outline: none;
  border-color: var(--primary);
}

.mode-description {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-left: 0.25rem;
}

/* Run Section */
.run-row {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.run-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.progress-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  box-shadow: 0 0 10px var(--primary);
  transition: width 0.03s linear;
}

/* Buttons */
button {
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s;
}

.primary-button {
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 15px rgba(37, 99, 235, 0.3);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.5);
}

.primary-button:active {
  transform: translateY(0);
}

.secondary-button {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

.ghost-button {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.ghost-button:hover {
  color: #ef4444; /* Red for delete */
  background: rgba(239, 68, 68, 0.1);
}

/* Presets */
.preset-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.preset-form input[type="text"] {
  flex: 1;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
}

.preset-form input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s;
}

.preset-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hover);
}

.preset-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.preset-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.preset-buttons {
  display: flex;
  gap: 0.5rem;
}

.preset-empty,
.preset-error {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

/* Visualizer */
.visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

.orb {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 40px var(--primary);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.05);
    opacity: 1;
  }
}

/* Logged Out State */
.logged-out-message {
  text-align: center;
  margin-top: 4rem;
  padding: 3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s ease-out;
}

.logged-out-message p {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.logged-out-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.hidden {
  display: none !important;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
