:root {
  color-scheme: dark;
}
html {
  background: #111114;
}
.pwa-update-notice {
  position: fixed;
  z-index: 100;
  bottom: calc(82px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 10px 12px;
  background: #242128;
  border: 1px solid #5b4b59;
  border-radius: 12px;
  box-shadow: 0 8px 28px #0005;
  font-size: 12px;
}
.pwa-update-notice span {
  flex-basis: 100%;
}
.pwa-update-notice button {
  min-height: 44px;
  padding: 6px 10px;
  font-size: 12px;
}
.pwa-update-notice button:first-of-type {
  color: var(--accent);
}
.book.is-recommended .compact-status {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  line-height: 1.4;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #615866 transparent;
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #615866;
  border-radius: 20px;
}
::-webkit-scrollbar-button {
  display: none;
}
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --status-clearance: 0px;
}
/* iOS draws a soft blur below the status bar of installed web apps that reaches
   past the safe area, so text placed there looks out of focus. Top controls
   start below it. Zero in Safari tabs, in landscape and without a status bar. */
@media (display-mode: standalone) {
  :root {
    --status-clearance: calc(min(var(--safe-top), 1px) * 12);
  }
}
/* WebKit bug 301994: some installed iPhones report a viewport shorter than the
   screen by the status-bar height, leaving a black strip at the bottom. The
   document reaches the physical edge so WebKit paints there; fixed bars keep
   their buttons inside the reported viewport and only extend their background. */
