@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/assets/fonts/PlusJakartaSans-Regular.ttf') format('truetype');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/JetBrainsMono-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/JetBrainsMono-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0e17;
  --bg-elev: #121726;
  --card: #161c2e;
  --card-hover: #1d253b;
  --border: #252f4a;
  --border-strong: #374569;
  --text: #eef2ff;
  --muted: #94a3c4;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --danger: #f43f5e;
  --success: #10b981;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at 12% 0%, rgba(99, 102, 241, 0.14), transparent 36%),
              radial-gradient(circle at 88% 8%, rgba(168, 85, 247, 0.12), transparent 34%),
              var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  background: rgba(99, 102, 241, 0.14);
  color: #c7d2fe;
  padding: 1px 6px;
  border-radius: 5px;
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: rgba(11, 14, 23, 0.84);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.brand-name {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-domain {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: #a5b4fc;
}

.topbar-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lang-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.chip-ml { color: #fb923c; border-color: rgba(251, 146, 60, 0.35); background: rgba(251, 146, 60, 0.09); }
.chip-c { color: #60a5fa; border-color: rgba(96, 165, 250, 0.35); background: rgba(96, 165, 250, 0.09); }
.chip-py { color: #facc15; border-color: rgba(250, 204, 21, 0.35); background: rgba(250, 204, 21, 0.09); }
.chip-more { color: var(--muted); }

/* ===== WORKSPACE ===== */
.workspace {
  max-width: 1520px;
  margin: 0 auto;
  padding: 20px 22px 36px;
  display: grid;
  grid-template-columns: minmax(380px, 490px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.section-title {
  margin: 0 0 12px 0;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #c7d2fe;
}

/* ===== TABS & SAMPLES ===== */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tabs {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: #ffffff;
}

.sample-bar {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sample-label {
  font-size: 0.74rem;
  color: var(--muted);
}

.mini-btn {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-btn:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.2);
}

.mode-pane {
  display: none;
}

.mode-pane.active {
  display: block;
}

/* ===== DROPZONE ===== */
.dropzone {
  border: 1.8px dashed var(--border-strong);
  border-radius: 12px;
  padding: 26px 18px;
  text-align: center;
  background: rgba(11, 14, 23, 0.48);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
}

.dropzone-icon {
  color: #818cf8;
  margin-bottom: 8px;
}

.dropzone-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.dropzone-sub {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.link-accent {
  color: #a5b4fc;
  font-weight: 600;
  text-decoration: underline;
}

/* ===== FILE LIST ===== */
.file-list-wrap {
  margin-top: 12px;
}

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.text-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
}

.text-btn.danger {
  color: #fda4af;
}

.text-btn.danger:hover {
  background: rgba(244, 63, 94, 0.14);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.file-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.file-ext-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
  white-space: nowrap;
}

.file-item-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.file-item-size {
  font-size: 0.73rem;
  color: var(--muted);
}

.icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.icon-btn.remove:hover {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
}

/* ===== PASTE TEXTAREA ===== */
.paste-meta-row {
  margin-bottom: 10px;
}

.code-textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  outline: none;
}

.code-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== FORM FIELDS ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mt-12 {
  margin-top: 12px;
}

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

.field > span {
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--muted);
}

.field input[type="text"],
.field select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input[type="text"]:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== HEADER STYLE SELECTOR ===== */
.segmented-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.style-option {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.style-option:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
}

.style-option.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.16);
  box-shadow: 0 0 0 1px var(--accent);
}

.style-option-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.style-option-desc {
  display: block;
  font-size: 0.69rem;
  color: var(--muted);
  line-height: 1.3;
}

/* ===== THEME GRID ===== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 11px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s ease;
}

.theme-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.theme-card.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.14);
  box-shadow: 0 0 0 1px var(--accent);
}

.theme-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.theme-name {
  font-size: 0.82rem;
  font-weight: 700;
}

.theme-swatches {
  display: flex;
  gap: 4px;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.theme-desc {
  font-size: 0.71rem;
  color: var(--muted);
  line-height: 1.3;
}

/* ===== TOGGLES ===== */
.toggles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.81rem;
  color: #dbe4ff;
  cursor: pointer;
  user-select: none;
}

.toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== RIGHT PREVIEW PANEL ===== */
.preview-panel {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - 98px);
}

.preview-toolbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  min-width: 0;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.status-dot.ready {
  background: var(--success);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.65);
}

.status-dot.loading {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 10px;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--card-hover);
  border-color: var(--accent);
}

.preview-stage {
  flex: 1;
  min-height: 460px;
  background: #0e1320;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.empty-state {
  margin: auto;
  max-width: 480px;
  text-align: center;
  padding: 30px 20px;
}

.empty-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.empty-state h3 {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.empty-state p {
  margin: 0 0 18px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.paper-frame {
  width: 100%;
  max-width: 820px;
  height: 100%;
  min-height: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #ffffff;
}

.paper-frame.landscape {
  max-width: 1060px;
}

#preview-iframe {
  width: 100%;
  height: 100%;
  min-height: 620px;
  border: none;
  display: block;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 60;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.toast.error {
  border-color: rgba(244, 63, 94, 0.6);
  background: #331320;
  color: #fecdd3;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.55);
  background: #0d2b24;
  color: #a7f3d0;
}

.hidden {
  display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1060px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .preview-panel {
    position: static;
    height: auto;
  }
  .preview-stage {
    min-height: 540px;
  }
  #preview-iframe {
    min-height: 540px;
  }
}

@media (max-width: 560px) {
  .grid-2,
  .theme-grid,
  .segmented-grid,
  .toggles-grid {
    grid-template-columns: 1fr;
  }
}
