/* BulldogDrive — dark by default, light when the device is set to light. Mobile first. */
:root {
  --bg: #11141c; --panel: #181c27; --panel2: #1f2432; --line: #2a3142; --ink: #e6e9ef; --ink2: #b4bccb; --muted: #8590a3;
  --gold: #f2b84b; --gold-ink: #1b1405; --teal: #5fd4c4; --red: #f0716a; --red-soft: rgba(240, 113, 106, .14);
  --radius: 14px; --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --player-h: 68px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f6f8; --panel: #ffffff; --panel2: #eef0f4; --line: #dde1e8; --ink: #161a22; --ink2: #3f4756; --muted: #6b7486; --gold: #d99a1e; --gold-ink: #1b1405; --teal: #138a7c; --red: #c9372f; --red-soft: rgba(201, 55, 47, .1); color-scheme: light; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-tap-highlight-color: transparent; }
body.has-player { padding-bottom: calc(var(--player-h) + var(--safe-b) + 8px); }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); }
.pad { padding: 24px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink); cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, transparent); background: var(--red-soft); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: var(--ink2); cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { background: var(--panel2); color: var(--ink); }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink2); font-size: 13px; cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--gold); color: var(--ink); }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-size: 16px; }
.search { flex: 1; min-width: 0; max-width: 420px; margin-left: auto; }
.search input { width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.top-actions { position: relative; display: flex; align-items: center; gap: 4px; margin-left: auto; }
.search:not([hidden]) + .top-actions { margin-left: 0; }
.ai-btn { color: var(--teal); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 16px 40px rgba(0, 0, 0, .4); display: grid; }
.menu.pop { position: fixed; top: 0; left: 0; right: auto; }
.menu a, .menu button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; font-size: 14px; }
.menu a:hover, .menu button:hover { background: var(--panel2); }
.menu .danger { color: var(--red); }
.menu-note { margin: 6px 12px 4px; font-size: 12px; color: var(--muted); }

main { max-width: 980px; margin: 0 auto; padding: 14px 16px 40px; outline: none; }

/* sign-in and setup */
.gate { max-width: 380px; margin: 8vh auto; text-align: center; }
.gate h1 { margin: 12px 0 6px; }
.gate-form { display: grid; gap: 12px; margin-top: 20px; text-align: left; }
.gate-form label { display: grid; gap: 4px; font-size: 13px; color: var(--ink2); }
.gate-form input, dialog input:not([type=radio]):not([type=checkbox]) { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); width: 100%; }
.gate-form .btn { justify-content: center; }
.setup { max-width: 720px; }
.steps { padding-left: 22px; display: grid; gap: 10px; }
.steps li { padding-left: 4px; }
code { padding: 1px 6px; border-radius: 6px; background: var(--panel2); font-size: 13px; }

/* browsing */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 12px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--ink2); text-decoration: none; }
.crumbs a:hover { color: var(--gold); }
.crumbs span { color: var(--ink); font-weight: 600; }
.crumbs i { font-style: normal; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.folder-play { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 12px; padding: 12px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--teal) 40%, var(--line)); background: color-mix(in srgb, var(--teal) 7%, var(--panel)); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink2); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--teal); }
.selbar { position: sticky; top: 62px; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--gold); }
.list-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 18px; margin: 4px 0 12px; }
.list-title small { color: var(--muted); font-weight: 400; font-size: 13px; }
.resume { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.resume span { flex: 1; min-width: 180px; font-size: 14px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.row { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.row:hover { background: var(--panel); }
.row.sel { background: color-mix(in srgb, var(--gold) 12%, var(--panel)); }
.row.playing .txt b { color: var(--teal); }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 12px; }
.ico { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--panel2); font-size: 20px; }
.txt { min-width: 0; display: grid; }
.txt b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txt small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { display: grid; place-items: center; width: 40px; height: 40px; flex: none; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; margin-left: auto; }
.eq i { width: 3px; background: var(--teal); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .2s; } .eq i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }
@media (prefers-reduced-motion: reduce) { .eq i { animation: none; height: 10px; } }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .big { font-size: 44px; margin: 0; }

