button, a[href], input[type="range"] {
  touch-action: manipulation;
}

* {
  box-sizing: border-box;
}
html {
  color-scheme: dark;
  background: #080809;
}
body {
  margin: 0;
  color: #f8f7f4;
  font:
    16px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    sans-serif;
  background: #101011;
  min-height: 100dvh;
}
main {
  max-width: 780px;
  margin: auto;
  --gutter: clamp(16px, 3vw, 24px);
  padding: calc(env(safe-area-inset-top) + 8px) max(var(--gutter), env(safe-area-inset-right)) calc(104px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
.library-controls { display: flex; align-items: center; gap: 2px; }
.order-control { position: relative; }
#order-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ccc8c4;
}
#library-order {
  position: absolute;
  z-index: 5;
  inset-inline-end: 0;
  top: 100%;
  width: max-content;
  padding: 3px;
  background: #242426;
  border: 1px solid #ffffff26;
  border-radius: 10px;
  box-shadow: 0 6px 18px #0005;
}
#library-order button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  white-space: nowrap;
}
#library-order button::before {
  content: "";
  width: 10px;
  height: 6px;
  box-sizing: border-box;
}
#library-order [aria-checked="true"]::before {
  border-left: 2px solid #ffd65a;
  border-bottom: 2px solid #ffd65a;
  transform: translateY(-1px) rotate(-45deg);
}
#library-order button:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  #order-toggle:hover, #library-order button:hover, #settings-open:hover { background: #ffffff0d; }
}
#settings-open { display: grid; place-items: center; background: transparent; border: 0; color: #ccc8c4; min-height: 44px; min-width: 44px; padding: 0 6px; font-size: 14px; }
header {
  margin-bottom: 4px;
  border-bottom: 1px solid #ffffff1a;
}
header,
.brand,
.dialog-head,
.row,
.check {
  display: flex;
  align-items: center;
}
header,
.dialog-head {
  justify-content: space-between;
  gap: 12px;
}
.brand {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0;
  gap: 9px;
}
.brand img {
  width: 28px;
  height: 28px;
  border-radius: 10px;
}
button,
a {
  font: inherit;
  cursor: pointer;
}
button,
#action-list a {
  color: inherit;
  background: #262629;
  border: 1px solid #ffffff17;
  border-radius: 11px;
  padding: 8px 13px;
}
button:hover,
#action-list a:hover {
  background: #353538;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid #ffd65a;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
}
.primary {
  background: #ffd65a;
  color: #201d16;
  font-weight: 650;
}
.primary:hover {
  background: #ffe28a;
}
#new-open {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: grid;
  place-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font: 400 32px/1 sans-serif;
}
.hint,
label,
#status,
.meta,
.empty,
.job small {
  color: #aaa7a6;
  font-size: 14px;
}
#library,
#jobs {
  display: grid;
  gap: 12px;
}
.job {
  border: 1px solid #ffffff13;
  background: #171719;
  border-radius: 18px;
  padding: 16px;
}
#library { gap: 0; }
.card + .card { border-top: 1px solid #ffffff0e; }
.row-front {
  flex: 0 0 100%;
  min-width: 0;
  position: relative;
  z-index: 1;
  background: #101011;
  touch-action: pan-y pinch-zoom;
  transition: transform 160ms ease-out;
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.cover {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(145deg, #564a3e, #302a25);
}
.cover.ted { background: linear-gradient(145deg, #903f3b, #51292b); }
.cover.url { background: linear-gradient(145deg, #34555c, #223438); }
.cover.image { background: linear-gradient(145deg, #575070, #332f40); }
.cover-play {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: #0004;
  box-shadow: inset 0 0 0 1px #ffffff50;
}
.cover-play::after {
  content: "";
  border-left: 10px solid white;
  border-block: 6px solid transparent;
  margin-left: 2px;
}
@media (hover: hover) and (pointer: fine) {
  .cover:hover .cover-play { background: #0008; }
  .book:hover strong { text-decoration: underline; text-underline-offset: 3px; }
}
.cover:active .cover-play, #new-open:active { scale: .96; }
.book {
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}
.book strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.sub {
  display: block;
  color: #c2bfba;
  font-size: 14px;
  margin: 3px 0;
}
.meta {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.card progress,
.job progress {
  display: block;
  height: 3px;
  width: 100%;
  margin-top: 9px;
  accent-color: #ffd65a;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background: #353536;
}
progress::-webkit-progress-value {
  background: #ffd65a;
}
.job {
  overflow-wrap: anywhere;
  margin-bottom: 10px;
}
.job small {
  display: block;
}
.empty {
  padding: 24px;
  border: 1px dashed #444;
  border-radius: 15px;
}
.error {
  color: #ffae9d;
}
#status {
  margin-bottom: 12px;
}
#demo {
  margin-bottom: 15px;
}
dialog {
  width: min(480px, calc(100% - 24px));
  max-height: 88dvh;
  border: 1px solid #424244;
  border-radius: 20px;
  padding: 22px;
  background: #19191b;
  color: white;
}
dialog::backdrop {
  background: #000b;
  backdrop-filter: blur(4px);
}
h2 {
  font-size: 22px;
  margin: 0;
}
.dialog-head {
  margin-bottom: 15px;
}
.close {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 22px;
}
label {
  display: grid;
  gap: 5px;
  margin: 12px 0;
}
input,
textarea,
select {
  min-width: 0;
  width: 100%;
  background: #101011;
  color: white;
  border: 1px solid #48484b;
  border-radius: 9px;
  padding: 10px;
  font: inherit;
}
.check input {
  width: auto;
}
.check {
  gap: 8px;
}
.hint {
  margin-top: -5px;
}
.error:empty {
  display: none;
}
nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
nav button {
  font-size: 13px;
  padding: 6px 9px;
}
nav button[aria-pressed="true"] {
  color: #ffda79;
  border-color: #a98e4e;
}
#previews {
  padding: 0;
}
#previews li {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}
#previews li span {
  flex: 1;
  overflow-wrap: anywhere;
  font-size: 12px;
}
#previews img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 5px;
}
#action-list {
  display: grid;
  gap: 8px;
}
#action-list a {
  text-decoration: none;
  text-align: center;
}
[hidden] {
  display: none !important;
}
@media (max-width: 500px) {
  .row-front {
    gap: 10px;
  }
  .cover {
    width: 48px;
    height: 48px;
  }
  .book strong {
    font-size: 16px;
  }
}

#action-list { gap: 0; }
#action-list > :is(a, button) {
  min-height: 44px;
  padding: 10px 4px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid #ffffff12;
  background: transparent;
  text-align: start;
}
#action-list > :last-child { border: 0; }
#action-list .destructive { color: #ffafa6; }
@media (max-width: 500px) {
  #actions {
    margin: auto 0 0;
    width: 100%;
    max-width: 100%;
    padding: 16px 20px calc(14px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  #actions .close { min-width: 44px; min-height: 44px; }
  #actions .dialog-head { margin-bottom: 4px; }
}

#filter-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: #ccc8c4;
}
#filter-toggle[aria-expanded="true"] { color: #ffd65a; }
#library-filters { padding: 10px 0 4px; }
.filter-options, .filter-options label { display: flex; align-items: center; }
.filter-options { justify-content: space-between; }
.filter-options label { gap: 8px; min-height: 44px; margin: 0; color: inherit; }
#offline-only { width: 16px; height: 16px; accent-color: #ffd65a; }
#clear-filters { min-height: 44px; border: 0; background: transparent; font-size: 14px; }
#filter-result { margin: 0; color: #aaa7a6; font-size: 14px; }

#library { grid-template-columns: minmax(0, 1fr); }
.card { position: relative; overflow: hidden; }
.dragging .row-front { transition: none; }
.row-open .row-front { transform: translateX(calc(-1 * var(--rail-width))); }
.row-actions {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 12px;
  visibility: hidden;
}
.row-open .row-actions, .dragging .row-actions { visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .row-front { transition: none; }
}
.row-actions button { min-height: 44px; }
.cover { position: relative; overflow: hidden; isolation: isolate; text-decoration: none; }
.row-front :focus-visible { outline-offset: -2px; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-initial { font: 600 24px/1 system-ui, sans-serif; color: #fff; }
.cover .cover-play { position: absolute; bottom: 2px; right: 2px; width: 19px; height: 19px; background: #141414a8; }
.cover-play::after { border-left-width: 6px; border-block-width: 4px; }
#create-fields { margin: 0; padding: 0; border: 0; min-width: 0; }
#create-fields:disabled { opacity: .58; }
#admin-unlock { border-bottom: 1px solid #ffffff24; padding-bottom: 14px; margin-bottom: 18px; }
