/* nas-player — calm dark UI. Values follow the approved mockups (Main / PadLibrary). */

:root {
  --bg: #111214;
  --side: #0E0F11;
  --fg: #E8E6E1;
  --fg2: #C9C5BD;
  --muted: #A09C94;
  --dim: #8A867F;
  --accent: #D4A65A;      /* stars and progress only */
  --star-off: #4A4844;
  --line: rgba(255, 255, 255, .07);
  --border: rgba(255, 255, 255, .12);
  --border-strong: rgba(255, 255, 255, .18);
  --hover: rgba(255, 255, 255, .07);
  --sans: 'IBM Plex Sans KR', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --tabs-h: calc(61px + env(safe-area-inset-bottom, 0px));
  /* side gutters: 16px, or more where a landscape iPhone notch needs it */
  --gl: max(16px, env(safe-area-inset-left, 0px));
  --gr: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fg); text-decoration: none; }
@media (hover: hover) { a:hover { color: #FFFFFF; } }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
[hidden] { display: none !important; }
::selection { background: rgba(255, 255, 255, .22); color: var(--fg); }
:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.quiet { padding: 12px var(--gr) 12px var(--gl); font-size: 13px; color: var(--dim); }

/* ---- buttons -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: var(--fg2); font-size: 13px; white-space: nowrap;
}
.btn.icon-only { width: 44px; padding: 0; color: var(--dim); }
.btn.icon-only.on { color: var(--fg); border-color: var(--border-strong); }
.btn.inline { margin: 4px var(--gr) 4px var(--gl); }
.btn:disabled { opacity: .5; }
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted);
}

/* ---- shell ---------------------------------------------------------------------------- */

.shell { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.view { min-width: 0; padding-bottom: calc(var(--tabs-h) + 8px); }

.wide .shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.wide .side {
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(36px + env(safe-area-inset-top, 0px)) 12px 20px calc(12px + env(safe-area-inset-left, 0px));
  border-right: 1px solid var(--line); background: var(--side);
}
.wide .view { padding: calc(36px + env(safe-area-inset-top, 0px)) calc(28px + env(safe-area-inset-right, 0px)) 24px 28px; }
.wide .tabs, .wide .narrow-only { display: none !important; }

.immersive .side, .immersive .tabs { display: none !important; }
.immersive .shell { display: block; }
.immersive .view { padding: 0; }

/* ---- page header ---------------------------------------------------------------------- */

.page-head {
  display: flex; flex-direction: column; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--gr) 8px var(--gl);
}
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.title { font-size: 22px; font-weight: 600; letter-spacing: -0.2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-row .icon-btn { margin-right: -12px; }
.title-wrap { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.title-stars { letter-spacing: 3px; }
.head-count { font-size: 13px; color: var(--dim); flex: none; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--dim); }
.crumbs a { color: var(--dim); }
.crumbs .crumb-cur { color: var(--fg2); }

.toolbar { display: flex; gap: 8px; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; color: var(--dim); font-size: 14px;
}
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--fg); font-size: 16px; /* 16px keeps iOS from zooming */ }
.search input::placeholder { color: var(--dim); }

.wide .page-head { padding: 0 0 20px; }
.wide .folder-head, .wide .list-head, .wide .home-head { flex-direction: row; align-items: center; gap: 12px; }
.wide .folder-head .title-row { display: none; }
.wide .folder-head .crumbs { flex: 1; min-width: 0; gap: 8px; font-size: 20px; font-weight: 600; color: var(--fg); }
.wide .folder-head .crumbs a { color: var(--dim); font-weight: 500; }
.wide .folder-head .crumbs .crumb-cur { color: var(--fg); }
.wide .folder-head .crumbs .crumb-home, .wide .folder-head .crumbs .sep-home { display: none; }
.wide .list-head .title-row, .wide .home-head .title-row { flex: 1; }
.wide .title { font-size: 20px; }
.wide .toolbar { flex: none; gap: 12px; }
.wide .search { width: 240px; flex: none; }
.wide .search input { font-size: 14px; }

/* ---- lists ---------------------------------------------------------------------------- */

.page-body { padding: 4px 0; }
.wide .page-body { padding: 0; display: flex; flex-direction: column; gap: 20px; }
.divider { height: 1px; background: var(--line); margin: 6px var(--gr) 6px var(--gl); }
.wide .divider { display: none; }
.section-label { padding: 14px var(--gr) 4px var(--gl); font-size: 12px; font-weight: 500; color: var(--dim); }
.wide .section-label { padding: 0 0 8px; }
.wide .home-sections { display: flex; flex-direction: column; gap: 24px; }

.folder { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 12px var(--gr) 12px var(--gl); }
.folder svg { flex: none; }
.f-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.f-name { font-size: 15px; overflow-wrap: anywhere; }
.f-sub { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wide .list.folders { display: flex; flex-wrap: wrap; gap: 10px; }
.wide .list.folders .folder {
  min-height: 44px; padding: 0 16px; gap: 8px;
  border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; font-size: 14px;
}
.wide .list.folders .folder svg { width: 18px; height: 18px; }
.wide .list.folders .f-name { font-size: 14px; }
.wide .home-sec .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.wide .home-sec .folder { border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; padding: 10px 14px; }

/* video: row on iPhone, card on iPad */
/* content-visibility: off-screen rows in very large folders skip layout and paint */
.video {
  display: flex; gap: 12px; padding: 10px var(--gr) 10px var(--gl);
  content-visibility: auto; contain-intrinsic-size: auto 92px;
}
.thumb {
  position: relative; flex: none; width: 128px; height: 72px;
  border-radius: 6px; background: #2B2E33; overflow: hidden;
}
.thumb img, .pthumb img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .2s;
}
.thumb img.loaded, .pthumb img.loaded { opacity: 1; }
.badge {
  position: absolute; right: 5px; bottom: 7px; z-index: 1;
  font: 500 11px var(--mono); color: var(--fg);
  background: rgba(0, 0, 0, .55); padding: 1px 4px; border-radius: 3px;
}
.bar { position: absolute; left: 0; bottom: 0; z-index: 1; height: 3px; background: var(--accent); }
.bar.done { width: 100%; background: rgba(255, 255, 255, .35); }
.info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.v-title { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.v-meta { font-size: 12px; color: var(--dim); }
.v-third { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video.watched .v-title { color: var(--muted); }
.video.watched .thumb img { opacity: .55; }

.wide .videos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 20px; }
.wide .video { flex-direction: column; gap: 8px; padding: 0; contain-intrinsic-size: auto 200px; }
.wide .thumb { width: auto; height: auto; aspect-ratio: 16 / 9; border-radius: 8px; }
.wide .badge { right: 6px; bottom: 8px; padding: 1px 5px; }
.wide .info { gap: 4px; }
.wide .v-title { font-size: 14px; }

/* photos: thumbnails only */
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 6px var(--gr) 6px var(--gl); }
.pthumb { position: relative; aspect-ratio: 1; border-radius: 4px; overflow: hidden; }
.photo { display: block; content-visibility: auto; contain-intrinsic-size: auto 120px; }
.wide .photos { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 0; }
.wide .photo { contain-intrinsic-size: auto 160px; }

/* ---- sidebar (iPad) ------------------------------------------------------------------- */

.side-head { display: flex; align-items: center; justify-content: space-between; padding-left: 12px; min-height: 24px; }
.side-title { font-size: 15px; font-weight: 600; }
.side-head .icon-btn { margin: -10px -4px -10px 0; }
.side-folders { display: flex; flex-direction: column; gap: 2px; }
.side-label { padding: 0 12px 6px; font-size: 12px; color: var(--dim); }
.side-link {
  min-height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 10px;
  border-radius: 8px; font-size: 14px; color: var(--fg2);
}
.side-link svg { flex: none; }
.side-link.active { background: var(--hover); color: var(--fg); }
.side-sep { height: 1px; background: var(--line); margin: 0 12px; flex: none; }

.acc { display: flex; flex-direction: column; gap: 4px; }
.acc-sec { display: flex; flex-direction: column; gap: 4px; }
.acc-btn {
  min-height: 44px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between;
  border: 0; border-radius: 8px; background: transparent; color: var(--fg);
  font-size: 14px; font-weight: 500; text-align: left;
}
.rows { display: flex; flex-direction: column; gap: 2px; }
.star-row, .named-row {
  min-height: 44px; padding: 0 12px 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-radius: 8px;
}
.star-row.active, .named-row.active { background: var(--hover); }
.stars { font-size: 15px; letter-spacing: 2px; }
.star-on { color: var(--accent); }
.star-off { color: var(--star-off); }
.stars-none { color: var(--muted); font-size: 14px; letter-spacing: 0; }
.count { font-size: 12px; color: var(--dim); flex: none; }
.named-row { font-size: 14px; color: var(--fg2); }
.named-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.named-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-mark { color: var(--dim); display: inline-flex; flex: none; }
.acc-tools { display: flex; gap: 6px; margin: 0 4px 4px 12px; }
.acc-search {
  flex: 1; min-width: 0; height: 44px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--fg);
  font-size: 16px; /* 16px keeps iOS from zooming */ outline: none;
}
.sort-mini {
  flex: none; height: 44px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--dim); font-size: 12px;
}
.side .quiet { padding: 6px 12px 6px 20px; }

