/* =========================================================
   Chitrons Archive — Design System (Refined)
   ========================================================= */

:root {
  --bg: #faf8f5;
  --bg-secondary: #f2efe9;
  --bg-tertiary: #e8e4dd;
  --text: #1a1a1a;
  --text-secondary: #6b6560;
  --text-tertiary: #9a9590;
  --border: #e0dcd6;
  --border-light: #ece8e2;
  --accent: #8b5e3c;
  --accent-hover: #724e32;
  --accent-light: rgba(139, 94, 60, 0.08);
  --link: #8b5e3c;
  --link-hover: #724e32;
  --code-bg: #f0ece6;
  --code-text: #8b5e3c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 10px rgba(0,0,0,0.06);
  --radius-sm: 3px;
  --radius-md: 5px;
  --transition: 150ms ease;
  --font-serif: 'Times New Roman', Times, 'Noto Serif Bengali', 'Kalpurush', serif;
  --font-sans: 'Kalpurush', 'Noto Sans Bengali', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
  --max-width: 680px;
  --max-width-wide: 1060px;
  --header-height: 54px;
  --gutter: 20px;
}

[data-theme="dark"] {
  --bg: #1a1917;
  --bg-secondary: #232220;
  --bg-tertiary: #2e2c29;
  --text: #e8e4de;
  --text-secondary: #9a9590;
  --text-tertiary: #6b6560;
  --border: #333130;
  --border-light: #2a2928;
  --accent: #c49a6c;
  --accent-hover: #d4aa7c;
  --accent-light: rgba(196, 154, 108, 0.1);
  --link: #c49a6c;
  --link-hover: #d4aa7c;
  --code-bg: #2a2928;
  --code-text: #c49a6c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 2px 10px rgba(0,0,0,0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-wrap: break-word;
  word-wrap: break-word;
  transition: background-color var(--transition), color var(--transition);
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--link-hover); }
ul, ol { list-style: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--accent-light); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6, p, .article-title, .hero h1, .hero p, .post-item h3 {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.container {
  width: 100%;
  max-width: var(--max-width-wide);
  margin-left: auto;
  margin-right: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.container--narrow { max-width: var(--max-width); }

/* =========================================================
   HEADER
   ========================================================= */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  height: var(--header-height);
  display: flex; align-items: center;
  transition: background-color var(--transition);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
}
.site-logo {
  font-family: var(--font-serif);
  font-size: 15px; font-weight: 400; letter-spacing: 0.01em;
  color: var(--text);
}
.site-logo:hover { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 24px; }
.site-nav a {
  font-family: var(--font-sans);
  font-size: 13px; color: var(--text-tertiary);
  transition: color var(--transition); letter-spacing: 0.01em;
}
.site-nav a:hover, .site-nav a.active { color: var(--text); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.theme-toggle {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-tertiary);
  transition: color var(--transition);
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }
.mobile-menu-btn {
  display: none; width: 30px; height: 30px;
  align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.mobile-menu-btn svg { width: 18px; height: 18px; }
.mobile-nav {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: var(--bg); padding: var(--gutter);
  flex-direction: column; gap: 0;
}
.mobile-nav.open { display: flex; }
.mobile-nav-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.mobile-nav-header .site-logo { font-size: 16px; }
.mobile-nav-close { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.mobile-nav-close svg { width: 18px; height: 18px; }
.mobile-nav a {
  display: block; padding: 12px 0; font-family: var(--font-sans);
  font-size: 15px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  transition: color var(--transition);
}
.mobile-nav a:last-child { border-bottom: none; }
.mobile-nav a:hover, .mobile-nav a.active { color: var(--text); }

@media (max-width: 768px) {
  .site-nav { display: none; }
  .mobile-menu-btn { display: flex; }
}

/* =========================================================
   HERO
   ========================================================= */
.hero {
  padding-top: 48px;
  padding-bottom: 36px;
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: 30px; font-weight: 400; letter-spacing: -0.01em;
  line-height: 1.25; margin-bottom: 14px;
}
.hero p {
  font-family: var(--font-serif);
  font-size: 16px; color: var(--text-secondary);
  line-height: 1.7; max-width: 520px; margin-bottom: 24px;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px;
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 500; letter-spacing: 0.01em;
  border-radius: var(--radius-sm); transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  border: 1px solid var(--border); color: var(--text-secondary);
  background: transparent;
}
.btn-secondary:hover { border-color: var(--text-secondary); color: var(--text); }
.btn-secondary:active { transform: translateY(1px); }
.btn-ghost {
  color: var(--text-secondary); padding: 7px 10px;
}
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* =========================================================
   SECTION
   ========================================================= */
.section {
  padding-top: 36px;
  padding-bottom: 36px;
}
.section-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 20px;
}
.section-header h2 {
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-tertiary);
}
.section-header a {
  font-family: var(--font-sans);
  font-size: 12px; color: var(--text-tertiary);
}
.section-header a:hover { color: var(--text); }

/* =========================================================
   ARTICLE CARDS / LIST
   ========================================================= */
.post-list { display: flex; flex-direction: column; }
.post-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.post-item:first-child { padding-top: 0; }
.post-item:last-child { border-bottom: none; }
.post-item-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
  font-family: var(--font-sans);
  font-size: 12px; color: var(--text-tertiary);
}
.post-item-meta .category {
  color: var(--accent); font-weight: 500;
}
.post-item-meta .dot { color: var(--border); }
.post-item h3 {
  font-family: var(--font-serif);
  font-size: 17px; font-weight: 400; line-height: 1.4;
  letter-spacing: -0.005em; margin-bottom: 4px;
}
.post-item h3 a { color: var(--text); }
.post-item h3 a:hover { color: var(--accent); }
.post-item p {
  font-family: var(--font-serif);
  font-size: 15px; color: var(--text-secondary); line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-item-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-sans);
  font-size: 11px; color: var(--text-tertiary);
  padding: 2px 7px; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); transition: all var(--transition);
}
.tag:hover { border-color: var(--text-tertiary); color: var(--text-secondary); }