html:not(.keyboard-open)[data-ios-installed-canvas] {
  min-height: var(--ios-installed-height);
}
/* Long-press on artwork and covers should not open the save/share menu. */
.cover img,
.book img {
  -webkit-touch-callout: none;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
}
.has-modal {
  overflow: hidden;
}
.downloads-page #offline-pages img {
  user-select: none;
  -webkit-user-select: none;
}
@media (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
  :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea
  ) {
    min-height: 44px;
  }
  button,
  summary {
    min-height: 44px;
  }
}
@media (max-width: 700px),
  (pointer: coarse) and (max-width: 1024px) and (max-height: 500px) {
  html {
    scrollbar-gutter: auto;
    scroll-padding-bottom: calc(72px + var(--safe-bottom));
  }
  body {
    min-width: 0;
    overflow-wrap: break-word;
  }
  .sidebar {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    border: 0;
    padding: calc(10px + var(--safe-top)) max(16px, var(--safe-right)) 8px
      max(16px, var(--safe-left));
    background: var(--bg);
  }
  .sidebar > .brand > span:last-child {
    display: block;
    font-size: 23px;
  }
  .sidebar .brand-mark {
    width: 29px;
    height: 30px;
    font-size: 24px;
  }
  .workspace-label {
    display: none;
  }
  .sidebar nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
    padding: 5px max(8px, var(--safe-right)) calc(5px + var(--safe-bottom))
      max(8px, var(--safe-left));
    margin: 0;
    background: #19181d;
    border-top: 1px solid #ffffff10;
    -webkit-user-select: none;
    user-select: none;
  }
  html:not(.keyboard-open)[data-ios-installed-canvas] .sidebar nav {
    padding-bottom: max(
      5px,
      calc(var(--safe-bottom) - var(--ios-bottom-gap, 0px))
    );
  }
  html:not(.keyboard-open)[data-ios-installed-canvas] .sidebar nav::after {
    content: "";
    position: absolute;
    inset: 100% 0 auto;
    height: var(--ios-bottom-gap, 0px);
    background: inherit;
    pointer-events: none;
  }
  .sidebar nav a:active {
    opacity: 0.6;
  }
  .sidebar nav a {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 48px;
    padding: 4px 1px;
    background: none;
  }
  .sidebar nav a.active {
    background: none;
    color: var(--accent);
  }
  .sidebar nav a[data-nav="sources"],
  .sidebar nav .nav-label,
  .nav-divider,
  .sidebar nav #library-count {
    display: none;
  }
  .mobile-label {
    display: block;
    font-size: 10px;
    line-height: 1.2;
  }
  .nav-icon,
  .nav-icon svg {
    width: 20px;
    height: 20px;
  }
  .app-shell {
    margin-left: 0;
    padding-bottom: calc(74px + var(--safe-bottom));
    min-height: 100svh;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    height: 64px;
    padding: 8px max(16px, var(--safe-right)) 8px max(16px, var(--safe-left));
    background: var(--bg);
    border-bottom: 0;
  }
  .search-box {
    width: 100%;
    height: 48px;
    padding: 2px 3px 2px 12px;
    gap: 8px;
  }
  .search-box button {
    min-height: 42px;
    padding: 6px 10px;
    font-size: 12px;
  }
  .search-box button span {
    display: none;
  }
  .search-box input::placeholder {
    font-size: 12px;
  }
  main {
    padding: 12px max(16px, var(--safe-right)) 24px max(16px, var(--safe-left));
    min-height: calc(100svh - 200px);
    width: 100%;
    min-width: 0;
  }
  .breadcrumb {
    display: none;
  }
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 12px;
  }
  .book h3 {
    font-size: 13px;
  }
  .cover-taxonomy {
    right: 44px;
  }
  .book-caption {
    gap: 4px;
  }
  .book-read {
    min-height: 44px;
  }
  .compact-source,
  .compact-status {
    font-size: 10px;
  }
  .library-tools {
    justify-content: flex-start;
    gap: 7px;
  }
  .library-tools select {
    flex: 1 1 130px;
    max-width: 100%;
    width: 0;
    min-width: 0;
  }
  .library-tools .refresh-library {
    margin-left: auto;
  }
  .discovery-controls {
    gap: 6px;
    margin-bottom: 10px;
  }
  .discovery-controls button {
    min-height: 44px;
    padding-inline: 10px;
  }
  .discovery-controls label {
    margin-left: 0;
    min-height: 44px;
    gap: 5px;
  }
  .discovery-controls input[type="checkbox"] {
    width: 17px;
    height: 17px;
  }
  .taste-tools summary,
  .personal-tools summary {
    min-height: 44px;
  }
  .taste-tools form,
  .personal-tools form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .taste-tools label,
  .personal-tools label {
    min-width: 0;
  }
  .taste-tools input,
  .personal-tools input:not([type="checkbox"]),
  .personal-tools select {
    width: 100%;
    min-width: 0;
  }
  .taste-tools .recent-searches {
    max-height: 140px;
    overflow: auto;
  }
  #detail-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - var(--safe-top));
    margin: 0;
    border-radius: 16px 16px 0 0;
    overscroll-behavior-y: contain;
  }
  #detail-dialog .detail-toolbar {
    padding: 4px max(12px, var(--safe-right)) 4px max(12px, var(--safe-left));
  }
  #detail-dialog .detail-body {
    padding: 16px max(16px, var(--safe-right)) calc(20px + var(--safe-bottom))
      max(16px, var(--safe-left));
  }
  #detail-dialog .detail-info {
    min-width: 0;
  }
  #detail-dialog .detail-info h2 {
    font-size: 22px;
    overflow-wrap: anywhere;
  }
  #detail-dialog .alias-inline {
    min-width: 0;
  }
  #detail-dialog .alias-inline input {
    min-width: 0;
    flex-basis: 100px;
    width: 0;
  }
  .chapter-item,
  .chapter-row {
    min-width: 0;
  }
  .chapter-toggle {
    flex-shrink: 0;
    min-width: 44px;
  }
  .source-tabs {
    gap: 6px;
  }
  .source-tabs button {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  #toast {
    bottom: calc(78px + var(--safe-bottom));
    font-size: 12px;
    max-width: calc(100% - 32px - var(--safe-left) - var(--safe-right));
  }
  .auth-page,
  .pair-page {
    padding: calc(24px + var(--safe-top)) max(22px, var(--safe-right))
      calc(24px + var(--safe-bottom)) max(22px, var(--safe-left));
    min-height: 100svh;
  }
  .downloads-page {
    padding: calc(16px + var(--safe-top) + var(--status-clearance))
      max(16px, var(--safe-right)) calc(20px + var(--safe-bottom))
      max(16px, var(--safe-left));
  }
  .keyboard-open .sidebar nav {
    visibility: hidden;
    pointer-events: none;
  }
  .keyboard-open .app-shell {
    padding-bottom: 12px;
  }
  .keyboard-open #detail-dialog {
    top: var(--mobile-visible-top, 0px);
    bottom: auto;
    max-height: var(--mobile-visible-height, 100dvh);
  }
  .keyboard-open #toast {
    bottom: 12px;
  }
}
@media (min-width: 540px) and (max-width: 700px) {
  .book-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .sidebar > .brand {
    font-size: 20px;
  }
  .sidebar {
    padding-top: max(6px, var(--safe-top));
    padding-bottom: 4px;
  }
  .topbar {
    height: 58px;
  }
  .book-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .sidebar nav a {
    min-height: 44px;
  }
  .sidebar nav .mobile-label {
    display: none;
  }
  #detail-dialog {
    max-height: calc(100dvh - 8px);
    width: min(760px, 100%);
    margin-inline: auto;
    left: 0;
    right: 0;
  }
}
@media (display-mode: standalone) and (max-width: 700px) {
  .topbar {
    top: calc(var(--safe-top) + var(--status-clearance));
  }
  .topbar::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: calc(var(--safe-top) + var(--status-clearance));
    background: var(--bg);
    pointer-events: none;
  }
}
/* Ficha: reaches the physical bottom on affected iPhones and rises into place
   like an iOS sheet. Opacity/transform only, short and interruptible. */
