:root {
  --night: #0f0b28;
  --night-soft: #1b1542;
  --card: rgba(24, 18, 56, 0.82);
  --card-strong: rgba(18, 12, 43, 0.96);
  --ink: #f7f4ff;
  --muted: #c8c1e7;
  --accent: #f2545b;
  --accent-soft: #ff8b73;
  --line: rgba(255, 255, 255, 0.11);
  --shadow: 0 30px 70px rgba(5, 3, 16, 0.45);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --content-width: 1340px;
  --header-font: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --body-font: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--body-font);
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(242, 84, 91, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(255, 139, 115, 0.16), transparent 34%),
    linear-gradient(155deg, #080613 0%, #120d2d 38%, #090612 100%);
}

body.reader-mode {
  background: #000;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.comic-body {
  position: relative;
  overflow-x: hidden;
}

.comic-body.reader-mode {
  overflow: hidden;
}

.backdrop-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.06), transparent 20%),
    radial-gradient(circle at 76% 14%, rgba(242, 84, 91, 0.1), transparent 18%),
    linear-gradient(transparent 0, rgba(255, 255, 255, 0.02) 49%, transparent 50%, transparent 100%);
  background-size: auto, auto, 100% 12px;
  opacity: 0.75;
}

.comic-shell {
  position: relative;
  z-index: 1;
  width: min(100%, calc(var(--content-width) + 48px));
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.comic-body.reader-mode .comic-shell {
  width: 100%;
  max-width: none;
  padding: 0;
}

.site-header,
.hero-card,
.reader-topbar,
.book-card,
.page-stage {
  backdrop-filter: blur(18px);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 28px;
}

.brand-kicker,
.section-kicker {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.brand-block h1,
.hero-copy h2,
.section-head h2 {
  margin: 0;
  font-family: var(--header-font);
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand-block h1 {
  font-size: clamp(2.3rem, 4vw, 4.2rem);
  line-height: 0.92;
}

.site-tagline,
.reader-byline,
.hero-copy p,
.hero-note,
.section-note,
.book-description,
.book-byline {
  color: var(--muted);
}

.site-tagline {
  margin: 10px 0 0;
  max-width: 42rem;
}

.header-chip {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.page-layout {
  display: grid;
}

.library-view {
  display: grid;
  gap: 28px;
}

.hero-card,
.reader-topbar,
.page-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  gap: 28px;
  padding: 28px;
  background:
    radial-gradient(circle at right bottom, rgba(242, 84, 91, 0.22), transparent 34%),
    linear-gradient(145deg, rgba(35, 27, 80, 0.96), rgba(15, 11, 40, 0.88));
}

.hero-copy h2 {
  font-size: clamp(2rem, 3.5vw, 3.6rem);
  line-height: 0.95;
}

.hero-copy p {
  margin: 16px 0 0;
  max-width: 44rem;
  font-size: 1.04rem;
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.hero-featured-book {
  display: grid;
  gap: 16px;
  justify-items: start;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(8, 6, 19, 0.52);
}

.hero-cover {
  width: min(100%, 300px);
  aspect-ratio: 3 / 4.75;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(12, 8, 28, 0.65));
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.32);
}

.hero-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-companion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(140deg, rgba(19, 14, 44, 0.92), rgba(10, 8, 24, 0.88)),
    var(--card-strong);
}

.hero-companion-media {
  flex: 0 0 min(240px, 30vw);
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
}

.hero-companion-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-companion-copy {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
}

.hero-companion h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
}

.primary-button,
.ghost-button,
.book-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 12px 18px;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #140d23;
  font-weight: 700;
}

.ghost-button,
.book-open {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
  color: var(--ink);
}

.primary-button:hover,
.ghost-button:hover,
.book-open:hover,
.book-card:hover {
  transform: translateY(-2px);
}

.shelf-section {
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.section-head h2 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.section-note {
  margin: 0;
  max-width: 28rem;
  text-align: right;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
  gap: 22px;
}

.book-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--card);
  text-align: left;
}

.book-cover {
  position: relative;
  aspect-ratio: 3 / 4.75;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(12, 8, 28, 0.65));
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.32);
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: auto 10% -12px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  filter: blur(14px);
}

