/* ===== CSS VARIABLES ===== */
:root {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --light: #f5f2ee;
  --border: #e8e3dc;
  --accent: #c0392b;
  --white: #fffef9;
  --card-bg: #fffef9;
  --nav-bg: #fffef9;
  --input-bg: #fff;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --radius: 6px;
}

[data-theme="dark"] {
  --ink: #e8e4dd;
  --muted: #9a9590;
  --light: #2a2825;
  --border: #3a3835;
  --accent: #e05a4a;
  --white: #1a1917;
  --card-bg: #222120;
  --nav-bg: #1a1917;
  --input-bg: #2a2825;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--white);
  color: var(--ink);
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 300;
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
}
a { color: inherit; }
img { max-width: 100%; }

/* ===== NAV ===== */
nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 40px;
  height: 64px;
  transition: background 0.3s, border-color 0.3s;
}
.logo {
  font-family: 'Lora', serif;
  font-size: 1.6rem; font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--ink);
  text-decoration: none;
}
.logo span { color: var(--accent); }
.nav-links {
  display: flex; align-items: center; gap: 16px;
}
.nav-links > a {
  text-decoration: none; color: var(--muted);
  font-size: 0.9rem; transition: color 0.2s;
}
.nav-links > a:hover { color: var(--ink); }

/* Theme Toggle */
.theme-toggle {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: flex; align-items: center;
}
.theme-toggle:hover { background: var(--border); }
[data-theme="light"] .icon-dark { display: none; }
[data-theme="dark"] .icon-light { display: none; }

