/* ───────── Resets & Variables ───────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Shadcn UI Dark Zinc/Slate Palette */
  --background: #09090b; /* Zinc 950 */
  --foreground: #f4f4f5; /* Zinc 100 */
  --card: #09090b; /* Zinc 950 */
  --card-foreground: #f4f4f5;
  --popover: #09090b;
  --popover-foreground: #f4f4f5;
  --primary: #fafafa; /* Zinc 50 (white/silver button style) */
  --primary-foreground: #18181b; /* Zinc 900 */
  --secondary: #27272a; /* Zinc 800 */
  --secondary-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa; /* Zinc 400 */
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #7f1d1d; /* Red 900 */
  --destructive-foreground: #fef2f2;
  --border: #27272a; /* Zinc 800 */
  --input: #27272a;
  --ring: #d4d4d8; /* Zinc 300 */
  --radius: 8px;
  --radius-sm: 6px;

  /* Legacy variables bridged for compatibility */
  --bg: var(--background);
  --surface: #09090b;
  --surface-hover: #18181b; /* Zinc 900 */
  --text: var(--foreground);
  --text-secondary: var(--muted-foreground);
  --primary-hover: #e4e4e7;
  --primary-light: rgba(255, 255, 255, 0.08);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --border-focus: var(--ring);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* ───────── Navigation ───────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav__inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav__logo-svg {
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--primary);
}

.nav__logo:hover .nav__logo-svg {
  transform: scale(1.1) rotate(-6deg);
  color: var(--primary-hover);
}

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

.nav__badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--secondary);
  color: var(--foreground);
  border: 1px solid var(--border);
}

.nav__github-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: all 140ms ease;
}

.nav__github-btn:hover {
  border-color: var(--border-focus);
  background: var(--surface-hover);
  color: #fff;
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.25);
}

.nav__github-btn svg {
  color: var(--text-secondary);
  transition: color 140ms ease;
}

.nav__github-btn:hover svg {
  color: var(--border-focus);
}

/* ───────── Hero ───────── */
.hero {
  position: relative;
  text-align: center;
  padding: 64px 24px 48px;
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--primary-light) 0%, transparent 100%);
  opacity: 0.5;
  z-index: 0;
}

.hero__content {
  position: relative;
  z-index: 1;
}

.hero__chip {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 99px;
  background: var(--primary-light);
  color: var(--border-focus);
  border: 1px solid rgba(129, 140, 248, 0.2);
  margin-bottom: 20px;
  letter-spacing: 0.01em;
}

.hero__title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.hero__sub {
  margin-top: 16px;
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* ───────── Demo Video ───────── */
.video {
  text-align: center;
  padding: 8px 24px 40px;
}

.video__inner {
  max-width: 720px;
  margin: 0 auto;
}

.video__frame {
  margin-top: 20px;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: #000;
}

.video__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ───────── App Container ───────── */
.app {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 64px;
  transition: max-width 0.3s ease;
}

/* Expand to full width on big screens when editor is active */
.app--wide {
  max-width: 1400px;
}

/* ───────── Steps (Timeline style) ───────── */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 16px 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.4;
  transition: var(--transition);
}

.step--active {
  opacity: 1;
}

.step--done {
  opacity: 0.8;
}

.step--done .step__num {
  background: var(--foreground);
  color: var(--background);
}

.step__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--secondary);
  color: var(--muted-foreground);
  transition: var(--transition);
}

.step--active .step__num {
  background: var(--primary);
  color: var(--primary-foreground);
}

.step__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

.step__line {
  flex: 1;
  max-width: 48px;
  height: 1px;
  background: var(--border);
}

/* ───────── Card ───────── */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  animation: fadeUp 0.3s ease;
}

.card__title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.card__desc {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 24px;
  line-height: 1.5;
}

.card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ───────── Upload Grid ───────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

/* ───────── Dropzone ───────── */
.dropzone {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
}

.dropzone:hover {
  border-color: var(--ring);
  background: var(--secondary);
}

.dropzone--dragover {
  border-color: var(--ring);
  background: var(--secondary);
  transform: scale(1.01);
}

.dropzone--has-file {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-light);
}

.dropzone__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.dropzone__icon {
  color: var(--muted-foreground);
  opacity: 0.7;
  transition: var(--transition);
}

.dropzone:hover .dropzone__icon {
  color: var(--foreground);
  opacity: 1;
}

.dropzone__text {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.dropzone__text small {
  font-size: 0.75rem;
  opacity: 0.7;
}

.dropzone__preview {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
}

.dropzone__preview img {
  max-height: 100px;
  max-width: 100%;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.dropzone__csv-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-weight: 500;
  font-size: 0.875rem;
}

.dropzone__csv-name {
  font-weight: 500;
}

.dropzone__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--muted-foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 2;
}