/* drag and drop, uploads */
.drop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 80%, transparent); border: 3px dashed var(--gold); pointer-events: none; font-size: 20px; font-weight: 700; }
.uploads { position: fixed; right: 16px; bottom: calc(16px + var(--safe-b)); z-index: 30; width: min(380px, calc(100vw - 32px)); max-height: 46vh; overflow: auto; padding: 10px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, .4); }
body.has-player .uploads { bottom: calc(var(--player-h) + var(--safe-b) + 16px); }
.up-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.up-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.up-row progress { grid-column: 1 / 3; width: 100%; height: 6px; accent-color: var(--teal); }
.up-row.bad .up-meta { color: var(--red); white-space: normal; }
/* 下载到这台手机: the progress box sits above the upload box when both are open; 已下载 (#/offline) rows */
.downloads .up-meta { white-space: normal; text-align: right; }
.uploads:not([hidden]) ~ .downloads { bottom: calc(16px + var(--safe-b) + min(46vh, 220px)); }
body.has-player .uploads:not([hidden]) ~ .downloads { bottom: calc(var(--player-h) + var(--safe-b) + 16px + min(46vh, 220px)); }
.crumb-off { margin-left: auto; padding: 3px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--teal) 45%, var(--line)); color: var(--teal) !important; font-size: 13px; }
.off-row { flex-wrap: wrap; padding: 2px 0 8px; border-bottom: 1px solid var(--line); border-radius: 0; }
.off-row .row-main { cursor: default; }
.off-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 0 60px; width: 100%; }
.off-notes { list-style: none; }
.off-note { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--teal) 8%, var(--panel)); font-size: 14px; }
.off-note.muted { background: var(--panel); }
.off-empty { list-style: none; text-align: center; color: var(--ink2); padding: 30px 10px; }
.off-empty .big { font-size: 44px; margin: 0; }
@media (max-width: 520px) { .off-actions { padding-left: 8px; } }

