:root {
  --bg: #0b0c10;
  --bg-2: #14161c;
  --bg-3: #1d2028;
  --bg-4: #272a34;
  --border: #2c303b;
  --fg: #e8e9ee;
  --fg-2: #a6aab5;
  --fg-3: #6f7380;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-dim: rgba(245, 158, 11, .15);
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
.hidden { display: none !important; }

.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 1fr; height: 100vh; }
.sidebar { grid-row: 1; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 12px; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 6px 10px 18px; letter-spacing: .2px; }
.brand.big { font-size: 24px; justify-content: center; padding-bottom: 24px; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--accent-2), var(--accent) 60%, #b45309); box-shadow: 0 0 18px var(--accent-dim); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--fg-2); font-weight: 500; }
.nav a:hover { background: var(--bg-3); color: var(--fg); }
.nav a.active { background: var(--accent-dim); color: var(--accent-2); }
.nav .ico { width: 20px; text-align: center; font-size: 16px; opacity: .9; }
.badge { margin-left: auto; background: var(--bg-4); color: var(--fg-2); font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.badge:empty { display: none; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar-footer .version { font-size: 11px; padding: 6px 10px 0; }

.main { overflow-y: auto; padding: 28px 32px 40px; }
.main h1 { font-size: 26px; margin: 0 0 18px; font-weight: 700; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.main h1 .sub { font-size: 14px; color: var(--fg-3); font-weight: 400; }
.main h2 { font-size: 17px; margin: 26px 0 10px; color: var(--fg-2); font-weight: 600; }
.spacer { flex: 1; }

.btn { border: 1px solid var(--border); background: var(--bg-3); border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--bg-4); border-color: #3a3f4c; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(239,68,68,.12); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--bg-3); color: var(--fg); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.icon { width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 17px; }
.btn.icon.big { width: 50px; height: 50px; font-size: 20px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type=text], input[type=url], input[type=password], input:not([type]), select, textarea {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--fg-2); }
label.inline { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; color: var(--fg); }
label.inline input { width: auto; }
.form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.muted { color: var(--fg-3); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.empty { color: var(--fg-3); text-align: center; padding: 60px 20px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* episode list */
.ep-list { display: flex; flex-direction: column; gap: 6px; }
.ep { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid transparent; transition: border-color .15s, background .15s; }
.ep:hover { border-color: var(--border); background: var(--bg-3); }
.ep.played { opacity: .55; }
.ep-art { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--bg-4); }
.ep-body { min-width: 0; }
.ep-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ep-title:hover { color: var(--accent-2); }
.ep-meta { font-size: 13px; color: var(--fg-3); display: flex; gap: 10px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.ep-meta .pod { color: var(--fg-2); cursor: pointer; }
.ep-meta .pod:hover { color: var(--accent-2); }
.progress { height: 3px; background: var(--bg-4); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.ep-actions { display: flex; gap: 4px; align-items: center; }
.ep-actions .btn.icon { width: 34px; height: 34px; font-size: 15px; background: transparent; border-color: transparent; }
.ep-actions .btn.icon:hover { background: var(--bg-4); }
.ep.dragging { opacity: .4; }
.ep.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.ep.drop-after { box-shadow: 0 3px 0 0 var(--accent); }
.handle { cursor: grab; color: var(--fg-3); padding: 0 6px; user-select: none; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--bg-4); color: var(--fg-2); }
.tag.q { background: var(--accent-dim); color: var(--accent-2); }

/* podcast grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.pod-card { cursor: pointer; }
.pod-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--border); transition: transform .15s; }
.pod-card:hover img { transform: translateY(-3px); border-color: #3a3f4c; }
.pod-card .t { margin-top: 8px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-card .s { font-size: 12px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-card .err { color: var(--danger); }

.pod-head { display: grid; grid-template-columns: 180px 1fr; gap: 24px; margin-bottom: 26px; }
.pod-head img { width: 180px; height: 180px; border-radius: 16px; object-fit: cover; background: var(--bg-3); }
.pod-head .desc { color: var(--fg-2); max-height: 96px; overflow: hidden; margin: 8px 0 12px; }
.pod-head .desc.open { max-height: none; }

/* search results */
.results { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.result { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 8px 10px; background: var(--bg-2); border-radius: 10px; }
.result img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--bg-3); }
.result .t { font-weight: 600; }
.result .s { font-size: 13px; color: var(--fg-3); }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--fg-3); font-weight: 500; font-size: 13px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg-4); border: 1px solid var(--border); padding: 10px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 50; font-size: 14px; }
.toast.err { border-color: var(--danger); }

/* login */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #1a1c24, var(--bg) 60%); }
.login-card { width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 32px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--bg-4); border-radius: 999px; transition: .2s; }
.switch i::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::before { transform: translateX(18px); }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { grid-row: 1; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand span + * { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 8px 10px; font-size: 13px; }
  .sidebar-footer { margin-top: 0; flex-direction: row; }
  .main { padding: 18px 16px 30px; }
  .pod-head { grid-template-columns: 1fr; }
  .pod-head img { width: 140px; height: 140px; }
  .ep { grid-template-columns: 44px 1fr; }
  .ep-actions { grid-column: 1 / 3; justify-content: flex-end; }
}