.book-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-card h3 {
  margin: 0;
  font-size: 1.5rem;
}

.book-byline,
.book-description {
  margin: 0;
  line-height: 1.5;
}

.book-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.book-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(242, 84, 91, 0.14);
  color: #ffd6d3;
  font-size: 0.9rem;
}

.reader-view {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000;
}

.reader-viewport {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.reader-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 24px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0.42), transparent);
  transition: opacity 220ms ease, transform 220ms ease;
}

.reader-view[data-dev="off"] .reader-topbar {
  display: flex;
  justify-content: flex-start;
  gap: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 0;
  background: none;
}

.reader-progress {
  min-width: 0;
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}

.reader-progress-primary,
.reader-progress-secondary,
.reader-byline {
  margin: 0;
}

.reader-progress-primary,
.reader-progress-secondary,
.scrubber-label,
#pageBrowserCount,
.reader-nav-button,
.reader-tool-button,
.loading-overlay {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reader-progress-secondary,
.reader-byline {
  color: rgba(255, 255, 255, 0.7);
}

.reader-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-view[data-dev="off"] .reader-progress,
.reader-view[data-dev="off"] .reader-actions {
  display: none;
}

.reader-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.reader-nav-button,
.reader-tool-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  backdrop-filter: blur(16px);
  white-space: nowrap;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

.reader-view[data-dev="off"] .reader-nav-button {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.72);
}

.reader-tool-button {
  min-width: 68px;
}

.reader-mode-switch .reader-tool-button {
  min-width: 0;
  border-color: transparent;
  background: transparent;
  backdrop-filter: none;
}

.reader-mode-switch .reader-tool-button:hover,
.reader-mode-switch .reader-tool-button:focus-visible {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.1);
}

.reader-mode-switch .reader-tool-button.is-active,
.reader-mode-switch .reader-tool-button[aria-pressed="true"] {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.18);
}

.reader-nav-button:hover,
.reader-tool-button:hover,
.reader-nav-button:focus-visible,
.reader-tool-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
}

.reader-tool-button[aria-pressed="true"],
.reader-tool-button.is-active {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.18);
}

.reader-view[data-chrome="hidden"] .reader-topbar {
  opacity: 0;
  transform: translateY(-14px);
  pointer-events: none;
}

.reader-view[data-browser="open"] .reader-topbar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ghost-button:disabled,
.reader-nav-button:disabled,
.reader-tool-button:disabled,
.nav-zone:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.page-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  display: block;
  padding: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #000;
  touch-action: none;
}

.page-media {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
}

.page-media img {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: auto;
  max-width: none;
  max-height: none;
  user-select: none;
  box-shadow: none;
  border-radius: 0;
  transform-origin: top left;
  transition: transform 380ms cubic-bezier(0.2, 1, 0.3, 1);
  will-change: transform;
}

.page-debug-overlay {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transform-origin: top left;
  transition:
    transform 380ms cubic-bezier(0.2, 1, 0.3, 1),
    opacity 180ms ease;
  will-change: transform, opacity;
}

.reader-view[data-dev="on"] .page-debug-overlay {
  opacity: 1;
  z-index: 6;
  pointer-events: auto;
}

.page-debug-box {
  position: absolute;
  border-radius: 20px;
  border: 2px solid rgba(116, 237, 186, 0.95);
  background: rgba(116, 237, 186, 0.1);
  box-shadow: inset 0 0 0 1px rgba(5, 10, 9, 0.28);
  cursor: pointer;
  pointer-events: none;
}

.reader-view[data-dev="on"] .page-debug-box {
  pointer-events: auto;
}

.page-debug-box.is-active {
  border-color: rgba(255, 139, 115, 0.98);
  background: rgba(242, 84, 91, 0.16);
}