/* phone tab index screens: same content, full width */
.tab-index .star-row, .tab-index .named-row { padding: 0 var(--gr) 0 var(--gl); min-height: 52px; border-radius: 0; }
.tab-index .stars { font-size: 18px; letter-spacing: 3px; }
.tab-index .stars-none { font-size: 15px; }
.tab-index .named-row { font-size: 15px; color: var(--fg); }
.tab-index .count { font-size: 13px; }
.tab-index .acc-tools { margin: 0 var(--gr) 8px var(--gl); gap: 8px; }
.tab-index .acc-search { height: 44px; border-radius: 10px; font-size: 16px; padding: 0 12px; }
.tab-index .sort-mini { height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--fg2); font-size: 13px; }
.tab-index .rows { gap: 0; }

/* ---- bottom tabs (iPhone) ------------------------------------------------------------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 6px var(--gr) calc(6px + env(safe-area-inset-bottom, 0px)) var(--gl);
  border-top: 1px solid var(--line); background: var(--bg);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 48px; padding: 6px 0; font-size: 11px; color: var(--dim);
}
.tab.active { color: var(--fg); }

/* ---- placeholder, sheet, toast -------------------------------------------------------- */

.placeholder {
  min-height: 100vh; min-height: 100dvh; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px;
}
.placeholder .icon-btn { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 8px; color: var(--fg); }
.ph-name { font-size: 14px; color: var(--fg2); text-align: center; overflow-wrap: anywhere; }