/* =========================================================
   LOADING / EMPTY
   ========================================================= */
.loading { padding: 32px 0; text-align: center; color: var(--text-tertiary); font-family: var(--font-sans); font-size: 13px; }
.empty-state { padding: 40px 0; text-align: center; color: var(--text-tertiary); }
.empty-state p { font-family: var(--font-sans); font-size: 14px; margin-bottom: 12px; }
.skeleton {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line--title { width: 55%; height: 16px; margin-bottom: 10px; }
.skeleton-line--short { width: 35%; }

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
  padding: 24px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 40px;
}
.site-footer .container {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.site-footer p {
  font-family: var(--font-sans);
  font-size: 12px; color: var(--text-tertiary);
}
.footer-links { display: flex; gap: 14px; }
.footer-links a { font-family: var(--font-sans); font-size: 12px; color: var(--text-tertiary); }
.footer-links a:hover { color: var(--text-secondary); }

/* =========================================================
   WRITING PAGE
   ========================================================= */
.writing-controls {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 24px; align-items: center;
}
.search-box { flex: 1; min-width: 180px; position: relative; }
.search-box input {
  width: 100%; padding: 7px 10px 7px 32px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); font-family: var(--font-sans);
  font-size: 13px; transition: border-color var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-tertiary);
}
.sort-select {
  padding: 7px 24px 7px 10px; font-family: var(--font-sans);
  font-size: 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text-secondary);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239a9590' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 32px; padding-top: 20px;
  border-top: 1px solid var(--border-light);
}
.pagination button {
  padding: 6px 12px; font-family: var(--font-sans);
  font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  transition: all var(--transition);
}
.pagination button:hover { border-color: var(--text-secondary); color: var(--text); }
.pagination button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* =========================================================
   ARTICLE PAGE
   ========================================================= */
