:root {
  --bg: #07070a;
  --bg-deep: #111118;
  --ink: #f5f5f7;
  --ink-soft: #a1a1aa;
  --panel: rgba(18, 18, 25, 0.9);
  --line: rgba(255, 255, 255, 0.09);
  --accent: #e85d3d;
  --accent-deep: #ff8a65;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 24px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(232, 93, 61, 0.16), transparent 24%),
    linear-gradient(180deg, #141419 0%, #0c0c10 46%, #07070a 100%);
  color: var(--ink);
}

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

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea {
  font: inherit;
}

.site-header,
.reader-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
  background: rgba(10, 10, 13, 0.82);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand {
  font-weight: 900;
  letter-spacing: -0.05em;
  font-size: 19px;
}

.admin-link,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.shell,
.admin-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 72px;
}

.hero {
  padding: 24px 2px 22px;
}

.home-hero {
  padding-top: 30px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-deep);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 800;
}

.hero h1 {
  margin: 0 0 14px;
  max-width: 720px;
  font-size: clamp(38px, 9vw, 74px);
  line-height: 0.92;
  letter-spacing: -0.07em;
}

.hero p {
  margin: 0;
  max-width: 680px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.55;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-stats span {
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  font-size: 13px;
}

.hero-stats b {
  color: var(--ink);
}

.comic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.comic-card,
.admin-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pro-card {
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.pro-card.is-visible {
  animation: rise-in 0.55s ease both;
}

.pro-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 75px rgba(0, 0, 0, 0.38);
}

.cover-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  background: linear-gradient(180deg, #1d1d27, #09090c);
}

.library-cover {
  aspect-ratio: 9 / 8;
}

.cover-wrap::before,
.slide::before,
.thumbs button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.05) 20%, rgba(255, 255, 255, 0.22) 42%, rgba(255, 255, 255, 0.05) 64%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  pointer-events: none;
}

.cover-wrap:has(.media-loaded)::before,
.slide:has(.media-loaded)::before,
.thumbs button:has(.media-loaded)::before {
  display: none;
}

.cover-wrap::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.media-loading {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.media-loaded {
  opacity: 1;
}

.badge,
.progress-chip {
  position: absolute;
  z-index: 2;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.badge {
  right: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff7ef;
}

.progress-chip {
  top: 12px;
  left: 12px;
  background: rgba(232, 93, 61, 0.92);
  color: #fff7ef;
}

.comic-card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.comic-card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.comic-card p,
.panel-note,
.muted-panel p,
.admin-item p,
.frames-head p,
.reader-meta p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.comic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comic-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 900;
  border: 1px solid transparent;
}

.card-button-primary {
  background: var(--accent);
  color: #fff7ef;
}

.card-button-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.1);
}

.empty-card,
.notice {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.empty-card h2 {
  margin: 0 0 8px;
}

.error-card {
  border-color: rgba(239, 68, 68, 0.28);
  color: var(--danger);
}

.notice {
  margin-bottom: 14px;
  border-color: rgba(34, 197, 94, 0.18);
  color: var(--success);
}

.reader-page {
  background: #000;
  overflow: hidden;
}

.reader-title {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: right;
}

.reader-title strong {
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}

.reader-title span {
  color: var(--ink-soft);
  font-size: 12px;
}

.reader-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 8px 8px;
  min-height: calc(100dvh - 68px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
}

.reader-shell-immersive {
  width: 100%;
  max-width: none;
  min-height: 100dvh;
  padding: 0;
  display: block;
}

.compact-meta h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.resume-banner {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 0;
  padding: 12px;
  border: 1px solid rgba(232, 93, 61, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  font-size: 13px;
}

.resume-banner-eyebrow {
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.resume-banner-title {
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.05em;
  text-align: center;
}

.resume-banner[hidden] {
  display: none !important;
}

.reader-stage-immersive .resume-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  right: auto;
  width: min(360px, calc(100vw - 24px));
  transform: translate(-50%, -50%);
  z-index: 10;
  background: rgba(10, 10, 13, 0.94);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.resume-banner.is-hidden {
  display: none;
}

.resume-banner.is-open {
  display: grid;
}

.resume-banner-text {
  min-width: 0;
  width: 100%;
  line-height: 1.35;
  text-align: center;
  color: var(--ink-soft);
}

.resume-banner-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.resume-banner button,
.admin-form button,
.danger-link,
.small-btn,
.reader-popover button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--accent);
  color: #fff7ef;
  font-weight: 800;
  cursor: pointer;
}

.resume-primary-btn,
.resume-secondary-btn {
  width: 100%;
}

.resume-dismiss-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #f5f5f7 !important;
}