.dropzone__remove:hover {
  background: var(--secondary);
  color: var(--foreground);
}

/* ───────── CSV Preview (Shadcn Data Table) ───────── */
.csv-preview {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--background);
  animation: fadeUp 0.3s ease;
}

.csv-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.csv-preview__header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--foreground);
}

.csv-preview__count {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-weight: 400;
}

.csv-preview__table-wrap {
  overflow-x: auto;
}

.csv-preview__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.csv-preview__table th {
  padding: 12px 16px;
  font-weight: 500;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.csv-preview__table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--foreground);
}

.csv-preview__table tr {
  transition: var(--transition);
}

.csv-preview__table tr:hover {
  background: var(--secondary);
}

.csv-preview__table tr:last-child td {
  border-bottom: none;
}

.csv-preview__footer {
  padding: 12px 16px;
  background: var(--secondary);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--foreground);
  border-top: 1px solid var(--border);
}

/* ───────── Form ───────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group--wide {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group--wide {
    grid-column: span 1;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

.form-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--foreground);
  background: var(--background);
  transition: var(--transition);
  outline: none;
}

.form-input::placeholder {
  color: var(--muted-foreground);
}

.form-input:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

/* ───────── Buttons (Shadcn Style) ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.25;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--secondary);
}

.btn--secondary:hover:not(:disabled) {
  background: #3f3f46; /* Zinc 700 */
}

.btn--secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--foreground);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn--ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

/* ───────── Progress ───────── */
.progress {
  margin: 32px 0;
  animation: fadeUp 0.3s ease;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.progress__bar-wrap {
  height: 10px;
  background: #111a2e;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--border-focus));
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.5);
}

