/* ========================================
   Platform - Modern Dark Theme
   Single source of truth for colors, spacing, components
   ======================================== */

:root {
  /* Core dark palette */
  --bg-primary: #0E0E0E;
  --bg-secondary: #1A1A1A;
  --bg-tertiary: #292929;
  --bg-elevated: #252525;

  --border: #555;
  --border-strong: #666;

  --text-primary: #E5E5E5;
  --text-secondary: #CCCCCC;
  --text-muted: #AAAAAA;
  --text-inverse: #000;

  --accent: #4a76a8;
  --accent-hover: #3a5f8a;

  --danger: #c33;
  --success: #4a7c4a;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-base: 0.95rem;
  --font-size-sm: 0.85rem;
  --font-size-xs: 0.75rem;

  /* Components */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --transition-fast: 0.1s ease;
}

/* Base reset & body */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

/* Links */
a {
  color: var(--text-primary);
  text-decoration: none;
}
a:hover {
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: #4E4E4E;
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  font-size: var(--font-size-base);
  transition: background var(--transition-fast);
}
.btn:hover {
  background: #454545;
}
.btn-secondary {
  background: #3F3F3F;
}
.btn-secondary:hover {
  background: #353535;
}

/* Cards & containers */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  border: 1px solid #555;
}

.post-card {
  background: var(--bg-elevated);
  border: 1px solid #555;
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

/* Forms */
form label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

input[type="file"] {
  max-width: 100%;
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form textarea,
input[type="number"] {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #555;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-base);
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Alerts */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }

.flex { display: flex; }
.gap-2 { gap: var(--space-sm); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Wall / Posts specific (migrated from inline) */
.wall-header {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-strong);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.post-header {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  border-bottom: 1px solid #555;
}

.post-avatar {
  width: 32px;
  height: 32px;
  background: #444;
  color: #aaa;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  margin-right: var(--space-sm);
}

.post-content {
  padding: var(--space-sm) var(--space-md);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.media-container {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
}

/* Media items on wall - reduces massive inline styles */
.media-item {
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  background: #000;
  position: relative;
}

.media-item img,
.media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-item video {
  opacity: 0.8;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0,0,0,0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

/* Size variants (used instead of per-element inline width/height) */
.media-item.size-single,
.media-item.size-2-3,
.media-item.size-4,
.media-item.size-many {
  /* base container sizing */
}

.media-item.size-single {
  max-width: 100%;
  max-height: 640px;
}

.media-item.size-2-3 {
  max-width: 620px;
  max-height: 620px;
}

.media-item.size-4 {
  max-width: 340px;
  max-height: 340px;
}

.media-item.size-many {
  max-width: 260px;
  max-height: 260px;
}

/* Prevent descendant height:100% from fighting size classes on direct img usage */
.media-item.size-single img,
.media-item.size-2-3 img,
.media-item.size-4 img,
.media-item.size-many img {
  height: auto;
}

/* Single image special centering */
.media-single-wrapper {
  width: 100%;
  text-align: center;
}

/* Wall post action bar */
.post-actions {
  display: flex;
  border-top: 1px solid #555;
  font-size: 13px;
  color: #aaa;
}

/* Comment form on wall */
.comment-form {
  display: flex;
  border-top: 1px solid #555;
  padding: 6px 10px;
  background: #252525;
}

.post-comments {
  background: #252525;
  padding: 8px 12px;
  font-size: 13px;
  color: #ddd;
}

.comment-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #555;
  color: #e5e5e5;
  padding: 4px 8px;
  font-size: 13px;
}

.comment-submit {
  margin-left: 6px;
  padding: 4px 12px;
  font-size: 13px;
}

/* Prevent horizontal scroll from 100vw / wide children on mobile */
html {
  overflow-x: clip;
}

body {
  overflow-x: clip;
  max-width: 100%;
}

/* Manga reader simple layout */
.reader-container {
  max-width: 1280px;
  margin: 0 auto;
}

.reader-header {
  background: #1f1f1f;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #353535;
  font-size: 0.9rem;
}

.reader-progress {
  width: 180px;
  height: 3px;
  background: #292929;
  border-radius: 2px;
  overflow: hidden;
  margin-left: 12px;
}

.reader-progress-bar {
  height: 100%;
  background: #4E4E4E;
  width: 0%;
  transition: width 0.1s ease;
}

.reader-thumbs {
  background: #1a1a1a;
  padding: 0.5rem;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  border-top: 1px solid #353535;
}

.reader-thumb {
  height: 60px;
  width: auto;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Manga reader viewer - core container (JS zoom/pan still needs some inline for transform) */
.reader-viewer {
  position: relative;
  background: #0a0a0a;
  min-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

.reader-viewer > .zoom-wheel-lock {
  z-index: 5;
}

.reader-page-img {
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
}

.reader-thumbs {
  background: #1a1a1a;
  padding: 0.5rem;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  border-top: 1px solid #353535;
  -webkit-overflow-scrolling: touch;
}

.reader-thumb {
  height: 60px;
  width: auto;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

.reader-thumb-active {
  border-color: #4E4E4E !important;
}

.zoom-viewport {
  touch-action: none;
}

.zoom-viewport.zoom-active {
  cursor: grab;
}

.zoom-viewport.zoom-grabbing {
  cursor: grabbing;
}

/* Wheel zoom lock — bottom-left, semi-transparent */
.zoom-wheel-lock {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 12;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
  transition: opacity 0.2s, background 0.2s, border-color 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.zoom-wheel-lock:hover,
.zoom-wheel-lock:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.62);
  border-color: rgba(255, 255, 255, 0.35);
  outline: none;
}

.zoom-wheel-lock.zoom-lock-active {
  color: rgba(255, 255, 255, 0.95);
}

.zoom-wheel-lock:not(.zoom-lock-active) {
  color: #7dd3fc;
  border-color: rgba(125, 211, 252, 0.4);
}

/* Click zones for page navigation (disabled on zoom via JS) */
.reader-click-zone {
  position: absolute;
  top: 0;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}

.reader-click-prev {
  left: 0;
  width: 25%;
}

.reader-click-next {
  right: 0;
  width: 25%;
}

/* Site header */
.site-header {
  background: var(--bg-tertiary);
  padding: 0.8rem 1.5rem;
  flex-wrap: wrap;
}

.site-header a {
  color: var(--text-primary);
}

.site-nav {
  flex: 1;
}

/* Tiny utility for remaining text tweaks (to be removed later) */
.text-emphasis {
  font-weight: 500;
}

.reader-topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.reader-topnav-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-topnav-actions {
  display: flex;
  gap: 0.4rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
}

.reader-fullscreen-btn {
  display: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  font-size: 1.1rem;
  line-height: 1;
}

.reader-card {
  padding: 0;
  overflow: hidden;
  background: #111;
}

.post-action {
  flex: 1;
  text-align: center;
  padding: 8px 0;
}

.post-action + .post-action {
  border-left: 1px solid var(--border);
}

.post-action button,
.post-action a {
  width: 100%;
  padding: 8px 0;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

/* Wall specific create button */
.wall-create-btn {
  background: #4a76a8;
  color: white;
  padding: 6px 16px;
  font-size: 13px;
  text-decoration: none;
  border-radius: 2px;
  font-weight: 500;
}

/* Wall pagination */
.wall-pagination {
  text-align: center;
  margin: 15px 0;
  font-size: 13px;
  color: #888;
}

.wall-pagination a {
  color: #4a76a8;
}



/* Responsive container */
.main-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Homepage / accounts home */
.home-card {
  max-width: 800px;
  margin: 0 auto;
}

.home-notice {
  background: #252525;
  border: 1px solid #555;
  padding: 0.8rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #ddd;
}

.home-title {
  margin-bottom: 0.3rem;
  font-size: 2rem;
}

.home-subtitle {
  color: #888;
  margin-bottom: 1.5rem;
}

.home-info {
  background: #2a2a2a;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  border: 1px solid #555;
}

.home-section-title {
  margin-bottom: 0.8rem;
  color: #ddd;
}

.home-grid {
  display: grid;
  gap: 0.8rem;
}

.home-link {
  display: block;
  padding: 0.8rem 1rem;
  background: #252525;
  border: 1px solid #555;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}

.home-link:hover {
  background: #2a2a2a;
  border-color: #666;
}

.home-link-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: #e5e5e5;
}

.home-link-desc {
  color: #aaa;
  font-size: 0.85rem;
}

.home-footer {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

/* ========================================
   Lightbox v2 - Viewport-based zoom/pan
   ======================================== */

/* Lightbox container - fixed to viewport */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  outline: none;
}

.lightbox-overlay[aria-hidden="false"] {
  display: flex;
}

.lightbox-container {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.lightbox-container > .zoom-wheel-lock {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 15;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    outline: none;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: auto;
    will-change: transform;
    cursor: pointer;
    transform-origin: center;
 }

.lightbox-video {
  max-width: 90vw;
  max-height: 90vh;
  background: #000;
  border-radius: 4px;
  outline: none;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s;
}

.lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.7);
}

.lightbox-nav.prev {
  left: 16px;
}

.lightbox-nav.next {
  right: 16px;
}

.lightbox-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #aaa;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 12px;
  z-index: 10;
}

.lightbox-preloader {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid #454545;
  border-top-color: #E5E5E5;
  border-radius: 50%;
  animation: lightboxSpin 0.8s linear infinite;
  z-index: 5;
}

@keyframes lightboxSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.lightbox-grab {
  cursor: grab !important;
}

.lightbox-grabbing {
  cursor: grabbing !important;
}

.lightbox-zoomed {
  cursor: grab !important;
}

.lightbox-zoomed.lightbox-grabbing {
  cursor: grabbing !important;
}

/* ========================================
   Profile page — modern, professional dark interface
   Clean, spacious, high-quality feel (matches PLATFORM CORE)
   ======================================== */

.profile-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: #e5e5e5;
}

/* Header */
.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid #2a2a2a;
}

@media (max-width: 640px) {
  .profile-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

.profile-avatar {
  font-size: 48px;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1f1f1f;
  border-radius: 9999px;
  border: 3px solid #2a2a2a;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.profile-user-info h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: #f0f0f0;
  margin: 0 0 6px 0;
  letter-spacing: -0.4px;
  line-height: 1.1;
}

.profile-user-info .profile-meta {
  font-size: 0.95rem;
  color: #888;
  font-weight: 400;
}

/* Stats Grid - professional cards */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}

/* Sections */
.profile-section {
  margin-bottom: 36px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.section-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #d0d0d0;
  margin: 0;
  letter-spacing: -0.2px;
}

.section-link {
  font-size: 0.85rem;
  color: #4a9eff;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.section-link:hover {
  color: #6eb3ff;
  text-decoration: underline;
}

/* Recent Posts */
.recent-posts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recent-post {
  background: #1a1a1a;
  border: 1px solid #2f2f2f;
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 0.94rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.recent-post:hover {
  border-color: #3a3a3a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.recent-post .post-meta {
  color: #777;
  font-size: 0.8rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.recent-post .post-content {
  white-space: pre-wrap;
  line-height: 1.5;
  color: #d4d4d4;
  margin-bottom: 8px;
}

.recent-post .post-stats {
  font-size: 0.8rem;
  color: #666;
  display: flex;
  gap: 12px;
}

/* Actions */
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0 20px;
}

.profile-actions .btn {
  padding: 10px 20px;
  font-size: 0.92rem;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.profile-actions .btn-primary {
  background: #2563eb;
  color: white;
  border: none;
}

.profile-actions .btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.profile-actions .btn-secondary {
  background: #2a2a2a;
  color: #ddd;
  border: 1px solid #3a3a3a;
}

.profile-actions .btn-secondary:hover {
  background: #333;
  border-color: #4a4a4a;
}

/* Verified badge */
.profile-verified {
  font-size: 0.85rem;
  color: #666;
  padding-top: 16px;
  border-top: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive tweaks */
@media (max-width: 480px) {
  .profile-page {
    padding: 20px 12px;
  }
  
  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-value {
    font-size: 1.65rem;
  }
  
  .recent-post {
    padding: 14px 15px;
  }
}

/* Create post page */
.create-post-container {
  max-width: 600px;
  margin: 0 auto;
}

.create-post-form {
  background: #1a1a1a;
  padding: 1.25rem;
  border-radius: 8px;
  border: 1px solid #333;
}

.upload-progress {
  display: none;
  margin-top: 12px;
}

.upload-progress-text {
  font-size: 13px;
  color: #aaa;
  margin-bottom: 4px;
}

.upload-progress-bar {
  background: #2a2a2a;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-inner {
  background: #3498db;
  height: 100%;
  width: 0%;
  animation: uploadProgress 1.5s infinite linear;
}

@keyframes uploadProgress {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* Manga list grid */
.manga-list-container {
  max-width: 900px;
  margin: 0 auto;
}

.manga-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.manga-card {
  background: #1A1A1A;
  border: 1px solid #353535;
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}

.manga-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.manga-card .no-cover {
  width: 100%;
  height: 200px;
  background: #292929;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #707070;
  font-size: 0.9rem;
}

.manga-card .info {
  padding: 0.6rem 0.7rem;
}

.manga-card .title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  color: #E5E5E5;
  margin-bottom: 0.2rem;
}

.manga-card .meta {
  font-size: 0.75rem;
  color: #B0B0B0;
}

/* Manga detail page */
.manga-detail {
  max-width: 700px;
  margin: 0 auto;
}

.manga-detail-header {
  margin-bottom: 1rem;
}

.manga-detail-cover {
  width: 140px;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.manga-detail-info {
  flex: 1;
}

.manga-detail-title {
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

.manga-detail-description {
  margin: 0.8rem 0;
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.manga-chapters {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.manga-chapter-link {
  display: flex;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.manga-chapter-link:last-child {
  border-bottom: none;
}

/* Reader bottom controls and help text */
.reader-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 6px 0;
  opacity: 0.4;
}

.reader-help-text {
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.8rem;
  color: #707070;
}

/* Keyboard help overlay (manga reader) */
#keyboard-help {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1A1A1A;
  border: 1px solid #353535;
  border-radius: 8px;
  padding: 16px 20px;
  z-index: 10000;
  min-width: 320px;
  max-width: calc(100vw - 2rem);
  color: #E5E5E5;
  font-size: 0.9rem;
}

/* ========================================
   Site-wide mobile / responsive polish
   ======================================== */
@media (max-width: 768px) {
  main.moner-main,
  main {
    padding: 0.75rem 0.5rem !important;
    margin-top: 0.5rem !important;
  }

  main:has(.wide-page),
  main:has(.gallery-layout) {
    padding: 0.75rem 0.5rem !important;
  }

  .card,
  .moner-card {
    padding: 1rem !important;
    border-radius: 6px;
  }

  .btn {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
  }

  form input[type="text"],
  form input[type="email"],
  form input[type="password"],
  form input[type="search"],
  form textarea,
  select {
    font-size: 16px !important;
  }

  .reader-viewer {
    min-height: 65dvh;
  }

  .reader-click-prev,
  .reader-click-next {
    width: 22%;
  }

  .reader-thumb {
    height: 48px;
  }

  .reader-help-text {
    font-size: 0.72rem;
    padding: 0 0.25rem;
  }

  .reader-topnav {
    gap: 0.35rem;
    flex-wrap: nowrap;
  }

  .reader-topnav-title {
    font-size: 0.85rem;
  }

  .reader-fullscreen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .reader-controls {
    gap: 8px;
    opacity: 0.85;
  }

  .reader-controls .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem 0.9rem;
  }

  .zoom-wheel-lock {
    left: calc(10px + env(safe-area-inset-left, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
  }

  .lightbox-close {
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  #lightbox-like-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .lightbox-nav.prev { left: 8px; }
  .lightbox-nav.next { right: 8px; }

  .lightbox-image {
    max-width: 96vw;
    max-height: 82dvh;
  }

  .lightbox-counter {
    bottom: 10px;
    font-size: 12px;
  }

  .manga-detail-header {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
    gap: 16px !important;
  }

  .manga-detail-cover,
  .manga-detail-header img {
    width: 160px !important;
    height: 220px !important;
  }

  .profile-page {
    padding: 20px 12px;
  }

  .paywall-box {
    padding: 1.25rem;
  }

  .home-title {
    font-size: 1.5rem;
  }

  .wall-box {
    min-width: 0 !important;
    width: 100%;
  }

  .banner-placeholder {
    height: 220px;
    min-height: 180px;
  }
}

@media (max-width: 480px) {
  .reader-viewer {
    min-height: 58dvh;
  }

  .reader-help-text {
    display: none;
  }

  #keyboard-help {
    min-width: 0;
    width: calc(100% - 1.5rem);
    max-width: calc(100vw - 1.5rem);
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)) 14px;
    font-size: 0.82rem;
  }
}