.page-debug-box-label {
  position: absolute;
  top: 10px;
  left: 10px;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(5, 10, 9, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fff9;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.guided-window {
  position: absolute;
  z-index: 4;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 0 2400px rgba(0, 0, 0, 0.98),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  opacity: 0;
  pointer-events: none;
  transition:
    left 380ms cubic-bezier(0.2, 1, 0.3, 1),
    top 380ms cubic-bezier(0.2, 1, 0.3, 1),
    width 380ms cubic-bezier(0.2, 1, 0.3, 1),
    height 380ms cubic-bezier(0.2, 1, 0.3, 1),
    opacity 180ms ease,
    border-color 180ms ease;
  will-change: left, top, width, height, opacity;
}

.guided-window.is-visible {
  opacity: 1;
}

.reader-view[data-dev="on"] .guided-window {
  border-color: rgba(255, 139, 115, 0.3);
}

.nav-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 5;
  width: 24%;
  border: none;
  background: transparent;
  color: transparent;
  opacity: 0;
  transition: background 180ms ease, outline-color 180ms ease;
}

.nav-zone-left {
  left: 0;
}

.nav-zone-right {
  right: 0;
}

.nav-zone:focus-visible {
  opacity: 1;
  outline: 2px solid rgba(255, 255, 255, 0.48);
  outline-offset: -2px;
  background: rgba(255, 255, 255, 0.06);
}

.loading-overlay {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 7;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(8, 7, 22, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
}

.page-browser {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 12px;
}

.page-browser-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(12px);
}

.page-browser-sheet {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  max-height: min(80dvh, 840px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at top right, rgba(242, 84, 91, 0.14), transparent 28%),
    rgba(12, 12, 16, 0.96);
  box-shadow: 0 26px 72px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.page-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.page-browser-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-browser-copy {
  min-width: 0;
}

.page-browser-copy h2 {
  margin: 0;
  font-family: var(--header-font);
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 0.95;
  text-transform: uppercase;
}

.reader-byline {
  margin-top: 8px;
  max-width: 48rem;
  line-height: 1.5;
}

.page-browser-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.scrubber-label {
  color: rgba(255, 255, 255, 0.82);
}

#pageScrubber {
  width: 100%;
  accent-color: var(--accent);
}

#pageBrowserCount {
  min-width: 108px;
  text-align: right;
}

.thumbnail-drawer {
  min-height: 0;
  overflow: auto;
}

.thumbnail-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 14px;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
}

.thumbnail-button {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  text-align: center;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.thumbnail-button img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4.75;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.thumbnail-button span {
  font-size: 0.82rem;
}

.thumbnail-button.is-active {
  border-color: rgba(255, 139, 115, 0.8);
  background: rgba(242, 84, 91, 0.16);
}

.thumbnail-button:hover {
  transform: translateY(-2px);
}

.thumbnail-rail::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.thumbnail-rail::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.panel-editor {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: grid;
  padding: 12px;
  align-items: stretch;
  justify-items: center;
}

.panel-editor-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
}