.article-header {
  padding-top: 40px;
  padding-bottom: 24px;
}
.article-header .back-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-sans);
  font-size: 12px; color: var(--text-tertiary); margin-bottom: 20px;
}
.article-header .back-link:hover { color: var(--text); }
.article-header .back-link svg { width: 12px; height: 12px; }
.article-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-sans);
  font-size: 12px; color: var(--text-tertiary); margin-bottom: 12px;
  flex-wrap: wrap;
}
.article-meta .category { color: var(--accent); font-weight: 500; }
.article-title {
  font-family: var(--font-serif);
  font-size: 28px; font-weight: 400; letter-spacing: -0.015em;
  line-height: 1.3; margin-bottom: 10px;
}
.article-excerpt {
  font-family: var(--font-serif);
  font-size: 16px; color: var(--text-secondary); line-height: 1.65;
}
.article-tags {
  display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap;
}

/* --- Article Prose --- */
.article-body {
  padding-top: 0;
  padding-bottom: 40px;
  font-family: var(--font-serif);
  font-size: 18px; line-height: 1.85; color: var(--text);
}
.article-body p { margin-bottom: 1.4em; }
.article-body h2 {
  font-family: var(--font-serif);
  font-size: 22px; font-weight: 700; letter-spacing: -0.01em;
  margin: 2em 0 0.7em; line-height: 1.35;
}
.article-body h3 {
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 700;
  margin: 1.6em 0 0.5em; line-height: 1.4;
}
.article-body h4 {
  font-family: var(--font-serif);
  font-size: 16px; font-weight: 700;
  margin: 1.4em 0 0.4em;
}
.article-body ul, .article-body ol {
  margin-bottom: 1.4em; padding-left: 1.4em;
}
.article-body ul { list-style: disc; }
.article-body ol { list-style: decimal; }
.article-body li { margin-bottom: 0.4em; }
.article-body blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.4em 0 0.4em 1.2em;
  margin: 1.4em 0; color: var(--text-secondary);
  font-style: italic;
}
.article-body pre {
  background: var(--code-bg); padding: 14px 18px;
  border-radius: var(--radius-sm); overflow-x: auto;
  margin: 1.4em 0; font-family: var(--font-mono);
  font-size: 13px; line-height: 1.6;
}
.article-body code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--code-bg); color: var(--code-text);
  padding: 1px 5px; border-radius: 2px;
}
.article-body pre code { background: none; padding: 0; color: inherit; }
.article-body img {
  width: 100%; border-radius: var(--radius-sm);
  margin: 1.4em 0;
}
.article-body a { text-decoration: underline; text-underline-offset: 2px; }
.article-body hr {
  border: none; border-top: 1px solid var(--border);
  margin: 2em 0;
}
.article-body table {
  border: 1px solid var(--border); margin: 1.4em 0;
  font-family: var(--font-sans); font-size: 14px;
}
.article-body th, .article-body td {
  padding: 8px 12px; border: 1px solid var(--border);
  text-align: left;
}
.article-body th { background: var(--bg-secondary); font-weight: 600; }

/* --- Post Navigation --- */
.post-nav {
  padding-top: 24px;
  padding-bottom: 24px;
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: space-between; gap: 20px;
}
.post-nav a {
  font-family: var(--font-sans); font-size: 13px;
  color: var(--text-secondary);
  display: flex; flex-direction: column; gap: 2px;
}
.post-nav a:hover { color: var(--text); }
.post-nav a .label { font-size: 11px; color: var(--text-tertiary); }
.post-nav .next { text-align: right; margin-left: auto; }

/* =========================================================
   ABOUT PAGE
   ========================================================= */
