:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b10;
  color: #f7f8fb;
  --muted: #a7adba;
  --panel: #151922;
  --panel-hover: #1e2531;
  --accent: #ff4d67;
  --line: rgba(255, 255, 255, 0.09);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% -10%, #3b1622 0, transparent 32rem), #090b10; }
button, input { font: inherit; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: clamp(2rem, 6vw, 5.5rem) clamp(1.25rem, 6vw, 6rem) 2rem; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 .4rem; color: var(--accent); font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 5rem); line-height: .95; letter-spacing: -.055em; }
.summary { margin: 1rem 0 0; color: var(--muted); }
.search { display: grid; gap: .45rem; width: min(24rem, 100%); color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.search input { width: 100%; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .75rem; outline: none; background: rgba(10, 12, 17, .8); color: white; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 77, 103, .16); }
main { padding: 2rem clamp(1.25rem, 6vw, 6rem) 5rem; }
.organizer { margin-bottom: 1.4rem; }
.tabs { display: flex; gap: .5rem; overflow-x: auto; padding: 0 0 .7rem; scrollbar-width: thin; }
.tabButton { display: flex; flex: 0 0 auto; align-items: center; gap: .55rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); color: var(--muted); cursor: pointer; }
.tabButton:hover, .tabButton:focus-visible { color: white; border-color: rgba(255,77,103,.5); outline: none; }
.tabButton[aria-current="page"] { border-color: var(--accent); background: var(--accent); color: white; box-shadow: 0 .4rem 1.4rem rgba(255,77,103,.2); }
.tabCount { display: grid; place-items: center; min-width: 1.45rem; height: 1.45rem; padding: 0 .35rem; border-radius: 999px; background: rgba(0,0,0,.24); font-size: .72rem; font-weight: 800; }
.organizerRow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 2.7rem; }
.viewSummary { margin: 0; color: var(--muted); font-size: .85rem; }
.saveStatus { margin: .22rem 0 0; color: #7fcf9d; font-size: .72rem; }
.saveStatus[data-state="saving"] { color: var(--muted); }
.saveStatus[data-state="error"] { color: #ff8da0; }
.organizerActions { display: flex; align-items: center; gap: .55rem; }
.customTagForm { display: flex; }
.customTagForm input { width: 10rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .65rem 0 0 .65rem; outline: none; background: var(--panel); color: white; }
.customTagForm input:focus { border-color: var(--accent); }
.customTagForm button { padding: .55rem .7rem; border: 1px solid var(--accent); border-radius: 0 .65rem .65rem 0; background: rgba(255,77,103,.14); color: white; cursor: pointer; font-weight: 700; }
.customTagForm button:hover, .customTagForm button:focus-visible { background: var(--accent); outline: none; }
.customTagError { min-height: 1rem; margin: .25rem 0 0; color: #ff8da0; font-size: .74rem; text-align: right; }
.visuallyHidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hideMenu { position: relative; }
.hideMenu summary { padding: .55rem .75rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--panel); color: white; cursor: pointer; font-size: .82rem; font-weight: 700; list-style: none; }
.hideMenu summary::-webkit-details-marker { display: none; }
.hideMenu summary::after { content: " ▾"; color: var(--muted); }
.hideMenu[open] summary::after { content: " ▴"; }
.hiddenCount { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; margin-left: .3rem; border-radius: 999px; background: var(--accent); font-size: .68rem; }
.hidePanel { position: absolute; z-index: 5; top: calc(100% + .45rem); right: 0; width: min(20rem, calc(100vw - 2.5rem)); padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: #161a22; box-shadow: 0 1.2rem 3rem rgba(0,0,0,.5); }
.hideControls { display: grid; gap: .65rem; }
.hidePanel .hideLegend { margin: 0 0 .15rem; color: white; font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.hidePanel label { display: flex; align-items: center; gap: .65rem; color: #e7e9ef; cursor: pointer; }
.hidePanel input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.hidePanel > p { margin: .8rem 0 0; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.clearHidden { width: 100%; margin-top: .9rem; padding: .55rem; border: 1px solid var(--line); border-radius: .55rem; background: rgba(255,255,255,.04); color: white; cursor: pointer; }
.clearHidden:disabled { opacity: .45; cursor: default; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.025)); color: inherit; transition: transform .18s ease, background .18s ease, border-color .18s ease; }
.card:hover { transform: translateY(-2px); border-color: rgba(255, 77, 103, .45); background: var(--panel-hover); }
.cardOpen { display: grid; grid-template-columns: 4.6rem 1fr; gap: 1rem; width: 100%; min-width: 0; padding: .85rem; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.cardOpen:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.poster { position: relative; display: grid; place-items: center; aspect-ratio: 3/4; overflow: hidden; border-radius: .65rem; background: linear-gradient(150deg, #ff4d67, #731a3e 55%, #161a24); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.thumbnail { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .22s ease; }
.hasThumbnail .thumbnail { opacity: 1; }
.playIcon { position: absolute; display: grid; place-items: center; width: 2rem; height: 2rem; padding-left: .15rem; border-radius: 50%; background: rgba(0,0,0,.62); box-shadow: 0 .3rem 1rem rgba(0,0,0,.35); font-size: .8rem; }
.cardText { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.cardTitle { display: -webkit-box; overflow: hidden; font-size: 1rem; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.cardMeta { margin-top: .55rem; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.cardTags { display: flex; flex-wrap: wrap; gap: .35rem; padding: .65rem .75rem .75rem; border-top: 1px solid var(--line); }
.tagButton { padding: .34rem .52rem; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; background: rgba(255,255,255,.035); color: var(--muted); cursor: pointer; font-size: .68rem; font-weight: 750; }
.tagButton:hover, .tagButton:focus-visible { border-color: rgba(255,255,255,.35); color: white; outline: none; }
.tagButton[aria-pressed="true"] { border-color: transparent; color: white; }
.tagButton[data-tag="watched"][aria-pressed="true"] { background: #24745a; }
.tagButton[data-tag="watch-later"][aria-pressed="true"] { background: #245f91; }
.tagButton[data-tag="favourite"][aria-pressed="true"] { background: #a52f55; }
.tagButton[data-tag^="custom-"][aria-pressed="true"] { background: #65519a; }
.notice, .empty { max-width: 42rem; margin: 3rem auto; padding: 2rem; border: 1px solid rgba(255,77,103,.35); border-radius: 1rem; background: rgba(255,77,103,.08); text-align: center; }
.notice h2 { margin-top: 0; }
.notice p, .empty { color: var(--muted); }
dialog { width: min(70rem, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: 1.1rem; background: #0d1016; color: white; box-shadow: 0 2rem 7rem rgba(0,0,0,.72); }
dialog::backdrop { background: rgba(0,0,0,.8); backdrop-filter: blur(8px); }
.playerHeader { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; }
.playerHeader h2 { margin: 0; font-size: clamp(1.1rem, 3vw, 1.6rem); }
.close { padding: .65rem .85rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--panel); color: white; cursor: pointer; }
video { display: block; width: 100%; max-height: 72vh; background: black; }
.resumeNote { min-height: 1.25rem; margin: .65rem 1.2rem 1rem; color: var(--muted); font-size: .82rem; }

@media (max-width: 700px) {
  .hero { align-items: stretch; flex-direction: column; }
  .organizerRow { align-items: flex-start; flex-direction: column; }
  .organizerActions { align-items: stretch; flex-direction: column; width: 100%; }
  .customTagForm input { width: 100%; }
  .hideMenu { align-self: flex-end; }
  .customTagError { text-align: left; }
  .library { grid-template-columns: 1fr; }
  dialog { width: 100vw; max-width: none; margin: auto 0 0; border-radius: 1rem 1rem 0 0; }
}