/* player */
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: color-mix(in srgb, var(--panel) 96%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.seek { width: 100%; accent-color: var(--teal); }
.mini-seek { position: absolute; top: -9px; left: 0; height: 18px; margin: 0; background: transparent; }
.mini { display: flex; align-items: center; gap: 4px; max-width: 980px; height: var(--player-h); margin: 0 auto; padding: 0 12px; }
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 10px; }
.art { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, #2b3566, #11141c); color: var(--gold); font-size: 22px; }
.mini-text { min-width: 0; display: grid; }
.mini-text b, .mini-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-text small { color: var(--muted); font-size: 12.5px; }
.play-btn { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--gold); color: var(--gold-ink); font-size: 18px; cursor: pointer; }
.play-btn.big { width: 68px; height: 68px; font-size: 26px; }
.sheet { max-width: 640px; margin: 0 auto; padding: 4px 18px 20px; max-height: calc(100dvh - var(--player-h) - 40px); overflow-y: auto; text-align: center; }
.player.open { top: 0; display: flex; flex-direction: column-reverse; justify-content: flex-end; background: var(--panel); }
.player.open .sheet { flex: 1; min-height: 0; max-height: none; width: 100%; }
.player.open .mini-seek { display: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding-top: env(safe-area-inset-top); }
.sheet-head small { color: var(--muted); }
.sheet-art { width: min(56vw, 240px); aspect-ratio: 1; margin: 6px auto 14px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(135deg, #2b3566, #11141c 70%); color: var(--gold); font-size: 80px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.sheet h2 { margin: 0 0 10px; font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0; }
.controls .icon-btn { font-size: 15px; font-weight: 700; }
.controls .icon-btn.big { font-size: 26px; min-width: 52px; min-height: 52px; }
.controls2 { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 14px; }
.queue-title { text-align: left; font-size: 15px; margin: 14px 0 6px; }
.queue-title small { color: var(--muted); font-weight: 400; }
.queue { list-style: none; margin: 0; padding: 0; text-align: left; display: grid; gap: 2px; }
.queue button { width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; display: grid; color: var(--ink2); }
.queue button:hover { background: var(--panel2); }
.queue button.on { background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--ink); font-weight: 600; }
.queue small { color: var(--muted); font-weight: 400; font-size: 12px; }

/* AI panel */
.ai-panel { position: fixed; z-index: 35; right: 16px; top: 72px; bottom: 16px; width: min(440px, calc(100vw - 32px)); display: flex; flex-direction: column; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); overflow: hidden; }
body.has-player .ai-panel { bottom: calc(var(--player-h) + var(--safe-b) + 12px); }
.ai-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.ai-head b { color: var(--teal); white-space: nowrap; }
.ai-head select { flex: 1; min-width: 0; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); padding: 0 8px; font-size: 13px; }
.ai-where { margin: 0; padding: 8px 14px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); }
.ai-thread { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: color-mix(in srgb, var(--gold) 18%, var(--panel2)); }
.msg.bot { align-self: flex-start; background: var(--panel2); }
.msg.bot small { display: block; color: var(--muted); font-size: 11.5px; }
.msg p { margin: 2px 0 0; }
.thinking { display: flex; gap: 4px; }
.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.thinking span:nth-child(2) { animation-delay: .2s; } .thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.plan { margin-top: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.plan-head { margin: 0 0 6px; font-weight: 600; font-size: 13px; }
.plan ol { margin: 0; padding-left: 4px; list-style: none; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.plan li label { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.plan li input { margin-top: 3px; accent-color: var(--gold); }
.plan li.warn span { color: var(--red); }
.plan-actions { display: flex; gap: 8px; margin-top: 8px; }
.plan.done p { margin: 0; color: var(--teal); font-size: 13px; }
.ai-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; scrollbar-width: none; }
.ai-chips .chip { flex: none; }
.ai-form { display: flex; gap: 8px; padding: 10px 12px 12px; align-items: flex-end; }
.ai-form textarea { flex: 1; min-height: 44px; max-height: 140px; resize: vertical; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); }

/* dialogs, viewer, toast */
dialog { width: min(460px, calc(100vw - 32px)); max-height: 80dvh; padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { margin: 0 0 12px; font-size: 17px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.pick-list { max-height: 50dvh; overflow-y: auto; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.pick { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; cursor: pointer; }
.pick:hover { background: var(--panel2); }
.pick input { accent-color: var(--gold); }
.viewer { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: rgba(0, 0, 0, .92); }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); color: #fff; }
.viewer-bar .icon-btn { color: #fff; }
.viewer img, .viewer video { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 80; transform: translate(-50%, 20px); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
body.has-player .toast { bottom: calc(var(--player-h) + var(--safe-b) + 18px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* phones */
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .top { flex-wrap: wrap; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .top-actions { margin-left: auto !important; }
  main { padding: 10px 12px 30px; }
  .toolbar .btn { flex: 1; justify-content: center; }
  .selbar { top: 104px; }
  .ai-panel { left: 0; right: 0; top: 0; bottom: 0; width: auto; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  body.has-player .ai-panel { bottom: calc(var(--player-h) + var(--safe-b)); }
  .uploads { right: 8px; left: 8px; width: auto; }
}
body.touch .hide-touch { display: none; }
@media (min-width: 900px) {
  .player.open { top: auto; height: min(92dvh, 820px); left: auto; right: 16px; bottom: 16px; width: 440px; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
  body.ai-on .player.open { right: 472px; }
}
@media print { .top, .player, .ai-panel, .uploads, .toast { display: none !important; } }
