/* ============================================================
   Sevin StoryHub v2 — Premium Design System
   Mobile-first · Bootstrap 5.3 · CSS Custom Properties
   ============================================================ */

/* ---------- Custom Properties ---------- */
:root {
  --sh-primary:       #4f46e5;
  --sh-primary-light: #818cf8;
  --sh-primary-dark:  #3730a3;
  --sh-accent:        #06b6d4;
  --sh-bg:            #f8f9fc;
  --sh-bg-card:       #ffffff;
  --sh-text:          #1e293b;
  --sh-text-muted:    #64748b;
  --sh-border:        #e2e8f0;
  --sh-navbar-bg:     rgba(255,255,255,0.95);
  --sh-sidebar-bg:    #1e1b4b;
  --sh-sidebar-text:  #c7d2fe;
  --sh-sidebar-w:     240px;
  --sh-radius:        1rem;
  --sh-shadow:        0 4px 24px rgba(0,0,0,.07);
  --sh-shadow-lg:     0 8px 40px rgba(0,0,0,.14);
  --sh-transition:    .2s ease;
  --sh-font-body:     'Inter', system-ui, sans-serif;
  --sh-font-serif:    'Lora', Georgia, serif;
}

[data-bs-theme="dark"] {
  --sh-bg:          #0f172a;
  --sh-bg-card:     #1e293b;
  --sh-text:        #e2e8f0;
  --sh-text-muted:  #94a3b8;
  --sh-border:      #334155;
  --sh-navbar-bg:   rgba(15,23,42,0.97);
  --sh-shadow:      0 4px 24px rgba(0,0,0,.3);
  --sh-shadow-lg:   0 8px 40px rgba(0,0,0,.45);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sh-font-body);
  background: var(--sh-bg);
  color: var(--sh-text);
  line-height: 1.7;
  transition: background var(--sh-transition), color var(--sh-transition);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Body lock when sidebar open */
body.sh-sidebar-open { overflow: hidden; }

/* ---------- Navbar ---------- */
.sh-navbar {
  background: var(--sh-navbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--sh-border);
  padding: .65rem 0;
  transition: background var(--sh-transition);
  z-index: 1030;
}

.sh-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  flex-shrink: 0;
}
.sh-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--sh-primary), var(--sh-accent));
  border-radius: .65rem;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.15rem;
  flex-shrink: 0;
}
.sh-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sh-brand-name { font-weight: 700; font-size: .95rem; color: var(--sh-text); }
.sh-brand-tag  { font-size: .62rem; color: var(--sh-text-muted); display: none; }

@media (min-width: 576px) {
  .sh-brand-tag { display: block; }
}

.sh-navbar .nav-link {
  color: var(--sh-text-muted);
  font-weight: 500;
  font-size: .875rem;
  padding: .45rem .75rem;
  border-radius: .5rem;
  transition: color var(--sh-transition), background var(--sh-transition);
}
.sh-navbar .nav-link:hover { color: var(--sh-primary); background: rgba(79,70,229,.07); }

/* Category dropdown */
.sh-cat-dropdown { min-width: 180px; padding: .4rem 0; }
.sh-cat-dropdown .dropdown-item {
  font-size: .875rem;
  padding: .45rem 1rem;
  border-radius: .4rem;
  transition: background var(--sh-transition), color var(--sh-transition);
}
.sh-cat-dropdown .dropdown-item:hover { background: rgba(79,70,229,.08); color: var(--sh-primary); }
.sh-cat-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Navbar toggler — bigger tap target */
.navbar-toggler {
  padding: .45rem .6rem !important;
  border-radius: .5rem !important;
}
.navbar-toggler:focus { box-shadow: 0 0 0 2px rgba(79,70,229,.25) !important; }

.sh-search-input {
  border-radius: .75rem !important;
  background: var(--sh-bg);
  border-color: var(--sh-border);
  font-size: .875rem;
  min-width: 0;
}
.sh-search-input:focus { background: var(--sh-bg-card); }

.sh-theme-toggle { color: var(--sh-text-muted); padding: .45rem .6rem; line-height: 1; min-width: 36px; }
.sh-theme-toggle:hover { color: var(--sh-primary); }

/* ---------- Main ---------- */
.sh-main { min-height: calc(100vh - 66px); }

