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

:root {
  --bg-deep: #1a1410;
  --bg-surface: #2a221c;
  --bg-panel: rgba(42, 34, 28, 0.85);
  --accent-terracotta: #c45c3e;
  --accent-gold: #d4a843;
  --accent-blue: #2a5a7a;
  --accent-teal: #3a7a6a;
  --text-primary: #f0e8dc;
  --text-muted: #a89888;
  --border: rgba(212, 168, 67, 0.2);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --font-display: 'Bitter', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-deep);
  line-height: 1.6;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(196, 92, 62, 0.15), transparent),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(42, 90, 122, 0.12), transparent),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(212, 168, 67, 0.06), transparent),
    var(--bg-deep);
}

.page-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(45deg, rgba(212, 168, 67, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(212, 168, 67, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(212, 168, 67, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(212, 168, 67, 0.03) 75%);
  background-size: 40px 40px;
  background-position: 0 0, 0 20px, 20px -20px, -20px 0;
  opacity: 0.5;
}

.header {
  padding: 2rem 1.5rem 1rem;
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo__icon {
  font-size: 2rem;
  color: var(--accent-gold);
  filter: drop-shadow(0 0 8px rgba(212, 168, 67, 0.4));
}

.logo__title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-terracotta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.intro {
  margin-bottom: 2rem;
}

.intro__text {
  max-width: 720px;
  font-size: 1.05rem;
  color: var(--text-muted);
  border-left: 3px solid var(--accent-terracotta);
  padding-left: 1.25rem;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 2rem;
  align-items: start;
}

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

.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.panel--disabled {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.panel--disabled.is-active {
  opacity: 1;
  pointer-events: auto;
}

.panel__title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--accent-gold);
}

.panel__subtitle {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem;
  color: var(--text-primary);
}

.panel__desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragover {
  border-color: var(--accent-gold);
  background: rgba(212, 168, 67, 0.06);
  outline: none;
}

.dropzone__icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent-terracotta);
}

.dropzone__label {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.dropzone__hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.slider-group {
  margin-bottom: 0.75rem;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.slider-labels span:nth-child(2) {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-gold);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent-blue),
    var(--accent-terracotta),
    var(--accent-gold)
  );
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 3px solid var(--accent-gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 3px solid var(--accent-gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.slider-preview {
  text-align: center;
  margin-bottom: 0.5rem;
}

.slider-preview__tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(212, 168, 67, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 168, 67, 0.3);
}

.palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.palette-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.palette-btn:hover {
  border-color: rgba(212, 168, 67, 0.4);
}

.palette-btn--active {
  border-color: var(--accent-gold);
  background: rgba(212, 168, 67, 0.1);
  color: var(--text-primary);
}

.palette-btn__swatches {
  display: flex;
  gap: 3px;
}

.palette-btn__swatches i {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
}

.btn {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent-terracotta), #a04030);
  color: white;
  box-shadow: 0 4px 16px rgba(196, 92, 62, 0.35);
}

.btn--primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(196, 92, 62, 0.45);
}

.btn--primary:not(:disabled):active {
  transform: translateY(0);
}

.preview__frame {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 400px;
  box-shadow: var(--shadow);
}

.preview__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 2rem;
}

.preview__placeholder[hidden] {
  display: none;
}

.preview__placeholder-inner {
  text-align: center;
  color: var(--text-muted);
}

.preview__placeholder-inner p {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.mosaic-pattern {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  opacity: 0.6;
}

.mosaic-pattern::before {
  content: '';
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  background:
    var(--accent-terracotta) 0 0 / 25% 25%,
    var(--accent-blue) 25% 0 / 25% 25%,
    var(--accent-gold) 50% 0 / 25% 25%,
    var(--accent-teal) 75% 0 / 25% 25%;
}

#outputCanvas {
  display: block;
  width: 100%;
  height: auto;
}

.preview__compare {
  margin-top: 0.75rem;
  text-align: center;
}

.compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}

.compare-toggle input {
  accent-color: var(--accent-gold);
  width: 16px;
  height: 16px;
}

.footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.processing .preview__frame::after {
  content: 'Przetwarzanie…';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 20, 16, 0.7);
  font-weight: 500;
  color: var(--accent-gold);
  z-index: 2;
}