.reader-progress {
  height: 4px;
  margin: 0 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.reader-progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #d68852);
  transition: width 0.2s ease;
}

.reader-stage {
  position: relative;
  min-height: 0;
  height: min(72dvh, calc(100dvh - 180px));
  background: #000;
}

.reader-stage-immersive {
  width: 100%;
  height: 100dvh;
}

.slider,
.immersive-slider {
  height: 100%;
  background: #000;
}

.slides {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-y pinch-zoom;
  background: #000;
  position: relative;
}

.slides-track {
  height: 100%;
  display: flex;
  will-change: transform;
}

.slides::-webkit-scrollbar,
.thumbs::-webkit-scrollbar {
  display: none;
}

.slide {
  flex: 0 0 100%;
  min-height: 100%;
  margin: 0;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 20px 56px;
  background: #000;
}

.slide-media {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}

.slide-media.is-zoomed {
  cursor: grab;
}

.slide-media.is-panning {
  cursor: grabbing;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 18px;
  background: #000;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.slide::after {
  content: "";
  position: absolute;
  inset: 20px 56px;
  border-radius: 18px;
  box-shadow: inset -20px 0 28px rgba(255, 255, 255, 0.05), inset 24px 0 32px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.reader-nav {
  position: absolute;
  top: 50%;
  z-index: 8;
  width: 44px;
  height: 72px;
  margin-top: -36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.62);
  color: #f5f5f7;
  font-size: 34px;
  line-height: 1;
  backdrop-filter: blur(10px);
}

.reader-nav-prev {
  left: 10px;
}

.reader-nav-next {
  right: 10px;
}

.reader-nav:disabled {
  opacity: 0.35;
}

.reader-zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 8;
  display: flex;
  gap: 8px;
}

.reader-zoom-controls button {
  min-width: 46px;
  height: 46px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.7);
  color: #f5f5f7;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.reader-zoom-controls button:disabled {
  opacity: 0.45;
}

.reader-desktop-hud {
  display: none;
}

.reader-desktop-pill {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 10, 13, 0.72);
  color: #f5f5f7;
  backdrop-filter: blur(14px);
}

.reader-hint {
  position: absolute;
  left: 12px;
  right: 70px;
  top: 12px;
  z-index: 5;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f5f5f7;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.reader-hint.is-hidden {
  opacity: 0;
}

.reader-menu-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 11;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.76);
  color: #f5f5f7;
  font-size: 24px;
  line-height: 1;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  transition: opacity 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.reader-menu-toggle-compact {
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  width: 42px;
  height: 42px;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.52);
}

.reader-page.reader-chrome-idle .reader-menu-toggle-compact,
.reader-page.reader-chrome-idle .reader-nav,
.reader-page.reader-chrome-idle .reader-zoom-controls {
  opacity: 0.2;
}

.reader-menu-toggle-compact.is-open,
.reader-page .reader-menu-toggle-compact:hover,
.reader-page .reader-menu-toggle-compact:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.82);
  transform: scale(1.02);
}

.reader-popover {
  position: absolute;
  top: 72px;
  right: 12px;
  z-index: 8;
  min-width: 220px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(10, 10, 13, 0.94);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
}

.reader-popover-compact {
  top: calc(env(safe-area-inset-top) + 56px);
  right: 10px;
  min-width: 190px;
  z-index: 12;
}

.reader-popover[hidden] {
  display: none;
}

.reader-popover button,
.reader-popover-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f7;
  font-size: 14px;
  font-weight: 700;
}

.thumbs {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
}