@media (max-width: 700px) {
  html:not(.keyboard-open)[data-ios-installed-canvas] #detail-dialog {
    top: 0;
    height: var(--ios-installed-height);
    max-height: var(--ios-installed-height);
  }
  #detail-dialog[open] {
    animation: koma-sheet-in 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  }
}
#reader-dialog[open] {
  animation: koma-fade-in 0.18s ease-out;
}
@keyframes koma-sheet-in {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
}
@keyframes koma-fade-in {
  from {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #detail-dialog[open],
  #reader-dialog[open] {
    animation: none;
  }
}
@media (max-width: 700px),
  (pointer: coarse) and (max-width: 1024px) and (max-height: 500px) {
  #detail-dialog {
    inset: var(--mobile-visible-top, 0px) 0 auto;
    height: var(--mobile-visible-height, 100dvh);
    max-height: var(--mobile-visible-height, 100dvh);
    overflow: hidden;
    border-radius: 0;
    border: 0;
    margin: 0;
  }
  #detail-content {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #detail-dialog .detail-toolbar {
    position: relative;
    top: auto;
    flex: 0 0 auto;
    z-index: 20;
    min-height: calc(52px + var(--safe-top) + var(--status-clearance));
    padding: calc(4px + var(--safe-top) + var(--status-clearance))
      max(12px, var(--safe-right)) 4px max(16px, var(--safe-left));
    background: var(--bg);
  }
  #detail-dialog #close-detail {
    display: grid;
    place-items: center;
    position: relative;
    z-index: 21;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 10px;
    color: var(--text);
    background: #ffffff06;
    touch-action: manipulation;
    pointer-events: auto;
  }
  #detail-dialog .detail-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    overscroll-behavior-y: contain;
    touch-action: pan-y pinch-zoom;
    scroll-padding-top: 16px;
    -webkit-overflow-scrolling: touch;
  }
  .keyboard-open #detail-dialog {
    height: var(--mobile-visible-height, 100dvh);
    max-height: var(--mobile-visible-height, 100dvh);
  }
}
@media (max-width: 700px),
  (pointer: coarse) and (max-width: 1024px) and (max-height: 500px) {
  .personal-tools form > label:has(input[type="checkbox"]) {
    align-items: flex-start;
    line-height: 1.6;
  }
  .personal-tools input[type="checkbox"] {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin-top: 2px;
  }
}
.discovery-controls {
  display: inline-flex;
  border: 1px solid #ffffff10;
  border-radius: 10px;
  padding: 3px;
  background: #ffffff03;
  gap: 3px;
}
.discovery-controls button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding-inline: 15px;
  color: var(--muted);
  background: none;
}
.discovery-controls button.active {
  color: var(--text);
  background: none;
}
/* Segmented control: one highlight slides between the options (transform and
   width of an empty layer); the labels only change colour. */