.sheet {
  width: min(360px, calc(100vw - 32px)); padding: 20px;
  border: 1px solid var(--border); border-radius: 14px; background: #18191C; color: var(--fg);
}
.sheet::backdrop { background: rgba(0, 0, 0, .55); }
.sheet-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.sheet-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; font-size: 14px; color: var(--fg2); }
.sheet-row input { width: 22px; height: 22px; accent-color: var(--muted); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px); z-index: 20; transform: translateX(-50%);
  padding: 8px 14px; border-radius: 10px; background: #222428; color: var(--fg2); font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.wide .toast { bottom: 24px; }

/* ---- login ---------------------------------------------------------------------------- */

.login-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.login { width: min(320px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 28px; }
.login-title { font-size: 22px; font-weight: 600; letter-spacing: -0.2px; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-label { font-size: 13px; color: var(--dim); }
.login-input {
  height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: var(--fg); font-size: 16px; outline: none;
}
.login-input:focus { border-color: var(--border-strong); }
.login-btn { height: 48px; font-size: 15px; color: var(--fg); border-color: var(--border-strong); margin-top: 6px; }
.login-msg { min-height: 20px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---- player (PhonePlayer / PadPlayer / PhoneFullscreen / PhoneGestures) ----------------- */

.narrow .wide-only { display: none !important; }
.vp-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.vp-head {
  display: flex; align-items: center; min-width: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 4px) var(--gr) 0 max(4px, env(safe-area-inset-left, 0px));
}
.vp-crumbs { font-size: 13px; color: var(--dim); }
.vp-main { display: flex; flex-direction: column; }

.vp-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; flex: none; background: #000; overflow: hidden;
  /* pan-y: vertical scroll stays with the browser, horizontal moves are swipes */
  touch-action: pan-y; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.vp-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.vp-msg {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--dim); pointer-events: none;
}

/* gesture feedback */
.vp-ripple {
  position: absolute; top: 0; bottom: 0; width: 50%; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .25s;
}
.vp-ripple.vp-left { left: 0; border-radius: 0 50% 50% 0 / 0 100% 100% 0; }
.vp-ripple.vp-right { right: 0; border-radius: 50% 0 0 50% / 100% 0 0 100%; }
.vp-ripple.show { opacity: 1; background: rgba(255, 255, 255, .12); }
.vp-ripple span { color: #F2F0EB; font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.vp-seeklabel, .vp-badge {
  position: absolute; z-index: 45; pointer-events: none; opacity: 0;
  background: rgba(0, 0, 0, .55); color: #F2F0EB; font-size: 13px; line-height: 1.4;
}
.vp-seeklabel { left: 4%; top: 6%; padding: 3px 9px; border-radius: 10px; font-weight: 500; transition: opacity .2s; }
.vp-badge { right: 4%; top: 6%; padding: 4px 10px; border-radius: 12px; font-weight: 600; transition: opacity .15s; }
.vp-seeklabel.show, .vp-badge.show { opacity: 1; }

/* controls */
.vp-ui { transition: opacity .2s; }
.vp-stage.vp-hide { cursor: none; }
.vp-stage.vp-hide .vp-ui { opacity: 0; }
.vp-stage.vp-hide .vp-ui, .vp-stage.vp-hide .vp-ui *,
.vp-stage.vp-revealing .vp-ui, .vp-stage.vp-revealing .vp-ui * { pointer-events: none !important; }
.vp-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 12px 8px; background: rgba(0, 0, 0, .45);
}
.vp-track { position: relative; padding: 10px 0 9px; cursor: pointer; touch-action: none; outline-offset: 0; }
.vp-rail { position: relative; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .2); }
.vp-bufs { position: absolute; inset: 0; }
.vp-buf, .vp-played { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px; }
.vp-buf { background: rgba(255, 255, 255, .45); }
/* 버퍼링 표시: 재생을 기다리는 동안 가운데 얇은 원 */
.vp-spin {
  position: absolute; left: 50%; top: 50%; z-index: 30; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .2); border-top-color: rgba(255, 255, 255, .85);
  pointer-events: none; animation: vp-spin .9s linear infinite;
}
.vp-spin[hidden] { display: none; }
.vp-stage.vp-waiting .vp-bigplay { visibility: hidden; }
@keyframes vp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .vp-spin { animation-duration: 2.5s; } }
.vp-played { background: var(--fg); }
.vp-knob { position: absolute; left: 0; top: -5px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: var(--fg); }
.vp-row { display: flex; align-items: center; gap: 4px; font: 500 12px var(--mono); color: var(--fg2); }
.vp-btn {
  height: 36px; min-width: 40px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--fg); font: inherit;
}
.vp-time { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; }
.vp-speed { padding: 0 8px; color: var(--fg2); }
.vp-next { padding: 0 10px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; color: var(--fg2); font-family: var(--sans); font-size: 13px; }
.vp-menu {
  position: absolute; right: 12px; bottom: calc(100% + 6px); z-index: 50;
  display: flex; flex-direction: column; min-width: 96px; padding: 4px;
  border: 1px solid var(--border); border-radius: 10px; background: rgba(24, 25, 28, .96);
}
.vp-menu-item {
  height: 40px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent;
  color: var(--fg2); font: 500 13px var(--mono); text-align: left;
}
.vp-menu-item[aria-checked="true"] { color: var(--fg); background: var(--hover); }

