:root {
  color-scheme: dark;
  --bg: #0b0911;
  --surface: rgba(24, 22, 31, 0.82);
  --surface-strong: rgba(32, 29, 41, 0.96);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f2ff;
  --muted: #aaa4b8;
  --muted-strong: #d7d0e4;
  --accent: #a76cff;
  --accent-strong: #c7a2ff;
  --accent-soft: rgba(167, 108, 255, 0.18);
  --danger: #ff6f91;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --radius: 8px;
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "Helvetica Neue",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 22% 0%, rgba(167, 108, 255, 0.24), transparent 32rem),
    linear-gradient(140deg, #0b0911 0%, #111018 48%, #07070a 100%);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
label.button,
select {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 340px;
  height: 100svh;
  padding: 14px;
  gap: 14px;
  transition: grid-template-columns 180ms ease;
}

.app-shell.inspector-collapsed {
  grid-template-columns: 76px minmax(0, 1fr) 0;
}

.rail,
.workspace,
.inspector {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(135%);
}

.app-shell.inspector-collapsed .inspector {
  padding: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 18px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(167, 108, 255, 0.92), rgba(76, 51, 110, 0.78));
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.rail-button,
.icon-button,
.ghost-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.rail-button:hover,
.icon-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.rail-button.is-active,
.icon-button.is-active {
  border-color: rgba(167, 108, 255, 0.42);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  border-radius: 22px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  line-height: 1;
}

.logo-lockup {
  display: flex;
  align-items: center;
  min-width: 180px;
}

.logo-lockup img {
  display: block;
  width: min(220px, 34vw);
  max-height: 62px;
  object-fit: contain;
  object-position: left center;
}

.logo-lockup h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

h2 {
  margin-bottom: 0;
  font-size: 0.94rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
}

.button-primary {
  border-color: rgba(167, 108, 255, 0.46);
  background: linear-gradient(180deg, rgba(167, 108, 255, 0.96), rgba(117, 72, 190, 0.94));
}

.panel-toggle {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.stage-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 16px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  flex-wrap: wrap;
}

.segmented {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.16);
}

.zoom-readout {
  margin-left: auto;
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crop-inline,
.padding-inline,
.resize-inline,
.text-inline,
.watermark-inline {
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(167, 108, 255, 0.24);
  border-radius: 12px;
  padding: 5px;
  background: rgba(167, 108, 255, 0.1);
}

.crop-inline.is-visible,
.padding-inline.is-visible,
.resize-inline.is-visible,
.text-inline.is-visible,
.watermark-inline.is-visible {
  display: flex;
}

.padding-inline,
.resize-inline,
.text-inline,
.watermark-inline {
  flex-wrap: wrap;
}

.toolbar-number,
.toolbar-color,
.toolbar-check,
.toolbar-text {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 0.78rem;
}

.toolbar-number input,
.toolbar-text input,
.toolbar-select {
  width: 76px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 8px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
}

.toolbar-text input {
  width: 150px;
}

.toolbar-number .toolbar-percent-input {
  width: 58px;
  text-align: center;
}

.toolbar-number .toolbar-size-input {
  width: 58px;
  text-align: center;
}

.toolbar-select {
  width: auto;
  min-width: 110px;
}

.toolbar-font-select {
  min-width: 122px;
}

.toolbar-color input {
  width: 38px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 3px;
  background: rgba(0, 0, 0, 0.22);
}

.toolbar-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.file-action-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-action-button {
  position: relative;
  overflow: hidden;
}

.canvas-wrap {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  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%),
    rgba(2, 2, 5, 0.22);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  overflow: hidden;
}

.canvas-wrap.is-dragging {
  border-color: rgba(167, 108, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(167, 108, 255, 0.34);
}

.canvas-wrap.is-cropping {
  cursor: crosshair;
}

canvas {
  display: block;
  max-width: calc(100% - 42px);
  max-height: calc(100% - 42px);
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.48);
}

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.overlay-item {
  position: absolute;
  display: grid;
  place-items: center;
  border: 1px solid rgba(199, 162, 255, 0.68);
  border-radius: 6px;
  color: white;
  cursor: move;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 0 1px rgba(2, 2, 5, 0.36);
}

.overlay-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.overlay-handle {
  position: absolute;
  display: block;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(199, 162, 255, 0.9));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}

.overlay-handle-nw {
  top: -8px;
  left: -8px;
  cursor: nwse-resize;
}