.discovery-controls {
  position: relative;
  isolation: isolate;
}
.segment-indicator {
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 7px;
  background: #ffffff12;
  box-shadow:
    0 1px 2px #0006,
    inset 0 0 0 1px #ffffff0a;
  pointer-events: none;
  will-change: transform;
  transition:
    transform 0.28s var(--ease-out),
    width 0.28s var(--ease-out);
}
.segment-indicator.is-instant {
  transition: none;
}
.discovery-controls button {
  transition:
    color 0.2s ease,
    transform 0.16s var(--ease-out);
}
.discovery-controls button:active:not(:disabled) {
  transform: scale(0.97);
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .segment-indicator {
    transition: none;
  }
  .discovery-controls button {
    transition: color 0.2s ease;
  }
}
.taste-tools {
  margin-top: 0;
}
.catalog-visibility {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.catalog-visibility label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.catalog-visibility input {
  width: 18px;
  height: 18px;
}
#toast.actionable.visible {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 10px 7px 16px;
}
#toast.actionable button {
  min-height: 44px;
  padding: 7px 10px;
  border: 0;
  background: #28202a10;
  color: #31242a;
  font-size: 12px;
  font-weight: 650;
}
@media (pointer: coarse) {
  .discovery-controls button {
    min-height: 44px;
  }
  .taste-tools summary {
    min-height: 44px;
  }
}
:root {
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
.interface-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
}
.interface-setting select {
  min-width: 140px;
  min-height: 44px;
  font-size: 1rem;
}
.interface-setting input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
html[data-ui-text="large"] {
  --ui-body: 1rem;
  --ui-small: 0.875rem;
  --ui-caption: 0.8125rem;
  --ui-title: 1.625rem;
  --ui-card-min: 160px;
}
html[data-ui-text="larger"] {
  --ui-body: 1.125rem;
  --ui-small: 1rem;
  --ui-caption: 0.875rem;
  --ui-title: 1.75rem;
  --ui-card-min: 190px;
}
html[data-ui-text]:not([data-ui-text="standard"]) body {
  font-size: var(--ui-body);
}
html[data-ui-text]:not([data-ui-text="standard"])
  :is(
    .detail-synopsis p,
    .settings-card p,
    .auth-intro,
    .reader-footer,
    .empty p
  ) {
  font-size: var(--ui-body);
  line-height: 1.7;
}
html[data-ui-text]:not([data-ui-text="standard"])
  :is(.book h3, .chapter-row, .reader-title strong) {
  font-size: var(--ui-small);
  line-height: 1.5;
}
html[data-ui-text]:not([data-ui-text="standard"])
  #detail-dialog
  .detail-info
  h2 {
  font-size: var(--ui-title);
  line-height: 1.3;
}
html[data-ui-text]:not([data-ui-text="standard"])
  :is(
    .compact-source,
    .compact-status,
    .detail-credits,
    .detail-original,
    .chapter-row small,
    .reader-title small,
    .mobile-label,
    .result-count
  ) {
  font-size: var(--ui-caption);
  line-height: 1.5;
}
html[data-ui-text]:not([data-ui-text="standard"])
  #detail-dialog
  :is(.alias-list > span, .detail-facts dd, .detail-genres button > span) {
  font-size: var(--ui-small);
}
html[data-ui-text]:not([data-ui-text="standard"])
  #detail-dialog
  :is(.detail-facts dt, .reading-state-control label) {
  font-size: var(--ui-caption);
}
html[data-ui-text]:not([data-ui-text="standard"])
  button:not(.close-button):not(#close-reader):not(#close-reader-options):not(
    .bookmark-button
  ):not(.chapter-toggle):not(.reader-nav) {
  font-size: var(--ui-small);
  white-space: normal;
}
html[data-ui-text]:not([data-ui-text="standard"]) .book-grid {
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--ui-card-min)), 1fr)
  );
}
html[data-ui-text]:not([data-ui-text="standard"]) .book h3 {
  -webkit-line-clamp: 3;
}
html[data-ui-text]:not([data-ui-text="standard"])
  #detail-dialog
  .detail-facts
  > div {
  flex-basis: 110px;
}
.interface-setting:focus-within {
  color: var(--text);
}
:root[data-high-contrast="true"] {
  --muted: #d0c9d6;
  --line: #716a79;
}
html[data-high-contrast="true"]
  :is(
    .compact-source,
    .compact-status,
    .detail-credits,
    .detail-original,
    .chapter-row small,
    .reader-title small,
    .detail-facts dt
  ) {
  color: var(--muted);
}
html[data-high-contrast="true"] :is(button, input, select, .alias-list > span) {
  border-color: var(--line);
}
html[data-quiet-motion="true"] *,
html[data-quiet-motion="true"] *::before,
html[data-quiet-motion="true"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
@media (prefers-contrast: more) {
  :root {
    --muted: #d0c9d6;
    --line: #716a79;
  }
  .compact-source,
  .compact-status,
  .detail-original,
  .chapter-row small {
    color: var(--muted);
  }
}
@media (pointer: coarse) and (min-width: 701px) and (max-width: 1180px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 22px 16px;
  }
  main {
    padding-inline: max(24px, var(--safe-left)) max(24px, var(--safe-right));
  }
  #detail-dialog {
    position: fixed;
    inset: calc(var(--mobile-visible-top, 0px) + max(16px, var(--safe-top))) 0
      auto;
    width: min(820px, calc(100% - 32px - var(--safe-left) - var(--safe-right)));
    height: min(
      860px,
      calc(
        var(--mobile-visible-height, 100dvh) - max(16px, var(--safe-top)) -
          max(16px, var(--safe-bottom))
      )
    );
    max-height: calc(var(--mobile-visible-height, 100dvh) - 32px);
    margin: 0 auto;
    overflow: hidden;
  }
  #detail-content {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #detail-dialog .detail-toolbar {
    position: relative;
    flex: 0 0 auto;
    min-height: 56px;
    padding: 4px 16px;
  }
  #detail-dialog .detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #detail-dialog #close-detail {
    min-width: 48px;
    min-height: 48px;
  }
}
@media (max-width: 420px) {
  html[data-ui-text]:not([data-ui-text="standard"])
    #detail-dialog
    .detail-hero {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
  }
  html[data-ui-text]:not([data-ui-text="standard"])
    #detail-dialog
    .detail-hero
    .cover {
    width: 72px;
  }
  .interface-setting {
    flex-wrap: wrap;
  }
}
#detail-dialog .detail-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}
#detail-dialog .detail-actions > button {
  min-height: 48px;
  justify-content: center;
  font-weight: 550;
  padding: 10px 14px;
  border-radius: 10px;
}
#detail-dialog .detail-actions #save-detail {
  font-weight: 450;
  background: var(--surface);
  border-color: var(--line);
}
.detail-personal,
.detail-aliases {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
}
.detail-personal > summary,
.detail-aliases > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 13px;
  list-style: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
}
.detail-personal > summary::-webkit-details-marker,
.detail-aliases > summary::-webkit-details-marker {
  display: none;
}
.detail-personal > summary::after,
.detail-aliases > summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
}
.detail-personal[open] > summary::after,
.detail-aliases[open] > summary::after {
  content: "−";
}
.personal-status,
.alias-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 400;
  overflow-wrap: anywhere;
  min-width: 0;
}
.detail-personal-body {
  padding: 2px 13px 14px;
}
#detail-dialog .detail-personal .reading-state-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 48%);
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
}
#detail-dialog .detail-personal .reading-state-control label {
  font-size: 0.75rem;
  color: var(--muted);
}
#detail-dialog .detail-personal select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
}
#detail-dialog .detail-personal .work-reactions {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px 0;
}
#detail-dialog .detail-personal .work-reactions > span {
  font-size: 0.75rem;
  margin: 0;
  color: var(--muted);
}
.reaction-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#detail-dialog .reaction-choices button {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  font-size: 0.75rem;
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}
#detail-dialog .reaction-choices button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: #efab8708;
}
#detail-dialog
  .reaction-choices
  button[data-reaction="dislike"][aria-pressed="true"] {
  color: #dcabb0;
  border-color: #dcabb0;
}
#detail-dialog .reaction-choices .icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
#detail-dialog .detail-personal .reading-tools {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
#detail-dialog .reading-tools .read-until {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 8px 0;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 0.75rem;
}
.detail-personal .personal-tools {
  margin: 0;
  padding-top: 14px;
}
.detail-personal .personal-tools h4 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}
.detail-personal .personal-tools form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 10px 0 0;
}
.detail-personal .personal-tools label {
  display: grid;
  gap: 7px;
  font-size: 0.75rem;
  line-height: 1.6;
  min-width: 0;
}
.detail-personal .personal-tools label:has(input[type="checkbox"]) {
  display: flex;
  align-items: flex-start;
}
.detail-personal .personal-tools input:not([type="checkbox"]),
.detail-personal .personal-tools select {
  width: 100%;
  min-width: 0;
  margin: 0;
}
.detail-personal .personal-tools button {
  min-height: 44px;
  margin: 0;
  font-size: 0.75rem;
  border-color: var(--line);
}
#detail-dialog details.detail-aliases .alias-list {
  padding: 0 13px 12px;
  margin: 0;
}
#detail-dialog .detail-genres .aliases {
  margin-bottom: 12px;
}
#detail-dialog .detail-chapters {
  margin-top: 4px;
}
#detail-dialog .single-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
}
#detail-dialog .single-source button {
  min-height: 44px;
  background: none;
  border: 0;
  color: var(--accent);
  padding: 8px 0;
  font-size: 0.6875rem;
}
@media (max-width: 700px) {
  #detail-dialog .detail-body {
    padding-top: 16px;
  }
  #detail-dialog .detail-facts {
    margin: 16px 0;
    padding: 12px 0;
    gap: 12px;
  }
  #detail-dialog .detail-actions > button {
    font-size: 0.8125rem;
  }
  #detail-dialog .detail-info h2 {
    font-size: 1.375rem;
    line-height: 1.25;
  }
  #detail-dialog .detail-personal {
    margin-bottom: 18px;
  }
  #detail-dialog .detail-genres button {
    min-height: 40px;
    padding: 6px 0;
  }
  #detail-dialog .detail-aliases {
    margin-bottom: 16px;
  }
  #detail-dialog .detail-chapters .detail-section-heading {
    font-size: 0.875rem;
    margin-top: 16px;
  }
}
@media (max-width: 700px), (pointer: coarse) {
  :is(html, body, dialog, .detail-body, .reader-options, .recent-searches) {
    scrollbar-width: none;
    scrollbar-gutter: auto;
  }
  :is(
    html,
    body,
    dialog,
    .detail-body,
    .reader-options,
    .recent-searches
  )::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
}
@media (forced-colors: active) {
  * {
    scrollbar-color: auto;
  }
  :is(html, body, dialog, .detail-body, .reader-options, .recent-searches) {
    scrollbar-width: auto;
  }
  :is(
    html,
    body,
    dialog,
    .detail-body,
    .reader-options,
    .recent-searches
  )::-webkit-scrollbar {
    display: revert;
    width: revert;
    height: revert;
  }
}