.about-page { padding: 44px 0; }
.about-page .container { max-width: var(--max-width); }
.about-intro {
  margin-bottom: 36px; padding-bottom: 28px;
  border-bottom: 1px solid var(--border-light);
  display: flex; gap: 28px; align-items: flex-start;
}
.about-intro .profile-image {
  width: 100px; height: 100px;
  border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0;
}
.about-intro h1 {
  font-family: var(--font-serif);
  font-size: 24px; font-weight: 400; letter-spacing: -0.01em;
  margin-bottom: 10px; line-height: 1.3;
}
.about-intro p {
  font-family: var(--font-serif);
  font-size: 16px; color: var(--text-secondary); line-height: 1.7;
  max-width: 480px;
}
.about-section { margin-bottom: 32px; }
.about-section h2 {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-tertiary);
  margin-bottom: 12px;
}
.about-section p, .about-section li {
  font-family: var(--font-serif);
  font-size: 16px; color: var(--text-secondary); line-height: 1.7;
}
.about-section p { margin-bottom: 0.9em; }
.about-section ul { list-style: none; }
.about-section ul li {
  padding: 5px 0; border-bottom: 1px solid var(--border-light);
  font-family: var(--font-serif);
}
.about-section ul li:last-child { border-bottom: none; }
.project-list { display: flex; flex-direction: column; gap: 12px; }
.project-item {
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.project-item:last-child { border-bottom: none; }
.project-item h3 {
  font-family: var(--font-serif);
  font-size: 16px; font-weight: 400; margin-bottom: 3px;
}
.project-item p {
  font-family: var(--font-serif);
  font-size: 14px; color: var(--text-secondary); line-height: 1.65;
  margin-bottom: 0;
}
.project-item .tech {
  font-family: var(--font-sans);
  font-size: 11px; color: var(--text-tertiary); margin-top: 3px;
}
.skill-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.skill-grid li {
  font-family: var(--font-sans);
  font-size: 13px; padding: 6px 10px;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  border-bottom: none !important;
}
.contact-links { display: flex; gap: 12px; flex-wrap: wrap; }
.contact-links a {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-sans);
  font-size: 13px; color: var(--text-secondary);
  padding: 6px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: all var(--transition);
}
.contact-links a:hover { border-color: var(--accent); color: var(--accent); }
.contact-links svg { width: 14px; height: 14px; }

@media (max-width: 480px) {
  .about-intro { flex-direction: column; align-items: center; text-align: center; }
  .about-intro .profile-image { width: 80px; height: 80px; }
  .about-intro p { max-width: 100%; }
}

/* =========================================================
   IMAGE COMPONENTS
   ========================================================= */
.cover-image {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  border-radius: var(--radius-sm); margin-bottom: 16px;
}
.post-item-cover {
  width: 100%; aspect-ratio: 2/1; object-fit: cover;
  border-radius: var(--radius-sm); margin-bottom: 10px;
}
.article-cover {
  width: 100%; max-width: var(--max-width); margin: 0 auto 24px;
  aspect-ratio: 2/1; object-fit: cover; border-radius: var(--radius-sm);
}
.img-caption {
  font-family: var(--font-sans); font-size: 12px;
  color: var(--text-tertiary); text-align: center;
  margin-top: 6px; margin-bottom: 1.4em;
}

/* =========================================================
   ADMIN LAYOUT (Viewport Locked & Responsive)
   ========================================================= */
body.admin-body {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  margin: 0;
  padding: 0;
  width: 100%;
}

.admin-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.admin-sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  height: 100%;
  max-height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .site-logo { font-family: var(--font-serif); font-size: 14px; display: block; }
.sidebar-header .admin-label { font-family: var(--font-sans); font-size: 10px; color: var(--text-tertiary); margin-top: 1px; text-transform: uppercase; letter-spacing: 0.06em; }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
  overscroll-behavior: contain;
}
.sidebar-section { margin-bottom: 6px; }
.sidebar-section-title {
  padding: 6px 18px 3px; font-family: var(--font-sans);
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-tertiary);
}
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 18px; font-family: var(--font-sans);
  font-size: 13px; color: var(--text-secondary);
  transition: all var(--transition); width: 100%;
}
.sidebar-link:hover { background: var(--bg-tertiary); color: var(--text); }
.sidebar-link.active { color: var(--accent); font-weight: 500; background: var(--accent-light); }
.sidebar-link svg { width: 14px; height: 14px; flex-shrink: 0; }

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.sidebar-footer .btn { width: 100%; justify-content: center; }