/* User Menu */
.user-menu { position: relative; }
.user-avatar-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  display: flex; align-items: center;
}
.user-dropdown {
  display: none;
  position: absolute; top: 48px; right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
  display: block; padding: 10px 16px;
  font-size: 0.88rem; text-decoration: none;
  color: var(--ink);
  transition: background 0.15s;
}
.user-dropdown a:hover { background: var(--light); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-name { padding: 12px 16px 2px; font-weight: 600; font-size: 0.9rem; }
.dropdown-email { padding: 0 16px 10px; font-size: 0.8rem; color: var(--muted); }
.nav-avatar { width: 32px !important; height: 32px !important; font-size: 0.72rem !important; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 8px 20px; border-radius: 20px;
  font-size: 0.85rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  border: none; transition: all 0.2s;
  font-family: inherit;
}
.btn-outline {
  border: 1.5px solid var(--ink);
  color: var(--ink); background: transparent;
}
.btn-outline:hover { background: var(--ink); color: var(--white); }
.btn-solid { background: var(--accent); color: white; }
.btn-solid:hover { opacity: 0.85; }
.btn-ghost { background: var(--light); color: var(--ink); border-radius: 6px; }
.btn-ghost:hover { background: var(--border); }

/* ===== HERO ===== */
.hero {
  border-bottom: 1px solid var(--border);
  padding: 80px 40px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 60px; max-width: 1100px; margin: 0 auto;
}
.hero-text h1 {
  font-family: 'Lora', serif;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.15; font-weight: 600;
  letter-spacing: -1.5px;
}
.hero-text p {
  margin-top: 20px; font-size: 1.1rem;
  color: var(--muted); max-width: 420px;
}
.hero-text .btn { margin-top: 32px; font-size: 1rem; padding: 12px 28px; }
.hero-art { flex-shrink: 0; width: 240px; height: 240px; position: relative; }
.hero-art .circle { position: absolute; border-radius: 50%; }
.c1 { width: 240px; height: 240px; background: var(--light); top:0;left:0; }
.c2 { width: 170px; height: 170px; background: var(--border); top:35px;left:35px; }
.c3 { width: 100px; height: 100px; background: var(--accent); opacity:.15; top:70px;left:70px; }
.hero-art .quote {
  position: absolute; inset:0;
  display:flex;align-items:center;justify-content:center;
  font-family:'Lora',serif; font-size:5rem;
  color:var(--accent); opacity:0.4;
}

/* ===== TOPICS BAR ===== */
.topics-bar {
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  display: flex; align-items: center; gap: 4px;
  overflow-x: auto; scrollbar-width: none;
}
.topics-bar::-webkit-scrollbar { display: none; }
.topic-pill {
  flex-shrink: 0; padding: 14px 18px;
  font-size: 0.85rem; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s; white-space: nowrap;
  text-decoration: none;
}
.topic-pill:hover, .topic-pill.active { color: var(--ink); border-color: var(--ink); }

/* ===== MAIN CONTAINER ===== */
.container {
  max-width: 1100px; margin: 0 auto;
  padding: 48px 40px;
  display: grid; grid-template-columns: 1fr 300px; gap: 60px;
}

/* ===== ARTICLE CARD ===== */
.article-card {
  display: flex; gap: 24px;
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.4s ease both;
}
.article-card:first-child { padding-top: 0; }
@keyframes fadeIn {
  from { opacity:0; transform: translateY(10px); }
  to   { opacity:1; transform: translateY(0); }
}
.article-meta { flex: 1; }
.author-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.avatar {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0;
  font-weight: 600; letter-spacing: 0.5px;
  width: 26px; height: 26px; font-size: 0.65rem;
}
.author-name { font-size: 0.82rem; font-weight: 600; }
.meta-sep { color: var(--muted); font-size: 0.8rem; }
.read-time { font-size: 0.8rem; color: var(--muted); }
.article-title-link { text-decoration: none; }
.article-title {
  font-family: 'Lora', serif;
  font-size: 1.22rem; font-weight: 600;
  line-height: 1.35; margin-bottom: 8px;
  letter-spacing: -0.3px; color: var(--ink);
  transition: color 0.2s;
}
.article-title-link:hover .article-title { color: var(--accent); }
.article-preview { font-size: 0.95rem; color: var(--muted); 
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.article-footer {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap;
}
.tag-badge {
  background: var(--light); padding: 3px 10px; border-radius: 12px;
  font-size: 0.75rem; text-decoration: none; color: var(--ink);
  transition: background 0.2s;
}
.tag-badge:hover { background: var(--border); }
.edit-link {
  text-decoration: none; color: var(--accent);
  font-size: 0.78rem; padding: 2px 8px;
  border: 1px solid var(--accent); border-radius: 10px;
  transition: all 0.2s;
}
.edit-link:hover { background: var(--accent); color: white; }
.article-thumb {
  width: 110px; height: 80px; border-radius: 6px;
  flex-shrink: 0; background: var(--light);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; overflow: hidden;
  transition: transform 0.2s;
}
.article-thumb:hover { transform: scale(1.03); }
.thumb-inner { font-size: 2.2rem; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 80px 20px;
  color: var(--muted);
}
.empty-state h3 { font-size: 1.3rem; margin: 16px 0 8px; color: var(--ink); }

/* ===== SEARCH FORM ===== */
.search-form { display: flex; gap: 8px; }
.search-input {
  flex: 1; padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--border); font-size: 0.9rem;
  background: var(--input-bg); color: var(--ink);
  outline: none; font-family: inherit;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-info { color: var(--muted); margin-bottom: 24px; font-size: 0.9rem; }

/* ===== SIDEBAR ===== */
.sidebar-section { margin-bottom: 40px; }
.sidebar-title {
  font-size: 0.78rem; font-weight: 600;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 16px;
}
.sidebar-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.sidebar-tag {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); font-size: 0.82rem;
  color: var(--ink); cursor: pointer; text-decoration: none;
  transition: all 0.2s;
}
.sidebar-tag:hover { border-color: var(--ink); background: var(--light); }
.mini-card {
  display: flex; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer; text-decoration: none; color: var(--ink);
  transition: opacity 0.2s;
}
.mini-card:hover { opacity: 0.7; }
.mini-num {
  font-family: 'Lora', serif; font-size: 1.4rem; font-weight: 600;
  color: var(--border); flex-shrink: 0; width: 28px;
  line-height: 1; padding-top: 2px;
}
.mini-title {
  font-family: 'Lora', serif; font-size: 0.88rem;
  font-weight: 600; line-height: 1.4; margin-bottom: 4px;
}
.mini-sub { font-size: 0.75rem; color: var(--muted); }

/* ===== ARTICLE READ PAGE ===== */
.article-page {
  max-width: 680px; margin: 60px auto; padding: 0 40px 80px;
}
.article-page h1 {
  font-family: 'Lora', serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600; line-height: 1.2;
  letter-spacing: -1px; margin-bottom: 24px;
}
.article-byline {
  display: flex; align-items: center; gap: 14px;
  font-size: 0.88rem; color: var(--muted);
  margin-bottom: 36px; padding-bottom: 36px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.byline-avatar { width: 36px !important; height: 36px !important; font-size: 0.8rem !important; }
.byline-author { font-weight: 600; color: var(--ink); }
.article-body { font-family: 'Lora', serif; font-size: 1.12rem; line-height: 1.9; }
.article-body p { margin-bottom: 28px; }
.article-body h1, .article-body h2, .article-body h3 {
  font-family: 'Lora', serif; font-weight: 600;
  margin: 36px 0 16px; letter-spacing: -0.5px;
}
.article-body h1 { font-size: 1.8rem; }
.article-body h2 { font-size: 1.4rem; }
.article-body h3 { font-size: 1.2rem; }
.article-body a { color: var(--accent); }
.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }

/* Dark mode toggle in reading mode */
.reading-toolbar {
  position: sticky; top: 64px;
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 12px 40px; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 100%;
}
.reading-tools { display: flex; align-items: center; gap: 12px; }
.font-size-btn {
  background: var(--light); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  font-size: 0.85rem; color: var(--ink);
  transition: all 0.2s;
}
.font-size-btn:hover { background: var(--border); }
.reading-progress {
  position: fixed; top: 0; left: 0; height: 3px;
  background: var(--accent); width: 0%; transition: width 0.1s;
  z-index: 9999;
}

/* ===== COMMENTS ===== */
.comments-section { margin-top: 60px; padding-top: 40px; border-top: 1px solid var(--border); }
.comments-title {
  font-family: 'Lora', serif; font-size: 1.3rem; font-weight: 600;
  margin-bottom: 28px;
}
.comment-form { margin-bottom: 40px; }
.comment-form textarea {
  width: 100%; padding: 14px; min-height: 100px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Source Sans 3', sans-serif; font-size: 0.95rem;
  background: var(--input-bg); color: var(--ink);
  resize: vertical; outline: none; transition: border-color 0.2s;
}
.comment-form textarea:focus { border-color: var(--accent); }
.comment-form input[type=text] {
  width: 100%; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 0.9rem;
  background: var(--input-bg); color: var(--ink);
  outline: none; transition: border-color 0.2s;
}
.comment-form input:focus { border-color: var(--accent); }
.comment-form-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; flex-wrap: wrap; gap: 10px;
}
.comment-item {
  padding: 20px 0; border-bottom: 1px solid var(--border);
}
.comment-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.comment-name { font-weight: 600; font-size: 0.9rem; }
.comment-date { font-size: 0.78rem; color: var(--muted); }
.comment-body { font-size: 0.95rem; color: var(--ink); line-height: 1.6; }
.delete-comment {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 0.8rem; padding: 2px 6px;
  border-radius: 4px; transition: all 0.2s;
}
.delete-comment:hover { color: var(--accent); background: var(--light); }
.no-comments { color: var(--muted); font-size: 0.9rem; padding: 20px 0; }