/* ---- Downloads: ficha panel, chapter marks, offline library. ---- */
.detail-downloads {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.detail-downloads > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 13px;
  list-style: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
}
.detail-downloads > summary::-webkit-details-marker {
  display: none;
}
.detail-downloads > summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
}
.detail-downloads[open] > summary::after {
  content: "−";
}
.download-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 400;
}
.detail-downloads-body {
  display: grid;
  gap: 10px;
  padding: 2px 13px 14px;
}
.download-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.download-choices button {
  min-height: 48px;
  padding: 8px 6px;
  font-size: 0.75rem;
  line-height: 1.3;
  border-radius: 9px;
  white-space: normal;
}
.download-choices small {
  display: block;
  color: var(--muted);
  font-size: 0.6875rem;
}
.download-progress {
  margin: 0;
  min-height: 1.4em;
  color: var(--text);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.download-manage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.download-manage button,
.download-manage a {
  min-height: 44px;
  font-size: 0.75rem;
}
.download-manage a {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  color: var(--accent);
}
.download-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.5;
}
.chapter-item.is-downloaded .chapter-row::after {
  content: "↓";
  flex-shrink: 0;
  margin-left: 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 650;
}

/* Back to the top of a long list (appears while scrolling up). */
.back-to-top {
  position: fixed;
  z-index: 29;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #ffffff1c;
  background: #26242cf2;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 6px 24px #0008;
  animation: koma-fade-in 0.18s ease-out;
}
@media (max-width: 700px),
  (pointer: coarse) and (max-width: 1024px) and (max-height: 500px) {
  .back-to-top {
    bottom: calc(84px + var(--safe-bottom));
  }
  html:not(.keyboard-open)[data-ios-installed-canvas] .back-to-top {
    bottom: calc(
      84px + max(0px, var(--safe-bottom) - var(--ios-bottom-gap, 0px))
    );
  }
  .keyboard-open .back-to-top {
    display: none;
  }
}

