:root {
  color-scheme: light dark;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: #f4f6f8;
  color: #1f2a37;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f5f7fb 0%, #e6ecf5 100%);
}

header,
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

header h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.8rem, 2.5vw, 2.4rem);
}

main {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 2rem;
}

.controls,
.palette-manager,
.previews {
  background-color: rgba(255, 255, 255, 0.88);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 22px 50px -28px rgba(15, 23, 42, 0.28);
}

.controls h2,
.palette-manager h2,
.previews h2 {
  margin-top: 0;
}

.section-subtitle {
  margin: 0.35rem 0 1.5rem;
  color: rgba(15, 23, 42, 0.7);
}

.form-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
}

.color-input {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type='color'] {
  width: 52px;
  height: 52px;
  border: none;
  padding: 0;
  border-radius: 12px;
  cursor: pointer;
  background: none;
}

.color-chip {
  min-width: 6rem;
  padding: 0.4rem 0.75rem;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(15, 23, 42, 0.12);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  background-color: rgba(15, 23, 42, 0.04);
  font-variant-numeric: tabular-nums;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

select,
textarea {
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  font-size: 1rem;
  background-color: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus,
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

button {
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.75rem 1.3rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  box-shadow: 0 14px 24px -16px rgba(37, 99, 235, 0.7);
}

button.secondary {
  background-color: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.empty-state {
  margin: 0;
  padding: 1rem;
  border-radius: 12px;
  background-color: rgba(15, 23, 42, 0.05);
  color: rgba(15, 23, 42, 0.7);
  text-align: center;
}

.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;
}


.palette-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}


.palette-rail {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background-color: rgba(248, 250, 252, 0.92);
  box-shadow: 0 16px 40px -34px rgba(15, 23, 42, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-wrap: nowrap;
  min-height: 54px;
}

.palette-rail--builder {
  border-color: rgba(99, 102, 241, 0.45);
  background-color: rgba(99, 102, 241, 0.18);
}

.palette-rail--dragging {
  cursor: grabbing;
  box-shadow: 0 12px 36px -24px rgba(15, 23, 42, 0.5);
  opacity: 0.9;
  z-index: 10;
}

.palette-rail--placeholder {
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.04);
  box-shadow: none;
}



.palette-rail__drag {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 120px;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background-color: rgba(15, 23, 42, 0.06);
  color: rgba(15, 23, 42, 0.75);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: grab;
}

.palette-rail__drag:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.palette-rail__handle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.palette-rail__handle::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  mask: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" fill="none"%3E%3Ccircle cx="2" cy="2" r="1" fill="white"/%3E%3Ccircle cx="8" cy="2" r="1" fill="white"/%3E%3Ccircle cx="2" cy="5" r="1" fill="white"/%3E%3Ccircle cx="8" cy="5" r="1" fill="white"/%3E%3Ccircle cx="2" cy="8" r="1" fill="white"/%3E%3Ccircle cx="8" cy="8" r="1" fill="white"/%3E%3C/svg%3E') center/contain;
  background-color: rgba(15, 23, 42, 0.5);
}


.palette-rail__group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.palette-rail__group select {
  min-width: 128px;
  height: 34px;
  font-size: 0.78rem;
  padding: 0 1.75rem 0 0.7rem;
}


.palette-rail__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}


.palette-rail__actions button {
  padding: 0.35rem 0.7rem;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background-color: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  font-size: 0.82rem;
  min-width: 96px;
  text-align: center;
}

.palette-rail__actions .primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  border-color: transparent;
}

.palette-global-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.palette-rail__group--image {
  gap: 0.5rem;
}

.palette-rail__thumb {
  width: 64px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background-color: rgba(15, 23, 42, 0.06);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  flex: 0 0 auto;
}

.palette-rail__thumb--empty::after {
  content: 'IMG';
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.45);
  width: 100%;
  height: 100%;
}

.palette-rail__file {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  width: 0.1px;
  height: 0.1px;
}


.hex-pill-input {
  width: 76px;
  padding: 0.32rem 0.45rem;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.hex-pill-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.hex-pill-input.invalid {
  border-color: rgba(220, 38, 38, 0.75);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}


.scenarios-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: stretch;
}

.scenario-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 22px 45px -35px rgba(15, 23, 42, 0.35);
}

.scenario-column header {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.4rem;
  min-height: 92px;
}

.scenario-column header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.scenario-column header p {
  margin: 0;
  color: rgba(15, 23, 42, 0.7);
  font-size: 0.9rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0.5rem 0;
  width: 100%;
}

.scenario-board {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  flex: 1 1 auto;
}

.scenario-sample {
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.scenario-sample + .scenario-sample {
  border-top: 1px solid rgba(15, 23, 42, 0.1);
}

.scenario-label-row {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.scenario-text {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 110px;
}

.scenario-text p {
  margin: 0;
  line-height: 1.6;
  font-size: 1rem;
}

.scenario-hex-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
}

.hex-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  background-color: rgba(15, 23, 42, 0.12);
  color: rgba(15, 23, 42, 0.85);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}

.scenario-image {
  width: 100%;
  max-height: 300px;
  border-radius: 12px;
  overflow: hidden;
  background-color: rgba(15, 23, 42, 0.04);
  margin: 0.25rem auto;
  padding: 5px;
  box-sizing: border-box;
  position: relative;
}

.scenario-image__media {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  position: relative;
}

.hex-pill::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--swatch-color, currentColor);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

footer {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    background-color: #0f172a;
    color: #e2e8f0;
  }

  body {
    background: radial-gradient(circle at top, rgba(37, 99, 235, 0.35), transparent 55%),
      #0f172a;
  }

  header,
  footer,
  .controls,
  .palette-manager,
  .previews,
  .palette-item,
  .scenario-column {
    background-color: rgba(15, 23, 42, 0.82);
    border-color: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
  }

  .scenario-column header p {
    color: rgba(226, 232, 240, 0.78);
  }

  select,
  textarea {
    background-color: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.25);
  }

  button.secondary {
    background-color: rgba(148, 163, 184, 0.18);
    color: #e2e8f0;
  }

  .empty-state {
    background-color: rgba(148, 163, 184, 0.18);
    color: rgba(226, 232, 240, 0.78);
  }

  .palette-actions button {
    background-color: rgba(148, 163, 184, 0.22);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.25);
  }

  .scenario-entry {
    background-color: rgba(15, 23, 42, 0.55);
    border-color: rgba(148, 163, 184, 0.22);
  }

  .scenario-entry-header {
    background-color: rgba(148, 163, 184, 0.2);
  }

  .scenario-board {
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.15);
  }

  .scenario-sample + .scenario-sample {
    border-top: 1px solid rgba(148, 163, 184, 0.2);
  }

  .hex-pill {
    background-color: rgba(148, 163, 184, 0.25);
    color: #f8fafc;
  }
}