.thumbs button {
  position: relative;
  flex: 0 0 58px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 15px;
  overflow: hidden;
  background: #111118;
  opacity: 0.66;
  transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.thumbs button.active {
  opacity: 1;
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.94);
}

.thumbs img {
  width: 58px;
  aspect-ratio: 9 / 16;
  object-fit: cover;
}

.thumbs span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff7ef;
  font-size: 10px;
}

.reader-page.story-ui-hidden .reader-header,
.reader-page.story-ui-hidden .reader-meta,
.reader-page.story-ui-hidden .thumbs {
  display: none;
}

.reader-page.story-ui-hidden .reader-shell {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100dvh;
  padding: 0;
  gap: 0;
}

.reader-page.story-ui-hidden .reader-stage {
  height: 100dvh;
}

.reader-page.story-ui-hidden .reader-menu-toggle,
.reader-page.story-ui-hidden .reader-popover {
  position: fixed;
}

.admin-page .hero {
  padding-bottom: 18px;
}

.admin-grid-layout {
  display: grid;
  gap: 16px;
}

.admin-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-panel h2,
.frames-head h3 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 14px;
}

.dropzone {
  position: relative;
  padding: 14px;
  border: 1px dashed rgba(232, 93, 61, 0.35);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(232, 93, 61, 0.12);
}

.dropzone-copy {
  color: var(--ink);
  font-weight: 800;
}

.dropzone-hint {
  color: var(--ink-soft);
  font-size: 12px;
}

.label-title {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 14px;
}

.admin-form input,
.admin-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  outline: none;
}

.admin-form textarea {
  min-height: 108px;
  resize: vertical;
}

.upload-grid,
.upload-preview-row {
  display: grid;
  gap: 12px;
}

.cover-live-slot,
.frames-live-slot {
  display: grid;
  gap: 8px;
}

.upload-preview {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: thin;
}

.upload-preview[hidden] {
  display: none;
}

.upload-preview-item {
  flex: 0 0 78px;
  display: grid;
  gap: 6px;
}

.upload-preview-item img {
  width: 78px;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
}

.upload-preview-item span {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.25;
  word-break: break-word;
}

.admin-list {
  display: grid;
  gap: 12px;
}

.admin-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-item.active {
  border-color: rgba(232, 93, 61, 0.34);
  background: rgba(232, 93, 61, 0.08);
}

.admin-item img,
.admin-cover-empty {
  width: 64px;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 14px;
  background: #1b1b24;
}

.admin-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.15;
}

.admin-item-copy {
  min-width: 0;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-btn,
.danger-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 800;
}

.small-btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border-color: var(--line);
}

.danger-link {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.24);
}

.inline-form {
  margin: 0;
}

.cover-editor {
  display: grid;
  gap: 12px;
}

.cover-editor img,
.cover-placeholder {
  width: 120px;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink-soft);
  padding: 10px;
}

.frames-editor {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
}

.sortable-frames {
  display: grid;
  gap: 10px;
}

