:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text: #0f172a;
  --muted: #52607a;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --danger: #be123c;
  --success: #0f9d58;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.22), transparent 30%),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.20), transparent 28%),
    linear-gradient(160deg, #0b1020 0%, #111827 100%);
  color: white;
  min-height: 100vh;
}

.app-shell {
  max-width: 1700px;
  margin: 0 auto;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.68);
  font-size: 12px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); }
.topbar-note {
  color: rgba(255,255,255,0.75);
  max-width: 420px;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: 520px minmax(700px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.controls-panel {
  min-height: 78vh;
  padding: 22px;
}

.viewer-panel {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 20px 22px 12px;
}

.panel-header p {
  color: var(--muted);
  margin-top: 4px;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.viewer-switch {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: rgba(37,99,235,0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-color: transparent;
}

.dropzone {
  border: 1.5px dashed rgba(37, 99, 235, 0.45);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(124, 58, 237, 0.06));
  border-radius: 18px;
  padding: 18px;
  cursor: pointer;
  transition: 0.2s ease;
}

.dropzone.dragover {
  transform: translateY(-1px);
  border-color: var(--accent-2);
  background: rgba(124, 58, 237, 0.08);
}

.dropzone-inner {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.drop-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: white;
  box-shadow: 0 10px 20px rgba(37,99,235,0.12);
  font-size: 20px;
}

.file-meta {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.control-grid {
  display: grid;
  gap: 12px;
}

.control-grid label,
.export-box label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.control-grid small,
.dropzone small {
  color: var(--muted);
}

input[type="number"],
input[type="password"],
select {
  width: 100%;
  border: 1px solid rgba(15,23,42,0.12);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  background: white;
}

button {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.secondary-btn {
  background: rgba(37,99,235,0.1);
  color: var(--accent);
}

.ghost-btn {
  background: rgba(15,23,42,0.06);
  color: var(--text);
}

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

.full-width { width: 100%; }

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.export-box,
.stats-card {
  margin-top: 20px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(15,23,42,0.04);
  border: 1px solid rgba(15,23,42,0.06);
}

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

.export-header-simple {
  justify-content: flex-start;
}

.export-unlocked-note {
  display: flex;
  justify-content: flex-end;
  margin: 14px 0 10px;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.locked {
  background: rgba(190,18,60,0.1);
  color: var(--danger);
}

.status-pill.unlocked {
  background: rgba(15,157,88,0.12);
  color: var(--success);
}

.export-options {
  display: grid;
  gap: 12px;
  margin: 12px 0 14px;
}

.checkbox-wrap {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.checkbox-wrap input {
  width: 18px;
  height: 18px;
}

.hidden {
  display: none !important;
}

.stats-list {
  display: grid;
  gap: 10px;
}

.stats-list > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: white;
}

.stats-list span {
  color: var(--muted);
}

.image-stage {
  position: relative;
  flex: 1;
  margin: 0 22px 22px;
  border-radius: 18px;
  background:
    linear-gradient(45deg, #edf2f7 25%, transparent 25%),
    linear-gradient(-45deg, #edf2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf2f7 75%),
    linear-gradient(-45deg, transparent 75%, #edf2f7 75%);
  background-size: 26px 26px;
  background-position: 0 0, 0 13px, 13px -13px, -13px 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.large-stage {
  min-height: 760px;
}

.image-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.placeholder {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.76);
  backdrop-filter: blur(4px);
  font-size: 22px;
  font-weight: 800;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 360px;
  background: #111827;
  color: white;
  padding: 14px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .controls-panel,
  .viewer-panel {
    min-height: auto;
  }

  .large-stage {
    min-height: 420px;
  }

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

  .topbar-note {
    text-align: left;
  }

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