/* ---------- Hero card ---------- */
.sh-hero-card { background: var(--sh-bg-card); overflow: hidden; }
.sh-hero-img {
  width: 100%;
  height: clamp(200px, 40vw, 380px);
  object-fit: cover; object-position: center;
  display: block;
}
.sh-hero-placeholder {
  height: clamp(200px, 40vw, 380px);
  background: linear-gradient(135deg, color-mix(in srgb, var(--sh-primary) 15%, transparent), color-mix(in srgb, var(--sh-accent) 15%, transparent));
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem; color: var(--sh-primary);
}
.sh-hero-title {
  font-family: var(--sh-font-serif);
  font-size: clamp(1.3rem, 3.5vw, 2rem);
  line-height: 1.3;
  font-weight: 600;
}
.sh-hero-title a { color: var(--sh-text); text-decoration: none; }
.sh-hero-title a:hover { color: var(--sh-primary); }

/* ---------- Section titles ---------- */
.sh-section-title {
  font-weight: 700;
  font-size: clamp(1.15rem, 2.5vw, 1.4rem);
  display: flex; align-items: center; gap: .5rem;
}
.sh-cat-pill { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

/* ---------- Post cards ---------- */
.sh-post-card {
  background: var(--sh-bg-card);
  border-radius: var(--sh-radius) !important;
  transition: transform var(--sh-transition), box-shadow var(--sh-transition);
  overflow: hidden;
}
.sh-post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-shadow-lg) !important;
}
.sh-card-img {
  width: 100%;
  height: clamp(140px, 25vw, 200px);
  object-fit: cover; object-position: center;
  display: block;
}
.sh-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: .5rem;
}
.sh-post-link { color: var(--sh-text); text-decoration: none; }
.sh-post-link:hover { color: var(--sh-primary); }

/* ---------- Badges ---------- */
.sh-badge {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .03em;
  padding: .3em .7em;
  border-radius: 2rem;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  color: white !important;
  transition: opacity var(--sh-transition);
}
.sh-badge:hover { opacity: .85; }

/* ---------- Meta info ---------- */
.sh-meta { font-size: .78rem; color: var(--sh-text-muted); }
.sh-meta i { opacity: .7; }

/* ---------- Listen button ---------- */
.btn-xs { padding: .25rem .6rem; font-size: .75rem; border-radius: .5rem; touch-action: manipulation; }
.sh-btn-listen {
  font-size: .72rem;
  border-radius: 2rem !important;
  padding: .25rem .65rem;
  touch-action: manipulation;
}

/* ---------- Pagination ---------- */
.sh-pagination .page-link {
  border-radius: .5rem !important;
  margin: 0 .15rem;
  border: 1px solid var(--sh-border);
  color: var(--sh-text);
  background: var(--sh-bg-card);
  font-size: .85rem;
  padding: .45rem .9rem;
  transition: all var(--sh-transition);
  min-width: 40px; text-align: center;
}
.sh-pagination .page-item.active .page-link {
  background: var(--sh-primary);
  border-color: var(--sh-primary);
  color: white;
}
.sh-pagination .page-link:hover { background: var(--sh-primary); color: white; border-color: var(--sh-primary); }

/* ---------- Empty state ---------- */
.sh-empty { padding: 3.5rem 0; }

/* ---------- Single post page ---------- */
.sh-post-title {
  font-family: var(--sh-font-serif);
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.25;
}
.sh-featured-img img {
  max-height: 480px;
  object-fit: cover;
  width: 100%;
}
.sh-excerpt { color: var(--sh-text-muted); font-size: 1.05rem; line-height: 1.7; }

.sh-post-content {
  font-family: var(--sh-font-serif);
  font-size: clamp(1rem, 2vw, 1.1rem);
  line-height: 1.85;
  color: var(--sh-text);
}
.sh-post-content h1,.sh-post-content h2,.sh-post-content h3,
.sh-post-content h4,.sh-post-content h5 {
  font-family: var(--sh-font-body);
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: .75rem;
  line-height: 1.3;
}
.sh-post-content h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); }
.sh-post-content h3 { font-size: clamp(1.1rem, 2.5vw, 1.3rem); }
.sh-post-content p  { margin-bottom: 1.25rem; }
.sh-post-content blockquote {
  border-left: 4px solid var(--sh-primary);
  padding: .85rem 1.25rem;
  background: rgba(79,70,229,.06);
  border-radius: 0 .75rem .75rem 0;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--sh-text-muted);
}
.sh-post-content img { max-width: 100%; border-radius: .75rem; margin: 1rem 0; }
.sh-post-content a { color: var(--sh-primary); }
.sh-post-content code {
  background: var(--sh-bg);
  padding: .15em .4em;
  border-radius: .3em;
  font-size: .9em;
}
.sh-post-content pre {
  background: var(--sh-bg);
  border: 1px solid var(--sh-border);
  border-radius: .75rem;
  padding: 1.25rem;
  overflow-x: auto;
}
.sh-post-content pre code {
  background: none;
  padding: 0;
  font-size: .875rem;
  border-radius: 0;
}
.sh-post-content ul,
.sh-post-content ol {
  padding-left: 1.75rem;
  margin-bottom: 1.25rem;
}
.sh-post-content li { margin-bottom: .4rem; line-height: 1.75; }
.sh-post-content ul li::marker { color: var(--sh-primary); }
.sh-post-content ol li::marker { color: var(--sh-primary); font-weight: 600; }
.sh-post-content hr {
  border: none;
  border-top: 2px solid var(--sh-border);
  margin: 2rem 0;
}
.sh-post-content strong { font-weight: 700; color: var(--sh-text); }
.sh-post-content em { font-style: italic; }
.sh-blockquote {
  border-left: 4px solid var(--sh-primary);
  padding: .85rem 1.25rem;
  background: rgba(79,70,229,.06);
  border-radius: 0 .75rem .75rem 0;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--sh-text-muted);
}
/* First paragraph drop-cap effect */
.sh-post-content > p:first-of-type { font-size: 1.05em; }