/* Offline library (downloads.html). */
.downloads-summary,
.downloads-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.download-work {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.download-work > header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
}
.download-work h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}
.download-work header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.download-work header > div {
  flex: 1;
  min-width: 0;
}
.downloads-page .download-chapters {
  margin: 0;
  padding: 0;
  list-style: none;
}
.download-chapters li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 2px 14px;
  border-top: 1px solid var(--line);
}
.downloads-page .download-chapters button {
  margin: 0;
}
.download-read {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  text-align: left;
  background: none;
  border: 0;
  font-size: 13px;
}
.download-chapters small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.download-remove {
  min-width: 44px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 20px;
}
.offline-reader-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -16px;
  padding: calc(6px + var(--safe-top) + var(--status-clearance)) 16px 6px;
  background: #161619f2;
  border-bottom: 1px solid var(--line);
}
.offline-reader-bar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
/* Reading: the page header gives way to the reader bar. */
.downloads-page:has(#offline-pages:not([hidden])) {
  padding-top: 0;
}
.downloads-page:has(#offline-pages:not([hidden])) > header {
  display: none;
}
.offline-page {
  margin: 0 -16px;
}
.offline-page img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 80px;
  aspect-ratio: 850 / 1200;
  -webkit-touch-callout: none;
  user-select: none;
}
.offline-reader-end {
  display: grid;
  gap: 10px;
  padding: 28px 0 calc(28px + var(--safe-bottom));
  text-align: center;
  color: var(--muted);
}

/* ---- «Descargas» section and its tab. ---- */
.sidebar nav #downloads-count {
  display: inline-flex;
  min-width: 17px;
  height: 17px;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--accent);
  color: #241b15;
  font-size: 10px;
  font-weight: 650;
}
.sidebar nav #downloads-count[hidden] {
  display: none;
}
@media (max-width: 700px),
  (pointer: coarse) and (max-width: 1024px) and (max-height: 500px) {
  .sidebar nav a[data-nav="downloads"] {
    position: relative;
  }
  .sidebar nav #downloads-count {
    position: absolute;
    top: 0;
    right: calc(50% - 26px);
  }
}
.download-queue {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}
.download-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.download-card.is-failed {
  border-color: #dcabb055;
}
.download-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.download-card-head button {
  min-height: 40px;
  font-size: 12px;
}
.download-card p,
.download-card small {
  margin: 0;
  font-size: 12px;
}
.download-card small {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Progress fills with a transform: no layout work on every page. */
.download-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #ffffff10;
}
.download-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transition: transform 0.25s var(--ease-out);
}
.storage-meter {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}
.storage-meter p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.storage-meter strong {
  color: var(--text);
}
.downloaded-work {
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.downloaded-work > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  list-style: none;
  cursor: pointer;
}
.downloaded-work > summary::-webkit-details-marker {
  display: none;
}
.downloaded-work > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-size: 18px;
}
.downloaded-work[open] > summary::after {
  content: "−";
}
.downloaded-work summary img,
.downloaded-thumb {
  flex: 0 0 40px;
  width: 40px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--raised);
  -webkit-touch-callout: none;
}
.downloaded-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.downloaded-name {
  display: grid;
  min-width: 0;
}
.downloaded-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 550;
}
.downloaded-name small {
  color: var(--muted);
  font-size: 12px;
}
.downloaded-chapter {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
}
.downloaded-read {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: left;
  font-size: 13px;
}
.downloaded-read small {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 11px;
}
.downloaded-actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}
.downloaded-actions button {
  flex: 1;
  min-height: 44px;
  font-size: 12px;
}
.downloads-https {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.5;
}
.downloads-offline-link {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
}
.downloads-offline-link a {
  color: var(--accent);
}
@media (prefers-reduced-motion: reduce) {
  .download-bar span {
    transition: none;
  }
}