.overlay-handle-n {
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.overlay-handle-ne {
  top: -8px;
  right: -8px;
  cursor: nesw-resize;
}

.overlay-handle-e {
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.overlay-handle-se {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.overlay-handle-s {
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.overlay-handle-sw {
  bottom: -8px;
  left: -8px;
  cursor: nesw-resize;
}

.overlay-handle-w {
  top: 50%;
  left: -8px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  display: none;
  width: 2px;
  background: rgba(245, 242, 255, 0.95);
  box-shadow:
    0 0 0 1px rgba(167, 108, 255, 0.8),
    0 0 26px rgba(167, 108, 255, 0.55);
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: none;
}

.compare-divider.is-visible {
  display: block;
}

.compare-divider::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(245, 242, 255, 0.9);
  border-radius: 999px;
  background: rgba(24, 22, 31, 0.94);
  content: "";
  transform: translate(-50%, -50%);
}

.crop-selection {
  position: absolute;
  display: none;
  border: 1px solid rgba(245, 242, 255, 0.95);
  background:
    linear-gradient(rgba(245, 242, 255, 0.18), rgba(245, 242, 255, 0.18)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(33.333% - 1px),
      rgba(245, 242, 255, 0.55) calc(33.333% - 1px),
      rgba(245, 242, 255, 0.55) 33.333%
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent calc(33.333% - 1px),
      rgba(245, 242, 255, 0.55) calc(33.333% - 1px),
      rgba(245, 242, 255, 0.55) 33.333%
    );
  box-shadow:
    0 0 0 9999px rgba(2, 2, 5, 0.56),
    0 0 0 1px rgba(167, 108, 255, 0.8),
    0 16px 44px rgba(0, 0, 0, 0.38);
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.crop-selection.is-visible {
  display: block;
}

.crop-handle {
  position: absolute;
  display: block;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(199, 162, 255, 0.86));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}

.crop-handle-nw {
  top: -9px;
  left: -9px;
  cursor: nwse-resize;
}

.crop-handle-n {
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.crop-handle-ne {
  top: -9px;
  right: -9px;
  cursor: nesw-resize;
}

.crop-handle-e {
  top: 50%;
  right: -9px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.crop-handle-se {
  right: -9px;
  bottom: -9px;
  cursor: nwse-resize;
}

.crop-handle-s {
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.crop-handle-sw {
  bottom: -9px;
  left: -9px;
  cursor: nesw-resize;
}

.crop-handle-w {
  top: 50%;
  left: -9px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.crop-action {
  color: var(--accent-strong);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.empty-state i {
  color: var(--accent-strong);
  font-size: 2.3rem;
}

.empty-state strong {
  color: var(--text);
  font-size: 1.08rem;
}

.empty-state span {
  max-width: 360px;
  line-height: 1.45;
}

.empty-state.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border-radius: 18px;
  overflow: auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.control,
.select-control,
.color-control,
.check-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: center;
  margin-top: 16px;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.color-control input {
  width: 46px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 3px;
  background: rgba(0, 0, 0, 0.22);
}

.check-control {
  grid-template-columns: auto 1fr;
  justify-content: start;
}

.check-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.dimension-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.number-control {
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.number-control input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
}

.control output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.control input {
  grid-column: 1 / -1;
}

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

select {
  min-width: 116px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
}

.roadmap p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.app-footer {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding: 2px 2px 0;
  color: rgba(170, 164, 184, 0.62);
  font-size: 0.7rem;
  line-height: 1.35;
}

.app-footer a {
  color: rgba(199, 162, 255, 0.72);
  text-decoration: none;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 3, 8, 0.62);
  backdrop-filter: blur(18px);
}

.modal-backdrop.is-visible {
  display: flex;
}

.download-modal {
  width: min(620px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 20px;
  background: rgba(24, 22, 31, 0.96);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
}

.modal-heading,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-heading {
  margin-bottom: 18px;
}

.modal-kicker {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.modal-heading h2 {
  max-width: 470px;
  font-size: clamp(1.45rem, 3.2vw, 2.35rem);
  line-height: 1.04;
}

.file-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.file-summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.file-summary dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.file-summary dd {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.modal-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100svh;
  }

  .app-shell.inspector-collapsed {
    grid-template-columns: 1fr;
  }

  .rail {
    flex-direction: row;
    justify-content: center;
    border-radius: 16px;
  }

  .brand-mark {
    margin: 0 auto 0 0;
  }

  .workspace {
    min-height: 72svh;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .stage-section {
    min-height: 60svh;
  }

  .inspector {
    max-height: none;
  }

  .app-shell.inspector-collapsed .inspector {
    display: none;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .button {
    flex: 1 1 130px;
    padding-inline: 10px;
  }

  .stage-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
    justify-content: space-between;
  }

  .crop-inline,
  .padding-inline,
  .resize-inline,
  .text-inline,
  .watermark-inline {
    width: 100%;
  }

  .toolbar-number,
  .toolbar-color,
  .toolbar-check,
  .toolbar-text {
    flex: 1;
  }

  .toolbar-number input,
  .toolbar-text input,
  .toolbar-select {
    width: 100%;
  }

  .zoom-readout {
    width: 100%;
    margin-left: 0;
  }

  .icon-button {
    flex: 1;
  }

  canvas {
    max-width: calc(100% - 22px);
    max-height: calc(100% - 22px);
  }

  .file-summary {
    grid-template-columns: 1fr;
  }
}
