:root {
  --if-border: rgba(12, 74, 110, 0.12);
  --if-border-strong: rgba(12, 74, 110, 0.32);
  --if-surface: rgba(255, 255, 255, 0.86);
  --if-muted: #64748b;
  --if-background: #f4f7fb;
  --if-radius-lg: 18px;
  --if-radius-md: 12px;
  --if-radius-sm: 8px;
  --if-shadow-soft: 0 25px 45px rgba(15, 23, 42, 0.08);
  --if-shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  --if-primary: #2563eb;
  --if-primary-dark: #1d4ed8;
}

body.dark-mode {
  --if-border: rgba(148, 163, 184, 0.18);
  --if-border-strong: rgba(148, 163, 184, 0.4);
  --if-surface: rgba(15, 23, 42, 0.9);
  --if-muted: #cbd5f5;
  --if-background: #101828;
  --if-shadow-soft: 0 20px 40px rgba(15, 23, 42, 0.65);
}

.image-filter-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.page-hero {
  background: var(--if-surface);
  border-radius: var(--if-radius-lg);
  padding: 1.75rem 2rem;
  border: 1px solid var(--if-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.page-hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  color: var(--if-muted);
  margin-bottom: 0.5rem;
}

.page-hero h1 {
  font-size: clamp(2rem, 3vw, 2.5rem);
  margin: 0;
  color: #0f172a;
}

body.dark-mode .page-hero h1 {
  color: #e2e8f0;
}

.page-hero .subtitle {
  max-width: 520px;
  font-size: 0.95rem;
  color: var(--if-muted);
  margin: 0.5rem 0 0;
  line-height: 1.5;
}

.hero-details {
  background: rgba(37, 99, 235, 0.06);
  border-radius: var(--if-radius-md);
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
}

.hero-details summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-weight: 600;
  color: #0f172a;
  list-style: none;
  position: relative;
}

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

.hero-details summary::after {
  content: '\25BE';
  font-size: 0.75rem;
  transform: translateY(1px);
}

.hero-details[open] summary::after {
  transform: rotate(180deg) translateY(-1px);
}

.hero-details[open] {
  border-color: var(--if-border);
  background: rgba(37, 99, 235, 0.08);
}

body.dark-mode .hero-details {
  background: rgba(37, 99, 235, 0.18);
}

body.dark-mode .hero-details[open] {
  background: rgba(37, 99, 235, 0.24);
}

.hero-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  align-self: center;
}

.hero-highlights li {
  padding: 0.65rem 0.85rem;
  border-radius: var(--if-radius-md);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--if-border);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hero-highlights li::before {
  content: '✦';
  color: var(--if-primary);
  font-size: 0.85rem;
}

body.dark-mode .hero-highlights li {
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
}

body.dark-mode .hero-highlights li::before {
  color: var(--if-primary);
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.page-grid > * {
  min-width: 0;
}

.image-filter-form {
  background: var(--if-surface);
  border-radius: var(--if-radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--if-border);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-section.compact {
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--if-border);
}

.form-section.compact:last-of-type {
  border-bottom: none;
}

.section-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.section-header .muted {
  margin-top: 0.25rem;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-weight: 600;
  color: #0f172a;
  background: rgba(37, 99, 235, 0.12);
  box-shadow: var(--if-shadow-inner);
}

body.dark-mode .step {
  color: #e2e8f0;
  background: rgba(37, 99, 235, 0.25);
}

.muted {
  color: var(--if-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.small-print {
  font-size: 0.8rem;
}

.option-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
}

.option-tile {
  border: 1px solid var(--if-border);
  border-radius: var(--if-radius-md);
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 0.35rem;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.option-tile:hover {
  border-color: var(--if-border-strong);
}

.option-tile input {
  position: absolute;
  inset: 16px 16px auto auto;
  width: 18px;
  height: 18px;
}

.option-tile .title {
  font-weight: 600;
  color: #0f172a;
}

body.dark-mode .option-tile {
  background: rgba(15, 23, 42, 0.75);
}

body.dark-mode .option-tile .title {
  color: #e2e8f0;
}

.option-tile input:checked + .title,
.option-tile input:checked ~ .description {
  color: var(--if-primary);
}

.upload-input input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--if-radius-md);
  border: 1px dashed var(--if-border-strong);
  background: rgba(37, 99, 235, 0.05);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--if-radius-md);
  border: 1px solid var(--if-border);
  cursor: pointer;
  position: relative;
  background: rgba(255, 255, 255, 0.7);
  transition: border-color 0.2s ease;
}

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

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch-indicator {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  position: relative;
  transition: background 0.2s ease;
}

.switch-indicator::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.2);
  transition: transform 0.2s ease;
}

.switch-row input:checked + .switch-indicator {
  background: rgba(37, 99, 235, 0.6);
}