/* ---------- Paragraph highlight (TTS) ---------- */
.sh-para-highlight {
  background: rgba(79,70,229,.12) !important;
  border-radius: .35rem;
  transition: background .3s;
}

/* ---------- TTS Player ---------- */
.sh-tts-player {
  background: var(--sh-bg-card);
  border: 1px solid var(--sh-border) !important;
  position: relative;
}
.sh-tts-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--sh-primary), var(--sh-accent));
  border-radius: .65rem;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.sh-tts-select {
  max-width: 150px;
  font-size: .8rem;
  border-radius: .5rem;
  padding: .25rem .5rem;
  height: auto;
  flex: 1 1 auto;
  min-width: 80px;
}
.sh-tts-range { width: 70px; accent-color: var(--sh-primary); flex-shrink: 0; }
.sh-progress-bar { border-radius: 1rem; background: var(--sh-border); }
.sh-audio-player { border-radius: .75rem; }
.sh-tts-btn { min-height: 34px; touch-action: manipulation; }

/* ---------- Gallery ---------- */
.sh-gallery-thumb {
  width: 100%;
  height: clamp(100px, 20vw, 160px);
  object-fit: cover;
  cursor: pointer;
  transition: transform var(--sh-transition), opacity var(--sh-transition);
  border-radius: .5rem;
}
.sh-gallery-thumb:hover { transform: scale(1.03); opacity: .92; }

/* ---------- Share / Nav links ---------- */
.sh-share { flex-wrap: wrap; }
.sh-nav-link { color: var(--sh-text); transition: all var(--sh-transition); }
.sh-nav-link:hover { transform: translateY(-2px); }
.sh-breadcrumb { font-size: .78rem; }
.sh-breadcrumb a { color: var(--sh-text-muted); text-decoration: none; }
.sh-breadcrumb a:hover { color: var(--sh-primary); }

/* ---------- Category header ---------- */
.sh-cat-header { min-height: 160px; display: flex; flex-direction: column; justify-content: center; }

/* ---------- Search ---------- */
.sh-search-thumb {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: .5rem;
}
.sh-search-result:hover { transform: translateX(3px); }
.sh-search-result { transition: transform var(--sh-transition); }

/* ---------- Footer ---------- */
.sh-footer {
  background: var(--sh-bg-card);
  border-top: 1px solid var(--sh-border);
  padding: 2.5rem 0 1.5rem;
}
.sh-footer-brand { display: flex; align-items: center; font-size: 1.05rem; font-weight: 700; }
.sh-footer-links { padding: 0; }
.sh-footer-links li { margin-bottom: .4rem; }
.sh-footer-links a { color: var(--sh-text-muted); text-decoration: none; font-size: .875rem; transition: color var(--sh-transition); }
.sh-footer-links a:hover { color: var(--sh-primary); }
.sh-footer-hr { border-color: var(--sh-border); }

/* ---------- Login page ---------- */
.sh-login-body {
  background: linear-gradient(135deg, rgba(79,70,229,.07), rgba(6,182,212,.07)), var(--sh-bg);
  min-height: 100vh;
}
.sh-login-card { max-width: 420px; }
.sh-login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--sh-primary), var(--sh-accent));
  border-radius: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  font-size: 1.6rem; color: white;
}
.sh-login-input { background: var(--sh-bg) !important; }

