:root {
  color-scheme: light;
  --ink: #142d2d;
  --muted: #526561;
  --paper: #f5f5ef;
  --white: #fff;
  --line: #d9e1d8;
  --dark: #112a2c;
  --lime: #c9ef9b;
  --red: #9b2b2e;
  --red-bg: #fbeceb;
  font-family: "Aptos", "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid #287e60; outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { letter-spacing: -.04em; line-height: 1.08; }
h1 { font-size: clamp(2rem, 4vw, 3.45rem); }
h2 { font-size: clamp(1.45rem, 3vw, 2.12rem); }

.skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 4; padding: 1rem; background: var(--white); transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.topbar { background: var(--dark); color: var(--white); padding-inline: max(1rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
.top-inner { max-width: 68rem; min-height: 62px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; font-weight: 750; letter-spacing: -.015em; }
.brand-icon { width: 28px; height: 22px; border: 2px solid var(--lime); border-radius: 6px; position: relative; }
.brand-icon::before { content: ""; position: absolute; inset: auto 4px 4px; height: 3px; border-radius: 2px; background: var(--lime); }
.brand-icon::after { content: ""; position: absolute; top: 4px; right: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--lime); }
.sign-out { color: #e3eee8; background: none; border: 0; min-height: 44px; padding: 0 .2rem; font-size: .87rem; }

.wrap { max-width: 70rem; margin-inline: auto; padding: 2.1rem max(1rem, env(safe-area-inset-left), env(safe-area-inset-right)) max(2.6rem, env(safe-area-inset-bottom)); }
.overview h1 { margin-bottom: 1.15rem; }
.drive-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.drive { display: flex; flex-direction: column; gap: .9rem; padding: 1.1rem 1.2rem; border: 2px solid transparent; background: #e8eee5; border-radius: 1.1rem; text-decoration: none; }
.drive:hover { border-color: #789486; }
.drive.selected { background: var(--dark); color: white; border-color: var(--dark); box-shadow: inset 0 0 0 1px #497168; }
.drive.selected:hover { border-color: #3a6c59; }
.drive-top, .drive-extra { display: flex; align-items: center; justify-content: space-between; gap: .25rem; }
.drive-name { font-size: .89rem; font-weight: 700; letter-spacing: .025em; }
.disk-glyph { border: 1px solid currentColor; width: 1.15rem; height: .65rem; border-radius: .22rem; position: relative; opacity: .7; }
.disk-glyph::after { content: ""; position: absolute; top: 3px; right: 3px; border-radius: 50%; width: 3px; height: 3px; background: currentColor; }
.drive strong { line-height: 1; font-size: clamp(1.3rem, 3vw, 2.15rem); letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.drive strong small { font-size: .54em; font-weight: 550; letter-spacing: 0; }
.drive-extra { font-size: .8rem; color: var(--muted); }
.drive.selected .drive-extra { color: #c0d0c9; }
.drive meter { appearance: none; width: 100%; height: .46rem; border: 0; border-radius: 1rem; background: #d1ded3; }
.drive.selected meter { background: #355656; }
.drive meter::-webkit-meter-bar { height: .46rem; border: 0; background: transparent; }
.drive meter::-webkit-meter-optimum-value { background: #4c8367; border-radius: 1rem; }
.drive meter::-moz-meter-bar { background: #4c8367; border-radius: 1rem; }
.drive.selected meter::-webkit-meter-optimum-value { background: var(--lime); }
.drive.selected meter::-moz-meter-bar { background: var(--lime); }
.drive meter.full::-webkit-meter-optimum-value { background: #df9b64; }
.drive meter.full::-moz-meter-bar { background: #df9b64; }

.catalog { margin-top: 2rem; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.section-head p, .sort-label, .review-top span { color: var(--muted); font-size: .88rem; }
.section-head p { margin-top: .4rem; }
.sort-label { white-space: nowrap; padding-bottom: .1rem; }
.filters { display: grid; grid-template-columns: minmax(10rem, 2fr) repeat(4, minmax(0, 1fr)) auto; align-items: end; gap: .55rem; margin-bottom: .85rem; }
label { display: flex; flex-direction: column; gap: .35rem; color: var(--muted); font-size: .82rem; font-weight: 650; min-width: 0; }
label input, select { height: 44px; border: 1px solid #c6d1c7; border-radius: .6rem; padding: 0 .65rem; background: var(--white); color: var(--ink); min-width: 0; width: 100%; font-size: .95rem; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: .55rem; min-height: 44px; border: 1px solid transparent; border-radius: .65rem; padding: .55rem .9rem; text-align: center; text-decoration: none; font-weight: 700; font-size: .9rem; line-height: 1.25; }
.button.primary { background: var(--lime); border-color: #b4da86; color: var(--dark); }
.button.primary:hover { background: #bae68a; }
.button.secondary { background: var(--white); border-color: var(--line); color: var(--ink); }
.button.secondary:hover { background: #edf3eb; }
.button.danger-outline { background: var(--white); border-color: #dcbaba; color: var(--red); }
.button.danger-outline:hover { background: var(--red-bg); }
.button.danger { background: var(--red); color: white; }
.button.danger:hover { background: #7f2225; }
button:disabled { cursor: wait; opacity: .7; }

.torrent-list { list-style: none; margin: 0; padding: 0; background: var(--white); border: 1px solid var(--line); border-radius: .95rem; }
.torrent-list li + li { border-top: 1px solid var(--line); }
.torrent-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: .75rem; padding: .85rem 1rem; min-height: 70px; text-decoration: none; }
.torrent-row:hover { background: #f5f9f3; }
.torrent-list li:first-child .torrent-row { border-radius: .9rem .9rem 0 0; }
.torrent-list li:last-child .torrent-row { border-radius: 0 0 .9rem .9rem; }
.film-icon { display: grid; place-items: center; background: #e9f0e7; width: 2.4rem; height: 2.4rem; border-radius: .55rem; color: #3d6958; font-size: 1.24rem; }
.torrent-summary { display: flex; flex-direction: column; gap: .27rem; min-width: 0; }
.torrent-summary strong { font-size: .95rem; overflow-wrap: anywhere; }
.torrent-summary > span { font-size: .78rem; color: var(--muted); }
.torrent-size { font-weight: 730; font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chevron { color: #55706a; font-size: 1.25rem; line-height: 1; }
.empty, .confirmation, .auth-card { background: var(--white); border: 1px solid var(--line); border-radius: 1rem; padding: 1.4rem; }
.empty p, .confirmation > p, .auth-card > p { color: var(--muted); margin-top: .5rem; line-height: 1.55; }
.pagination { padding: .9rem 0 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .45rem; }
.pagination > a:first-child { justify-self: start; }
.pagination > a:last-child { justify-self: end; }
.pagination > span { font-size: .8rem; color: var(--muted); }

.review-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; color: #355e52; font-weight: 700; text-decoration-thickness: 1px; text-underline-offset: .25rem; font-size: .88rem; }
.review-heading { display: flex; align-items: end; justify-content: space-between; gap: .8rem; margin-bottom: 1.25rem; }
.review-heading h1 { font-size: clamp(1.6rem, 3.3vw, 2.75rem); overflow-wrap: anywhere; text-wrap: pretty; }
.item-type { margin-bottom: .45rem; font-size: .86rem; font-weight: 650; color: #496b60; }
.item-type span { margin-inline: .2rem; }
.size-badge { white-space: nowrap; display: inline-block; border-radius: .6rem; padding: .45rem .65rem; background: #e3efdb; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem); align-items: start; gap: 1rem; }
.preview-panel { min-width: 0; color: white; background: var(--dark); border-radius: .95rem; padding: 1rem; }
.preview-panel :focus-visible { outline-color: var(--lime); }
.preview-title { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-bottom: .8rem; }
.preview-title h2 { font-size: 1.4rem; }
.preview-idle { display: grid; place-items: center; align-content: center; gap: .7rem; min-height: clamp(8rem, 24vw, 16rem); color: #bfd2ca; border: 1px dashed #4c6c68; border-radius: .65rem; font-size: .9rem; text-align: center; }
.preview-glyph { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: .6rem; background: #355353; color: var(--lime); font-size: 1.4rem; }
.preview-status { color: #cae1d5; font-size: .84rem; line-height: 1.45; margin-top: .75rem; }
.preview-status:empty { display: none; }
.storyboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.storyboard button { display: flex; flex-direction: column; gap: .37rem; border: 1px solid #5d7872; border-radius: .55rem; padding: .2rem; overflow: hidden; color: white; background: #1c3939; font-weight: 680; font-size: .79rem; text-align: left; }
.storyboard button[aria-pressed="true"] { border-color: var(--lime); color: var(--lime); }
.storyboard button > span { padding: 0 .25rem .2rem; }
.storyboard button:hover { border-color: var(--lime); }
.storyboard img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; border-radius: .35rem; background: #0a1718; }
video { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: min(56vh, 24rem); margin-top: .6rem; border-radius: .5rem; background: #0a1718; }
.details { display: grid; gap: .55rem; padding: .9rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--white); }
.details dl { margin: 0 0 .35rem; }
.details dl div { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .84rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 700; text-align: right; }
.details form .button { width: 100%; }
.review-nav { display: flex; justify-content: space-between; margin-top: 1rem; }
.review-nav .button { min-width: 6rem; }
.confirmation { max-width: 38rem; margin: 0 auto; }
.confirmation h1, .auth-card h1 { font-size: clamp(1.7rem, 4vw, 2.45rem); }
.confirmation > .button { margin-top: 1rem; }
.confirm-item { margin: 1.2rem 0; padding: 1rem; background: var(--paper); border-radius: .75rem; }
.confirm-item strong { overflow-wrap: anywhere; }
.confirm-item div { display: flex; gap: .7rem; color: var(--muted); margin-top: .5rem; font-size: .84rem; }
.checkbox { display: flex; flex-direction: row; align-items: center; gap: .6rem; padding-block: .5rem; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--red); flex-shrink: 0; }
.confirm-actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: .75rem; }
.login-wrap { display: grid; justify-items: center; padding-top: min(15vh, 6rem); }
.auth-card { max-width: 26rem; width: 100%; padding: 1.6rem; }
.auth-card form { display: grid; gap: .8rem; margin-top: 1rem; }
.auth-card button { margin-top: .2rem; }
.notice { margin-bottom: .8rem; padding: .65rem .85rem; border: 1px solid #b9d2b0; background: #e8f4de; border-radius: .65rem; }
.notice.warning { margin: .8rem 0 0; background: var(--red-bg); border-color: #e7bdba; color: var(--red); }

@media (max-width: 760px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-label { grid-column: 1 / -1; }
  .filters button { grid-column: 1 / -1; justify-self: end; min-width: 6rem; }
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .details { grid-template-columns: 1fr 1fr; }
  .details dl { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .wrap { padding-top: 1.25rem; }
  .top-inner { min-height: 55px; }
  .drive-grid { gap: .45rem; }
  .drive { padding: .7rem .55rem; gap: .58rem; border-radius: .75rem; }
  .drive-name { font-size: .79rem; }
  .drive strong { font-size: clamp(.93rem, 4.35vw, 1.45rem); white-space: nowrap; }
  .disk-glyph, .drive-extra > span { display: none; }
  .drive-extra { font-size: .7rem; }
  .catalog { margin-top: 1.45rem; }
  .torrent-row { gap: .5rem; padding-inline: .55rem; }
  .film-icon { width: 1.75rem; height: 1.75rem; font-size: .95rem; }
  .torrent-summary strong { font-size: .87rem; }
  .torrent-summary > span { font-size: .72rem; }
  .torrent-size { font-size: .8rem; }
  .chevron { display: none; }
  .review-heading { align-items: start; flex-direction: column; }
  .review-nav { position: sticky; bottom: 0; background: var(--paper); padding: .45rem 0 max(.45rem, env(safe-area-inset-bottom)); }
  .section-head p, .sort-label { font-size: .8rem; }
}
