*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a2e;
  --bg4: #22223a;
  --surface: #16213e;
  --border: #2a2a4a;
  --text: #e0e0f0;
  --text2: #9090b0;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --accent3: #4a3db8;
  --green: #00b894;
  --red: #e17055;
  --orange: #fdcb6e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; transition: var(--transition); }
a:hover { color: #c8c4ff; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  width: 100%;
  outline: none;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,92,231,0.15); }
textarea { resize: vertical; min-height: 80px; }
button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
button:hover, .btn:hover { background: var(--accent2); color: #000; transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent2);
}
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #d63031; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #00a383; }
.btn-sm { padding: 6px 14px; font-size: 0.875rem; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.page { padding: 40px 0; min-height: calc(100vh - 60px); }

/* Navbar */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; }
.navbar .logo {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.navbar .logo:hover { opacity: 0.85; }
.nav-links { display: flex; align-items: center; gap: 8px; list-style: none; }
.nav-links a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg3); }
.nav-links .btn { color: #fff; padding: 6px 18px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}
.card:hover { border-color: var(--accent3); }
.card-header { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Hero */
.hero {
  text-align: center;
  padding: 80px 0 60px;
  background: linear-gradient(180deg, var(--bg3) 0%, transparent 100%);
}
.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
  line-height: 1.2;
}
.hero p { font-size: 1.15rem; color: var(--text2); max-width: 600px; margin: 0 auto 32px; }
.hero .btn { font-size: 1.1rem; padding: 14px 36px; }

/* Features */
.features { padding: 60px 0; }
.features h2 { text-align: center; font-size: 2rem; margin-bottom: 40px; }
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  transition: var(--transition);
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-card .icon { font-size: 2.5rem; margin-bottom: 16px; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.feature-card p { color: var(--text2); font-size: 0.9rem; line-height: 1.5; }

/* Demo gallery */
.demo-gallery { padding: 60px 0; }
.demo-gallery h2 { text-align: center; font-size: 2rem; margin-bottom: 40px; }
.demo-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.demo-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--shadow); }
.demo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.demo-card .body { padding: 16px; }
.demo-card .body h4 { font-size: 0.9rem; margin-bottom: 4px; }
.demo-card .body p { color: var(--text2); font-size: 0.8rem; }
.demo-card .badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 6px;
}

/* Auth forms */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card h2 { text-align: center; font-size: 1.6rem; margin-bottom: 8px; }
.auth-card .subtitle { text-align: center; color: var(--text2); margin-bottom: 28px; font-size: 0.9rem; }
.auth-card .form-group { margin-bottom: 18px; }
.auth-card .form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text2); font-weight: 500; }
.auth-card .btn { width: 100%; justify-content: center; padding: 12px; }
.auth-card .footer-text { text-align: center; margin-top: 20px; font-size: 0.85rem; color: var(--text2); }
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
}
.alert-error { background: rgba(225,112,85,0.15); border: 1px solid var(--red); color: var(--red); }
.alert-success { background: rgba(0,184,148,0.15); border: 1px solid var(--green); color: var(--green); }

/* Dashboard */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.dashboard-header h2 { font-size: 1.5rem; }
.search-bar { display: flex; gap: 8px; max-width: 400px; }
.search-bar input { flex: 1; }

.story-list { display: grid; gap: 12px; }
.story-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}
.story-item:hover { border-color: var(--accent3); }
.story-item .info { flex: 1; min-width: 0; }
.story-item .info h4 { font-size: 1rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-item .info p { color: var(--text2); font-size: 0.8rem; }
.story-item .actions { display: flex; gap: 6px; flex-shrink: 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* Calendar */
.calendar-widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.calendar-header h3 { font-size: 1rem; }
.calendar-header button {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.calendar-header button:hover { background: var(--accent); color: #fff; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-grid .day-name { text-align: center; font-size: 0.75rem; color: var(--text2); padding: 4px 0; font-weight: 600; }
.calendar-grid .day {
  text-align: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text2);
}
.calendar-grid .day:hover { background: var(--bg3); }
.calendar-grid .day.has-stories { background: var(--accent3); color: #fff; font-weight: 600; }
.calendar-grid .day.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(108,92,231,0.3);
}
.calendar-grid .day.other-month { opacity: 0.3; }

/* Generator */
.generator-page { display: grid; grid-template-columns: 320px 1fr; gap: 24px; min-height: calc(100vh - 60px); }
.generator-sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 24px;
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}
.generator-sidebar h3 { font-size: 1rem; margin-bottom: 16px; }
.generator-sidebar .form-group { margin-bottom: 16px; }
.generator-sidebar .form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text2); font-weight: 500; }
.generator-main { padding: 24px; overflow-y: auto; }
.generator-main .empty-prompt { text-align: center; padding: 80px 20px; color: var(--text2); }
.generator-main .empty-prompt .icon { font-size: 4rem; margin-bottom: 16px; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.panel-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}
.panel-card:hover { border-color: var(--accent3); }
.panel-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.panel-card .panel-body { padding: 12px; }
.panel-card .panel-body p { font-size: 0.8rem; color: var(--text2); }

/* Editor */
.editor-page { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; min-height: calc(100vh - 60px); padding: 24px; }
.editor-panel { display: flex; flex-direction: column; gap: 16px; }
.editor-panel h3 { font-size: 1rem; }
.editor-panel .upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.editor-panel .upload-area:hover { border-color: var(--accent); background: rgba(108,92,231,0.05); }
.editor-panel .upload-area .icon { font-size: 3rem; margin-bottom: 12px; }
.editor-panel .upload-area p { color: var(--text2); font-size: 0.9rem; }
.editor-panel img { width: 100%; border-radius: var(--radius-sm); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  z-index: 999;
  animation: slideUp 0.3s ease;
  max-width: 360px;
  font-size: 0.9rem;
}
.toast.error { border-color: var(--red); }
.toast.success { border-color: var(--green); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Loading */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,15,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 16px;
}
.loading-overlay p { color: var(--text2); }

/* Footer */
.footer { text-align: center; padding: 24px 0; color: var(--text2); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 900;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay::backdrop {
  background: rgba(0,0,0,0.6);
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 1.15rem; margin-bottom: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Responsive */
@media (max-width: 900px) {
  .generator-page { grid-template-columns: 1fr; }
  .generator-sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .editor-page { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 2rem; }
}
.admin-table th, .admin-table td { white-space: nowrap; }
.admin-table .btn-sm { padding: 4px 10px; font-size: 0.75rem; }
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .story-item { flex-direction: column; align-items: flex-start; }
  .story-item .actions { align-self: flex-end; }
  .dashboard-header { flex-direction: column; align-items: stretch; }
  .search-bar { max-width: 100%; }
  .navbar .container { gap: 8px; }
  .nav-links { gap: 4px; }
  .nav-links a { padding: 4px 10px; font-size: 0.8rem; }
}
