* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #C0392B;
  --primary-dark: #96281B;
  --accent: #D4A843;
  --accent-hover: #C49A3A;
  --gradient-btn: linear-gradient(135deg, #C0392B, #D4A843);
  --glow: rgba(192, 57, 43, 0.3);
  --bg: #0a0a0a;
  --bg-card: #121212;
  --bg-dark: #0d0d0d;
  --bg-light: #1e1e1e;
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.12);
  --text: #f0e8e0;
  --text-muted: #7a7a7a;
  --success: #27AE60;
  --error: #E74C3C;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.6);
}

[data-theme="light"] {
  --bg: #f5f0eb;
  --bg-card: #ffffff;
  --bg-dark: #f0ebe5;
  --bg-light: #e5ddd5;
  --border: rgba(0,0,0,0.08);
  --border-light: rgba(0,0,0,0.15);
  --text: #1a1a1a;
  --text-muted: #7a7168;
  --glow: rgba(192, 57, 43, 0.15);
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

[data-theme="light"] #landing {
  background: linear-gradient(160deg, #f5f0eb 0%, #ede4d8 40%, #e8dcd0 100%);
}

html, body {
  height: 100%;
  font-family: 'Georgia', 'Times New Roman', 'Playfair Display', serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Splash ─── */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s, visibility 0.5s;
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-content { text-align: center; }
.splash-icon { width: 64px; height: 64px; color: var(--accent); }
.splash-content h1 {
  font-size: 36px; margin-top: 16px;
  background: var(--gradient-btn);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.tagline { font-size: 14px; color: var(--text-muted); margin-top: 6px; font-family: -apple-system, sans-serif; }

/* ─── Landing ─── */
.landing {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0a0a0a 0%, #100e0c 40%, #1a1410 100%);
  padding: 24px;
}
.landing-content { max-width: 420px; width: 100%; padding: 32px 24px; text-align: center; }
.landing-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px; }
.logo-badge {
  display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 700;
  background: var(--gradient-btn);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  font-family: -apple-system, sans-serif;
}
.logo-icon { width: 32px; height: 32px; color: var(--accent); }
.landing-hero h1 {
  font-size: 38px; line-height: 1.15; font-weight: 700; margin-bottom: 14px;
  color: var(--text);
}
.landing-hero p { font-size: 15px; color: var(--text-muted); line-height: 1.7; margin-bottom: 28px; font-family: -apple-system, sans-serif; }
.features { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 28px; }
.feature {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--bg-card);
  border-radius: 20px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); font-family: -apple-system, sans-serif;
}
.feature .icon { width: 18px; height: 18px; color: var(--accent); }

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 16px 48px; border: none;
  background: var(--gradient-btn); color: white;
  border-radius: 30px; font-size: 16px; font-weight: 600;
  cursor: pointer; box-shadow: 0 4px 20px var(--glow);
  transition: all 0.2s; font-family: -apple-system, sans-serif;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 28px var(--glow); }
.btn-primary .icon { width: 20px; height: 20px; }
.note { font-size: 12px; color: var(--text-muted); margin-top: 20px; font-family: -apple-system, sans-serif; }

