@import url("https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap");

/* ---------- Design tokens ---------- */
:root {
  --page-bg: #f9f9f7;
  --surface: #ffffff;
  --surface-inset: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --border: rgba(11, 11, 11, 0.1);
  --border-strong: rgba(11, 11, 11, 0.18);
  --gridline: #e1e0d9;

  --brand: #4a3aa7;
  --brand-hover: #3d3089;
  --brand-soft: #f1eefb;
  --accent: #4a3aa7;
  --accent-blue: #2a78d6;

  --success: #0ca30c;
  --success-soft: #e6f7e6;
  --warning: #fab219;
  --warning-soft: #fff5e0;
  --danger: #d03b3b;
  --danger-hover: #b32f2f;
  --danger-soft: #fdeceb;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.05);
  --shadow-md: 0 8px 24px rgba(11, 11, 11, 0.08), 0 1px 2px rgba(11, 11, 11, 0.04);
  --shadow-lg: 0 24px 60px rgba(11, 11, 11, 0.14);

  --font: "Prompt", "Segoe UI", system-ui, -apple-system, sans-serif;
  --header-h: 72px;

  --wheel-1: #2a78d6;
  --wheel-2: #1baf7a;
  --wheel-3: #eda100;
  --wheel-4: #008300;
  --wheel-5: #4a3aa7;
  --wheel-6: #e34948;
  --wheel-7: #e87ba4;
  --wheel-8: #eb6834;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #0d0d0d;
    --surface: #1c1c1b;
    --surface-inset: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.2);
    --gridline: #2c2c2a;

    --brand-soft: rgba(144, 133, 233, 0.14);
    --accent: #9085e9;
    --accent-blue: #3987e5;

    --success: #0ca30c;
    --success-soft: rgba(12, 163, 12, 0.16);
    --warning: #fab219;
    --warning-soft: rgba(250, 178, 25, 0.16);
    --danger: #e66767;
    --danger-hover: #ea8080;
    --danger-soft: rgba(214, 59, 59, 0.18);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

    --wheel-1: #3987e5;
    --wheel-2: #199e70;
    --wheel-3: #c98500;
    --wheel-4: #008300;
    --wheel-5: #9085e9;
    --wheel-6: #e66767;
    --wheel-7: #d55181;
    --wheel-8: #d95926;

    color-scheme: dark;
  }
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: 24px;
}

.hidden {
  display: none !important;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--page-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.nav-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.nav-brand-mark svg {
  width: 20px;
  height: 20px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: var(--brand-soft);
  color: var(--text-primary);
}

.nav-link.is-active {
  background: var(--brand);
  color: #fff;
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

@media (max-width: 780px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 10px 16px 16px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
  }

  .nav-links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-link {
    padding: 12px 14px;
  }
}

/* ---------- Buttons ---------- */
.btn {
  --btn-fg: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: var(--btn-fg);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--accent-blue);
}

.btn-secondary:hover {
  filter: brightness(0.9);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--surface-inset);
  border-color: var(--text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-inset);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
}

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

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 9px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.panel-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

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

/* ---------- Page header ---------- */
.page-hero {
  padding: 40px 0 8px;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 14px;
  transition: color 0.15s ease;
}

.breadcrumb:hover {
  color: var(--accent);
}

.breadcrumb svg {
  width: 16px;
  height: 16px;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.page-title-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.page-title-icon svg {
  width: 24px;
  height: 24px;
}

.page-desc {
  color: var(--text-secondary);
  max-width: 640px;
  margin-bottom: 8px;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 500;
}

.privacy-note svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

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

.field-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-inset);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.range {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--gridline);
  appearance: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  border: 3px solid var(--surface);
  cursor: pointer;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-inset);
}

.color-field span {
  flex: 1;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.color-field input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border-strong);
  border-radius: 9px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-row .field-hint {
  margin-top: 2px;
}

/* Chip / segmented selectors */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-inset);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.shape-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 4px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-inset);
  cursor: pointer;
  transition: all 0.15s ease;
}

.shape-btn svg {
  width: 26px;
  height: 26px;
  color: var(--text-secondary);
}

.shape-btn:hover {
  border-color: var(--accent);
}

.shape-btn.is-active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.shape-btn.is-active svg {
  color: var(--brand);
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.swatch:hover {
  transform: translateY(-2px);
}

.swatch.is-active {
  box-shadow: 0 0 0 2px var(--brand);
}

/* ---------- Details / advanced settings ---------- */
details.adv {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 16px;
}

details.adv summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-primary);
}

details.adv summary::-webkit-details-marker {
  display: none;
}

details.adv summary .chev {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

details.adv[open] summary .chev {
  transform: rotate(180deg);
}

details.adv .adv-body {
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  gap: 4px;
  margin-bottom: 22px;
}

.tab-btn {
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.15s ease;
}

.tab-btn.is-active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-inset);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--brand-soft);
}

.dropzone svg {
  width: 34px;
  height: 34px;
  margin: 0 auto 10px;
  color: var(--text-muted);
}

.dropzone-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.dropzone-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.dropzone input[type="file"] {
  display: none;
}

/* ---------- File list (sortable) ---------- */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-inset);
}

.file-item.is-dragging {
  opacity: 0.4;
}

.file-item-handle {
  color: var(--text-muted);
  cursor: grab;
  display: flex;
  flex-shrink: 0;
  touch-action: none;
}

