/* ========== RESET & BASE ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #060d1a;
  --bg-2: #0b1526;
  --bg-3: #111e33;
  --bg-4: #172844;
  --border: #1c3354;
  --border-light: #274066;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --text: #f1f5f9;
  --text-muted: #8ba3c1;
  --text-dim: #5c7594;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  align-items: center;
  padding: 22px 36px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 13, 26, 0.85);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand i {
  color: var(--accent);
  font-size: 1.25rem;
}

.brand.small {
  font-size: 1.05rem;
}

/* ========== LANDING ========== */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #fff 30%, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.15rem;
  max-width: 520px;
  line-height: 1.55;
  margin-bottom: 40px;
}

.subtitle strong {
  color: var(--accent);
  font-weight: 600;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 14px 32px;
  font-size: 1.05rem;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 18px;
  font-size: 0.9rem;
}

.btn-ghost:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

/* ========== SETUP ========== */
.setup-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.85rem;
}

.form-group {
  margin: 28px 0 22px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.input-with-prefix {
  display: flex;
  align-items: stretch;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
}

.input-with-prefix:focus-within {
  border-color: var(--accent);
}

.prefix {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--bg-4);
  color: var(--text-dim);
  font-size: 0.9rem;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.input-with-prefix input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 13px 14px;
  font-family: inherit;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Source selector */
.source-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.source-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 10px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}

.source-btn i {
  font-size: 1.25rem;
}

.source-btn:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.source-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-3);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone i {
  font-size: 2.2rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.dropzone p {
  margin-bottom: 4px;
}

.file-list {
  margin-top: 14px;
  max-height: 140px;
  overflow-y: auto;
}

.file-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-radius: 6px;
}

.file-item-row:hover {
  background: var(--bg-3);
}

.file-item-row i {
  width: 16px;
  color: var(--accent);
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

#paste-html {
  width: 100%;
  height: 180px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 14px;
  resize: vertical;
  outline: none;
}

#paste-html:focus {
  border-color: var(--accent);
}

.source-panel {
  margin-bottom: 20px;
}

/* ========== LOADING ========== */
.loader-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-bottom: 28px;
}

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

.progress {
  width: 260px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 28px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 4px;
  transition: width 0.35s ease;
}

/* ========== READY ========== */
.ready-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.success-icon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-icon i {
  font-size: 2.4rem;
  color: var(--success);
}

@keyframes popIn {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.ready-wrap h2 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.url-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  margin: 24px 0 32px;
  font-size: 1.15rem;
  font-weight: 600;
}

.url-card a {
  color: var(--accent);
  text-decoration: none;
}

.url-card a:hover {
  text-decoration: underline;
}

.ready-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ========== EDITOR ========== */
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.site-info {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

#editor-sitename {
  font-weight: 600;
  font-size: 0.95rem;
}

#editor-url {
  font-size: 0.8rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editor-url:hover {
  color: var(--accent);
}

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

.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - 53px);
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 14px 16px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}

.tree-item:hover {
  background: var(--bg-3);
  color: var(--text);
}

.tree-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tree-item i {
  width: 16px;
  text-align: center;
  font-size: 0.85rem;
}

.tree-item.folder i { color: #f59e0b; }
.tree-item.file i { color: var(--accent); }

/* Tabs + panes */
.main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs {
  display: flex;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.12s;
}

.tab:hover {
  background: var(--bg-3);
  color: var(--text);
}

.tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tab .close {
  opacity: 0.4;
  font-size: 0.75rem;
  padding: 2px;
  border-radius: 3px;
}

.tab .close:hover {
  opacity: 1;
  background: rgba(255,255,255,0.1);
}

.split {
  flex: 1;
  display: flex;
  min-height: 0;
}

.code-pane {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #0d1117;
}

#editors-container {
  position: absolute;
  inset: 0;
}

.editor-instance {
  position: absolute;
  inset: 0;
  display: none;
}

.editor-instance.active {
  display: block;
}

.CodeMirror {
  height: 100% !important;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
}

.preview-pane {
  width: 42%;
  min-width: 280px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #fff;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

#preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-4);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 999;
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== LIVE VIEWER ========== */
#live-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #000;
}

.live-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.live-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.live-bar-left i {
  color: var(--accent);
}

.live-bar-right {
  display: flex;
  gap: 8px;
}

#live-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* Recent sites on landing */
.recent-sites {
  width: 100%;
  max-width: 480px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.recent-item:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg-3);
}

.recent-item i {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
  .preview-pane {
    display: none;
  }
  .source-options {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 200px;
  }
}


/* ========== AUTH ========== */
.auth-card {
  max-width: 400px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-3);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.auth-tab.active {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.auth-form input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-3);
  padding: 6px 12px;
  border-radius: 20px;
}

/* ========== DASHBOARD ========== */
.dashboard-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px;
  width: 100%;
}

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

.dash-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.sites-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.site-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  transition: border-color 0.15s;
}

.site-card:hover {
  border-color: var(--border-light);
}

.site-card-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.site-card-name {
  font-weight: 600;
  font-size: 1rem;
}

.site-card-url {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.site-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.no-sites {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-sites i {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.no-sites p {
  margin-bottom: 20px;
}

/* ========== LIVE VIEWER (public = pure, no chrome) ========== */
#live-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #fff;
}

#live-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* Responsive extras */
@media (max-width: 900px) {
  .site-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* Music toggle on landing */
.music-toggle {
  margin-top: 18px;
  opacity: 0.75;
}
.music-toggle:hover {
  opacity: 1;
}
.music-toggle.playing {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== FIXES & POLISH ===== */
.editor-topbar {
  flex-wrap: wrap;
  row-gap: 10px;
  min-height: 52px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.editor-actions .btn {
  white-space: nowrap;
}

.site-info {
  flex: 1 1 auto;
}

/* Make dropzone more obvious when files selected */
.dropzone.has-files {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.08);
}

.file-list {
  margin-top: 12px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--bg-3);
}

.file-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-radius: 6px;
}

.file-item-row i {
  color: var(--accent);
  width: 16px;
}

/* Music button more visible */
.music-toggle {
  margin-top: 20px;
  min-width: 120px;
  justify-content: center;
}

.music-toggle.playing {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* CodeMirror fill */
.CodeMirror {
  height: 100% !important;
  font-size: 13.5px;
}

.editor-instance {
  height: 100%;
}

/* Live viewer iframe */
#live-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0f172a;
}

#live-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ===== EDITOR MUST BE USABLE ===== */
#editor.view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
}

#editor.view.hidden {
  display: none !important;
}

.editor-body {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
  min-height: 0;
  height: auto;
}

.main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.split {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.code-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: #0d1117;
}

#editors-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.editor-instance {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.editor-instance.active {
  display: block !important;
}

.editor-instance .CodeMirror {
  height: 100% !important;
  width: 100% !important;
  position: absolute;
  inset: 0;
}

.editor-instance textarea {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.sidebar {
  overflow-y: auto;
  flex-shrink: 0;
}

.tree-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#preview-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  background: #fff;
}
