:root {
  color-scheme: dark;
  --ink: #f4f0e8;
  --muted: #9f9b92;
  --dim: #6d6961;
  --accent: #e5a93f;
  --accent-soft: rgba(229, 169, 63, 0.14);
  --paper: #171715;
  --panel: #111110;
  --panel-raised: #1d1d1a;
  --line: rgba(255, 255, 255, 0.09);
  --reader: #090909;
  font-family:
    Inter, Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui,
    sans-serif;
  background: var(--panel);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #16120a;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  height: 100dvh;
}

.library-panel {
  z-index: 20;
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 30% 0%, rgba(229, 169, 63, 0.08), transparent 26%),
    var(--panel);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(229, 169, 63, 0.42);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 20px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-size: 18px;
  letter-spacing: 0.12em;
}

.eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.14em;
}

.series-card {
  position: relative;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--line);
}

.series-panel-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  background: rgba(24, 24, 22, 0.92);
}

.series-card h1 {
  margin: 12px 0 7px;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 22px;
  line-height: 1.25;
}

.series-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 9px;
  border: 1px solid rgba(229, 169, 63, 0.28);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #efc678;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
}

.progress-track {
  height: 3px;
  margin: 18px 0 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #292824;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b67a22, var(--accent));
  transition: width 300ms ease;
}

.download-queue-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.download-queue-stat {
  min-width: 0;
  padding: 8px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  text-align: center;
}

.download-queue-stat span,
.download-queue-stat strong {
  display: block;
}

.download-queue-stat span {
  overflow: hidden;
  color: var(--dim);
  font-size: 9px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-queue-stat strong {
  margin-top: 4px;
  color: #d8d4cb;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  line-height: 1;
}

.download-queue-stat.running strong {
  color: var(--accent);
}

.download-queue-stat.failed strong {
  color: #d99072;
}

.download-queue-detail {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
}

.series-card .download-queue-detail {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.45;
}

.library-search {
  padding: 16px 14px 10px;
}

.library-search label {
  display: block;
  margin: 0 0 7px 4px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}

.search-field span {
  color: var(--dim);
  font-size: 18px;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.search-field input::placeholder {
  color: #625f59;
}

.episode-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px 8px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.09em;
}

.episode-list-head button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.episode-list-head button:hover {
  color: var(--accent);
}

.episode-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 18px;
  scrollbar-color: #3a3833 transparent;
  scrollbar-width: thin;
}

.episode-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  width: 100%;
  min-height: 54px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
}

.episode-item.available {
  cursor: pointer;
}

.episode-item.available:hover {
  background: rgba(255, 255, 255, 0.04);
}

.episode-item.active {
  border-color: rgba(229, 169, 63, 0.25);
  background: var(--accent-soft);
}

.episode-index {
  color: var(--dim);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-align: right;
}

.episode-copy {
  min-width: 0;
}

.episode-copy strong,
.episode-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-copy strong {
  color: #d9d5cc;
  font-size: 12px;
  font-weight: 620;
}

.episode-copy span {
  margin-top: 3px;
  color: var(--dim);
  font-size: 10px;
}

.episode-item.active .episode-copy strong {
  color: var(--ink);
}

.episode-state {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3f3d38;
}

.episode-state.complete {
  background: #5cb680;
  box-shadow: 0 0 0 3px rgba(92, 182, 128, 0.1);
}

.episode-state.running {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: pulse 1.4s ease-in-out infinite;
}

.episode-download {
  min-width: 44px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(229, 169, 63, 0.34);
  border-radius: 7px;
  background: rgba(229, 169, 63, 0.08);
  color: #e6b759;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.episode-download:hover:not(:disabled) {
  border-color: rgba(229, 169, 63, 0.65);
  background: rgba(229, 169, 63, 0.15);
  color: #f0c878;
}

.episode-download:disabled {
  cursor: default;
  opacity: 0.55;
}

.list-placeholder {
  padding: 24px 14px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.reader-column {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--reader);
}

.reader-toolbar {
  position: relative;
  z-index: 10;
  display: flex;
  min-width: 0;
  min-height: 70px;
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 17, 16, 0.96);
  backdrop-filter: blur(12px);
}

.episode-heading {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 170px;
  min-height: 40px;
  align-items: center;
  gap: 10px;
}

.episode-heading > div {
  min-width: 0;
}