/* ─── Page / Phone Frame ─── */
.page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; background: var(--bg); padding: 12px; }
.phone-frame {
  width: 100%; max-width: 380px; height: 100vh; max-height: 800px;
  background: var(--bg-dark); border-radius: 40px; overflow: hidden;
  position: relative; border: 4px solid var(--border-light);
  display: flex; flex-direction: column;
}
.phone-header {
  display: flex; justify-content: flex-end; align-items: center;
  padding: 10px 18px 6px; gap: 8px;
}
.status-bar { flex: 1; }
.theme-toggle-small { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.icon-sm { width: 18px; height: 18px; }
.app-header {
  display: flex; align-items: center; padding: 6px 16px 8px; gap: 8px; flex-shrink: 0;
}
.app-header h2 { font-size: 18px; font-weight: 700; flex: 1; font-family: -apple-system, sans-serif; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-time { font-size: 12px; color: var(--text-muted); font-weight: 500; font-family: -apple-system, sans-serif; }
.back-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.back-btn .icon { width: 20px; height: 20px; }
.app-content { flex: 1; overflow-y: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch; }
.page-content { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Bottom Nav ─── */
.bottom-nav {
  display: flex; gap: 4px; padding: 8px 12px 16px;
  border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; background: none; border: none;
  color: var(--text-muted); font-size: 10px; font-weight: 500;
  cursor: pointer; border-radius: 10px; transition: all 0.2s;
  font-family: -apple-system, sans-serif;
}
.nav-item.active { color: var(--accent); }
.nav-item.active .icon-nav { filter: drop-shadow(0 0 6px rgba(212,168,67,0.4)); }
.icon-nav { width: 22px; height: 22px; }

.btn-exit {
  background: transparent; border: 2px solid var(--border); color: var(--text-muted);
  padding: 12px 32px; border-radius: 50px; margin-top: 20px;
  cursor: pointer; font-size: 14px; transition: border-color 0.2s, color 0.2s;
  font-family: -apple-system, sans-serif;
}
.btn-exit:hover { border-color: var(--text); color: var(--text); }
.hidden { display: none !important; }

/* ─── Projects ─── */
.project-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 10px; border: 1px solid var(--border); cursor: pointer;
  transition: all 0.2s;
}
.project-card:hover { border-color: var(--accent); }
.project-cover {
  width: 100%; height: 140px; border-radius: var(--radius-sm); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  position: relative; overflow: hidden;
}
.project-cover-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.7));
}
.project-cover-title {
  font-size: 24px; font-weight: 700; color: white; z-index: 1; letter-spacing: 2px;
  text-transform: uppercase; text-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
.project-cover-sub {
  font-size: 11px; color: rgba(255,255,255,0.7); z-index: 1; letter-spacing: 1px;
  font-family: -apple-system, sans-serif; margin-top: 4px;
}
.project-info { display: flex; justify-content: space-between; align-items: center; }
.project-name { font-size: 15px; font-weight: 600; }
.project-meta { font-size: 12px; color: var(--text-muted); font-family: -apple-system, sans-serif; margin-top: 2px; }

/* ─── Editor ─── */
.editor-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--bg-card); border-radius: var(--radius-sm); padding: 4px;
  border: 1px solid var(--border);
}
.editor-tab {
  flex: 1; padding: 8px; border: none; background: transparent;
  color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer;
  border-radius: 8px; transition: all 0.2s; font-family: -apple-system, sans-serif;
}
.editor-tab.active { background: var(--primary); color: white; }

.editor-panel { animation: fadeIn 0.25s ease; }
.form-group { margin-bottom: 14px; }
.form-label {
  font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px;
  display: block; text-transform: uppercase; letter-spacing: 1px;
  font-family: -apple-system, sans-serif;
}
.form-input {
  width: 100%; padding: 10px 14px; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; outline: none; font-family: 'Georgia', serif;
}
.form-input:focus { border-color: var(--accent); }
textarea.form-input { resize: vertical; min-height: 80px; font-family: 'Georgia', serif; }

.color-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: all 0.2s;
}
.color-swatch.selected { border-color: white; transform: scale(1.15); }

/* ─── Page list ─── */
.page-list { margin-bottom: 12px; }
.page-editor-card {
  background: var(--bg-card); border-radius: var(--radius-sm); padding: 14px;
  margin-bottom: 8px; border: 1px solid var(--border);
}
.page-editor-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.page-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--bg-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent); font-family: -apple-system, sans-serif;
}
.page-layout-label { font-size: 12px; color: var(--text); flex: 1; font-family: -apple-system, sans-serif; }
.page-actions { display: flex; gap: 6px; }
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon.danger:hover { border-color: var(--error); color: var(--error); }
.btn-icon .icon { width: 18px; height: 18px; }

.layout-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.layout-option {
  padding: 8px 4px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-dark); cursor: pointer; text-align: center;
  transition: all 0.2s; font-size: 10px; color: var(--text-muted);
  font-family: -apple-system, sans-serif;
}
.layout-option:hover { border-color: var(--border-light); }
.layout-option.selected { border-color: var(--accent); color: var(--accent); }