/* ---------- Admin layout ---------- */
.sh-admin-body { background: var(--sh-bg); }

.sh-admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sh-sidebar {
  width: var(--sh-sidebar-w);
  min-height: 100vh;
  background: var(--sh-sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1050;
  transition: transform var(--sh-transition);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sh-sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1.1rem 1.25rem 1rem;
  color: white;
  font-weight: 700;
  font-size: .95rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  gap: .5rem;
  flex-shrink: 0;
}
.sh-admin-pill {
  background: rgba(255,255,255,.15);
  font-size: .62rem;
  padding: .15rem .5rem;
  border-radius: 2rem;
  font-weight: 600;
  letter-spacing: .05em;
}

.sh-sidebar-nav { flex: 1; padding: .6rem 0; overflow-y: auto; }
.sh-sidebar-link {
  display: flex;
  align-items: center;
  padding: .75rem 1.25rem;
  color: var(--sh-sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--sh-transition);
  min-height: 44px;
}
.sh-sidebar-link:hover { background: rgba(255,255,255,.09); color: white; }
.sh-sidebar-link.active { background: var(--sh-primary); color: white; }
.sh-sidebar-divider { border-color: rgba(255,255,255,.12); margin: .4rem 1rem; }

/* ---------- Sidebar backdrop ---------- */
.sh-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1040;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sh-sidebar-backdrop.show { display: block; }

/* ---------- Admin content ---------- */
.sh-admin-content {
  flex: 1;
  margin-left: var(--sh-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.sh-admin-topbar {
  background: var(--sh-bg-card);
  border-bottom: 1px solid var(--sh-border);
  padding: .65rem 1.25rem;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: .5rem;
}
.sh-sidebar-toggle {
  color: var(--sh-text-muted);
  display: none;
  padding: .45rem .55rem;
  min-width: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: .5rem;
}
.sh-sidebar-toggle:hover { color: var(--sh-primary); background: rgba(79,70,229,.07); }
.sh-user-btn { color: var(--sh-text); text-decoration: none; font-size: .875rem; }

.sh-admin-page {
  padding: 1.75rem 1.5rem;
  flex: 1;
  max-width: 1280px;
  width: 100%;
}

/* Admin page title */
.sh-page-title { font-weight: 700; font-size: 1.4rem; }

/* Tables */
.sh-admin-table th {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sh-text-muted);
  border-bottom: 2px solid var(--sh-border) !important;
  font-weight: 600;
  background: transparent;
  padding: .8rem 1rem;
}
.sh-admin-table td {
  padding: .8rem 1rem;
  vertical-align: middle;
  font-size: .875rem;
  border-bottom-color: var(--sh-border);
}
.sh-admin-table { overflow-x: auto; }

/* Stats */
.sh-stat-card { background: var(--sh-bg-card) !important; transition: transform var(--sh-transition); }
.sh-stat-card:hover { transform: translateY(-2px); }
.sh-stat-icon { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Rank badge */
.sh-rank-badge {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--sh-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--sh-text);
}

/* Post editor */
.sh-title-input {
  font-weight: 700; font-size: 1.25rem;
  border: none !important;
  border-bottom: 2px solid var(--sh-border) !important;
  border-radius: 0 !important;
  padding-left: 0 !important;
}
.sh-title-input:focus { box-shadow: none !important; border-bottom-color: var(--sh-primary) !important; }
.sh-content-editor {
  font-family: var(--sh-font-serif);
  font-size: 1rem;
  resize: vertical;
  line-height: 1.75;
  border: none !important;
  padding: 1rem;
}
.sh-content-editor:focus { box-shadow: none !important; }
.sh-editor-toolbar { background: var(--sh-bg); }
.sh-toolbar-btn { padding: .2rem .45rem; font-size: .8rem; }
.sh-toolbar-sep { width: 1px; background: var(--sh-border); height: 24px; align-self: center; margin: 0 .25rem; }

/* Sticky sidebar */
@media (min-width: 992px) {
  .sh-sticky-sidebar { position: sticky; top: 80px; }
}

/* Gallery admin */
.sh-gallery-item { cursor: pointer; }
.sh-gallery-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity var(--sh-transition);
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: .5rem;
  border-radius: .5rem;
}
.sh-gallery-item:hover .sh-gallery-overlay { opacity: 1; }

/* Category dot */
.sh-cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* Settings tabs */
.sh-settings-tabs .nav-link { border-radius: .75rem .75rem 0 0; color: var(--sh-text-muted); }
.sh-settings-tabs .nav-link.active { color: var(--sh-primary); font-weight: 600; }

/* Btn read */
.sh-btn-read { border-radius: 2rem; padding: .7rem 1.6rem; font-weight: 600; touch-action: manipulation; }

/* ---------- Dark mode card overrides ---------- */
[data-bs-theme="dark"] .card { background: var(--sh-bg-card) !important; }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #0f172a;
  border-color: var(--sh-border);
  color: var(--sh-text);
}
[data-bs-theme="dark"] .input-group-text { background: #1e293b; border-color: var(--sh-border); color: var(--sh-text-muted); }
[data-bs-theme="dark"] .table { color: var(--sh-text); }
[data-bs-theme="dark"] .sh-editor-toolbar { background: #0f172a; }
[data-bs-theme="dark"] .sh-content-editor { background: var(--sh-bg-card); color: var(--sh-text); }
[data-bs-theme="dark"] .sh-login-input { background: #0f172a !important; color: var(--sh-text) !important; }
[data-bs-theme="dark"] .sh-tts-player { background: var(--sh-bg-card) !important; }

/* ---------- Responsive — Tablet & below (≤991px) ---------- */
@media (max-width: 991.98px) {
  .sh-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--sh-shadow-lg);
  }
  .sh-sidebar.open { transform: translateX(0); }

  .sh-admin-content { margin-left: 0; }
  .sh-sidebar-toggle { display: flex !important; }
  .sh-admin-page { padding: 1.1rem 1rem; }

  .sh-admin-topbar { padding: .6rem 1rem; }

  /* Stack TTS controls on tablet */
  .sh-tts-player .d-flex.flex-wrap { gap: .5rem !important; }
}

/* ---------- Responsive — Mobile (≤767px) ---------- */
@media (max-width: 767.98px) {
  .sh-hero-card .row { flex-direction: column; }

  .sh-post-title { font-size: clamp(1.45rem, 6vw, 1.9rem); }

  .sh-meta { font-size: .75rem; gap: .5rem !important; }

  /* TTS player — stack on mobile */
  .sh-tts-player .d-flex.align-items-center.gap-3 {
    flex-direction: column;
    align-items: flex-start !important;
  }
  .sh-tts-icon { display: none; }
  .sh-tts-select { max-width: 100%; width: 100%; }
  .sh-tts-range { width: 90px; }

  /* Search form compact */
  .sh-search-form .input-group { border-radius: .75rem !important; }

  /* Cat header compact */
  .sh-cat-header { min-height: 120px; padding: 2rem 1.25rem !important; }

  /* Footer compact */
  .sh-footer { padding: 1.75rem 0 1rem; }

  /* Admin table — scroll */
  .sh-admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sh-admin-table { min-width: 580px; }
}

/* ---------- Responsive — Small mobile (≤575px) ---------- */
@media (max-width: 575.98px) {
  .sh-card-img { height: 150px; }
  .sh-gallery-thumb { height: 100px; }

  /* Prev/Next nav — stack */
  .sh-post-nav .col-6 { width: 100% !important; }
  .sh-post-nav .offset-6 { margin-left: 0 !important; }

  /* Share row — tighter */
  .sh-share { gap: .4rem !important; }

  /* Pagination — tighter */
  .sh-pagination .page-link { padding: .35rem .65rem; font-size: .8rem; }

  .sh-admin-topbar { padding: .5rem .75rem; }
  .sh-admin-topbar .btn-sm { font-size: .78rem; padding: .35rem .7rem; }

  /* Navbar brand tagline hidden — save space */
  .sh-brand-tag { display: none !important; }
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sh-post-card, .sh-stat-card, .sh-hero-card {
  animation: fadeInUp .35s ease both;
}
.sh-post-card:nth-child(2) { animation-delay: .05s; }
.sh-post-card:nth-child(3) { animation-delay: .10s; }
.sh-post-card:nth-child(4) { animation-delay: .15s; }
.sh-post-card:nth-child(5) { animation-delay: .20s; }

/* ---------- Scrollbar (webkit) ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sh-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--sh-text-muted); }

/* ---------- Touch / tap improvements ---------- */
a, button, [role="button"], input[type="submit"], input[type="button"] {
  touch-action: manipulation;
}

/* ============================================================
   AI Features — V4
   ============================================================ */

/* ---------- Sidebar section label ---------- */
.sh-sidebar-section-label {
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--sh-sidebar-text);
  opacity: .45;
  padding: 1rem 1.1rem .3rem;
  user-select: none;
}

/* ---------- btn-xs ---------- */
.btn-xs {
  padding: .2rem .55rem;
  font-size: .72rem;
  line-height: 1.4;
  border-radius: .35rem;
}

/* ---------- AI Writing Assistant Panel ---------- */
.sh-ai-panel {
  position: fixed;
  top: 0; right: -480px;
  width: 460px;
  max-width: 96vw;
  height: 100vh;
  background: var(--sh-bg-card);
  border-left: 1px solid var(--sh-border);
  box-shadow: -8px 0 40px rgba(0,0,0,.14);
  z-index: 1060;
  display: flex;
  flex-direction: column;
  transition: right .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.sh-ai-panel.open { right: 0; }

.sh-ai-panel-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--sh-border);
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(79,70,229,.06), rgba(6,182,212,.04));
}
.sh-ai-panel-header h5 {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  color: var(--sh-primary);
  flex: 1;
}