.episode-heading h2 {
  max-width: 330px;
  margin: 3px 0 0;
  overflow: hidden;
  color: #e6e2da;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.series-log-toggle,
.reader-exit {
  display: inline-flex;
  min-width: max-content;
  height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #181816;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.settings-toggle,
.reader-fullscreen {
  flex: 0 0 36px;
  background: #181816;
}

.settings-toggle:hover,
.reader-fullscreen:hover,
.series-log-toggle:hover,
.reader-exit:hover,
body.log-open .series-log-toggle {
  border-color: rgba(229, 169, 63, 0.3);
  color: var(--ink);
}

.settings-toggle > span:first-child,
.series-log-toggle > span:first-child,
.reader-exit > span:first-child {
  color: var(--accent);
  font-size: 14px;
}

.reader-page-position {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #eee9df;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.toolbar-groups {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.control-group,
.zoom-control {
  display: inline-flex;
  height: 36px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #151513;
}

.choice-button,
.zoom-control button,
.direction-button,
.icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.choice-button {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.choice-button:hover {
  color: var(--ink);
}

.choice-button.active {
  background: #2a2925;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.zoom-control {
  gap: 3px;
  padding-inline: 5px;
}

.zoom-control button {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 5px;
  color: var(--muted);
  font-size: 17px;
}

.zoom-control button:hover {
  background: #292823;
  color: var(--ink);
}

.zoom-control output {
  min-width: 43px;
  color: #c6c1b8;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-align: center;
}

.zoom-control input {
  width: 76px;
  accent-color: var(--accent);
}

.direction-button {
  display: inline-flex;
  height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.direction-button:hover {
  border-color: rgba(229, 169, 63, 0.28);
  color: var(--ink);
}

.direction-icon {
  color: var(--accent);
  font-size: 15px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 17px;
}

.icon-button:hover {
  color: var(--ink);
  background: #25241f;
}

.header-actions .settings-toggle,
.header-actions .reader-fullscreen {
  background: #181816;
}

.reader-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.025), transparent 45%),
    #090909;
  scrollbar-color: #3b3934 #111;
  scrollbar-width: thin;
  user-select: none;
  -webkit-user-select: none;
}

.reader-stage.fit-width {
  overflow-x: hidden;
  overflow-y: auto;
}

.reader-stage.zoom-overflow {
  overflow: auto;
}

.reader-stage::before,
.reader-stage::after {
  position: absolute;
  z-index: 4;
  top: 50%;
  display: grid;
  width: 36px;
  height: 48px;
  place-items: center;
  color: rgba(255, 255, 255, 0);
  font-size: 34px;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-50%);
  transition: color 140ms ease;
}

.reader-stage::before {
  left: 18px;
  content: "‹";
}

.reader-stage::after {
  right: 18px;
  content: "›";
}

.reader-stage:hover::before,
.reader-stage:hover::after {
  color: rgba(255, 255, 255, 0.22);
}

.spread {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 18px;
}

.page-slot {
  display: flex;
  min-width: 0;
  margin: 0;
  align-items: flex-start;
  justify-content: center;
}

.page-slot.blank {
  min-height: 1px;
}

.page-image {
  display: block;
  flex: 0 0 auto;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

.fit-height .page-image {
  width: auto;
  height: calc(100% * var(--zoom));
  max-width: calc(100% * var(--zoom));
  object-fit: contain;
}

.fit-height .spread {
  height: 100%;
  min-height: 0;
  align-items: center;
}

.fit-height .page-slot {
  height: 100%;
  align-items: center;
}

.fit-height.layout-single .page-slot {
  width: 100%;
}

.fit-height.layout-double .page-slot {
  width: 50%;
}

.fit-height.zoom-overflow .page-image {
  max-width: none;
}

.fit-width .spread {
  width: 100%;
}

.fit-width.layout-single .page-slot {
  width: 100%;
}

.fit-width.layout-double .page-slot {
  width: 50%;
}

.fit-width .page-image {
  width: calc(100% * var(--zoom));
  height: auto;
  max-width: none;
}

.layout-double .page-slot {
  flex: 0 0 auto;
}

.reader-empty,
.loading-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 9px;
  color: var(--muted);
  text-align: center;
}

.reader-empty strong {
  color: #d7d2c8;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 18px;
}

.reader-empty p {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
}

.empty-glyph {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 6px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 23px;
}

.spinner {
  width: 25px;
  height: 25px;
  border: 2px solid #34322e;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.page-buffer-indicator {
  position: absolute;
  z-index: 8;
  top: 14px;
  left: 50%;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 17, 16, 0.86);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translateX(-50%);
}

.page-buffer-indicator .spinner {
  width: 16px;
  height: 16px;
}

.hidden {
  display: none !important;
}

.library-toggle,
.mobile-scrim {
  display: none;
}

.library-toggle {
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
}

.library-toggle:hover {
  background: #25241f;
  color: var(--ink);
}

.library-toggle .menu-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

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

body.mode-tablet .library-panel {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(88vw, 360px);
  padding-left: env(safe-area-inset-left);
  transform: translateX(-105%);
  transition: transform 200ms ease;
}

