:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-elev: #1f242e;
  --border: #2a303d;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #7dd3fc;
  --accent-strong: #38bdf8;
  --warm: #f59e0b;
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top left, #19202d 0%, var(--bg) 52%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  color: #0b0e14;
  font-size: 20px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

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

.pill-badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-elev);
  border: 1px solid var(--border);
  color: var(--muted);
}

.pill-badge.pro {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 500px) minmax(360px, 1fr);
  gap: 22px;
  max-width: 1320px;
  margin: 22px auto;
  padding: 0 24px 40px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.section-block + .section-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

h2 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.upload-dropzone {
  border: 1.5px dashed #3d475c;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(125, 211, 252, 0.06);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.drop-icon {
  font-size: 20px;
  color: var(--accent);
}

.dropzone-inner small {
  color: var(--muted);
  font-size: 12px;
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.starter-card {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  background: var(--panel-elev);
  cursor: pointer;
  aspect-ratio: 3 / 4;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.starter-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.starter-card.active {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.starter-card img,
.starter-card canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.starter-label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 5px 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  text-align: center;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

input[type="text"],
select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-elev);
  color: var(--text);
  font-size: 13px;
}

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

.hidden {
  display: none !important;
}

.export-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.14s ease, transform 0.1s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn small {
  font-weight: 400;
  font-size: 11px;
  opacity: 0.85;
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #090d14;
}

.btn-secondary {
  background: var(--panel-elev);
  border-color: var(--border);
  color: var(--text);
}

.btn-accent {
  flex-direction: row;
  padding: 9px 14px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #120d05;
}

.btn-bundle {
  width: 100%;
  flex-direction: row;
  gap: 10px;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fde68a;
  font-size: 12.5px;
}

.pro-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--warm);
  color: #160e03;
}

.status-line {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* PREVIEW PANEL */
.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.preview-header h2 {
  margin-bottom: 2px;
}

.dims-badge {
  font-size: 12px;
  color: var(--muted);
}

.bezel-toggle {
  display: flex;
  gap: 6px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-elev);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.chip.active {
  border-color: var(--accent);
  color: var(--text);
}

.device-stage {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 12px 0 18px;
}

.ereader-bezel {
  width: min(100%, 400px);
  padding: 20px 20px 34px;
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease;
}

.bezel-dark {
  background: linear-gradient(160deg, #272b34 0%, #14171d 100%);
  border: 1px solid #383e4d;
}

.bezel-sage {
  background: linear-gradient(160deg, #98a991 0%, #6f8069 100%);
  border: 1px solid #afc0a8;
}

.ereader-screen {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #e9e6dc;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  aspect-ratio: 3 / 4;
}

#previewCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.eink-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: radial-gradient(rgba(0, 0, 0, 0.25) 0.5px, transparent 0.5px);
  background-size: 3px 3px;
}

.bezel-chin {
  text-align: center;
  margin-top: 12px;
}

.chin-mark {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.45;
  color: #fff;
}

.howto-box {
  width: 100%;
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel-elev);
  font-size: 13px;
}

.howto-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.howto-box ol {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.howto-box a {
  color: var(--accent);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px 36px;
  color: var(--muted);
  font-size: 12.5px;
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-about {
  max-width: 780px;
  line-height: 1.5;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
}

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

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.78);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  position: relative;
  width: min(100%, 480px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-card h2 {
  margin: 10px 0 6px;
  font-size: 20px;
  text-transform: none;
  letter-spacing: -0.02em;
  color: var(--text);
}

.modal-lead {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13.5px;
}

.perk-list {
  margin: 0 0 18px;
  padding-left: 18px;
  color: #d6dce8;
  font-size: 13.5px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.license-entry {
  display: flex;
  gap: 8px;
}

.modal-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