.add-page-btn {
  width: 100%; padding: 12px; border: 2px dashed var(--border);
  background: transparent; color: var(--text-muted); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  font-family: -apple-system, sans-serif;
}
.add-page-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Preview ─── */
.preview-container {
  position: relative; padding: 10px 0;
}
.preview-page {
  width: 100%; aspect-ratio: 210 / 297; border-radius: 4px;
  overflow: hidden; margin-bottom: 16px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
  position: relative;
  background: white;
}
.preview-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin: 12px 0;
}
.preview-nav-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border-light);
  background: var(--bg-card); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.preview-nav-btn .icon { width: 22px; height: 22px; }
.preview-page-num { font-size: 13px; color: var(--text-muted); font-family: -apple-system, sans-serif; }

/* ─── Magazine Page Layouts (rendered in preview) ─── */
.mag-cover {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: flex-start; padding: 0;
  position: relative; color: white; overflow: hidden;
}
.mag-cover .mag-cover-header {
  margin-top: 40px; padding: 16px 24px;
  background: rgba(0,0,0,0.65);
  width: 100%;
}
.mag-cover .mag-line {
  width: 60px; height: 2px; background: var(--accent); margin: 12px 0;
}
.mag-cover .mag-title {
  font-size: 28px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 3px; line-height: 1.2;
}
.mag-cover .mag-subtitle {
  font-size: 12px; opacity: 0.8; letter-spacing: 2px;
  font-family: -apple-system, sans-serif; margin-top: 4px;
}
.mag-cover .mag-date {
  font-size: 10px; opacity: 0.5; margin-top: 8px;
  font-family: -apple-system, sans-serif; letter-spacing: 1px;
}

.mag-page { width: 100%; height: 100%; padding: 20px; color: #1a1a1a; }
.mag-page-header {
  font-size: 9px; text-transform: uppercase; letter-spacing: 2px;
  color: #999; border-bottom: 1px solid #ddd; padding-bottom: 6px; margin-bottom: 10px;
  display: flex; justify-content: space-between; font-family: -apple-system, sans-serif;
}
.mag-title-block { margin-bottom: 10px; }
.mag-title-block h2 {
  font-size: 20px; font-weight: 700; line-height: 1.15; color: #000;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.mag-title-block .mag-divider {
  width: 40px; height: 2px; background: #c0392b; margin-top: 6px;
}
.mag-split {
  display: flex; gap: 12px; flex: 1;
}
.mag-split .mag-text-col {
  flex: 1; font-size: 11px; line-height: 1.6; color: #333;
}
.mag-split .mag-img-col {
  flex: 1; border-radius: 4px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.mag-full-text {
  font-size: 11px; line-height: 1.7; color: #333;
}
.mag-full-text p { margin-bottom: 8px; }
.mag-img-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 32px; font-family: -apple-system, sans-serif;
}

/* ─── Export ─── */
.export-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--border); text-align: center; margin-bottom: 12px;
}
.export-icon { width: 48px; height: 48px; color: var(--accent); margin-bottom: 12px; }
.export-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.export-card p { font-size: 13px; color: var(--text-muted); font-family: -apple-system, sans-serif; margin-bottom: 16px; }
.export-btn {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm);
  background: var(--gradient-btn); color: white; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; font-family: -apple-system, sans-serif;
}
.export-btn:hover { opacity: 0.9; }
.export-btn:disabled { opacity: 0.4; cursor: default; }
.export-format-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px;
}
.export-format {
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-dark); cursor: pointer; text-align: center; transition: all 0.2s;
}
.export-format.selected { border-color: var(--accent); }
.export-format .icon { width: 28px; height: 28px; color: var(--accent); margin-bottom: 6px; }
.export-format div { font-size: 13px; font-weight: 600; }
.export-format span { font-size: 11px; color: var(--text-muted); font-family: -apple-system, sans-serif; }
.export-success {
  color: var(--success); font-size: 14px; font-weight: 600; text-align: center;
  padding: 16px; font-family: -apple-system, sans-serif;
}

@media (min-width: 768px) {
  .landing { padding: 40px; }
  .page { padding: 24px; }
}