.progress__text {
  margin-top: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress__log {
  margin-top: 14px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: #090d16;
  padding: 12px;
  border-radius: var(--radius-sm);
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

/* ───────── Results ───────── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 24px;
}

.results-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.gallery__card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface);
  position: relative;
  cursor: pointer;
}

.gallery__card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-focus);
  transform: translateY(-4px);
}

.gallery__card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: #0d1222;
  transition: transform 0.3s ease;
}

.gallery__card:hover img {
  transform: scale(1.05);
}

.gallery__card-body {
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.gallery__card-name {
  font-size: 0.85rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  margin-bottom: 8px;
}

.gallery__card-actions {
  display: flex;
  gap: 8px;
}

.gallery__card-actions .btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.75rem;
  justify-content: center;
  border-radius: 6px;
}

/* Lightbox Modal upgrades */
.lightbox-meta {
  background: rgba(11, 15, 25, 0.9);
  color: #fff;
  padding: 12px 20px;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lightbox-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.lightbox-btn {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.lightbox-btn:hover {
  background: var(--primary-hover);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 10;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-nav--prev {
  left: 16px;
}

.lightbox-nav--next {
  right: 16px;
}

.results-summary {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--success-light);
  font-size: 0.9rem;
  font-weight: 500;
  color: #065f46;
  text-align: center;
}

/* ───────── Toast ───────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.15s ease;
  max-width: 360px;
  color: var(--foreground);
}

.toast--error {
  border-left: 2px solid var(--danger);
}

.toast--success {
  border-left: 2px solid var(--success);
}

.toast--info {
  border-left: 2px solid var(--primary);
}

/* ───────── Animations ───────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ───────── Loading Spinner ───────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ───────── Scrollbar ───────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

/* ───────── Modal / Lightbox ───────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  animation: fadeUp 0.15s ease;
}

.modal__content {
  max-width: 90vw;
  max-height: 90vh;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal__content img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  display: block;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal__close:hover {
  background: var(--secondary);
  color: var(--foreground);
}

/* ───────── Editor Layout ───────── */
/* ═══════════════════════════════════════════════════════════
   CertX — Rich Design Editor (v2)
   Excalidraw/Canva-style editor: toolbar, zoomable canvas,
   transformable elements, properties panel, layers.
   ═══════════════════════════════════════════════════════════ */

.card--editor {
  padding: 20px;
}

/* ───────── Editor shell ───────── */
.editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ───────── Toolbar ───────── */
.editor__toolbar {
  position: sticky;
  top: 62px;
  z-index: 60;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted-foreground);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: var(--transition);
}

.toolbar-btn:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.toolbar-btn.is-active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.toolbar-btn.is-on {
  background: var(--secondary);
  color: var(--foreground);
}

/* ───────── Workspace ───────── */
.editor__workspace {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  align-items: start;
}

@media (min-width: 1600px) {
  .editor__workspace {
    grid-template-columns: 1fr 360px;
  }
}

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

/* ───────── Canvas ───────── */
.editor__canvas {
  position: relative;
  width: 100%;
  height: auto;
  /* Sized exactly to the certificate via JS aspect-ratio — the image
     itself is the editing ground, no stage around it. */
  aspect-ratio: 3 / 2;
  min-height: 260px;
  max-height: calc(100vh - 320px);
  /* Checkerboard transparency grid */
  background-color: #1e1e2f;
  background-image:
    linear-gradient(45deg, #12121e 25%, transparent 25%),
    linear-gradient(-45deg, #12121e 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #12121e 75%),
    linear-gradient(-45deg, transparent 75%, #12121e 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  overflow: hidden;
  touch-action: none;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.editor__stage {
  position: absolute;
  inset: 0;
}

.editor__inner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.editor__inner img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.editor__inner .grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ───────── Elements ───────── */
.el {
  position: absolute;
  box-sizing: border-box;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
}

.el--rect,
.el--ellipse {
  pointer-events: auto;
}

.el--line {
  transform-origin: 0 50%;
  pointer-events: auto;
}

.el__content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  pointer-events: none;
}

.el__text {
  width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  line-height: inherit;
}

.el--selected {
  outline: calc(2.5px / var(--zoom, 1)) solid var(--ring);
  outline-offset: 1px;
}

.el--hovered {
  outline: calc(1.5px / var(--zoom, 1)) dashed var(--ring);
}

.el__badge {
  position: absolute;
  bottom: -20px;
  left: 0;
  z-index: 30;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  display: none;
  transform: scale(calc(1 / var(--zoom, 1)));
  transform-origin: left bottom;
}

.el--selected .el__badge,
.el--csv .el__badge {
  display: inline-block;
}

/* ───────── Selection handles ───────── */
.el__handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--foreground);
  border: 1px solid var(--background);
  border-radius: var(--radius-sm);
  z-index: 25;
  pointer-events: auto;
  display: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transform: scale(calc(1 / var(--zoom, 1)));
  transition: transform 100ms ease;
}

.el__handle:hover {
  transform: scale(calc(1.3 / var(--zoom, 1)));
}

.el--selected .el__handle {
  display: block;
}

.el__handle--nw { top: -5px; left: -5px; cursor: nwse-resize; }
.el__handle--n  { top: -5px; left: 50%; transform: translateX(-50%) scale(calc(1 / var(--zoom, 1))); cursor: ns-resize; }
.el__handle--ne { top: -5px; right: -5px; cursor: nesw-resize; }
.el__handle--e  { top: 50%; right: -5px; transform: translateY(-50%) scale(calc(1 / var(--zoom, 1))); cursor: ew-resize; }
.el__handle--se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.el__handle--s  { bottom: -5px; left: 50%; transform: translateX(-50%) scale(calc(1 / var(--zoom, 1))); cursor: ns-resize; }
.el__handle--sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.el__handle--w  { top: 50%; left: -5px; transform: translateY(-50%) scale(calc(1 / var(--zoom, 1))); cursor: ew-resize; }

.el__rotate {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%) scale(calc(1 / var(--zoom, 1)));
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: 50%;
  cursor: grab;
  z-index: 26;
  display: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.el--selected .el__rotate {
  display: block;
}

.el__rotate::after {
  content: '';
  position: absolute;
  top: 13px;
  left: 50%;
  width: 1px;
  height: 14px;
  background: var(--ring);
  transform: translateX(-50%);
}

.el__rotate:hover {
  background: var(--primary-light);
}

/* ───────── Marquee selection ───────── */
.editor__marquee {
  position: absolute;
  z-index: 45;
  border: 1.5px dashed var(--primary);
  background: rgba(99, 102, 241, 0.08);
  border-radius: 2px;
  pointer-events: none;
}

/* ───────── Multi-selection bounds ───────── */
.editor__selbox {
  position: absolute;
  z-index: 44;
  border: 1.5px solid var(--primary);
  pointer-events: none;
  display: none;
}

/* ───────── Inline text editor ───────── */
.el-editor {
  position: absolute;
  z-index: 50;
  border: 2px solid var(--primary);
  border-radius: 4px;
  outline: none;
  resize: none;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 2px 4px;
  font-family: inherit;
  line-height: inherit;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* ───────── Properties panel ───────── */
.editor__panel {
  position: sticky;
  top: 118px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  scrollbar-width: thin;
}

@media (max-width: 980px) {
  .editor__panel {
    position: static;
    max-height: 60vh;
  }
}

.panel__section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel__section:last-child {
  border-bottom: none;
}

.panel__label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.panel__name-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.panel__name-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
}

.panel__name-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.panel__row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.panel__row:last-child {
  margin-bottom: 0;
}

/* Segmented controls */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: #eef1f7;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg__btn {
  border: none;
  background: transparent;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 130ms ease;
}

.seg__btn:hover {
  color: var(--primary);
}

.seg__btn.is-active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
  font-weight: 700;
}

/* Inputs */
.prop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.prop-grid--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

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

.prop-field > label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.num-input,
.text-input,
.select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 140ms ease;
}

.num-input:focus,
.text-input:focus,
.select:focus {
  border-color: var(--primary);
}

.text-input--area {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

/* Range slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: #dfe4ee;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  cursor: pointer;
}

/* Color controls */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.swatch:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--primary);
}

