:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --surface: #1e293b;
  --border: rgba(59, 130, 246, 0.15);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
}

.site-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: conic-gradient(from 180deg, #ff6b9d, #c084fc, #60a5fa, #34d399, #fbbf24, #ff6b9d);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 36ch;
}

.ad-slot {
  min-height: 90px;
  min-width: min(100%, 728px);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
}

.ad-slot--header {
  flex: 1 1 280px;
  max-width: 728px;
}

.ad-placeholder {
  color: var(--muted);
  font-size: 0.8rem;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: 1fr 340px;
    grid-template-rows: auto auto;
  }

  .panel--preview {
    grid-column: 1;
    grid-row: 1;
  }

  .panel--controls {
    grid-column: 1;
    grid-row: 2;
  }

  .panel--presets {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .preset-grid {
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(124, 108, 240, 0.2);
  color: #c4b8ff;
}

.badge--muted {
  background: var(--bg-elevated);
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.gradient-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: #111;
  transition: background 0.08s ease-out;
}

.preview-meta {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field--inline {
  flex: 1 1 200px;
}

.field span {
  font-weight: 500;
}

select,
input[type="text"],
input[type="number"],
input[type="search"] {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

input[type="search"] {
  width: 100%;
}

select:focus,
input:focus {
  outline: 2px solid rgba(124, 108, 240, 0.45);
  outline-offset: 1px;
}

.seg {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.seg legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
  width: 100%;
}

.seg label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.control-block {
  margin-bottom: 1.25rem;
}

.control-block:last-child {
  margin-bottom: 0;
}

.hidden {
  display: none !important;
}

.angle-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.num-input {
  width: 4.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.label-strong {
  font-weight: 600;
  font-size: 0.9rem;
}

.hint {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.stop-track {
  position: relative;
  padding: 1.75rem 0 0.25rem;
  border-radius: var(--radius-sm);
  outline: none;
}

.stop-track:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.stop-bar {
  position: relative;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: visible;
}

.stop-thumb {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: grab;
  z-index: 2;
  transform: translateZ(0);
}

.stop-thumb:active {
  cursor: grabbing;
}

.stop-thumb.selected {
  z-index: 3;
  box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.stop-editor {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: grid;
  gap: 0.75rem;
}

.color-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

.color-row .mono {
  flex: 1;
}

.mono {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn--secondary:hover {
  border-color: var(--muted);
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: rgba(124, 108, 240, 0.35);
}

.btn--ghost:hover {
  background: rgba(124, 108, 240, 0.12);
}

.btn--danger {
  background: rgba(232, 93, 106, 0.15);
  color: #ff9aa5;
  border-color: rgba(232, 93, 106, 0.35);
}

.btn--danger:hover {
  background: rgba(232, 93, 106, 0.25);
}

.btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.code-block {
  margin: 0.5rem 0 0;
  padding: 0.85rem 1rem;
  background: #0a0b0e;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 140px;
  overflow: auto;
}

.toast {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
  font-size: 0.85rem;
}

.preset-search {
  margin-bottom: 0.75rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
}

.preset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-elevated);
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, transform 0.1s;
}

.preset-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.preset-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preset-swatch {
  height: 52px;
  width: 100%;
}

.preset-name {
  display: block;
  padding: 0.35rem 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-slot--footer {
  max-width: 1280px;
  margin: 0 auto 1.5rem;
  padding: 0 1.25rem;
  min-height: 100px;
}

.site-footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

code.mono {
  font-size: 0.85em;
}
