:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
  background: #f8fafc;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: #2563eb;
  text-underline-offset: 3px;
}

button, input, select, textarea {
  font: inherit;
  font-variant-numeric: tabular-nums;
}

button, select, input:not([type=file]), .btn-download {
  min-height: 44px;
}

button {
  cursor: pointer;
  border-radius: 6px;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* Header & Nav */
.topbar {
  height: 60px;
  min-height: 56px;
  max-height: 64px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  color: #0f172a;
  font-weight: 750;
  text-decoration: none;
  font-size: 1.05rem;
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.nav-inner nav {
  display: flex;
  gap: 16px;
}

.nav-inner nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.95rem;
  color: #475569;
  text-decoration: none;
  padding: 0 4px;
}

.nav-inner nav a:hover,
.nav-inner nav a.active {
  color: #0f172a;
  font-weight: 600;
}

/* Main Container */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
}

.breadcrumb {
  font-size: 0.85rem;
  color: #475569;
  margin-bottom: 6px;
}

.breadcrumb a {
  color: #475569;
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

h1 {
  font-size: clamp(1.4rem, 3.6vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.intro {
  margin: 0 0 18px;
  color: #475569;
  font-size: 0.95rem;
}

/* Task-First Workspace Grid */
.creative-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.15fr);
  gap: 28px;
  align-items: start;
}

/* Left: Controls Form */
.tool-controls {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.control-group {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

.control-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Upload Dropzone */
.dropzone {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  background: #ffffff;
  padding: 20px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.dropzone svg {
  width: 28px;
  height: 28px;
  color: #2563eb;
}

.dropzone label {
  font-weight: 650;
  cursor: pointer;
  color: #0f172a;
}

input[type=file] {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  font-size: 1rem;
}

input::file-selector-button {
  font: inherit;
  min-height: 44px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 14px;
  margin-right: 10px;
  color: #0f172a;
  cursor: pointer;
}

.hint {
  font-size: 0.85rem;
  color: #475569;
  margin: 4px 0 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#file-info {
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  color: #334155;
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 10px 0 0;
}

/* Inputs & Form Elements */
.option {
  margin: 12px 0;
  min-width: 0;
}

.option label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 650;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: #0f172a;
}

.option output {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #2563eb;
}

.option input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=color]),
.option select,
.option textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 12px;
  background: #ffffff;
  color: #0f172a;
  font-size: 1rem;
}

.option input[type=range] {
  width: 100%;
  min-height: 44px;
  accent-color: #2563eb;
  margin: 0;
  cursor: pointer;
}

.option input[type=color] {
  width: 100%;
  height: 44px;
  padding: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  background: #ffffff;
}

.row2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

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

/* Radio Pill Group (Sensor Type Selector) */
.radio-pill-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.radio-pill-item {
  position: relative;
}

.radio-pill-item input[type=radio] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  margin: 0;
}