body.mode-tablet.library-open .library-panel {
  transform: translateX(0);
}

body.mode-tablet .library-toggle {
  display: flex;
}

body.mode-tablet .mobile-scrim {
  position: fixed;
  z-index: 15;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
}

body.mode-tablet.library-open .mobile-scrim {
  display: block;
}

body.mode-tablet .reader-toolbar {
  min-height: 116px;
  align-items: stretch;
  flex-direction: column;
  gap: 8px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    9px
    max(14px, env(safe-area-inset-left));
}

body.mode-tablet .episode-heading h2 {
  max-width: 70vw;
  font-size: 16px;
}

body.mode-tablet .settings-toggle {
  width: 44px;
  height: 44px;
}

body.mode-tablet .reader-fullscreen {
  width: 44px;
  height: 44px;
}

body.mode-tablet .toolbar-groups {
  width: 100%;
  overflow-x: auto;
  justify-content: flex-start;
  gap: 9px;
  padding-bottom: 3px;
  scrollbar-width: none;
}

body.mode-tablet .toolbar-groups::-webkit-scrollbar {
  display: none;
}

body.mode-tablet .control-group,
body.mode-tablet .zoom-control,
body.mode-tablet .direction-button {
  min-width: max-content;
  height: 44px;
  flex: 0 0 auto;
}

body.mode-tablet .choice-button {
  min-width: 54px;
  height: 36px;
  padding-inline: 13px;
  font-size: 13px;
}

body.mode-tablet .zoom-control button {
  width: 34px;
  height: 34px;
  font-size: 20px;
}

body.mode-tablet .zoom-control output {
  min-width: 50px;
  font-size: 12px;
}

body.mode-tablet .direction-button {
  padding-inline: 14px;
  font-size: 13px;
}

body.mode-tablet .spread {
  gap: 1px;
  padding: 6px;
  touch-action: pan-x pan-y pinch-zoom;
}

body.mode-tablet .reader-stage::before,
body.mode-tablet .reader-stage::after {
  color: rgba(255, 255, 255, 0.2);
  font-size: 42px;
}

body.mode-tablet .reader-page-position {
  font-size: 14px;
}

body.mode-tablet .episode-item {
  min-height: 62px;
  padding-block: 10px;
}

body.mode-desktop .app-shell {
  grid-template-columns: 304px minmax(0, 1fr);
}

body.mode-desktop .library-panel {
  position: static;
  width: auto;
  transform: none;
}

body.mode-desktop .library-toggle,
body.mode-desktop .mobile-scrim {
  display: none !important;
}

body.controls-collapsed .reader-toolbar {
  min-height: 62px;
  align-items: center;
}

body.controls-collapsed .episode-heading {
  width: 100%;
}

body.controls-collapsed .header-actions {
  margin-left: auto;
}

body.controls-collapsed .toolbar-groups {
  display: none;
}

body.mode-tablet.controls-collapsed .reader-toolbar {
  min-height: 68px;
  align-items: center;
  flex-direction: row;
}

.log-scrim {
  display: none;
  position: fixed;
  z-index: 35;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(2px);
}

body.log-open .log-scrim {
  display: block;
}

.log-panel {
  position: fixed;
  z-index: 40;
  top: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  width: min(520px, calc(100vw - 28px));
  min-height: 0;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(229, 169, 63, 0.24);
  border-radius: 14px;
  background: #121210;
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 28px));
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

body.log-open .log-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.log-panel-head {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 15px 12px 18px;
  border-bottom: 1px solid var(--line);
}

.log-panel-head h2 {
  margin: 3px 0 0;
  font-size: 16px;
}

.log-download-status {
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(229, 169, 63, 0.025);
}

.log-download-status .download-queue-stats {
  margin-top: 0;
}

.log-download-status .download-queue-detail {
  margin: 8px 1px 0;
  font-size: 10px;
  line-height: 1.45;
  white-space: nowrap;
}

.log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.log-tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d0d0c;
}

.log-tabs button,
.log-refresh {
  min-width: 66px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.log-tabs button.active {
  background: #2a2925;
  color: var(--ink);
}

.log-refresh {
  border: 1px solid var(--line);
}

.log-refresh:hover,
.log-tabs button:hover {
  color: var(--ink);
}

.log-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 10px;
}

.log-meta strong {
  overflow: hidden;
  color: #c8c2b7;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-meta span {
  flex: 0 0 auto;
}

.log-content {
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.012), rgba(255, 255, 255, 0.012)),
    #090909;
  color: #c7d2c4;
  font-family: "SFMono-Regular", Consolas, "Noto Sans Mono", monospace;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  scrollbar-color: #3b3934 #111;
}

body.mode-tablet .log-panel {
  top: max(22vh, 120px);
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(105%);
}