.admin-main {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.admin-topbar {
  flex-shrink: 0;
  height: 50px;
  min-height: 50px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 40;
  width: 100%;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; }
.topbar-left .mobile-menu-btn { display: none; }
.topbar-title { font-family: var(--font-sans); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-search { position: relative; }
.topbar-search input {
  padding: 6px 10px 6px 28px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-secondary);
  font-family: var(--font-sans); font-size: 12px; width: 180px;
  transition: border-color var(--transition), width var(--transition);
}
.topbar-search input:focus { outline: none; border-color: var(--accent); width: 220px; }
.topbar-search svg {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; color: var(--text-tertiary);
}

.admin-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  overscroll-behavior: contain;
}

.admin-view {
  width: 100%;
  max-width: 100%;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 95;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100%;
    height: 100dvh;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; width: 100%; }
  .topbar-left .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
  }
  .topbar-right { gap: 6px; }
  .topbar-search input { width: 110px; }
  .topbar-search input:focus { width: 140px; }
  .admin-topbar { padding: 0 12px; height: 46px; min-height: 46px; }
  .admin-content { padding: 14px 12px; }
}

/* --- Scrollbars for Admin Elements --- */
.admin-content::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
.post-table-wrapper::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.admin-content::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb,
.post-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.admin-content::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.post-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* --- Login --- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  padding: 16px;
  overflow-y: auto;
}
.login-card {
  width: 100%; max-width: 340px; padding: 32px 28px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.login-card h1 { font-family: var(--font-serif); font-size: 18px; font-weight: 400; text-align: center; margin-bottom: 3px; }
.login-card .subtitle { text-align: center; font-family: var(--font-sans); font-size: 12px; color: var(--text-tertiary); margin-bottom: 24px; text-transform: uppercase; letter-spacing: 0.06em; }
.login-card label { display: block; font-family: var(--font-sans); font-size: 12px; font-weight: 500; margin-bottom: 5px; color: var(--text-secondary); }
.login-card input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px;
  background: var(--bg); transition: border-color var(--transition);
  text-align: center; letter-spacing: 0.2em;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 14px; }