.sh-ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.sh-ai-panel-footer {
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--sh-border);
  flex-shrink: 0;
  background: var(--sh-bg-card);
}

/* Panel backdrop */
.sh-ai-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1055;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.sh-ai-panel-backdrop.show {
  opacity: 1;
  pointer-events: all;
}

/* ---------- Skeleton loader ---------- */
.sh-ai-skeleton {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: .75rem 0;
}
.sh-skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--sh-border) 25%, rgba(255,255,255,.45) 50%, var(--sh-border) 75%);
  background-size: 200% 100%;
  animation: sh-shimmer 1.4s infinite;
}
.sh-skeleton-line.w-full  { width: 100%; }
.sh-skeleton-line.w-3\/4  { width: 75%; }
.sh-skeleton-line.w-2\/3  { width: 66%; }
.sh-skeleton-line.w-1\/2  { width: 50%; }
.sh-skeleton-line.w-1\/3  { width: 33%; }
.sh-skeleton-img {
  width: 100%;
  height: 180px;
  border-radius: .75rem;
  background: linear-gradient(90deg, var(--sh-border) 25%, rgba(255,255,255,.45) 50%, var(--sh-border) 75%);
  background-size: 200% 100%;
  animation: sh-shimmer 1.4s infinite;
}

@keyframes sh-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