.switch-row input:checked + .switch-indicator::after {
  transform: translateX(20px);
}

.switch-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.card {
  border: 1px solid var(--if-border);
  border-radius: var(--if-radius-md);
  padding: 1rem 1.2rem;
  background: rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

body.dark-mode .card {
  background: rgba(15, 23, 42, 0.8);
}

.card-title {
  font-weight: 600;
  color: #0f172a;
}

body.dark-mode .card-title {
  color: #e2e8f0;
}

.card select,
.card input[type="number"],
.card input[type="text"],
.upload-input input[type="file"] {
  font: inherit;
}

.card select,
.card input[type="number"],
.card input[type="text"] {
  border-radius: var(--if-radius-sm);
  border: 1px solid var(--if-border);
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.9);
}

body.dark-mode .card select,
body.dark-mode .card input[type="number"],
body.dark-mode .card input[type="text"] {
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
}

.custom-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.submit-row {
  display: flex;
  justify-content: flex-end;
}

.primary-btn {
  padding: 0.75rem 1.4rem;
  border-radius: 16px;
  border: none;
  background: var(--if-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  box-shadow: none;
}

.primary-btn:hover {
  background: var(--if-primary-dark);

}

.preview-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--if-surface);
  border-radius: var(--if-radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--if-border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: none;
}
.compact-panel {
  padding: 1.35rem 1.4rem;
  gap: 1rem;
}


.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.panel-header h2 {
  margin: 0;
}

.blend-control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
  font-size: 0.85rem;
  color: var(--if-muted);
}

.blend-control input[type="range"] {
  width: 160px;
}

.preview-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.image-wrap {
  position: relative;
  background: rgba(15, 23, 42, 0.04);
  border-radius: var(--if-radius-md);
  padding: 0.75rem;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}

.image-wrap img {
  width: 100%;
  border-radius: var(--if-radius-sm);
  display: block;
}

.image-wrap canvas {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(0.75rem + 36px);
  pointer-events: none;
}

.image-wrap figcaption {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--if-muted);
}

.plot-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.plot-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--if-border);
  cursor: pointer;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.8);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.chip:hover {
  border-color: var(--if-border-strong);
}

.chip input {
  accent-color: var(--if-primary);
}

.plot-area {
  border: 1px solid var(--if-border);
  border-radius: var(--if-radius-md);
  background: rgba(15, 23, 42, 0.02);
  display: grid;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
}

.plot-area img {
  width: 100%;
  border-radius: var(--if-radius-sm);

}

.plot-area img.active {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.plot-note {
  border: 1px dashed var(--if-border);
  border-radius: var(--if-radius-sm);
  padding: 0.7rem 0.85rem;
  font-size: 0.85rem;
  color: var(--if-muted);
  background: rgba(255, 255, 255, 0.65);
}

.plot-note summary {
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  position: relative;
}

.plot-note summary::after {
  content: '\25BE';
  font-size: 0.75rem;
  transform: translateY(1px);
}

.plot-note[open] summary::after {
  transform: rotate(180deg) translateY(-1px);
}

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

body.dark-mode .plot-note summary {
  color: #e2e8f0;
}
.plot-note[open] {
  background: rgba(37, 99, 235, 0.07);
}

.plot-note p {
  margin: 0.55rem 0 0;
  line-height: 1.5;
}

body.dark-mode .plot-note {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148, 163, 184, 0.35);
}

body.dark-mode .plot-note[open] {
  background: rgba(37, 99, 235, 0.2);
}

.cta {
  display: flex;
  justify-content: center;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--if-border);
  background: transparent;
  color: var(--if-primary-dark);
  text-decoration: none;
  font-weight: 600;
}

.plot-desc {
  font-size: 0.85rem;
  color: var(--if-muted);
  text-align: left;
}

.radial-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chart-canvas {
  border-radius: var(--if-radius-md);
  background: rgba(15, 23, 42, 0.04);
  padding: 0.75rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #b91c1c;
  padding: 0.9rem 1.1rem;
  border-radius: var(--if-radius-md);
}
@media (min-width: 1100px) {
  .page-grid {
    gap: 1.75rem;
  }

  .image-filter-form,
  .preview-column {
    max-width: 960px;
    justify-self: center;
    width: 100%;
  }
}

@media (max-width: 780px) {
  .page-hero {
    flex-direction: column;
  }

  .hero-highlights {
    align-self: stretch;
  }
}


@media (max-width: 640px) {
  .image-filter-page {
    padding: 1.75rem 1rem 2.5rem;
  }

  .page-hero {
    padding: 1.5rem;
  }

  .section-header {
    flex-direction: column;
  }

  .blend-control {
    align-items: stretch;
  }

  .blend-control input[type="range"] {
    width: 100%;
  }
}