* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #111111;
  --surface: #191919;
  --surface-2: #242424;
  --ink: #f7f7f7;
  --muted: #b6b6b6;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #28b39d;
  --accent-2: #b94758;
  --gold: #d7a73d;
  --button-ink: #0f1111;
  --shadow: 0 22px 56px rgba(0, 0, 0, 0.38);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --ink: #161719;
  --muted: #646a71;
  --line: rgba(20, 22, 25, 0.12);
  --accent: #168374;
  --accent-2: #9c3144;
  --gold: #b98518;
  --button-ink: #ffffff;
  --shadow: 0 20px 48px rgba(20, 24, 30, 0.13);
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(40, 179, 157, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(185, 71, 88, 0.12), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
.rb-dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.rb-shell {
  min-height: 100vh;
  padding: 28px;
}

.rb-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: min(1460px, 100%);
  margin: 0 auto 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 2.7rem;
  line-height: 1;
}

h2 {
  margin: 0;
  font-size: 1.05rem;
}

.rb-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
}

.rb-theme-toggle span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--gold);
}

.rb-theme-toggle strong {
  font-size: 0.82rem;
}

.rb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  width: min(1460px, 100%);
  margin: 0 auto;
}

.rb-workspace,
.rb-controls {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25, 25, 25, 0.86);
  box-shadow: var(--shadow);
}

:root[data-theme="light"] .rb-workspace,
:root[data-theme="light"] .rb-controls {
  background: rgba(255, 255, 255, 0.92);
}

.rb-workspace {
  min-height: 680px;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

.rb-dropzone {
  min-height: 520px;
  margin: 14px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 2px dashed rgba(40, 179, 157, 0.48);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  cursor: pointer;
  text-align: center;
}

.rb-dropzone.is-dragging,
.rb-dropzone:hover {
  border-color: var(--gold);
}

.rb-drop-mark {
  width: 74px;
  height: 74px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  position: relative;
}

.rb-drop-mark::before,
.rb-drop-mark::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 2px;
  background: var(--accent-2);
}

.rb-drop-mark::after {
  inset: 29px 18px;
  background: var(--gold);
}

.rb-dropzone p {
  margin: 0;
  color: var(--muted);
}

.rb-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.rb-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 620px;
  background: var(--line);
  gap: 1px;
}

.rb-preview-pane {
  margin: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
}

.rb-preview-pane figcaption {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.78rem;
}

.rb-preview-pane canvas {
  align-self: center;
  justify-self: center;
  max-width: calc(100% - 28px);
  max-height: 540px;
  background: #0b0b0b;
  border-radius: 4px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

#result-canvas {
  background: transparent;
}

.rb-preview-result {
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, rgba(127, 127, 127, 0.18) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(127, 127, 127, 0.18) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(127, 127, 127, 0.18) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(127, 127, 127, 0.18) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.rb-status {
  min-height: 44px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.rb-status[data-tone="error"] {
  color: var(--accent-2);
}

.rb-controls {
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.rb-control-section {
  display: grid;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.rb-control-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.rb-range {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}

.rb-range span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.rb-range strong {
  color: var(--accent);
}

.rb-range input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.rb-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.rb-segmented label {
  position: relative;
  cursor: pointer;
}

.rb-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rb-segmented span {
  display: block;
  border-radius: 6px;
  padding: 9px 10px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.rb-segmented input:checked + span {
  background: var(--surface);
  color: var(--accent);
}

.rb-color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 750;
}

.rb-color-row input {
  width: 54px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
}

.rb-stats {
  display: grid;
  gap: 8px;
  margin: 0;
}

.rb-stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.rb-stats div:last-child {
  border-bottom: 0;
}

.rb-stats dt {
  color: var(--muted);
}

.rb-stats dd {
  margin: 0;
  font-weight: 800;
}

.rb-actions {
  display: grid;
  gap: 10px;
}

.rb-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
  padding: 0 18px;
}

.rb-button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.rb-button-primary {
  background: var(--accent);
  color: var(--button-ink);
}

.rb-button-secondary {
  background: var(--surface-2);
  border-color: var(--line);
}

.rb-button-plain {
  background: transparent;
  border-color: var(--line);
}

@media (max-width: 1080px) {
  .rb-layout {
    grid-template-columns: 1fr;
  }

  .rb-preview-grid {
    grid-template-columns: 1fr;
  }

  .rb-controls {
    align-self: stretch;
  }
}

@media (max-width: 640px) {
  .rb-shell {
    padding: 16px;
  }

  .rb-header {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2.25rem;
  }

  .rb-workspace {
    min-height: 560px;
  }

  .rb-dropzone {
    min-height: 420px;
  }
}