[data-bs-theme="dark"] .sh-skeleton-line,
[data-bs-theme="dark"] .sh-skeleton-img {
  background: linear-gradient(90deg, #334155 25%, #3f4f66 50%, #334155 75%);
  background-size: 200% 100%;
  animation: sh-shimmer 1.4s infinite;
}

/* ---------- AI result box ---------- */
.sh-ai-result-box {
  border: 1px solid var(--sh-border);
  border-radius: .75rem;
  overflow: hidden;
}
.sh-ai-result-toolbar {
  background: var(--sh-bg);
  border-bottom: 1px solid var(--sh-border);
  padding: .45rem .75rem;
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
}
.sh-ai-pre {
  margin: 0;
  padding: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sh-font-body);
  font-size: .85rem;
  line-height: 1.65;
  color: var(--sh-text);
  max-height: 320px;
  overflow-y: auto;
  background: var(--sh-bg-card);
}

/* ---------- AI side-by-side compare ---------- */
.sh-ai-compare-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 767.98px) {
  .sh-ai-compare-box { grid-template-columns: 1fr; }
}
.sh-ai-compare-box .sh-compare-col {
  border: 1px solid var(--sh-border);
  border-radius: .75rem;
  overflow: hidden;
}
.sh-ai-compare-col-header {
  padding: .45rem .75rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--sh-border);
}
.sh-compare-col-original .sh-ai-compare-col-header {
  background: rgba(100,116,139,.08);
  color: var(--sh-text-muted);
}
.sh-compare-col-suggestion .sh-ai-compare-col-header {
  background: rgba(79,70,229,.07);
  color: var(--sh-primary);
}
.sh-ai-compare-pre {
  padding: .75rem;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sh-font-body);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--sh-text);
  max-height: 360px;
  overflow-y: auto;
  background: var(--sh-bg-card);
}

/* ---------- AI Image results grid ---------- */
.sh-ai-img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
}
.sh-ai-img-result {
  border-radius: .75rem;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
  position: relative;
  background: var(--sh-border);
}
.sh-ai-img-result:hover { border-color: var(--sh-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.18); }
.sh-ai-img-result img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.sh-ai-img-result-actions {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: .4rem;
  background: linear-gradient(0deg, rgba(0,0,0,.65) 0%, transparent 100%);
  display: flex;
  gap: .3rem;
  opacity: 0;
  transition: opacity .2s;
}
.sh-ai-img-result:hover .sh-ai-img-result-actions { opacity: 1; }