/* Ficha sheet: a grabber hints that it can be dragged down to close. */
@media (max-width: 700px) {
  #detail-dialog .detail-toolbar::before {
    content: "";
    position: absolute;
    left: 50%;
    top: max(4px, calc(var(--safe-top) + var(--status-clearance) - 7px));
    width: 36px;
    height: 5px;
    border-radius: 3px;
    background: #ffffff38;
    transform: translateX(-50%);
    pointer-events: none;
  }
}

/* ---- Compact headers. The logo lives in the search row, «Todas / Para ti»
   shares a row with the options, and the library tools fit in one row. ---- */
.topbar-mark {
  display: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 16px;
}
.catalog-toolbar .discovery-controls {
  margin: 0;
}
.catalog-toolbar .taste-tools {
  margin: 0 0 0 auto;
}
/* Open, the options take the full width under the selector. */
.catalog-toolbar .taste-tools[open] {
  flex-basis: 100%;
  margin-left: 0;
}
.catalog-toolbar .taste-tools > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}
.catalog-toolbar .taste-tools > summary::-webkit-details-marker {
  display: none;
}
.catalog-toolbar .taste-tools > summary::after {
  content: "▾";
  font-size: 10px;
  transition: transform 0.2s var(--ease-out);
}
.catalog-toolbar .taste-tools[open] > summary::after {
  transform: rotate(180deg);
}
.refresh-library .icon {
  width: 18px;
  height: 18px;
}
.refresh-library.is-busy .icon {
  animation: koma-spin 0.8s linear infinite;
}
@keyframes koma-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 700px),
  (pointer: coarse) and (max-width: 1024px) and (max-height: 500px) {
  /* Only the status-bar clearance remains above the search row. */
  .sidebar {
    padding: calc(var(--safe-top) + var(--status-clearance)) 0 0;
  }
  .sidebar > .brand {
    display: none;
  }
  .topbar {
    height: auto;
    gap: 6px;
    padding: 6px max(16px, var(--safe-right)) 6px max(10px, var(--safe-left));
  }
  .topbar-mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
  }
  .topbar-mark .brand-mark {
    width: 30px;
    height: 32px;
    border-radius: 8px;
    font-size: 22px;
  }
  .topbar .search-box {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 2px 2px 2px 12px;
  }
  .topbar .search-box input {
    min-height: 0;
  }
  .topbar .search-box button {
    min-height: 38px;
  }
  #main[data-view] {
    padding-top: 4px;
  }
  .catalog-toolbar {
    margin-bottom: 14px;
  }
  .catalog-toolbar .discovery-controls button {
    min-height: 34px;
    padding-inline: 14px;
  }
  .catalog-toolbar .taste-tools > summary {
    min-height: 40px;
  }
  .library-tools {
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 10px;
  }
  .library-tools select {
    flex: 1 1 0;
    height: 44px;
    padding-block: 0;
  }
  .library-tools .refresh-library {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    margin-left: 0;
  }
  .filters {
    margin-bottom: 14px;
  }
  .filter-top {
    gap: 8px;
    padding-bottom: 8px;
  }
  .kind-filters button {
    min-height: 36px;
    padding: 6px 12px;
  }
  #filter-toggle {
    width: 40px;
    height: 36px;
    min-height: 36px;
  }
  .result-count {
    margin-top: 8px;
  }
  .reading-filters {
    gap: 6px;
    margin-top: 6px;
    padding: 2px 0;
  }
  .reading-filters button {
    min-height: 36px;
    padding: 6px 13px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .refresh-library.is-busy .icon {
    animation-duration: 2.4s;
  }
}

/* ---- Covers fade in when they load (already shown ones render loaded). ---- */
.book .cover img {
  opacity: 0;
  transition: opacity 0.22s var(--ease-out);
}
.book .cover img.is-loaded {
  opacity: 1;
}

/* ---- Ficha loading: placeholders shaped like the ficha. ---- */
.detail-skeleton {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.detail-skeleton .sk {
  border-radius: 9px;
  background: #ffffff0d;
  animation: koma-skeleton 1.1s ease-in-out infinite alternate;
}
.detail-skeleton .sk-facts {
  height: 44px;
}
.detail-skeleton .sk-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.detail-skeleton .sk-primary {
  flex: 1;
  height: 46px;
}
.detail-skeleton .sk-secondary {
  width: 96px;
  height: 46px;
}
.detail-skeleton .sk-line {
  height: 12px;
  border-radius: 6px;
}
.detail-skeleton .sk-short {
  width: 62%;
}
.detail-skeleton .sk-heading {
  width: 38%;
  height: 16px;
  margin-top: 14px;
}
.detail-skeleton .sk-row {
  height: 52px;
}
@keyframes koma-skeleton {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

/* ---- A card's cover grows into the ficha (View Transitions). ---- */
::view-transition-group(koma-cover) {
  animation-duration: 0.34s;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}
::view-transition-old(koma-cover),
::view-transition-new(koma-cover) {
  height: 100%;
  animation-duration: 0.34s;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.24s;
  animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
}
/* The view transition already moves the ficha in: no second entrance. */
#detail-dialog.is-morphing[open] {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .book .cover img {
    transition: none;
  }
  .detail-skeleton .sk {
    animation: none;
  }
}