.radio-pill-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 4px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.radio-pill-item input[type=radio]:checked + .radio-pill-label {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

/* Actions Row */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

button.btn-primary, .btn-download {
  background: #2563eb;
  border: 1px solid #2563eb;
  color: #ffffff;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 600;
  border-radius: 6px;
}

button.btn-primary:hover:not(:disabled), .btn-download:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button.btn-secondary {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  padding: 9px 14px;
}

button.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

button.btn-subtle {
  background: transparent;
  border: 1px dashed #cbd5e1;
  color: #475569;
  font-size: 0.875rem;
  padding: 6px 12px;
}

button.btn-subtle:hover:not(:disabled) {
  background: #f8fafc;
  color: #0f172a;
}

/* Right: Canvas Preview & Stage */
.stage-panel {
  position: sticky;
  top: 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.stage-header h2 {
  font-size: 1.1rem;
  margin: 0;
  color: #0f172a;
}

.canvas-viewport {
  position: relative;
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 280px;
  max-height: 580px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  box-sizing: border-box;
}

.canvas-viewport canvas {
  width: 100%;
  max-width: 100%;
  max-height: 560px;
  height: auto;
  min-width: 0;
  flex-shrink: 1;
  display: block;
  object-fit: contain;
}

/* Selection Box for Censor Tool */
.selection-box {
  position: absolute;
  border: 2px dashed #2563eb;
  background: rgba(37, 99, 235, 0.2);
  pointer-events: none;
  box-sizing: border-box;
}

.stage-meta {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-badge {
  font-size: 0.85rem;
  color: #475569;
  display: flex;
  justify-content: space-between;
}

.download-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.privacy-notice {
  font-size: 0.825rem;
  color: #64748b;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  line-height: 1.45;
}

/* Preset Memes / Templates Quick Bar */
.preset-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 10px 0;
}

.preset-chip {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.85rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  white-space: nowrap;
}

.preset-chip:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

/* Below-the-fold FAQ & Theory Accordion */
.guide {
  border-top: 1px solid #e2e8f0;
  margin-top: 36px;
  padding-top: 12px;
}

.guide h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
  color: #0f172a;
}

details {
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 0;
}

summary {
  cursor: pointer;
  font-weight: 650;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: #0f172a;
}

summary:hover {
  color: #2563eb;
}

details p {
  max-width: 75ch;
  color: #475569;
  margin: 8px 0 4px;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Footer */
footer {
  max-width: 1120px;
  margin: 28px auto 20px;
  padding: 0 16px;
  color: #64748b;
  font-size: 0.85rem;
  text-align: center;
}

footer a {
  color: #475569;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive Rules */
@media (max-width: 768px) {
  .nav-inner {
    padding: 0 12px;
    gap: 10px;
  }
  .nav-inner nav {
    gap: 10px;
  }
  .nav-inner nav a {
    font-size: 0.9rem;
    padding: 0 2px;
  }
  .brand {
    font-size: 0.95rem;
  }
  .creative-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .stage-panel {
    position: static;
  }
  .canvas-viewport {
    min-height: 220px;
    max-height: 420px;
  }
  .canvas-viewport canvas {
    max-height: 400px;
  }
  .row2, .row3, .radio-pill-group {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Brush cursor & preview background modes for Remove BG tool */
.brush-cursor {
  position: absolute;
  border: 1.5px solid #2563eb;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  background: rgba(37, 99, 235, 0.15);
  display: none;
  z-index: 10;
}

.brush-cursor.mode-restore {
  border-color: #059669;
  background: rgba(5, 150, 105, 0.15);
}

.brush-cursor.mode-sample {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.15);
}

.canvas-viewport.bg-white {
  background: #ffffff !important;
}

.canvas-viewport.bg-black {
  background: #0f172a !important;
}

/* Resizable & Movable Selection Box for Face Blur */
.selection-box.interactive {
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 1.5px solid #2563eb;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  box-sizing: border-box;
  pointer-events: auto;
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-w { top: 50%; left: -5px; transform: translateY(-50%); cursor: ew-resize; }
.handle-e { top: 50%; right: -5px; transform: translateY(-50%); cursor: ew-resize; }

/* B2B Sponsor Slot */
.b2b-sponsor-slot {
  margin: 32px 0 24px;
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
}

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

.sponsor-copy {
  flex: 1 1 280px;
}

.sponsor-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2563eb;
  margin-bottom: 4px;
}

.sponsor-text {
  margin: 0;
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.5;
}

.sponsor-cta {
  white-space: nowrap;
}

/* Feedback Strip */
.feedback-strip {
  margin: 24px 0 32px;
}

.feedback-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.feedback-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.feedback-card h3 {
  font-size: 0.98rem;
  margin: 0 0 8px;
  color: #0f172a;
}

.feedback-card p {
  font-size: 0.875rem;
  color: #475569;
  margin: 0 0 14px;
  line-height: 1.5;
  flex: 1;
}

.feedback-btn {
  align-self: flex-start;
  text-decoration: none;
}

@media (max-width: 640px) {
  .feedback-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}


