:root {
  --bg: #0b0b10;
  --card: #16161e;
  --card-2: #1f1f2a;
  --line: #2a2a38;
  --text: #f4f4f8;
  --muted: #8d8da0;
  --accent: #ff3b5c;
  --accent-2: #ff7a3b;
  --ok: #30d158;
  --danger: #ff453a;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;
  --mini-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; -webkit-user-select: none; user-select: none; }
input, button { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }
.center { text-align: center; }

#app { height: 100dvh; display: flex; flex-direction: column; }
.topbar { flex: none; padding: calc(var(--top) + 8px) 20px 8px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
main { flex: 1; overflow: hidden; position: relative; }
.view { display: none; position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px calc(var(--tabbar-h) + var(--bottom) + 24px); }
body.has-mini .view { padding-bottom: calc(var(--tabbar-h) + var(--bottom) + var(--mini-h) + 32px); }
.view.active { display: block; }

.card { background: var(--card); border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; }
.gap { gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { margin: 14px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.section-title { margin: 22px 4px 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.error { color: var(--danger); margin: 10px 2px 0; font-size: 14px; }
.empty { text-align: center; color: var(--muted); margin: 60px 20px; line-height: 1.6; }

input[type=url], input[type=search], input[type=password] { width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); padding: 0 44px 0 16px; font-size: 17px; outline: none; -webkit-user-select: text; user-select: text; }
input:focus { border-color: var(--accent); }
input[type=search], input[type=password] { padding-right: 16px; }
.input-row { position: relative; margin-bottom: 12px; }
.input-row .icon-btn { position: absolute; right: 6px; top: 6px; }

.btn { height: 50px; border-radius: 14px; font-weight: 600; font-size: 17px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn.secondary { background: var(--card-2); }
.btn.danger { background: rgba(255, 69, 58, .15); color: var(--danger); }
.btn.big { width: 100%; height: 54px; margin-top: 18px; font-size: 18px; }
.btn.bg-btn { width: 100%; margin-top: 10px; height: 46px; font-size: 15px; }
.btn:active, .chip:active, .item:active { opacity: .7; transform: scale(.985); }
.btn:disabled { opacity: .45; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; font-size: 22px; color: var(--muted); }
.icon-btn.small { width: 38px; height: 38px; font-size: 16px; }
.link-btn { color: var(--muted); font-size: 18px; padding: 6px 8px; }

.hint { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.hint b { color: var(--text); }
.share-glyph { display: inline-block; transform: translateY(-1px); }

.preview .thumb-wrap { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .75); border-radius: 6px; padding: 2px 7px; font-size: 13px; font-weight: 600; }
.preview h2 { font-size: 18px; margin: 14px 0 4px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.preview p { margin: 0; }

.segmented { display: flex; background: var(--card-2); border-radius: 12px; padding: 3px; margin-top: 16px; }
.segmented button { flex: 1; height: 38px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--muted); }
.segmented button.active { background: var(--accent); color: #fff; }
.segmented.compact { margin-top: 12px; }
.segmented.compact button { height: 34px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 56px; min-width: 84px; padding: 6px 14px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.chip-main { font-weight: 700; font-size: 17px; }
.chip-size { font-size: 12px; color: var(--muted); font-weight: 500; }
.chip.active { background: rgba(255, 59, 92, .16); border-color: var(--accent); color: #fff; }
.chip.active .chip-size { color: #ffb3c0; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 12px; background: var(--card); border-radius: 16px; padding: 10px; align-items: center; }
.item .thumb { width: 104px; flex: none; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000 center / cover no-repeat; position: relative; }
.item .thumb .badge { right: 4px; bottom: 4px; font-size: 11px; padding: 1px 5px; }
.item .info { min-width: 0; flex: 1; }
.item .name { font-weight: 600; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }
.item .meta { margin-top: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; background: var(--card-2); margin-right: 6px; color: var(--text); }
.pill.ok { background: rgba(48, 209, 88, .16); color: var(--ok); }
.pill.warn { background: rgba(255, 159, 10, .16); color: #ff9f0a; }
.pill.bad { background: rgba(255, 69, 58, .16); color: var(--danger); }
.bar { height: 6px; border-radius: 3px; background: var(--card-2); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }

.library-head input { margin: 0; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--bottom)); padding-bottom: var(--bottom); display: flex; background: rgba(18, 18, 26, .86); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); border-top: 1px solid var(--line); z-index: 10; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); position: relative; }
.tabbar button.active { color: var(--accent); }
.tab-ico { font-size: 22px; line-height: 1; }
.dot { position: absolute; top: 6px; left: calc(50% + 12px); width: 9px; height: 9px; border-radius: 5px; background: var(--accent); }

.mini { position: fixed; left: 10px; right: 10px; bottom: calc(var(--tabbar-h) + var(--bottom) + 8px); height: var(--mini-h); display: flex; align-items: center; gap: 4px; padding: 8px 6px 8px 8px; background: rgba(34, 34, 48, .94); -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px); border: 1px solid var(--line); border-radius: 18px; z-index: 12; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.mini-thumb { width: 72px; flex: none; aspect-ratio: 16 / 9; border-radius: 8px; background: #000 center / cover no-repeat; }
.mini-text { min-width: 0; }
.mini-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .icon-btn { color: var(--text); font-size: 20px; }

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--card); border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--bottom) + 20px); z-index: 30; animation: slide .25s ease-out; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { margin: 12px 0 4px; font-size: 19px; line-height: 1.3; }
.sheet video { width: 100%; border-radius: 14px; background: #000; display: block; max-height: 56dvh; }
.sheet .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.sheet .kv { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; gap: 12px; }
.sheet .kv span:first-child { color: var(--muted); }
@keyframes slide { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.cover { width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; background: #000 center / cover no-repeat; }
.audio-panel { margin-top: 14px; }
.seek-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seek { flex: 1; height: 28px; accent-color: var(--accent); background: transparent; }
.transport { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 6px 0 10px; }
.play-btn { width: 68px; height: 68px; border-radius: 34px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 26px; color: #fff; display: flex; align-items: center; justify-content: center; }
.skip-btn { width: 56px; height: 56px; border-radius: 28px; background: var(--card-2); font-size: 15px; font-weight: 700; }
.play-btn:active, .skip-btn:active { opacity: .7; }

.toggle { width: 52px; height: 32px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); position: relative; flex: none; transition: background .2s; }
.toggle i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--ok); border-color: var(--ok); }
.toggle.on i { transform: translateX(20px); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--bottom) + 16px); background: #2b2b3a; padding: 12px 18px; border-radius: 14px; font-size: 15px; z-index: 50; max-width: 90vw; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
body.has-mini .toast { bottom: calc(var(--tabbar-h) + var(--bottom) + var(--mini-h) + 24px); }

.gate { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; padding: 20px; }
.gate .card { width: 100%; }
.gate input { margin: 14px 0 0; }