/* ---------- AI Media Library grid cards ---------- */
.sh-ai-media-card { transition: box-shadow .2s, transform .2s; }
.sh-ai-media-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.13) !important; transform: translateY(-2px); }

.sh-ai-media-thumb {
  width: 100%;
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  background-color: var(--sh-border);
}
.sh-ai-media-missing {
  background-color: var(--sh-bg);
}

/* ---------- Toast notifications ---------- */
.sh-toast-wrap {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.sh-toast {
  padding: .65rem 1rem;
  border-radius: .65rem;
  font-size: .82rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
  opacity: 0;
  transform: translateY(10px) scale(.97);
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  max-width: 320px;
  word-break: break-word;
}
.sh-toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.sh-toast-success { background: #16a34a; }
.sh-toast-error   { background: #dc2626; }
.sh-toast-info    { background: var(--sh-primary); }
.sh-toast-warning { background: #d97706; }

/* ---------- AI action selector optgroup styling ---------- */
.sh-ai-action-select optgroup { font-size: .8rem; }

/* ---------- AI panel label + hint ---------- */
.sh-ai-input-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--sh-text);
  margin-bottom: .25rem;
}
.sh-ai-input-hint {
  font-size: .72rem;
  color: var(--sh-text-muted);
  margin-top: .2rem;
}

/* ---------- Dark mode overrides for AI panel ---------- */
[data-bs-theme="dark"] .sh-ai-panel {
  background: var(--sh-bg-card);
  border-left-color: var(--sh-border);
  box-shadow: -8px 0 40px rgba(0,0,0,.45);
}
[data-bs-theme="dark"] .sh-ai-panel-header {
  background: linear-gradient(135deg, rgba(79,70,229,.1), rgba(6,182,212,.06));
}
[data-bs-theme="dark"] .sh-ai-result-toolbar { background: var(--sh-bg); }
[data-bs-theme="dark"] .sh-ai-pre,
[data-bs-theme="dark"] .sh-ai-compare-pre  { background: var(--sh-bg-card); color: var(--sh-text); }
[data-bs-theme="dark"] .sh-ai-media-thumb  { background-color: var(--sh-border); }

/* ---------- Responsive — AI panel on small screens ---------- */
@media (max-width: 575.98px) {
  .sh-ai-panel { width: 100vw; right: -100vw; }
  .sh-ai-panel.open { right: 0; }
  .sh-ai-img-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- AI Settings tab styles ---------- */
.sh-ai-key-wrap { position: relative; }
.sh-ai-key-wrap .sh-ai-key-toggle {
  position: absolute;
  right: .5rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--sh-text-muted);
  cursor: pointer;
  padding: .25rem .35rem;
  line-height: 1;
  z-index: 5;
}
.sh-ai-key-wrap .sh-ai-key-toggle:hover { color: var(--sh-primary); }
.sh-ai-key-wrap input { padding-right: 2.4rem; }

/* AI aspect-ratio presets */
.sh-aspect-presets { display: flex; gap: .35rem; flex-wrap: wrap; }
.sh-aspect-presets .btn { font-size: .72rem; padding: .2rem .55rem; border-radius: .4rem; }

/* AI feature badge */
.sh-ai-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .68rem; font-weight: 700;
  padding: .18rem .55rem;
  border-radius: 2rem;
  background: linear-gradient(135deg, var(--sh-primary), var(--sh-accent));
  color: #fff;
  letter-spacing: .03em;
  white-space: nowrap;
}

/* ---------- Inline AI generate buttons in post editor ---------- */
.sh-ai-inline-btn {
  font-size: .72rem;
  color: var(--sh-primary);
  text-decoration: none;
  white-space: nowrap;
  opacity: .85;
}
.sh-ai-inline-btn:hover { opacity: 1; color: var(--sh-primary); }
.sh-ai-inline-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Reading progress bar ---------- */
.sh-reading-progress {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--sh-primary), var(--sh-accent));
  z-index: 9999;
  transition: width .1s linear;
  border-radius: 0 2px 2px 0;
}

/* ---------- Scroll-to-top button ---------- */
.sh-back-top {
  position: fixed;
  bottom: 2rem; right: 2rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--sh-primary);
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .25s, transform .25s;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(79,70,229,.35);
}
.sh-back-top.show { opacity: 1; transform: translateY(0); }
.sh-back-top:hover { background: var(--sh-primary-dark); }

/* ---------- Card reveal animation ---------- */
@keyframes sh-fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sh-reveal {
  opacity: 0;
}
.sh-reveal.sh-revealed {
  animation: sh-fadeInUp .45s ease forwards;
}