/* ---- Reading progress bar (Continuar, ficha). ---- */
.history-resume[aria-busy="true"] {
  opacity: 0.55;
}
.reading-bar {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: #ffffff14;
}
.reading-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
}

/* ---- Continuar: one row per story. ---- */
.history-tools {
  justify-content: space-between;
  align-items: center;
}
.history-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}
.history-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.history-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  transition: transform 0.16s var(--ease-out);
}
.history-open:active {
  transform: scale(0.98);
}
.history-open .cover {
  flex: 0 0 56px;
  width: 56px;
  border-radius: 7px;
}
.history-open .cover > span {
  font-size: 20px;
}
.history-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.history-text strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.history-text small {
  font-size: 12px;
  color: var(--muted);
}
.history-text .history-meta {
  font-size: 11px;
}
.history-new {
  color: #b6d3b7;
  font-weight: 600;
}
.history-resume {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  transition:
    transform 0.16s var(--ease-out),
    opacity 0.16s ease;
}
.history-resume:active {
  transform: scale(0.97);
}
.history-resume .icon {
  width: 14px;
  height: 14px;
}

/* ---- Ficha: cover backdrop, chips, «Seguir» with progress, quick actions
   and the «⋯» sheet with the secondary panels. ---- */
.detail-toolbar-spacer {
  flex: 1;
}
.detail-more-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin-right: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff10;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.16s var(--ease-out);
}
.detail-more-button:active {
  transform: scale(0.94);
}
#detail-dialog .detail-hero {
  position: relative;
  isolation: isolate;
  align-items: end;
}
#detail-dialog .detail-hero::before,
#detail-dialog .detail-hero::after {
  content: "";
  position: absolute;
  /* Keep decoration inside the hero's layout bounds. Negative insets and
     scaling create horizontal scroll overflow in the iOS sheet. */
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
#detail-dialog .detail-hero::before {
  background: var(--detail-cover, none) center / cover no-repeat;
  filter: blur(24px) saturate(1.2);
  opacity: 0.34;
}
#detail-dialog .detail-hero::after {
  background: linear-gradient(180deg, transparent 25%, #111114);
}
@media (max-width: 700px) {
  #detail-dialog .detail-hero {
    grid-template-columns: 104px minmax(0, 1fr);
  }
  #detail-dialog .detail-hero .cover {
    width: 104px;
  }
}
#detail-dialog .detail-hero .cover {
  box-shadow: 0 10px 30px #0008;
}
.detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.detail-chips span {
  padding: 4px 9px;
  border-radius: 999px;
  background: #ffffff12;
  color: #e6e1ea;
  font-size: 11px;
}
.detail-cta {
  display: grid;
  gap: 6px;
  margin: 18px 0 8px;
}
#detail-dialog .detail-cta .primary {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 56px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 650;
  transition: transform 0.16s var(--ease-out);
}
#detail-dialog .detail-cta .primary:active {
  transform: scale(0.98);
}
.detail-cta .primary small {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}
.detail-progress-label {
  justify-self: end;
  font-size: 11px;
  color: var(--muted);
}
.detail-quick {
  display: flex;
  gap: 8px;
  margin: 4px 0 18px;
}
#detail-dialog .detail-quick button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 12px;
  transition: transform 0.16s var(--ease-out);
}
#detail-dialog .detail-quick button:active {
  transform: scale(0.97);
}
.detail-quick .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
#detail-dialog .detail-quick button[aria-pressed="true"] {
  border-color: #efab8755;
  color: var(--accent);
}
.detail-more-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #0009;
  animation: koma-fade-in 0.2s ease-out;
}
.detail-more {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 41;
  max-height: 80dvh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 16px calc(20px + var(--safe-bottom));
  border-radius: 16px 16px 0 0;
  background: #1d1c22;
  box-shadow: 0 -12px 40px #000a;
  animation: koma-more-in 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.detail-more::before {
  content: "";
  display: block;
  width: 36px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 3px;
  background: #ffffff38;
}
.detail-more[hidden],
.detail-more-backdrop[hidden] {
  display: none;
}
.detail-more-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.detail-more-head button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff10;
  color: var(--text);
  font-size: 18px;
}
.detail-more > details {
  margin: 0 0 8px;
}
.detail-more-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  color: var(--accent);
  font-size: 14px;
}
@keyframes koma-more-in {
  from {
    transform: translateY(100%);
  }
}
@media (min-width: 701px) {
  .detail-more {
    right: max(24px, calc(50vw - 380px));
    bottom: 24px;
    left: auto;
    width: 380px;
    border-radius: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .detail-more,
  .detail-more-backdrop {
    animation: none;
  }
}
.detail-skeleton .sk-primary {
  height: 56px;
}
.detail-skeleton .sk-actions .sk {
  flex: 1;
  height: 44px;
}