/* ===== EDITOR ===== */
.editor-page {
  max-width: 760px; margin: 0 auto; padding: 40px 40px 80px;
}
.editor-page h2 {
  font-family: 'Lora', serif; font-size: 1.6rem; margin-bottom: 28px;
  font-weight: 600;
}
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 0.82rem; font-weight: 600;
  margin-bottom: 8px; color: var(--muted); letter-spacing: 0.5px;
  text-transform: uppercase;
}
.form-input, .form-select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 0.95rem;
  background: var(--input-bg); color: var(--ink);
  outline: none; transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.editor-title-input {
  font-family: 'Lora', serif !important;
  font-size: 1.8rem !important; font-weight: 600 !important;
  border-left: 3px solid var(--accent) !important;
  padding-left: 16px !important;
}
.editor-toolbar-bar {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 8px; background: var(--light);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.toolbar-btn {
  background: none; border: 1px solid transparent; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; font-size: 0.82rem;
  color: var(--ink); font-family: inherit;
  transition: all 0.2s;
}
.toolbar-btn:hover { background: var(--border); }
.editor-textarea {
  width: 100%; min-height: 400px; padding: 20px;
  border: 1px solid var(--border); border-radius: 0 0 6px 6px;
  font-family: 'Source Sans 3', sans-serif; font-size: 1rem;
  line-height: 1.8; background: var(--input-bg); color: var(--ink);
  resize: vertical; outline: none;
  transition: border-color 0.2s;
}
.editor-textarea:focus { border-color: var(--accent); }
.editor-hint { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.editor-actions {
  display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap;
}
.preview-box {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 24px; margin-top: 24px; display: none;
  background: var(--card-bg);
}
.preview-box.show { display: block; }

/* ===== AUTH FORMS ===== */
.auth-page {
  min-height: 70vh; display: flex;
  align-items: center; justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card h2 {
  font-family: 'Lora', serif; font-size: 1.6rem;
  margin-bottom: 28px; font-weight: 600;
}
.auth-footer { margin-top: 20px; text-align: center; font-size: 0.88rem; color: var(--muted); }
.auth-footer a { color: var(--accent); text-decoration: none; }

/* ===== ADMIN ===== */
.admin-page { max-width: 1000px; margin: 0 auto; padding: 40px; }
.admin-page h2 { font-family: 'Lora', serif; font-size: 1.6rem; margin-bottom: 8px; }
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.admin-tab {
  padding: 10px 20px; cursor: pointer; font-size: 0.88rem;
  border-bottom: 2px solid transparent; color: var(--muted);
  text-decoration: none; transition: all 0.2s;
}
.admin-tab:hover, .admin-tab.active { color: var(--ink); border-color: var(--ink); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left; padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--light); }
.status-badge {
  padding: 2px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: 600;
}
.status-published { background: #d1f2e1; color: #1a6b3a; }
.status-draft { background: var(--light); color: var(--muted); }
[data-theme="dark"] .status-published { background: #1a3d2a; color: #4ade80; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px;
}
.stat-num {
  font-family: 'Lora', serif; font-size: 2.2rem; font-weight: 600;
  color: var(--accent);
}
.stat-label { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 20px; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.alert button { background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: 0.6; }
.alert-success { background: #d1f2e1; color: #1a6b3a; }
.alert-error { background: #fde8e8; color: #9b2226; }
[data-theme="dark"] .alert-success { background: #1a3d2a; color: #4ade80; }
[data-theme="dark"] .alert-error { background: #3d1a1a; color: #f87171; }

/* ===== MY ARTICLES ===== */
.my-articles-page { max-width: 800px; margin: 0 auto; padding: 40px; }

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border); margin-top: 60px;
  padding: 32px 40px; background: var(--white);
  transition: background 0.3s;
}
.footer-inner { max-width: 1100px; margin: 0 auto; text-align: center; }
.footer-links { display: flex; justify-content: center; gap: 24px; margin-top: 16px; flex-wrap: wrap; }
.footer-links a { font-size: 0.85rem; color: var(--muted); text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: var(--ink); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  nav { padding: 0 16px; }
  .nav-links > a:not(.btn) { display: none; }
  .hero { flex-direction: column; padding: 48px 20px; gap: 32px; }
  .hero-art { width: 160px; height: 160px; align-self: center; }
  .c1 { width: 160px; height: 160px; }
  .c2 { width: 110px; height: 110px; }
  .c3 { width: 65px; height: 65px; }
  .container { grid-template-columns: 1fr; padding: 28px 20px; }
  .sidebar { display: none; }
  .topics-bar { padding: 0 16px; }
  .article-page { padding: 0 20px 60px; margin: 32px auto; }
  .editor-page, .admin-page, .my-articles-page { padding: 24px 20px; }
  .reading-toolbar { padding: 10px 20px; }
  .article-thumb { width: 80px; height: 60px; }
}