.file-item-handle svg {
  width: 18px;
  height: 18px;
}

.file-item-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.file-item-body {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.file-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Thumb grid (images) ---------- */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.thumb-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-inset);
  aspect-ratio: 3 / 4;
  cursor: grab;
}

.thumb-card.is-dragging {
  opacity: 0.4;
}

.thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-order {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(11, 11, 11, 0.65);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: none;
  background: rgba(11, 11, 11, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.thumb-remove svg {
  width: 14px;
  height: 14px;
}

.thumb-remove:hover {
  background: var(--danger);
}

.thumb-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 5px 8px;
  font-size: 0.68rem;
  color: #fff;
  background: linear-gradient(to top, rgba(11, 11, 11, 0.75), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Range rows (PDF split) ---------- */
.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.range-row .input {
  flex: 1;
  min-width: 0;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ---------- Preview surfaces ---------- */
.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  gap: 20px;
}

.checkerboard {
  background-image: linear-gradient(45deg, #d8d8d3 25%, transparent 25%),
    linear-gradient(-45deg, #d8d8d3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8d8d3 75%),
    linear-gradient(-45deg, transparent 75%, #d8d8d3 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #efefec;
}

@media (prefers-color-scheme: dark) {
  .checkerboard {
    background-image: linear-gradient(45deg, #333331 25%, transparent 25%),
      linear-gradient(-45deg, #333331 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #333331 75%),
      linear-gradient(-45deg, transparent 75%, #333331 75%);
    background-color: #242422;
  }
}

/* ---------- Badges / notes ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.badge svg {
  width: 14px;
  height: 14px;
  color: var(--success);
}

.section-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.divider {
  height: 1px;
  background: var(--border);
  border: none;
  margin: 20px 0;
}

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
  animation: slideIn 0.2s ease;
}

.toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast.toast-success svg {
  color: var(--success);
}

.toast.toast-error svg {
  color: var(--danger);
}

.toast.toast-info svg {
  color: var(--accent-blue);
}

/* ---------- Loading spinner ---------- */
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner.dark {
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
}

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

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

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

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-end-space {
  height: 60px;
}

/* ---------- Random wheel ---------- */
.wheel-stage {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 1;
  margin: 10px auto 26px;
}

.wheel-canvas-el {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  filter: drop-shadow(0 14px 28px rgba(11, 11, 11, 0.18));
  will-change: transform;
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid var(--brand);
  z-index: 5;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--page-bg);
  box-shadow: 0 2px 10px rgba(11, 11, 11, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  z-index: 4;
  pointer-events: none;
}

.wheel-hub svg {
  width: 26px;
  height: 26px;
}

.winner-banner {
  text-align: center;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--brand-soft);
  border: 1px solid var(--border);
  margin-top: 6px;
}

.winner-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.winner-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  word-break: break-word;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  max-height: 220px;
  overflow-y: auto;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-size: 0.84rem;
}

.history-row .idx {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* ---------- Group shuffler ---------- */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.group-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-inset);
}

.group-card-header {
  padding: 10px 14px;
  color: #fff;
  font-weight: 600;
  font-size: 0.86rem;
}

.group-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.group-card-body span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---------- Homepage: hero ---------- */
.hero {
  position: relative;
  padding: 76px 0 40px;
  overflow: hidden;
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  top: -220px;
  left: 50%;
  width: 900px;
  height: 560px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brand) 22%, transparent), transparent 72%),
    radial-gradient(closest-side at 30% 60%, color-mix(in srgb, var(--accent-blue) 18%, transparent), transparent 70%);
  z-index: -1;
  filter: blur(10px);
}

.hero-inner {
  text-align: center;
  max-width: 720px;
  margin-inline: auto;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .hero-eyebrow {
    color: var(--accent);
  }
}

.hero-title {
  font-size: clamp(2rem, 1.5rem + 2.2vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 18px;
}

.hero-title .accent-word {
  background: linear-gradient(100deg, var(--brand), var(--accent-blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 1.02rem;
  max-width: 560px;
  margin: 0 auto 28px;
}

.hero-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Homepage: tools grid ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 44px 0;
}

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

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.tool-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 18px;
}

.tool-card-icon svg {
  width: 26px;
  height: 26px;
}

.tool-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.tool-card-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  flex: 1;
  margin-bottom: 18px;
}

.tool-card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

.tool-card-link svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.tool-card:hover .tool-card-link svg {
  transform: translateX(3px);
}

.icon-bg-violet { background: linear-gradient(135deg, #4a3aa7, #7e6fd6); }
.icon-bg-blue { background: linear-gradient(135deg, #2a78d6, #5aa2ec); }
.icon-bg-aqua { background: linear-gradient(135deg, #1baf7a, #4fd19c); }
.icon-bg-orange { background: linear-gradient(135deg, #eb6834, #f2925f); }

/* ---------- Homepage: features strip ---------- */
.features-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px 0 60px;
}

@media (max-width: 780px) {
  .features-strip {
    grid-template-columns: 1fr;
  }
}

.feature {
  padding: 24px;
  border-radius: var(--radius-md);
  background: var(--surface-inset);
  border: 1px solid var(--border);
}

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 14px;
}

.feature-icon svg {
  width: 19px;
  height: 19px;
}

.feature-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.96rem;
}

.feature-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
}
