:root {
  --bg: #0b0d12;
  --bg2: #161b26;
  --panel: #141821;
  --line: #232a36;
  --fg: #f4f6fb;
  --muted: #8a93a6;
  --accent: #2ee6a6;
  --code-bg: #1d2330;
  --paper: #ffffff;
  --paper-line: #e8ebf0;
  --site-max: 720px;
  --viewer-max: 1320px;
  --side-width: clamp(282px, 24vw, 336px);
  --topbar-h: 66px;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg2: #ffffff;
  --panel: #ffffff;
  --line: #e8ebf0;
  --fg: #1b1f29;
  --muted: #5c6470;
  --accent: #0a9c6c;
  --code-bg: #f1f3f5;
  --paper: #ffffff;
  --paper-line: #d9dee7;
  --shadow: 0 18px 42px rgba(27, 31, 41, 0.12);
  color-scheme: light;
}

html:not([data-theme="light"]) {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg2) 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--fg);
  font-size: 16px;
  line-height: 1.65;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 2px;
}

.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.topbar-in {
  max-width: var(--site-max);
  min-height: var(--topbar-h);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  background: var(--panel);
}

.site-nav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 8px;
  padding: 7px 13px;
  transition: color 150ms ease, background 150ms ease;
}

.site-nav a:hover {
  color: var(--fg);
  text-decoration: none;
}

.site-nav a.active {
  background: var(--accent);
  color: #06140e;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 8px;
  padding-left: 6px;
}

.brand-link img {
  display: block;
  width: auto;
  height: 24px;
}

.brand-link b {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-link span {
  color: #5b9bd5;
}

.brand-link .mid {
  color: #7fb0e6;
}

.brand-link .last {
  color: #a9cdf0;
}

html[data-theme="light"] .brand-link span {
  color: #163b70;
}

html[data-theme="light"] .brand-link .mid {
  color: #2f6fc0;
}

html[data-theme="light"] .brand-link .last {
  color: #5b9bd5;
}

.ctrls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: border-color 150ms ease, color 150ms ease;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-btn svg {
  width: 18px;
  height: 18px;
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 28px 8px 11px;
  background-color: var(--panel);
  color: var(--fg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a6' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.lang-select option {
  background: var(--panel);
  color: var(--fg);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  max-width: var(--viewer-max);
  min-height: calc(100vh - var(--topbar-h));
  margin: 0 auto;
}

.library {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  padding: 20px 14px;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
  font-weight: 800;
}

h2 {
  max-width: 980px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
}

h3 {
  font-size: 20px;
  font-weight: 800;
}

.issue-count {
  display: grid;
  place-items: center;
  min-width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.search-box {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  background: var(--code-bg);
  color: var(--fg);
  font-weight: 650;
}

.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.filter-strip button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.filter-strip button:hover {
  color: var(--fg);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.filter-strip button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #06140e;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.comic-list {
  display: grid;
  gap: 8px;
  padding-bottom: 30px;
}

.comic-item {
  width: 100%;
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--code-bg);
  padding: 10px;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 150ms ease, background 150ms ease;
}

.comic-item:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
}

.comic-item.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--code-bg));
}

.comic-item:active {
  transform: translateY(1px);
}

.item-code {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.item-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--fg);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.item-series {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.reader {
  min-width: 0;
  padding: 24px clamp(16px, 2.2vw, 32px) 44px;
}

.reader-top {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding: 10px 0 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 96%, transparent) 78%, transparent);
  backdrop-filter: blur(10px);
}

.title-block {
  min-width: 0;
}

.series-pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  margin: 0 0 9px;
  border-radius: 999px;
  padding: 0 11px;
  background: var(--accent);
  color: #06140e;
  font-size: 13px;
  font-weight: 800;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.meta-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--code-bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.icon-button,
.text-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.icon-button {
  width: 44px;
  font-size: 28px;
  line-height: 1;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  font-size: 14px;
}

.icon-button:hover,
.text-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.icon-button:active,
.text-button:active {
  transform: translateY(1px);
}

.story-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.story-card-intro {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin: 4px 0 20px;
  padding: clamp(16px, 2.2vw, 24px);
}

.story-marker {
  display: grid;
  place-items: center;
  min-width: 82px;
  min-height: 58px;
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.story-body {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.story-body p {
  margin: 0;
  color: var(--fg);
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.76;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.page-stage {
  display: grid;
  place-items: start center;
  min-height: 70vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--code-bg);
  padding: clamp(8px, 1.2vw, 16px);
  box-shadow: var(--shadow);
}

.page-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  background: var(--paper);
}

.page-stage.is-natural {
  overflow: auto;
  place-items: start;
}

.page-stage.is-natural img {
  width: auto;
  max-width: none;
}

.bottom-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin: 22px 0 0;
}

.bottom-nav-button,
.bottom-nav-current {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.bottom-nav-button {
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 94px;
  padding: 15px;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, border-color 150ms ease, background 150ms ease;
}

.bottom-nav-button-next {
  background: color-mix(in srgb, var(--accent) 13%, var(--panel));
}

.bottom-nav-button:hover:not(:disabled) {
  border-color: var(--accent);
}

.bottom-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.bottom-nav-button:active:not(:disabled) {
  transform: translateY(1px);
}

.bottom-nav-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.bottom-nav-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.bottom-nav-current {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 94px;
  padding: 14px;
  background: var(--code-bg);
  color: var(--fg);
  text-align: center;
}

.bottom-nav-current span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.bottom-nav-current strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: var(--code-bg);
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .library {
    position: relative;
    top: auto;
    height: auto;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .reader {
    padding: 20px clamp(12px, 2vw, 24px) 38px;
  }
}

@media (max-width: 900px) {
  :root {
    --topbar-h: 0px;
  }

  .topbar-in {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .site-nav {
    width: 100%;
  }

  .ctrls {
    align-self: flex-end;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .reader {
    padding: 18px 12px 34px;
  }

  .reader-top {
    position: relative;
    top: auto;
    display: grid;
  }

  .reader-actions {
    justify-content: flex-start;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 24px;
  }

  .page-stage {
    padding: 8px;
  }

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

  .story-marker {
    min-width: 0;
    width: max-content;
  }

  .story-body p {
    font-size: 16px;
  }

  .bottom-nav {
    grid-template-columns: 1fr;
  }

  .bottom-nav-current {
    order: -1;
  }
}

@media (max-width: 560px) {
  .site-nav a {
    padding: 7px 10px;
  }

  .brand-link b {
    display: none;
  }

  .comic-item {
    grid-template-columns: 48px 1fr;
  }
}

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