.vp-top, .vp-center { display: none; }

/* fullscreen: real (iPad, container) or pseudo (iPhone, .vp-fs) */
.vp-stage.vp-fs { position: fixed; inset: 0; z-index: 1000; background: #000; width: auto; height: auto; aspect-ratio: auto; border-radius: 0 !important; }
html.vp-fs-lock, html.vp-fs-lock body { overflow: hidden; }
.vp-stage:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0 !important; }
.vp-stage:-webkit-full-screen { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0 !important; }
.vp-is-fs {
  --fs-l: max(16px, env(safe-area-inset-left, 0px), 6.6vw);
  --fs-r: max(16px, env(safe-area-inset-right, 0px), 6.6vw);
}
.vp-is-fs .vp-top {
  display: flex; align-items: center; gap: 12px;
  position: absolute; left: 0; right: 0; top: 0; z-index: 40;
  padding: max(14px, env(safe-area-inset-top, 0px)) var(--fs-r) 28px var(--fs-l); background: rgba(0, 0, 0, .5);
}
.vp-is-fs .vp-top .vp-btn { width: 44px; height: 44px; margin-left: -12px; }
.vp-top-title { font-size: 15px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-is-fs .vp-center {
  display: flex; align-items: center; justify-content: center; gap: 72px;
  position: absolute; inset: 0; z-index: 35; pointer-events: none;
}
.vp-center-btn {
  pointer-events: auto; border: 0; border-radius: 50%; color: var(--fg);
  display: inline-flex; align-items: center; justify-content: center;
}
.vp-step { width: 56px; height: 56px; background: rgba(0, 0, 0, .35); font: 500 13px var(--mono); }
.vp-bigplay { width: 68px; height: 68px; background: rgba(0, 0, 0, .45); }
.vp-is-fs .vp-bar { padding: 28px var(--fs-r) max(18px, env(safe-area-inset-bottom, 0px)) var(--fs-l); gap: 4px; background: rgba(0, 0, 0, .5); }
.vp-is-fs .vp-rail { height: 4px; }
.vp-is-fs .vp-knob { top: -6px; width: 16px; height: 16px; margin-left: -8px; }
.vp-is-fs .vp-row { gap: 8px; font-size: 13px; }
.vp-is-fs .vp-play { display: none; }
.vp-is-fs .vp-speed { padding: 0 10px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; }
.vp-is-fs .vp-menu { right: var(--fs-r); }
@media (max-width: 480px) { .vp-is-fs .vp-center { gap: 40px; } }

/* info */
.vp-titleblock { display: flex; flex-direction: column; gap: 4px; padding: 16px var(--gr) 0 var(--gl); }
.vp-title { font-size: 18px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.vp-sub { font-size: 12px; color: var(--dim); }
.vp-panel { display: flex; flex-direction: column; gap: 16px; padding: 16px var(--gr) calc(24px + env(safe-area-inset-bottom, 0px)) var(--gl); }
.vp-sec { display: flex; flex-direction: column; gap: 8px; }
.vp-label { font-size: 12px; color: var(--dim); }
.vp-rating-sec { gap: 4px; }
.vp-stars { display: flex; align-items: center; gap: 2px; }
.vp-star {
  width: 36px; height: 36px; padding: 0; border: 0; background: transparent; color: var(--star-off);
  display: inline-flex; align-items: center; justify-content: center;
}
.vp-star.on { color: var(--accent); }
.vp-rating-num { margin-left: 8px; font-size: 13px; color: var(--muted); }
.vp-rating-num.none { color: var(--dim); }
.vp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.vp-chip {
  height: 32px; padding: 0 6px 0 12px; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border-strong); border-radius: 16px; background: transparent; color: var(--fg); font-size: 13px;
}
.vp-chip svg { color: var(--dim); flex: none; }
.vp-chip-add { padding: 0 12px; border: 1px dashed rgba(255, 255, 255, .22); color: var(--muted); }
.vp-chip-opt { padding: 0 12px; border-color: var(--border); color: var(--fg2); }
.vp-coll {
  height: 30px; padding: 0 12px; display: inline-flex; align-items: center;
  border-radius: 15px; background: rgba(255, 255, 255, .06); color: var(--fg2); font-size: 13px;
}
.vp-picker { display: flex; flex-direction: column; gap: 8px; }
.vp-picker-row { display: flex; gap: 6px; }
.vp-genre-input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--fg);
  font-size: 16px; /* 16px keeps iOS from zooming */ outline: none;
}
.vp-genre-input:focus { border-color: var(--border-strong); }
.vp-chip-btn { height: 36px; padding: 0 10px; flex: none; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--fg2); font-size: 13px; }
.vp-genre-options { display: flex; flex-wrap: wrap; gap: 6px; max-height: 148px; overflow-y: auto; }
.vp-genre-options:empty { display: none; }
.vp-err { font-size: 12px; color: var(--muted); }
.vp-noplex { font-size: 13px; color: var(--dim); }
.vp-sep { height: 1px; background: var(--line); flex: none; }
.vp-auto { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 14px; }
.vp-switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0;
  width: 44px; height: 24px; border-radius: 12px; border: 1px solid var(--border-strong); background: transparent;
  transition: background .15s;
}
.vp-switch::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--dim); transition: transform .15s, background .15s;
}
.vp-switch:checked { background: var(--dim); border-color: var(--dim); }
.vp-switch:checked::before { transform: translateX(20px); background: var(--fg); }
.vp-next-list { display: flex; flex-direction: column; gap: 10px; }
.vp-next-item { display: flex; gap: 12px; align-items: center; min-height: 54px; }
.vp-next-thumb { position: relative; flex: none; width: 96px; height: 54px; border-radius: 5px; background: #33302B; overflow: hidden; }
.vp-next-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.vp-next-thumb img.loaded { opacity: 1; }
.vp-next-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.vp-next-kicker { font-size: 12px; color: var(--dim); }
.vp-next-name { font-size: 14px; overflow-wrap: anywhere; }
.narrow .vp-next-sec > .vp-label { display: none; }

/* iPad: video + title on the left, 320px panel on the right */
.wide .vp-head { height: 64px; flex: none; gap: 4px; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 0 max(16px, env(safe-area-inset-left, 0px)); }
.wide .vp-crumbs { font-size: 14px; }
.wide .vp-main {
  flex: 1; min-height: 0; display: grid; align-content: start;
  grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto 1fr;
  grid-template-areas: "stage panel" "title panel";
  gap: 16px 24px; padding: 8px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px));
}
.wide .vp-stage { grid-area: stage; border-radius: 6px; }
.wide .vp-titleblock { grid-area: title; padding: 0; }
.wide .vp-title { font-size: 20px; }
.wide .vp-sub { font-size: 13px; }
.wide .vp-panel-slot { grid-area: panel; min-width: 0; }
.wide .vp-panel { padding: 0; gap: 22px; }
.wide .vp-rating-sec { gap: 8px; }
.wide .vp-star { width: 40px; height: 40px; }
.wide .vp-star svg { width: 24px; height: 24px; }
.wide .vp-rating-num { font-size: 14px; }
.wide .vp-chip { height: 34px; padding: 0 8px 0 12px; border-radius: 17px; }
.wide .vp-chip-add, .wide .vp-chip-opt { padding: 0 12px; }
.wide .vp-coll { height: 32px; border-radius: 16px; }
.wide .vp-next-sec { gap: 10px; }
.wide .vp-next-thumb { width: 104px; height: 58px; }
.wide .vp-stage:not(.vp-is-fs) .vp-bar { padding: 24px 16px 10px; gap: 4px; }
.wide .vp-stage:not(.vp-is-fs) .vp-rail { height: 4px; }
.wide .vp-stage:not(.vp-is-fs) .vp-knob { top: -6px; width: 16px; height: 16px; margin-left: -8px; }
.wide .vp-stage:not(.vp-is-fs) .vp-row { gap: 6px; font-size: 13px; }
.wide .vp-stage:not(.vp-is-fs) .vp-play, .wide .vp-stage:not(.vp-is-fs) .vp-fsbtn { width: 44px; height: 40px; }
.wide .vp-stage:not(.vp-is-fs) .vp-speed { padding: 0 10px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- photo viewer --------------------------------------------------------------------- */

.ph-view { position: fixed; inset: 0; background: #000; color: var(--fg); overflow: hidden; }
.ph-stage {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ph-img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  will-change: transform; transform-origin: 50% 50%; -webkit-user-drag: none;
}
.ph-img[hidden] { display: none; }
.ph-img.anim { transition: transform .18s ease-out; }
.ph-error { margin: 0; padding: 24px; font-size: 14px; color: var(--muted); text-align: center; }
.ph-error[hidden] { display: none; }

.ph-top, .ph-bottom {
  position: absolute; left: 0; right: 0; z-index: 2; background: rgba(0, 0, 0, .55);
  transition: opacity .2s;
}
.ph-top {
  top: 0; display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) max(4px, env(safe-area-inset-right, 0px)) 10px max(4px, env(safe-area-inset-left, 0px));
}
.ph-back { color: var(--fg); }
.ph-names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ph-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-count { padding: 0 14px; font: 500 13px var(--mono); color: var(--fg2); flex: none; }

.ph-bottom {
  bottom: 0; display: flex; flex-direction: column; gap: 10px;
  padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 14px);
}
.ph-strip {
  display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.ph-strip::-webkit-scrollbar { display: none; }
.ph-item {
  flex: none; width: 44px; height: 44px; padding: 0; border: 2px solid transparent; border-radius: 4px;
  background: transparent; opacity: .6; box-sizing: border-box; overflow: hidden;
  content-visibility: auto; contain-intrinsic-size: 44px 44px;
}
.ph-item.current { border-color: var(--fg); opacity: 1; }
.ph-thumb { position: relative; width: 100%; height: 100%; }
.ph-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.ph-thumb img.loaded { opacity: 1; }
.ph-hint { padding: 0 16px; font-size: 12px; color: var(--dim); }

.ph-nav {
  display: none; position: absolute; top: 50%; z-index: 2; width: 52px; height: 52px; margin-top: -26px;
  align-items: center; justify-content: center; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 50%; background: rgba(0, 0, 0, .35); color: var(--fg);
  transition: opacity .2s;
}
.ph-nav:disabled { opacity: .3; }
.ph-prev { left: 24px; }
.ph-next { right: 24px; }

.wide .ph-nav { display: inline-flex; }
.wide .ph-top { padding: 20px 16px 12px; gap: 8px; }
.wide .ph-title { flex: none; max-width: 40%; font-size: 15px; }
.wide .ph-names { flex-direction: row; align-items: baseline; gap: 12px; }
.wide .ph-sub { font-size: 13px; }
.wide .ph-count { font-size: 14px; }
.wide .ph-bottom { padding: 16px 24px 24px; }
.wide .ph-strip { justify-content: safe center; gap: 6px; padding: 0; }
.wide .ph-item { width: 64px; height: 64px; border-radius: 5px; contain-intrinsic-size: 64px 64px; }
.wide .ph-hint { display: none; }

.bars-hidden .ph-top, .bars-hidden .ph-bottom, .bars-hidden .ph-nav { opacity: 0; pointer-events: none; }