.frame-row {
  display: grid;
  grid-template-columns: 22px 46px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.frame-row.dragging {
  opacity: 0.5;
}

.drag-handle {
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  cursor: grab;
}

.frame-row img {
  width: 46px;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  object-fit: cover;
}

.frame-title {
  align-self: center;
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
}

.cover-flag {
  display: inline-flex;
  margin-left: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(232, 93, 61, 0.14);
  color: var(--accent-deep);
  font-size: 10px;
  font-weight: 900;
}

.frame-actions {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.frame-actions button {
  width: auto;
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.delete-check {
  display: inline-flex !important;
  align-items: center;
  gap: 6px !important;
  color: var(--danger) !important;
  font-size: 12px !important;
}

.delete-check input {
  width: auto !important;
}

.login-panel {
  max-width: 440px;
}

@media (min-width: 700px) {
  .shell,
  .admin-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .comic-grid {
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  }

  .wide-card .cover-wrap {
    aspect-ratio: 16 / 9;
  }

  .upload-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-preview-row {
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: start;
  }

  .cover-editor {
    grid-template-columns: 120px 1fr;
    align-items: end;
  }

  .admin-item {
    grid-template-columns: 70px 1fr auto;
    align-items: center;
  }

  .admin-item img,
  .admin-cover-empty {
    width: 70px;
  }

  .actions {
    grid-column: auto;
    justify-content: flex-end;
  }
}

@media (min-width: 980px) {
  .admin-grid-layout {
    grid-template-columns: minmax(0, 1fr) 420px;
    align-items: start;
  }

  .admin-editor-col {
    position: sticky;
    top: 84px;
  }

  .reader-shell {
    width: min(100%, 960px);
    display: grid;
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
    grid-template-rows: none;
    gap: 20px;
    align-items: start;
    min-height: calc(100dvh - 68px);
  }

  .reader-meta,
  .reader-progress,
  .thumbs {
    grid-column: 1;
  }

  .reader-stage {
    grid-column: 2;
    grid-row: 1 / span 4;
    height: calc(100dvh - 84px);
  }

  .reader-shell-immersive {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    display: block;
    grid-template-columns: none;
    grid-template-rows: none;
    gap: 0;
  }

  .reader-stage-immersive {
    grid-column: auto;
    grid-row: auto;
    height: 100dvh;
  }
}

@media (min-width: 641px) {
  .reader-stage-immersive {
    --desktop-reader-gutter: 28px;
    --desktop-reader-bottom-ui: 108px;
    --desktop-reader-side-ui: 84px;
  }

  .reader-shell-immersive,
  .reader-stage-immersive,
  .slider,
  .immersive-slider,
  .slides,
  .slides-track,
  .slide,
  .slide-media {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
  }

  .slide {
    padding:
      var(--desktop-reader-gutter)
      calc(var(--desktop-reader-gutter) + var(--desktop-reader-side-ui))
      var(--desktop-reader-bottom-ui);
  }

  .slide::after {
    display: none;
  }

  .slide img {
    width: auto;
    height: auto;
    border-radius: 0;
    box-shadow: none;
    max-width: calc(100vw - (var(--desktop-reader-gutter) * 2));
    max-height: calc(100dvh - var(--desktop-reader-gutter) - var(--desktop-reader-bottom-ui));
  }

  .slide-media {
    cursor: zoom-in;
    width: 100%;
    margin: 0 auto;
  }

  .reader-page.reader-zoomed .slide-media {
    cursor: grab;
  }

  .reader-nav {
    top: 50%;
    bottom: auto;
    width: 54px;
    height: 54px;
    margin-top: -27px;
    font-size: 30px;
    border-radius: 16px;
    background: rgba(14, 14, 19, 0.88);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.26);
  }

  .reader-nav-prev {
    left: 28px;
  }

  .reader-nav-next {
    left: auto;
    right: 28px;
  }

  .reader-zoom-controls {
    right: 28px;
    bottom: 22px;
    gap: 10px;
    padding: 8px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 10, 13, 0.8);
    backdrop-filter: blur(18px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  }

  .reader-zoom-controls button {
    min-width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
  }

  .reader-menu-toggle-compact {
    top: 22px;
    right: 28px;
    width: 48px;
    height: 48px;
    font-size: 20px;
    border-radius: 16px;
    background: rgba(10, 10, 13, 0.82);
  }

  .reader-popover-compact {
    top: 78px;
    right: 28px;
    min-width: 240px;
    padding: 12px;
    border-radius: 20px;
  }

  .reader-popover button,
  .reader-popover-link {
    min-height: 46px;
    border-radius: 14px;
  }

  .reader-desktop-hud {
    position: absolute;
    left: 50%;
    bottom: 22px;
    z-index: 8;
    display: grid;
    justify-items: center;
    gap: 10px;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .reader-counter-pill {
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  }

  .reader-shortcuts-pill {
    padding: 9px 14px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--ink-soft);
    white-space: nowrap;
  }

  .reader-stage-immersive .resume-banner {
    width: min(430px, calc(100vw - 64px));
    padding: 22px 22px 20px;
    justify-items: stretch;
    gap: 14px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background:
      linear-gradient(180deg, rgba(24, 24, 31, 0.98), rgba(10, 10, 14, 0.96)),
      rgba(10, 10, 13, 0.96);
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.46);
  }

  .resume-banner-eyebrow {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-align: left;
  }

  .resume-banner-title {
    font-size: 28px;
    line-height: 0.98;
    text-align: left;
  }

  .resume-banner-text {
    width: auto;
    max-width: none;
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
  }

  .resume-banner-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
  }

  .resume-banner-actions button {
    min-width: 0;
    min-height: 50px;
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 14px;
    justify-content: center;
  }

  .resume-primary-btn {
    background: linear-gradient(180deg, #f06d48, #d9512f);
    color: #fff8f2;
    box-shadow: 0 12px 24px rgba(232, 93, 61, 0.24);
  }

  .resume-secondary-btn {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f5f5f7 !important;
  }

  .reader-page.reader-chrome-idle .reader-nav,
  .reader-page.reader-chrome-idle .reader-zoom-controls,
  .reader-page.reader-chrome-idle .reader-desktop-hud,
  .reader-page.reader-chrome-idle .reader-menu-toggle-compact {
    opacity: 0.14;
  }
}

@media (max-width: 640px) {
  .reader-stage {
    height: 100dvh;
  }

  .reader-stage-immersive .resume-banner {
    top: 50%;
    left: 50%;
    right: auto;
    width: min(340px, calc(100vw - 20px));
    transform: translate(-50%, -50%);
    display: grid;
    gap: 10px;
  }

  .resume-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    justify-content: center;
  }

  .resume-banner-actions button {
    min-width: 132px;
  }

  .reader-popover-compact {
    top: calc(env(safe-area-inset-top) + 52px);
    left: 10px;
    right: 10px;
    min-width: 0;
  }

  .wide-card .cover-wrap {
    aspect-ratio: 1 / 1;
  }

  .card-actions {
    grid-template-columns: 1fr;
  }

  .reader-popover {
    left: 12px;
    right: 12px;
    min-width: 0;
  }

  .slide {
    padding: 0;
  }

  .slide::after {
    display: none;
  }

  .slide-media {
    width: 100%;
    height: 100%;
  }

  .slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .reader-nav {
    top: auto;
    bottom: 12px;
    width: 48px;
    height: 48px;
    margin-top: 0;
    font-size: 28px;
  }

  .reader-nav-prev {
    left: 12px;
  }

  .reader-nav-next {
    left: 68px;
    right: auto;
  }

  .slide img {
    border-radius: 0;
  }
}