/* ---------- Enhanced post card ---------- */
.sh-post-card {
  position: relative;
}
.sh-post-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--sh-radius);
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow .2s;
  pointer-events: none;
}
.sh-post-card:hover::after {
  box-shadow: 0 0 0 2px var(--sh-primary);
}

/* ---------- Enhanced featured image on post page ---------- */
.sh-featured-img {
  position: relative;
  border-radius: 1.25rem;
  overflow: hidden;
  margin-bottom: 2rem;
}
.sh-featured-img img {
  max-height: 520px;
  width: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}

/* ---------- Post page header improvements ---------- */
.sh-post-hero {
  position: relative;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--sh-border);
}
.sh-post-title {
  font-family: var(--sh-font-serif);
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.01em;
}

/* ---------- Excerpt lead styling ---------- */
.sh-excerpt {
  color: var(--sh-text-muted);
  font-size: 1.1rem;
  line-height: 1.75;
  font-style: italic;
  border-left: 3px solid var(--sh-primary);
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}

/* ---------- Post content enhanced typography ---------- */
.sh-post-content {
  font-size: clamp(1.02rem, 2vw, 1.12rem);
  line-height: 1.9;
}
.sh-post-content > p:first-of-type {
  font-size: 1.08em;
  color: var(--sh-text);
}
.sh-post-content h2 {
  padding-top: 1rem;
  border-top: 1px solid var(--sh-border);
  margin-top: 2.5rem;
}
.sh-post-content blockquote {
  font-size: 1.05em;
}
.sh-post-content img {
  box-shadow: var(--sh-shadow);
}

/* ---------- Breadcrumb ---------- */
.sh-breadcrumb .breadcrumb-item a {
  color: var(--sh-text-muted);
  text-decoration: none;
  font-size: .82rem;
}
.sh-breadcrumb .breadcrumb-item a:hover { color: var(--sh-primary); }
.sh-breadcrumb .breadcrumb-item.active { font-size: .82rem; }

/* ---------- Prev/Next post navigation ---------- */
.sh-post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--sh-border);
}
.sh-post-nav-card {
  background: var(--sh-bg-card);
  border-radius: .85rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--sh-text);
  border: 1px solid var(--sh-border);
  transition: border-color .2s, box-shadow .2s;
  display: block;
}
.sh-post-nav-card:hover {
  border-color: var(--sh-primary);
  box-shadow: var(--sh-shadow);
  color: var(--sh-text);
}
.sh-post-nav-label { font-size: .7rem; font-weight: 600; color: var(--sh-text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
.sh-post-nav-title { font-size: .9rem; font-weight: 600; line-height: 1.4; }

/* ---------- Dark mode reading tweaks ---------- */
[data-bs-theme="dark"] .sh-post-content h2 {
  border-top-color: var(--sh-border);
}
[data-bs-theme="dark"] .sh-post-content blockquote {
  background: rgba(99,102,241,.08);
}
[data-bs-theme="dark"] .sh-featured-img img {
  opacity: .92;
}

/* ---------- Hero section gradient overlay option ---------- */
.sh-hero-gradient {
  background: linear-gradient(135deg, rgba(79,70,229,.06) 0%, rgba(6,182,212,.04) 100%);
  border-radius: 1.5rem;
  padding: 2.5rem;
  margin-bottom: 2rem;
}

/* ---------- Inline content images ---------- */
.sh-post-content figure.sh-inline-image,
.sh-content figure.sh-inline-image {
  margin: 1.75rem 0;
  text-align: center;
}
.sh-post-content figure.sh-inline-image img,
.sh-content figure.sh-inline-image img {
  max-width: 100%;
  height: auto;
  border-radius: .5rem;
  box-shadow: 0 4px 18px rgba(0,0,0,.10);
}
.sh-post-content figure.sh-inline-image figcaption,
.sh-content figure.sh-inline-image figcaption {
  margin-top: .5rem;
  font-size: .82rem;
  color: #6c757d;
  font-style: italic;
}
/* Content image inserted as plain <img> */
.sh-post-content img.sh-content-img,
.sh-content img.sh-content-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  border-radius: .5rem;
  box-shadow: 0 4px 18px rgba(0,0,0,.08);
}

/* ---------- Mobile adjustments ---------- */
@media (max-width: 575.98px) {
  .sh-back-top { bottom: 1.25rem; right: 1.25rem; }
  .sh-post-nav { grid-template-columns: 1fr; }
  .sh-post-hero .sh-post-title { font-size: 1.6rem; }
}