.swatch.is-active {
  box-shadow: 0 0 0 2px var(--primary);
  transform: scale(1.08);
}

.color-input {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  padding: 0;
  background: none;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--border);
}

/* Icon toggles (B I U) */
.icon-btn {
  width: 34px;
  height: 32px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 130ms ease;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Toggle switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
}

.switch-row > span {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 99px;
  background: #dfe4ee;
  border: none;
  cursor: pointer;
  transition: background 140ms ease;
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
  transition: transform 140ms ease;
}

.switch.is-on {
  background: var(--primary);
}

.switch.is-on::after {
  transform: translateX(16px);
}

/* Panel action buttons */
.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel-btn {
  padding: 9px 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 130ms ease;
}

.panel-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.panel-btn--danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Layers */
.layers {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 120ms ease;
  font-size: 0.8rem;
}

.layer-row:hover {
  background: var(--surface-hover);
}

.layer-row.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.layer-row__dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.layer-row__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.layer-row.is-hidden .layer-row__name {
  opacity: 0.45;
  text-decoration: line-through;
}

.layer-row__btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.layer-row__btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

/* Empty state */
.panel-empty {
  padding: 26px 20px;
  text-align: center;
}

.panel-empty__icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.panel-empty__title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.panel-empty__sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.panel-empty__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel-empty__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 140ms ease;
}

.panel-empty__btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ───────── Footer ───────── */
.editor__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.editor__footer-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  flex: 1;
}

/* ───────── Element hover cursor per tool ───────── */
.editor__canvas[data-tool='text'] .el,
.editor__canvas[data-tool='csv'] .el,
.editor__canvas[data-tool='rect'] .el,
.editor__canvas[data-tool='ellipse'] .el,
.editor__canvas[data-tool='line'] .el {
  cursor: crosshair;
}

.editor__canvas.is-panning {
  cursor: grabbing !important;
}

.editor__zoom {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(15, 17, 27, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 4px;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.editor__zoom-btn {
  min-width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
}

.editor__zoom-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.editor__zoom-val {
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
}

.editor__zoom-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* Hidden (removed-from-certificate) elements */
.el--hidden {
  opacity: 0.25 !important;
  filter: saturate(0.35);
}

.el--hidden .el__text {
  text-decoration: line-through;
  text-decoration-style: dashed;
}

/* Shortcuts Modal Custom styles */
.shortcuts-modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 90%;
  padding: 28px;
  color: var(--text);
}

.modal__title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 8px;
}

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

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.shortcut-item kbd {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--foreground);
  box-shadow: 0 2px 0 var(--border);
  min-width: 32px;
  text-align: center;
}

.shortcut-item span {
  color: var(--text-secondary);
}

/* Accordion sections for Properties Panel */
.prop-accordion {
  border-bottom: 1px solid var(--border);
}

.prop-accordion:last-child {
  border-bottom: none;
}

.prop-accordion__header {
  padding: 14px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.prop-accordion__header:hover {
  background: var(--secondary);
}

.prop-accordion__icon {
  transition: transform 0.2s ease;
  color: var(--muted-foreground);
}

.prop-accordion.is-open .prop-accordion__icon {
  transform: rotate(90deg);
}

.prop-accordion__content {
  padding: 0 16px 14px;
  display: none;
}

.prop-accordion.is-open .prop-accordion__content {
  display: block;
}

/* ───────── Site Footer ───────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--background);
  padding: 20px 24px 28px;
}

.site-footer__inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.site-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 140ms ease;
}

.site-footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.site-footer__github {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.site-footer__github .github-icon {
  flex-shrink: 0;
  transition: transform 140ms ease;
}

.site-footer__github:hover .github-icon {
  transform: rotate(12deg) scale(1.1);
}