.reader-stage:fullscreen,
.reader-stage:-webkit-full-screen {
  width: 100vw;
  height: 100dvh;
  background: #000;
  padding: 0;
}

.reader-stage:fullscreen .slider,
.reader-stage:-webkit-full-screen .slider,
.reader-stage:fullscreen .immersive-slider,
.reader-stage:-webkit-full-screen .immersive-slider,
.reader-stage:fullscreen .slides,
.reader-stage:-webkit-full-screen .slides,
.reader-stage:fullscreen .slides-track,
.reader-stage:-webkit-full-screen .slides-track,
.reader-stage:fullscreen .slide,
.reader-stage:-webkit-full-screen .slide {
  width: 100vw;
  min-width: 100vw;
  height: 100dvh;
  background: #000;
}

.reader-stage:fullscreen .slide-media,
.reader-stage:-webkit-full-screen .slide-media {
  width: 100%;
  height: 100%;
}

.reader-stage:fullscreen .slide img,
.reader-stage:-webkit-full-screen .slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.reader-stage:fullscreen .reader-menu-toggle,
.reader-stage:-webkit-full-screen .reader-menu-toggle,
.reader-stage:fullscreen .reader-popover,
.reader-stage:-webkit-full-screen .reader-popover,
.reader-stage:fullscreen .reader-nav,
.reader-stage:-webkit-full-screen .reader-nav,
.reader-stage:fullscreen .reader-zoom-controls,
.reader-stage:-webkit-full-screen .reader-zoom-controls,
.reader-stage:fullscreen .reader-hint,
.reader-stage:-webkit-full-screen .reader-hint {
  position: fixed;
}
