:root {
  color-scheme: dark;
  --void: #08090D;
  --card: #0F1117;
  --cyan: #06B6D4;
  --emerald: #10B981;
  --violet: #8B5CF6;
  --amber: #F59E0B;
  --text: #e4e4e7;
  --muted: #a1a1aa;
  --faint: #71717a;
  --line: rgba(255, 255, 255, 0.08);
  --glass: rgba(15, 17, 23, 0.78);
}

* { box-sizing: border-box; }
html, body { background: var(--void); min-height: 100%; }
html { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(1000px 540px at 12% -8%, rgba(16, 185, 129, 0.12), transparent 56%),
    radial-gradient(900px 520px at 92% 4%, rgba(6, 182, 212, 0.12), transparent 54%),
    var(--void);
  min-height: 100%;
}
button, select, input, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); text-decoration: none; }
a:hover { color: #67e8f9; }

.grid-veil {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 18%, transparent 74%);
}

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.site-header {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--line);
}
.site-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 600; letter-spacing: -0.02em;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
  color: var(--void); font-weight: 800; font-size: 14px;
}
.nav { display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--muted); }
.nav a { color: inherit; }
.nav a:hover, .nav a[aria-current="page"] { color: #fff; }
.badge {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.1);
  color: #67e8f9;
  border-radius: 999px;
  padding: 4px 10px;
}
.badge.emerald {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
}

.wrap { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; }

/* Empty state */
.empty {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 0 32px;
  text-align: center;
}
.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 16px;
}
.kicker-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }
h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #fff;
  font-weight: 800;
}
.lede { margin: 16px auto 0; max-width: 36rem; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }

.drop {
  margin: 36px auto 0;
  max-width: 560px;
  border-radius: 28px;
  padding: 1px;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(120deg, rgba(16,185,129,.55), rgba(6,182,212,.7), rgba(16,185,129,.35)) border-box;
  border: 1px solid transparent;
  transition: box-shadow .2s ease, transform .2s ease;
}
.drop.hot {
  box-shadow: 0 0 0 1px rgba(6,182,212,.7), 0 0 48px rgba(16,185,129,.22), inset 0 0 48px rgba(6,182,212,.08);
  transform: scale(1.01);
}
.drop-inner {
  border-radius: 26px;
  background: rgba(15, 17, 23, 0.88);
  padding: 48px 28px;
  cursor: pointer;
}
.drop-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 16px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--cyan);
}
.drop-title { color: #fff; font-weight: 600; font-size: 1.1rem; }
.drop-meta { margin-top: 8px; color: var(--faint); font-size: 13px; }
.pills { margin-top: 18px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

.privacy-row {
  margin-top: 28px;
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 0 8px;
}
.privacy-row .badge { max-width: 100%; }
.note {
  max-width: 640px;
  margin: 48px auto 0;
  text-align: left;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.7;
}
.note h2 { color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 8px; }
.note p { margin: 0 0 10px; }

/* Workspace */
.workspace { padding-top: 16px; display: none; }
body.is-workspace .empty { display: none; }
body.is-workspace .workspace { display: block; }
body.is-workspace { background: var(--void); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15,17,23,.72);
}
.file-chip {
  min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 160px;
}
.file-chip strong {
  color: #fff; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-chip span { color: var(--faint); font-size: 11px; }
.ctrl {
  display: flex; flex-direction: column; gap: 2px;
}
.ctrl label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.ctrl select, .ctrl input[type="number"] {
  background: #0b0d12;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.seg button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}
.seg button[aria-pressed="true"] {
  background: rgba(6,182,212,.14);
  color: #fff;
}
.progress-chip {
  flex: 1 1 180px;
  min-width: 160px;
  font-size: 12px;
  color: var(--muted);
}
.progress-chip strong { color: #fff; font-weight: 600; display: block; }
.bar {
  margin-top: 6px; height: 3px; border-radius: 99px;
  background: rgba(255,255,255,.06); overflow: hidden;
}
.bar > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--emerald), var(--cyan));
  transition: width .25s ease;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { background: rgba(255,255,255,.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: #fff; color: var(--void); border-color: #fff;
}
.btn.primary:hover { background: #e4e4e7; }
.btn.danger { border-color: rgba(244, 63, 94, .35); color: #fda4af; }

.banner {
  margin-top: 10px;
  border: 1px solid rgba(16,185,129,.28);
  background: rgba(16,185,129,.08);
  color: #a7f3d0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}
.banner.warn {
  border-color: rgba(245,158,11,.3);
  background: rgba(245,158,11,.08);
  color: #fde68a;
}
.banner.error {
  border-color: rgba(244,63,94,.35);
  background: rgba(244,63,94,.08);
  color: #fecdd3;
}

[hidden] { display: none !important; }

.stage {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 220px);
}
.stage.has-thumbs {
  grid-template-columns: 112px minmax(0, 1fr) minmax(0, 1fr);
}

.thumbs {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15,17,23,.65);
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.thumb {
  border: 1px solid transparent;
  background: #07080c;
  border-radius: 10px;
  padding: 4px;
  color: var(--faint);
  font-size: 10px;
  text-align: center;
}
.thumb img, .thumb canvas {
  width: 100%; height: auto; display: block; border-radius: 6px;
}
.thumb[aria-current="true"] {
  border-color: rgba(6,182,212,.6);
  box-shadow: 0 0 0 1px rgba(6,182,212,.25);
  color: #fff;
}
.thumb-ph {
  aspect-ratio: 3/4;
  background: repeating-linear-gradient(-45deg, #0b0d12, #0b0d12 6px, #10131a 6px, #10131a 12px);
  border-radius: 6px;
}

.preview, .textpane {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15,17,23,.65);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pane-h {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.preview-body {
  flex: 1;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #07080c;
}
.preview-body img, .preview-body canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  border-radius: 4px;
}
.page-nav {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}
.page-nav input {
  width: 64px;
  background: #0b0d12;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

.textpane textarea, .review {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  padding: 16px;
  font-size: 14px;
  line-height: 1.55;
  outline: none;
}
.review { overflow: auto; white-space: pre-wrap; word-break: break-word; }
.low {
  background: rgba(245, 158, 11, 0.22);
  border-radius: 3px;
  padding: 0 1px;
}

.stats {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--faint);
}
.stats b { color: var(--muted); font-weight: 600; }

.dock {
  margin-top: 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.hint { font-size: 12px; color: var(--faint); margin-left: auto; }

.engine-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(6,182,212,.28);
  background: rgba(8,9,13,.92);
  box-shadow: 0 18px 40px rgba(0,0,0,.5);
  display: none;
}
.engine-toast.show { display: block; }
.engine-toast strong { color: #fff; font-size: 13px; display: block; }
.engine-toast span { color: var(--muted); font-size: 12px; }

.advanced {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
}
.advanced summary { cursor: pointer; color: var(--muted); }
.advanced .row { margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.advanced label { display: flex; gap: 8px; align-items: center; color: var(--muted); }

footer.site {
  position: relative; z-index: 1;
  border-top: 1px solid var(--line);
  padding: 20px 16px;
  color: var(--faint);
  font-size: 12px;
}
footer.site .inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

@media (max-width: 960px) {
  .stage {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .thumbs {
    flex-direction: row;
    overflow-x: auto;
    max-height: 128px;
  }
  .thumb { min-width: 72px; max-width: 88px; }
  .preview { min-height: 280px; }
  .textpane { min-height: 280px; }
  .nav { display: none; }
  .actions { margin-left: 0; }
}

@media (max-width: 640px) {
  .empty { padding-top: 36px; }
  .drop-inner { padding: 32px 16px; }
  .toolbar { padding: 10px; }
}