.panel-editor-shell {
  position: relative;
  z-index: 1;
  width: min(1380px, 100%);
  height: min(calc(100dvh - 24px), 980px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at top right, rgba(242, 84, 91, 0.12), transparent 28%),
    rgba(10, 10, 14, 0.98);
  box-shadow: 0 26px 72px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.panel-editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.panel-editor-copy {
  min-width: 0;
}

.panel-editor-copy h2 {
  margin: 0;
  font-family: var(--header-font);
  font-size: clamp(1.7rem, 2.4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 0.95;
  text-transform: uppercase;
}

.panel-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel-editor-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.panel-editor-canvas-wrap,
.panel-editor-sidebar {
  min-height: 0;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.panel-editor-canvas-wrap {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.panel-editor-stage {
  position: relative;
  min-height: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    #050509;
  background-size: 32px 32px, 32px 32px, auto;
  overflow: hidden;
  touch-action: none;
}

.panel-editor-image {
  position: absolute;
  display: block;
  user-select: none;
  pointer-events: none;
}

.panel-editor-overlay {
  position: absolute;
  inset: 0;
}

.panel-editor-box,
.panel-editor-draft,
.panel-editor-handle {
  position: absolute;
}

.panel-editor-box {
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
  cursor: move;
  touch-action: none;
}

.panel-editor-box.is-selected {
  border-color: rgba(255, 139, 115, 0.96);
  background: rgba(242, 84, 91, 0.12);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 139, 115, 0.3);
}

.panel-editor-box-label {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(8, 7, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
  user-select: none;
  cursor: move;
}

.panel-editor-draft {
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.08);
}

.panel-editor-handle {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(8, 7, 22, 0.92);
  background: rgba(255, 139, 115, 0.98);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.panel-editor-handle-nw,
.panel-editor-handle-n,
.panel-editor-handle-ne {
  top: -9px;
}

.panel-editor-handle-sw,
.panel-editor-handle-s,
.panel-editor-handle-se {
  bottom: -9px;
}

.panel-editor-handle-nw,
.panel-editor-handle-w,
.panel-editor-handle-sw {
  left: -9px;
}

.panel-editor-handle-ne,
.panel-editor-handle-e,
.panel-editor-handle-se {
  right: -9px;
}

.panel-editor-handle-n,
.panel-editor-handle-s {
  left: calc(50% - 8px);
}

.panel-editor-handle-e,
.panel-editor-handle-w {
  top: calc(50% - 8px);
}

.panel-editor-handle-nw,
.panel-editor-handle-se {
  cursor: nwse-resize;
}

.panel-editor-handle-ne,
.panel-editor-handle-sw {
  cursor: nesw-resize;
}

.panel-editor-handle-n,
.panel-editor-handle-s {
  cursor: ns-resize;
}

.panel-editor-handle-e,
.panel-editor-handle-w {
  cursor: ew-resize;
}

.panel-editor-tip {
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.92rem;
  line-height: 1.5;
}

.panel-editor-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.panel-editor-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-editor-count {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.9rem;
  font-weight: 700;
}

.panel-editor-list {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.panel-editor-empty {
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.5;
}

.panel-editor-item {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.panel-editor-item.is-selected {
  border-color: rgba(255, 139, 115, 0.8);
  background: rgba(242, 84, 91, 0.12);
}

.panel-editor-item button {
  justify-self: start;
}

.panel-editor-item-head {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel-editor-item-title {
  font-weight: 700;
}

.panel-editor-item-meta {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.82rem;
  line-height: 1.45;
}

.panel-editor-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1024px) {
  .site-header,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .header-chip,
  .section-note {
    white-space: normal;
    text-align: left;
  }

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

  .hero-cover {
    width: min(100%, 360px);
  }

  .hero-companion {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-companion-media {
    width: min(100%, 420px);
    flex-basis: auto;
  }

  .page-browser-sheet {
    max-height: min(84dvh, 860px);
  }

  .panel-editor-layout {
    grid-template-columns: 1fr;
  }

  .panel-editor-sidebar {
    max-height: 320px;
  }
}

@media (max-width: 760px) {
  .comic-shell {
    padding: 18px 14px 24px;
  }

  .reader-topbar {
    grid-template-columns: auto 1fr;
    align-items: start;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 18px;
  }

  .reader-view[data-dev="off"] .reader-topbar {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 0;
  }

  .reader-progress {
    grid-column: 1 / -1;
    order: 3;
  }

  .reader-actions {
    gap: 6px;
    justify-content: flex-end;
  }

  .reader-mode-switch {
    gap: 3px;
    padding: 3px;
  }

  .reader-nav-button,
  .reader-tool-button {
    min-height: 36px;
    min-width: 0;
    padding: 0 10px;
    font-size: 0.68rem;
  }

  .reader-mode-switch .reader-tool-button {
    padding: 0 9px;
  }

  .page-browser {
    padding: 8px;
  }

  .page-browser-sheet {
    max-height: calc(100dvh - 16px);
    padding: 16px;
    border-radius: 20px;
  }

  .page-browser-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-browser-actions,
  .panel-editor-topbar,
  .panel-editor-actions {
    justify-content: flex-start;
  }

  .panel-editor {
    padding: 8px;
  }

  .panel-editor-shell {
    height: calc(100dvh - 16px);
    padding: 16px;
    border-radius: 20px;
  }

  .panel-editor-topbar {
    flex-direction: column;
  }

  .panel-editor-actions .reader-tool-button,
  .panel-editor-actions .reader-nav-button,
  .page-browser-actions .reader-tool-button,
  .page-browser-actions .reader-nav-button {
    flex: 1 1 140px;
  }

  .panel-editor-layout {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .panel-editor-sidebar {
    max-height: 260px;
  }

  .page-browser-controls {
    grid-template-columns: 1fr;
  }

  #pageBrowserCount {
    text-align: left;
  }

  .thumbnail-rail {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }

  .nav-zone {
    width: 28%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