.login-error { font-family: var(--font-sans); font-size: 12px; color: #c0392b; text-align: center; margin-top: 10px; min-height: 16px; }

/* --- Dashboard --- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
  width: 100%;
}
.dash-stat {
  padding: 14px; background: var(--bg-secondary);
  border-radius: var(--radius-sm); border: 1px solid var(--border-light);
}
.dash-stat .number { font-family: var(--font-serif); font-size: 26px; font-weight: 400; }
.dash-stat .label { font-family: var(--font-sans); font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }
.dash-section { margin-bottom: 28px; width: 100%; }
.dash-section h3 { font-family: var(--font-sans); font-size: 14px; font-weight: 600; margin-bottom: 10px; }

/* --- Post Table --- */
.post-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.post-table { width: 100%; min-width: 520px; font-size: 13px; }
.post-table th {
  text-align: left; padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-tertiary);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.post-table td {
  padding: 10px; border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
.post-table tr:hover td { background: var(--bg-secondary); }
.post-table .title-cell a { font-family: var(--font-serif); font-weight: 400; color: var(--text); font-size: 14px; }
.post-table .title-cell a:hover { color: var(--accent); }
.post-table .title-cell .excerpt {
  font-family: var(--font-sans); font-size: 11px; color: var(--text-tertiary);
  margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}
.status-badge {
  display: inline-block; padding: 2px 7px;
  font-family: var(--font-sans);
  font-size: 10px; font-weight: 600; border-radius: 10px;
  text-transform: capitalize;
}
.status-badge.published { background: #d5f5e3; color: #1e8449; }
.status-badge.draft { background: #fdebd0; color: #b7740e; }
.status-badge.scheduled { background: #d6eaf8; color: #2471a3; }
.status-badge.trashed { background: #fadbd8; color: #c0392b; }
[data-theme="dark"] .status-badge.published { background: rgba(30,132,73,0.15); color: #58d68d; }
[data-theme="dark"] .status-badge.draft { background: rgba(183,116,14,0.15); color: #f0b27a; }
[data-theme="dark"] .status-badge.scheduled { background: rgba(36,113,163,0.15); color: #85c1e9; }
[data-theme="dark"] .status-badge.trashed { background: rgba(192,57,43,0.15); color: #ec7063; }
.actions-cell { white-space: nowrap; }
.actions-cell button, .actions-cell a {
  font-family: var(--font-sans);
  padding: 3px 6px; font-size: 11px; color: var(--text-tertiary);
  transition: color var(--transition);
}
.actions-cell button:hover, .actions-cell a:hover { color: var(--text); }
.actions-cell .delete-btn:hover { color: #c0392b; }
.bulk-bar {
  display: none; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--accent-light);
  border-radius: var(--radius-sm); margin-bottom: 10px;
  font-family: var(--font-sans); font-size: 12px;
  width: 100%;
}
.bulk-bar.visible { display: flex; }
.bulk-bar select {
  padding: 4px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font-sans);
  font-size: 12px; background: var(--bg);
}
@media (max-width: 768px) {
  .post-table .hide-mobile { display: none; }
  .actions-cell { display: flex; gap: 2px; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* --- Editor --- */
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 100%;
}
.editor-main { min-width: 0; width: 100%; }
.editor-sidebar { width: 100%; max-width: 100%; }
.editor-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); margin-bottom: 12px; overflow: hidden;
}
.editor-card-header {
  padding: 10px 14px; font-family: var(--font-sans);
  font-size: 12px; font-weight: 600;
  border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between; align-items: center;
}
.editor-card-body { padding: 14px; }
.editor-card-body label {
  display: block; font-family: var(--font-sans);
  font-size: 11px; font-weight: 500;
  color: var(--text-tertiary); margin-bottom: 3px;
}
.editor-card-body input, .editor-card-body textarea,
.editor-card-body select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font-sans);
  font-size: 12px; background: var(--bg);
  transition: border-color var(--transition);
}
.editor-card-body input:focus, .editor-card-body textarea:focus,
.editor-card-body select:focus { outline: none; border-color: var(--accent); }
.editor-card-body textarea { resize: vertical; min-height: 50px; }
.editor-card-body .field { margin-bottom: 10px; }
.editor-card-body .field:last-child { margin-bottom: 0; }
.editor-card-body .help { font-family: var(--font-sans); font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }
.tags-input {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 5px 6px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-height: 32px; cursor: text;
}
.tags-input:focus-within { border-color: var(--accent); }
.tags-input .tag-item {
  display: flex; align-items: center; gap: 3px;
  padding: 1px 6px; background: var(--bg-secondary);
  border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 11px;
}
.tags-input .tag-item button { font-size: 12px; color: var(--text-tertiary); line-height: 1; }
.tags-input input {
  flex: 1; min-width: 60px; border: none !important;
  padding: 1px 0 !important; font-family: var(--font-sans); font-size: 12px;
  background: transparent !important;
}
.editor-title-input {
  width: 100%; padding: 0; border: none;
  font-family: var(--font-serif);
  font-size: 26px; font-weight: 400; letter-spacing: -0.015em;
  background: transparent; line-height: 1.3; margin-bottom: 12px;
}
.editor-title-input:focus { outline: none; }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 1px;
  padding: 6px 10px; border: 1px solid var(--border);
  border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--bg-secondary);
}
.toolbar-btn {
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  transition: all var(--transition);
}
.toolbar-btn:hover { background: var(--bg-tertiary); color: var(--text); }
.toolbar-btn.active { background: var(--accent-light); color: var(--accent); }
.toolbar-btn svg { width: 14px; height: 14px; }
.toolbar-sep { width: 1px; background: var(--border); margin: 3px 5px; }
.editor-area {
  border: 1px solid var(--border); border-radius: 0 0 var(--radius-md) var(--radius-md);
  min-height: 360px; padding: 18px;
  font-family: var(--font-serif); font-size: 16px; line-height: 1.75;
  outline: none; background: var(--bg);
}
.editor-area:empty::before { content: 'Start writing...'; color: var(--text-tertiary); }
.editor-area p { margin-bottom: 0.9em; }
.editor-area h2 { font-family: var(--font-serif); font-size: 20px; font-weight: 700; margin: 1.4em 0 0.5em; }
.editor-area h3 { font-family: var(--font-serif); font-size: 17px; font-weight: 700; margin: 1.2em 0 0.4em; }
.editor-area blockquote { border-left: 2px solid var(--accent); padding-left: 14px; margin: 1em 0; color: var(--text-secondary); font-style: italic; }
.editor-area pre { background: var(--code-bg); padding: 10px 14px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 13px; overflow-x: auto; }
.editor-area code { font-family: var(--font-mono); font-size: 0.88em; background: var(--code-bg); padding: 1px 4px; border-radius: 2px; }
.editor-area pre code { background: none; padding: 0; }
.editor-area img { max-width: 100%; border-radius: var(--radius-sm); }
.editor-area ul, .editor-area ol { padding-left: 1.4em; margin-bottom: 0.9em; }
.editor-area ul { list-style: disc; }
.editor-area ol { list-style: decimal; }
.editor-area hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.editor-actions {
  display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; align-items: center;
}
.editor-actions .spacer { flex: 1; }
.autosave-status {
  font-family: var(--font-sans);
  font-size: 11px; color: var(--text-tertiary);
  display: flex; align-items: center; gap: 5px;
}
.autosave-status .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-tertiary); }
.autosave-status.saving .dot { background: #f39c12; animation: pulse 1s infinite; }
.autosave-status.saved .dot { background: #27ae60; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (max-width: 1024px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar { position: static; }
}

/* --- Admin Checkbox --- */
.admin-checkbox { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center; justify-content: center; padding: 20px;
  animation: modal-fade-in 0.18s ease-out;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); width: 100%; max-width: 440px; padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: modal-scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal h3 { font-family: var(--font-sans); font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.modal p { font-family: var(--font-sans); font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 6px; justify-content: flex-end; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Toast --- */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 600;
  display: flex; flex-direction: column; gap: 6px;
}
.toast {
  padding: 10px 16px; background: var(--text);
  color: var(--bg); font-family: var(--font-sans);
  font-size: 12px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); animation: toast-in 0.2s ease;
}
.toast.error { background: #c0392b; color: #fff; }
.toast.success { background: #27ae60; color: #fff; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Content Sections in Admin --- */
.content-editor { margin-bottom: 20px; }
.content-editor h3 {
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
.content-field { margin-bottom: 12px; }
.content-field label {
  display: block; font-family: var(--font-sans);
  font-size: 11px; font-weight: 500; color: var(--text-tertiary);
  margin-bottom: 3px;
}
.content-field input, .content-field textarea, .content-field select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font-sans);
  font-size: 13px; background: var(--bg);
  transition: border-color var(--transition);
}
.content-field input:focus, .content-field textarea:focus {
  outline: none; border-color: var(--accent);
}
.content-field textarea { resize: vertical; min-height: 60px; }
.content-field .help { font-family: var(--font-sans); font-size: 10px; color: var(--text-tertiary); margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

@media (min-width: 641px) {
  :root {
    --gutter: 28px;
  }
}

@media (min-width: 1024px) {
  :root {
    --gutter: 32px;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 18px;
  }
  body { font-size: 16.5px; }
  .hero { padding-top: 32px; padding-bottom: 24px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15.5px; }
  .article-header { padding-top: 28px; padding-bottom: 18px; }
  .article-title { font-size: 24px; }
  .article-body { font-size: 17px; line-height: 1.8; padding-bottom: 32px; }
  .section { padding-top: 28px; padding-bottom: 28px; }
}
