:root {
  color-scheme: dark;
  --bg: #161616;
  --panel: #202020;
  --panel-strong: #252525;
  --surface: #101116;
  --surface-soft: #18191d;
  --ink: #f2f3f5;
  --muted: #8b8d93;
  --muted-strong: #b8bac0;
  --line: #303033;
  --line-soft: #26272b;
  --accent: #2f7dff;
  --accent-strong: #5f87ff;
  --accent-dark: #165fe6;
  --teal: #77d7c8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #2a2a2d;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.controls {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border: 1px solid #3a3c42;
  background:
    radial-gradient(circle at 32% 32%, #90b2ff 0 14%, transparent 15%),
    radial-gradient(circle at 68% 32%, #77d7c8 0 14%, transparent 15%),
    radial-gradient(circle at 32% 68%, #6f78ff 0 14%, transparent 15%),
    radial-gradient(circle at 68% 68%, #d8e2ff 0 14%, transparent 15%),
    #15161a;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.25;
}

.brand p,
.toolbar p,
.empty-state p,
.drop-zone small {
  color: var(--muted);
  line-height: 1.5;
}

.brand p {
  margin-top: 4px;
  font-size: 13px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 168px;
  border: 1px dashed #4a4b50;
  background: #191a1d;
  border-radius: 8px;
  text-align: center;
  padding: 20px;
  cursor: pointer;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #172133;
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: #25262a;
  border-radius: 50%;
  color: var(--accent-strong);
  font-size: 28px;
  line-height: 1;
}

.control-group {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.control-group h2 {
  margin-bottom: 14px;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #73757d;
}

.control-group label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted-strong);
}

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

.preset-button {
  min-height: 42px;
  border-color: var(--line);
  background: #2a2a2d;
  color: var(--muted-strong);
}

.preset-button.is-active {
  border-color: var(--accent);
  background: #243766;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(47, 125, 255, 0.22);
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18191d;
  color: var(--ink);
  padding: 0 10px;
}

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

.switch {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch input {
  width: 42px;
  height: 22px;
  accent-color: var(--accent);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.swatches label {
  margin: 0;
  gap: 6px;
  font-size: 12px;
}

input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18191d;
  padding: 4px;
}

.primary-action {
  width: 100%;
  margin-top: 16px;
  border-color: var(--accent-dark);
  background: var(--accent);
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 28px;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #17181b;
  background-size:
    24px 24px,
    160px 160px,
    160px 160px,
    auto;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.batch-action {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: #ffffff;
}

.toolbar h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: calc(100vh - 120px);
  text-align: center;
  color: var(--ink);
}

.empty-state.is-hidden {
  display: none;
}

.sample-stage {
  width: min(760px, 100%);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.sample-stage canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sample-copy {
  display: grid;
  gap: 6px;
  max-width: 560px;
}

.sample-copy h2 {
  font-size: 24px;
}

.sample-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 10px;
  justify-content: center;
  width: min(760px, 100%);
}

.sample-button {
  display: grid;
  gap: 6px;
  min-height: auto;
  padding: 8px;
  border-color: var(--line);
  background: #202124;
}

.sample-button.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(47, 125, 255, 0.28);
}

.sample-thumb {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background-position: center;
  background-size: cover;
}

.sample-button span {
  overflow: hidden;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  background: #202124;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  background:
    linear-gradient(45deg, #202126 25%, transparent 25%),
    linear-gradient(-45deg, #202126 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #202126 75%),
    linear-gradient(-45deg, transparent 75%, #202126 75%),
    #141519;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
  cursor: zoom-in;
}

.canvas-wrap:focus-visible,
.sample-stage:focus-visible {
  outline: 3px solid rgba(47, 125, 255, 0.48);
  outline-offset: 3px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
}

.card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.file-meta {
  min-width: 0;
}

.file-meta strong,
.file-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta strong {
  font-size: 14px;
}

.file-meta span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
}

.lightbox.is-open {
  display: grid;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: rgba(18, 22, 27, 0.78);
  cursor: zoom-out;
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, calc(100vw - 48px));
  height: min(840px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #111820;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.lightbox-header h2 {
  overflow: hidden;
  max-width: min(720px, 60vw);
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-header p {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.lightbox-header button {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

#lightboxImage {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    #0b1117;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

body.modal-open {
  overflow: hidden;
}

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

  .controls {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 20px;
  }

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

  .toolbar-actions {
    justify-content: flex-start;
  }

  .lightbox {
    padding: 12px;
  }

  .lightbox-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
  }

  .lightbox-header h2 {
    max-width: 54vw;
  }
}