body.mode-tablet.log-open .log-panel {
  transform: translateY(0);
}

body.mode-tablet .log-tabs button,
body.mode-tablet .log-refresh {
  min-width: 76px;
  height: 40px;
  font-size: 13px;
}

body.mode-tablet .log-content {
  padding: 16px;
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: 76px;
  max-width: 320px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #27251f;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

@media (max-width: 1120px) {
  .reader-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .toolbar-groups {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

}

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

  .library-panel {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 320px);
    transform: translateX(-105%);
    transition: transform 200ms ease;
  }

  body.library-open .library-panel {
    transform: translateX(0);
  }

  .library-toggle {
    display: flex;
  }

  .mobile-scrim {
    position: fixed;
    z-index: 15;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
  }

  body.library-open .mobile-scrim {
    display: block;
  }

  .episode-heading h2 {
    max-width: 58vw;
  }

  .spread {
    padding: 8px;
  }
}

@media (max-width: 560px) {
  .header-actions {
    gap: 5px;
  }

  .series-log-toggle,
  .reader-exit {
    padding-inline: 9px;
  }

  .zoom-control input {
    display: none;
  }

  .direction-button {
    padding-inline: 9px;
  }

}

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

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

.library-home {
  display: grid;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 8% 0%, rgba(229, 169, 63, 0.1), transparent 30%),
    #111110;
}

.library-home-header {
  display: grid;
  min-height: 82px;
  grid-template-columns:
    minmax(210px, 1fr)
    auto
    minmax(210px, 1fr);
  align-items: center;
  gap: clamp(10px, 1.4vw, 22px);
  padding: 12px clamp(16px, 2.4vw, 38px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 17, 16, 0.94);
  backdrop-filter: blur(14px);
}

.library-home-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.library-home-brand .brand-copy {
  min-width: 0;
}

.library-header-breadcrumb {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.library-brand-title {
  flex: none;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.library-header-separator {
  flex: none;
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
}

.library-header-breadcrumb h1 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #d5d0c7;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-count {
  display: inline-flex;
  min-width: 30px;
  min-height: 20px;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border: 1px solid rgba(229, 169, 63, 0.24);
  border-radius: 999px;
  background: rgba(229, 169, 63, 0.08);
  color: #dcb665;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
}

.catalog-search {
  width: clamp(160px, 20vw, 300px);
  height: 38px;
  background: rgba(255, 255, 255, 0.035);
}

.catalog-search input {
  font-size: 12px;
}

.library-header-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.library-filters {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-self: center;
  gap: 8px;
}

.library-sort,
.library-status-filter {
  display: inline-flex;
  flex: 0 0 auto;
  height: 38px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #181816;
}

.library-sort button,
.library-status-filter button {
  min-width: 56px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.library-status-filter button {
  min-width: 50px;
}

.library-sort button:hover,
.library-status-filter button:hover {
  color: var(--ink);
}

.library-sort button.active,
.library-status-filter button.active {
  background: var(--accent-soft);
  color: #efc678;
  box-shadow: inset 0 0 0 1px rgba(229, 169, 63, 0.2);
}

.library-pagination button,
.download-all {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1c1c19;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.library-refresh {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1c1c19;
  color: var(--muted);
  cursor: pointer;
}

.library-refresh svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.library-refresh:hover,
.library-pagination button:hover:not(:disabled) {
  border-color: rgba(229, 169, 63, 0.36);
  color: var(--ink);
}

.library-home-main {
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 18px 18px 42px;
  scrollbar-color: #3a3833 transparent;
}

.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 170px));
  align-items: start;
  justify-content: center;
  gap: 28px clamp(16px, 1.6vw, 24px);
}

.library-virtual-spacer {
  width: 100%;
  height: 0;
  pointer-events: none;
}

.series-tile {
  display: block;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.series-cover-frame {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 17 / 25;
  border: 1px solid var(--line);
  border-radius: 11px;
  background:
    linear-gradient(145deg, rgba(229, 169, 63, 0.13), transparent),
    #24231f;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
  transition:
    transform 160ms ease,
    border-color 160ms ease;
}

.series-tile:hover .series-cover-frame,
.series-tile:focus-visible .series-cover-frame {
  border-color: rgba(229, 169, 63, 0.48);
  transform: translateY(-4px);
}

.series-cover-frame img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-cover-placeholder {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(229, 169, 63, 0.65);
  font-family: Georgia, serif;
  font-size: 34px;
}

.series-tile.has-cover .series-cover-placeholder {
  display: none;
}

.series-state {
  position: absolute;
  z-index: 2;
  top: 9px;
  right: 9px;
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid rgba(229, 169, 63, 0.45);
  border-radius: 999px;
  background: rgba(17, 17, 16, 0.88);
  color: #f0c878;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  backdrop-filter: blur(5px);
}

.series-overlay {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  min-height: 92px;
  padding: 38px 11px 11px;
  background:
    linear-gradient(
      to bottom,
      transparent 0%,
      rgba(10, 10, 9, 0.48) 34%,
      rgba(10, 10, 9, 0.94) 72%,
      #0d0d0c 100%
    );
  pointer-events: none;
}

.series-overlay strong,
.series-overlay span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.series-overlay strong {
  display: -webkit-box;
  color: #f1ede5;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.series-overlay .series-author {
  margin-bottom: 5px;
  color: #e6b759;
  font-size: 10px;
  font-weight: 650;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}

.library-loading,
.library-empty {
  display: flex;
  min-height: 300px;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.library-pagination {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding:
    9px
    max(18px, env(safe-area-inset-right))
    max(9px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: #111110;
}

.library-scroll-sentinel {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--dim);
  font-size: 11px;
  text-align: center;
}

.library-scroll-sentinel .spinner {
  width: 20px;
  height: 20px;
}

.library-pagination button {
  min-width: 92px;
}

.library-pagination button:disabled {
  cursor: default;
  opacity: 0.35;
}

.library-pagination span {
  min-width: 90px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  text-align: center;
}

.back-library {
  flex: 0 0 auto;
}

.series-card-heading {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
  padding-right: 42px;
}

.series-card-cover {
  position: relative;
  display: block;
  overflow: hidden;
  width: 58px;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(145deg, rgba(229, 169, 63, 0.13), transparent),
    #24231f;
}

.series-card-cover img {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-card-cover img[hidden] {
  display: none;
}

.series-card-heading h1 {
  margin-top: 8px;
  font-size: 18px;
}

.series-card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.series-card-actions .download-all {
  width: 100%;
  margin-top: 0;
  border-color: rgba(229, 169, 63, 0.4);
  background: var(--accent);
  color: #201708;
}

.series-log-toggle {
  min-width: 68px;
  height: 40px;
  justify-content: center;
  padding-inline: 10px;
}

.download-all:hover:not(:disabled) {
  filter: brightness(1.08);
}

.download-all.stop-download {
  border-color: rgba(224, 95, 81, 0.65);
  background: #8b332b;
  color: #fff4f1;
}

.download-all:disabled {
  border-color: var(--line);
  background: #282721;
  color: var(--dim);
  cursor: default;
}

.series-card .download-copy {
  margin-top: 8px;
  font-size: 10px;
}

@media (min-width: 1500px) {
  .series-grid {
    grid-template-columns: repeat(auto-fill, minmax(165px, 175px));
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .library-home-header {
    grid-template-columns:
      minmax(170px, 1fr)
      auto
      minmax(170px, 1fr);
    gap: 8px;
    padding-inline: 14px;
  }

  .library-home-brand {
    gap: 8px;
  }

  .library-home-brand .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .library-brand-title {
    font-size: 16px;
  }

  .library-header-breadcrumb {
    gap: 6px;
  }

  .library-header-breadcrumb h1 {
    max-width: 12vw;
    font-size: 12px;
  }

  .catalog-search {
    width: clamp(130px, 18vw, 210px);
  }

  .library-filters {
    gap: 6px;
  }

  .library-sort button,
  .library-status-filter button {
    min-width: 46px;
    padding-inline: 7px;
    font-size: 10px;
  }

  .library-status-filter button {
    min-width: 42px;
  }
}

@media (max-width: 760px) {
  .library-home-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding:
      max(12px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      12px
      max(14px, env(safe-area-inset-left));
  }

  .library-header-breadcrumb {
    gap: 7px;
  }

  .library-home-brand {
    gap: 9px;
  }

  .library-home-brand .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .library-brand-title {
    font-size: 16px;
  }

  .library-header-breadcrumb h1 {
    max-width: 34vw;
    font-size: 12px;
  }

  .library-count {
    padding-inline: 6px;
    font-size: 8px;
  }

  .library-header-tools {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
  }

  .catalog-search {
    width: auto;
    flex: 1 1 auto;
  }

  .library-filters {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .library-filters::-webkit-scrollbar {
    display: none;
  }

  .library-home-main {
    padding: 14px 14px 30px;
  }

  .series-grid {
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    gap: 20px 13px;
  }

}

@media (max-width: 420px) {
  .series-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .series-overlay {
    min-height: 88px;
    padding-right: 9px;
    padding-left: 9px;
  }
}

/* 서재 → 회차 목록 → 뷰어 전환 */
:root {
  --library-header-height: 82px;
  --series-panel-width: clamp(330px, 22vw, 380px);
}

.library-home {
  grid-template-rows:
    var(--library-header-height)
    minmax(0, 1fr);
}

.library-home-header {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
}

.library-home-main {
  grid-row: 2;
}

.library-home-main {
  transition:
    padding-left 220ms ease,
    opacity 160ms ease;
}

body.layout-snap .library-home-main,
body.layout-snap .library-home-header,
body.layout-snap .app-shell {
  transition: none !important;
}

.app-shell {
  position: fixed;
  z-index: 25;
  top: var(--library-header-height);
  right: auto;
  bottom: 0;
  left: 0;
  width: var(--series-panel-width);
  height: auto;
  grid-template-columns: 1fr;
  overflow: hidden;
  box-shadow: 18px 0 42px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translateX(-105%);
  transition:
    width 220ms ease,
    transform 220ms ease;
}

body.series-panel-open .app-shell {
  top: 0;
  pointer-events: auto;
  transform: translateX(0);
}

body.series-panel-open:not(.reading-active) .library-home-header {
  left: var(--series-panel-width);
  width: calc(100% - var(--series-panel-width));
}

body.series-panel-open:not(.reading-active) .library-home-main {
  padding-left: calc(var(--series-panel-width) + 18px);
}

body.series-panel-open:not(.reading-active) .reader-column {
  display: none;
}

body.series-panel-open .app-shell .library-panel {
  position: static;
  inset: auto;
  width: auto;
  min-width: 0;
  padding-left: 0;
  transform: none;
  transition: none;
}

body.series-panel-open .mobile-scrim {
  display: none !important;
}

body.reading-active .library-home-main {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

body.reading-active .library-home-header {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

body.reading-active .app-shell {
  top: 0;
  width: 100vw;
  grid-template-columns: var(--series-panel-width) minmax(0, 1fr);
  box-shadow: none;
}

body.reading-active.episode-panel-collapsed .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.reading-active.episode-panel-collapsed .app-shell .library-panel {
  display: none;
}

body.reading-active .reader-column {
  display: grid;
}

body.reading-active:not(.episode-panel-collapsed) .library-toggle {
  display: none !important;
}

body.reading-active.episode-panel-collapsed .library-toggle {
  display: flex !important;
}

@media (max-width: 720px) {
  :root {
    --series-panel-width: 100vw;
  }

  body.series-panel-open:not(.reading-active) .library-home-main {
    visibility: hidden;
    padding-left: 18px;
    opacity: 0;
    pointer-events: none;
  }

  body.series-panel-open:not(.reading-active) .library-home-header {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

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

  body.reading-active .app-shell .library-panel {
    display: none;
  }

  body.reading-active:not(.episode-panel-collapsed) .app-shell .library-panel {
    display: flex;
  }

  body.reading-active .app-shell .reader-column {
    display: grid;
  }

  body.reading-active:not(.episode-panel-collapsed) .app-shell .reader-column {
    display: none;
  }

  body.reading-active.episode-panel-collapsed .app-shell .reader-column {
    display: grid;
  }

  body.reading-active.episode-panel-collapsed .library-toggle {
    display: flex !important;
  }
}
/* One shared eight-digit PIN guards the private archive. */
.pin-login-page {
  min-height: 100dvh;
  margin: 0;
  color: #f4f0e8;
  background:
    radial-gradient(circle at 50% 18%, rgba(208, 146, 35, 0.12), transparent 34rem),
    #0d0d0c;
}

.pin-login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.pin-login-card {
  width: min(100%, 390px);
  padding: 38px 34px 34px;
  border: 1px solid rgba(230, 176, 69, 0.22);
  border-radius: 20px;
  background: rgba(21, 20, 18, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.pin-login-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(230, 176, 69, 0.5);
  border-radius: 14px;
  color: #e7ad3d;
  background: rgba(199, 132, 22, 0.12);
  font: 600 27px/1 serif;
}

.pin-login-card h1 {
  margin: 7px 0 9px;
  font-size: clamp(25px, 6vw, 32px);
}

.pin-login-copy {
  margin: 0 0 27px;
  color: #aaa399;
  font-size: 14px;
}

.pin-login-form {
  display: grid;
  gap: 10px;
  text-align: left;
}

.pin-login-form label {
  color: #d8d1c6;
  font-size: 13px;
  font-weight: 700;
}

.pin-login-form input {
  width: 100%;
  height: 54px;
  border: 1px solid #3a3833;
  border-radius: 12px;
  outline: none;
  color: #f7f1e7;
  background: #11110f;
  font: 700 22px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.34em;
  text-align: center;
}

.pin-login-form input:focus {
  border-color: #d79829;
  box-shadow: 0 0 0 3px rgba(215, 152, 41, 0.14);
}

.pin-login-form > span {
  color: #7f7a72;
  font-size: 12px;
}

.pin-login-error {
  min-height: 18px;
  margin: 0;
  color: #ef9a88;
  font-size: 13px;
}

.pin-login-error:empty {
  visibility: hidden;
}

.pin-login-form button {
  height: 50px;
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  color: #1b1408;
  background: #e5a735;
  font-weight: 800;
  cursor: pointer;
}

.pin-login-form button:hover {
  background: #f0b64a;
}

.auth-logout-form {
  display: contents;
}

.auth-logout {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #2f2e2a;
  border-radius: 10px;
  color: #a9a49b;
  background: #171715;
  cursor: pointer;
}

.auth-logout:hover {
  border-color: rgba(230, 176, 69, 0.55);
  color: #e8b656;
}

.auth-logout svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.activity-nav {
  text-decoration: none;
}

.activity-nav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.activity-page {
  display: grid;
  min-width: 320px;
  height: 100dvh;
  grid-template-rows: 70px minmax(0, 1fr);
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(229, 169, 63, 0.07), transparent 28rem),
    #0d0d0c;
}

.activity-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 17, 16, 0.96);
}

.activity-title-group,
.activity-header-actions {
  display: flex;
  min-width: 0;
  align-items: center;
}

.activity-title-group {
  gap: 12px;
}

.activity-title-group .brand-mark {
  width: 38px;
  height: 38px;
  font-size: 19px;
}

.activity-title-group h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.activity-back {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
}

.activity-back:hover {
  border-color: rgba(229, 169, 63, 0.4);
  color: var(--ink);
}

.activity-back svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.activity-header-actions {
  justify-content: flex-end;
  gap: 8px;
}

.activity-connection {
  display: inline-flex;
  height: 32px;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #8e8a82;
  background: rgba(255, 255, 255, 0.025);
  font-size: 10px;
}

.activity-connection > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7d7870;
  box-shadow: 0 0 0 3px rgba(125, 120, 112, 0.1);
}

.activity-connection.connected {
  color: #9ccdb6;
}

.activity-connection.connected > span {
  background: #58c891;
  box-shadow: 0 0 0 3px rgba(88, 200, 145, 0.12);
}

.library-refresh.loading svg {
  animation: activity-spin 700ms linear infinite;
}

@keyframes activity-spin {
  to {
    transform: rotate(360deg);
  }
}

.activity-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
}

.activity-overview {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: rgba(17, 17, 16, 0.88);
}

.activity-summary,
.activity-schedules {
  flex: 0 0 auto;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.activity-section-heading,
.activity-job-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.activity-section-heading h2,
.activity-job-heading h2 {
  margin: 3px 0 0;
  color: #e2ddd4;
  font-size: 13px;
}

.activity-section-heading > span {
  color: var(--dim);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.activity-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.activity-stat {
  display: grid;
  min-width: 0;
  min-height: 60px;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.022);
}

.activity-stat span {
  color: var(--dim);
  font-size: 9px;
  white-space: nowrap;
}

.activity-stat strong {
  color: #cbc5bb;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
}

.activity-stat.active strong {
  color: #63d39d;
}

.activity-stat.queued strong {
  color: #e9b654;
}

.activity-stat.failed strong {
  color: #e88470;
}

.schedule-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.schedule-item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.022);
}

.schedule-item > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.schedule-item strong,
.schedule-item > div > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-item strong {
  color: #d9d4ca;
  font-size: 11px;
}

.schedule-item > div > span {
  color: var(--dim);
  font-size: 9px;
}

.schedule-status {
  flex: 0 0 auto;
  color: #70d2a2;
  font-size: 9px;
  font-weight: 750;
}

.schedule-item[data-enabled="false"] .schedule-status {
  color: var(--dim);
}

.activity-jobs {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  padding-top: 16px;
}

.activity-job-heading {
  flex: 0 0 auto;
  padding: 0 18px 12px;
}

.activity-filter,
.activity-log-filter {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #181816;
}

.activity-filter button,
.activity-log-filter button {
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  color: var(--dim);
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.activity-filter button.active,
.activity-log-filter button.active {
  color: #efc678;
  background: var(--accent-soft);
}

.activity-job-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 10px 12px;
  scrollbar-color: #3b3934 transparent;
  scrollbar-width: thin;
}

.activity-job {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 12px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.activity-job:hover {
  background: rgba(255, 255, 255, 0.035);
}

.activity-job.selected {
  border-color: rgba(229, 169, 63, 0.2);
  background: rgba(229, 169, 63, 0.08);
}

.activity-job-top {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.activity-job-top strong {
  overflow: hidden;
  color: #ded9d0;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-job-status,
.activity-job-state {
  flex: 0 0 auto;
  border-radius: 999px;
  color: #a8a39a;
  background: rgba(255, 255, 255, 0.06);
  font-size: 9px;
  font-weight: 750;
}

.activity-job-status {
  padding: 3px 7px;
}

.activity-job[data-status="running"] .activity-job-status,
.activity-job-state[data-status="running"] {
  color: #76d7a8;
  background: rgba(65, 180, 121, 0.12);
}

.activity-job[data-status="queued"] .activity-job-status,
.activity-job-state[data-status="queued"] {
  color: #e4b65b;
  background: rgba(229, 169, 63, 0.12);
}

.activity-job[data-status="failed"] .activity-job-status,
.activity-job-state[data-status="failed"] {
  color: #ed8d79;
  background: rgba(220, 94, 71, 0.12);
}

.activity-job-copy,
.activity-job-stage {
  overflow: hidden;
  color: var(--dim);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-job-stage {
  color: #8f8a82;
}

.activity-placeholder {
  margin: 10px 0;
  padding: 16px;
  color: var(--dim);
  font-size: 11px;
  text-align: center;
}

.activity-detail {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  padding: 0 22px 22px;
  overflow: hidden;
}

.activity-detail-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 2px 17px;
}

.activity-detail-header > div:first-child {
  min-width: 0;
}

.activity-detail-header h2 {
  margin: 4px 0 5px;
  overflow: hidden;
  color: #eee8df;
  font: 600 clamp(19px, 2vw, 27px)/1.25 Georgia, "Noto Serif KR", serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-detail-header p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-job-state {
  padding: 7px 11px;
}

.activity-job-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.activity-job-meta > div {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.022);
}

.activity-job-meta span {
  color: var(--dim);
  font-size: 9px;
}

.activity-job-meta strong {
  overflow: hidden;
  color: #c8c2b8;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-log-toolbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #151513;
}

.activity-follow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

.activity-follow input {
  accent-color: var(--accent);
}

.activity-log {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  background: #0a0a09;
  scrollbar-color: #393733 #111;
  scrollbar-width: thin;
}

.activity-log ol {
  min-width: max-content;
  margin: 0;
  padding: 9px 0 18px;
  list-style: none;
}

.activity-log-line {
  display: grid;
  min-height: 26px;
  grid-template-columns: 128px 66px minmax(360px, 1fr);
  align-items: start;
  gap: 10px;
  padding: 5px 13px;
  color: #aaa69e;
  font: 10px/1.55 "SFMono-Regular", Consolas, monospace;
}

.activity-log-line:hover {
  background: rgba(255, 255, 255, 0.025);
}

.activity-log-line time {
  color: #5f5c56;
}

.activity-log-type {
  color: #a7823c;
  font-weight: 750;
}

.activity-log-message {
  max-width: min(1100px, 72vw);
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-log-line[data-level="error"],
.activity-log-line[data-type="stderr"] {
  color: #eb9785;
}

.activity-log-line[data-level="error"] .activity-log-type,
.activity-log-line[data-type="stderr"] .activity-log-type {
  color: #e56f58;
}

.activity-log-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  color: #595650;
  text-align: center;
}

.activity-log-empty.hidden {
  display: none;
}

.activity-log-empty span {
  font-size: 25px;
}

.activity-log-empty p {
  margin: 0;
  font-size: 11px;
}

@media (max-width: 900px) {
  .activity-main {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .activity-detail {
    padding-inline: 14px;
  }

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

@media (max-width: 700px) {
  .activity-page {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: 62px auto;
    overflow-y: auto;
  }

  .activity-header {
    position: sticky;
    z-index: 30;
    top: 0;
    padding-inline: 12px;
  }

  .activity-title-group {
    gap: 8px;
  }

  .activity-title-group .brand-mark,
  .activity-connection {
    display: none;
  }

  .activity-main {
    display: block;
  }

  .activity-overview {
    overflow: visible;
    border-right: 0;
  }

  .activity-jobs {
    min-height: 360px;
  }

  .activity-job-list {
    max-height: 48vh;
  }

  .activity-detail {
    min-height: 75vh;
    padding: 0 12px 16px;
    overflow: visible;
  }

  .activity-detail-header {
    padding-top: 19px;
  }

  .activity-detail-header h2 {
    white-space: normal;
  }

  .activity-log {
    min-height: 52vh;
  }

  .activity-log-line {
    grid-template-columns: 72px minmax(230px, 1fr);
    gap: 7px;
  }

  .activity-log-type {
    display: none;
  }

  .activity-log-message {
    max-width: 78vw;
  }
}

@media (max-width: 540px) {
  .pin-login-shell {
    padding: 16px;
  }

  .pin-login-card {
    padding: 30px 22px 26px;
  }
}
