:root {
  --bg-0: #090b10;
  --bg-1: #111520;
  --bg-2: #171d2c;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text-1: #f4f6fb;
  --text-2: #94a0b8;
  --text-3: #64708a;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --teal: #2dd4bf;
  --danger: #f43f5e;
  --success: #22c55e;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --sidebar-w: 248px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60% 45% at 20% 0%, rgba(59, 130, 246, 0.14), transparent 70%),
    radial-gradient(50% 40% at 85% 10%, rgba(124, 58, 237, 0.10), transparent 70%);
}

.hidden { display: none !important; }
button, a, input { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { text-decoration: none; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 7px;
  border-radius: 6px;
  color: #cbd5e1;
}

:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, transform 0.12s, border-color 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-lg { height: 44px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-full { width: 100%; }

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 6px 18px rgba(37, 99, 235, 0.32);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-soft {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text-1);
}
.btn-soft:hover { background: rgba(255, 255, 255, 0.13); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}
.btn-danger:hover { background: rgba(244, 63, 94, 0.25); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

.field-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(9, 11, 16, 0.7);
  color: var(--text-1);
  font-size: 14.5px;
  transition: border-color 0.15s;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.form-error { color: #fb7185; font-size: 13px; margin: 8px 0; text-align: left; }

/* ================= Login Screen ================= */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-panel {
  width: 100%;
  max-width: 380px;
  background: rgba(17, 21, 32, 0.85);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  padding: 36px 28px 28px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.35);
}
.login-panel h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.login-desc { color: var(--text-2); font-size: 13px; margin: 4px 0 24px; }
.login-panel form { display: flex; flex-direction: column; gap: 12px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--text-3); }

/* ================= Desktop App Layout ================= */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(15, 19, 29, 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 16px;
  gap: 18px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 6px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.brand-sub { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 10px 6px;
}
.side-item {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.14s;
}
.side-item:hover { background: var(--bg-hover); color: var(--text-1); }
.side-item.active {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
}
.side-item .status-dot { margin-left: auto; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #475569;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.7); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mini-disk {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.mini-disk-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 7px; }
.mini-bar { height: 5px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.mini-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2dd4bf, #3b82f6); border-radius: 99px; transition: width 0.35s; }
.mini-disk-sub { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.side-logout {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-3);
}
.side-logout:hover { background: rgba(244, 63, 94, 0.1); color: #fda4af; }

/* Workspace */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mobile-header, .mobile-tabbar { display: none; }

.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 48px;
  -webkit-overflow-scrolling: touch;
}

.page { display: none; max-width: 1240px; margin: 0 auto; }
.page.active { display: block; animation: pageFade 0.18s ease; }
@keyframes pageFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.clock-badge {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fde68a;
  font-size: 13px;
  margin-bottom: 20px;
}

/* ================= Dashboard Metrics ================= */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
}
.metric-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.ring-wrap { position: relative; width: 62px; height: 62px; flex-shrink: 0; }
.ring-svg { width: 62px; height: 62px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 5.5; }
.ring-fg {
  fill: none;
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 163.36;
  transition: stroke-dashoffset 0.5s ease;
}
.stroke-blue { stroke: #3b82f6; }
.stroke-violet { stroke: #a78bfa; }
.stroke-teal { stroke: #2dd4bf; }
.stroke-emerald { stroke: #22c55e; }
.temp-warn { color: #fb923c !important; }
.ring-val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.metric-info { min-width: 0; }
.metric-label { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.metric-title { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }

.metric-net { flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; }
.net-speed-list { display: flex; flex-direction: column; gap: 7px; }
.net-speed-row { display: flex; align-items: center; justify-content: space-between; }
.net-badge { font-size: 12px; font-weight: 600; }
.net-badge.down { color: var(--cyan); }
.net-badge.up { color: var(--violet); }
.net-num { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.block-title {
  font-size: 15px;
  font-weight: 600;
  margin: 28px 0 14px;
  color: var(--text-1);
}

.app-launcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.launch-tile {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}
.launch-tile:hover {
  background: var(--bg-2);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.tile-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.grad-blue { background: linear-gradient(135deg, #2563eb, #38bdf8); }
.grad-rose { background: linear-gradient(135deg, #e11d48, #fb7185); }
.grad-cyan { background: linear-gradient(135deg, #0891b2, #2dd4bf); }
.grad-indigo { background: linear-gradient(135deg, #6366f1, #a855f7); }
.grad-amber { background: linear-gradient(135deg, #d97706, #fbbf24); }
.grad-emerald { background: linear-gradient(135deg, #059669, #34d399); }
.grad-orange { background: linear-gradient(135deg, #ea580c, #fb923c); }
.grad-sky { background: linear-gradient(135deg, #0284c7, #38bdf8); }

.tile-body { min-width: 0; }
.tile-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.tile-desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================= Surface Card & File Manager ================= */
.surface-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.surface-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.muted-text { color: var(--text-2); font-size: 13px; }

.fm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.fm-path-row { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.breadcrumbs::-webkit-scrollbar { display: none; }
.crumb-btn {
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
}
.crumb-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.crumb-btn:last-child { color: var(--text-1); font-weight: 600; }
.crumb-sep { color: var(--text-3); font-size: 12px; }

.fm-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  background: rgba(9, 11, 16, 0.65);
  border: 1px solid var(--border);
  color: var(--text-3);
}
.search-box:focus-within { border-color: var(--accent); color: var(--text-1); }
.search-box input {
  background: none;
  border: none;
  outline: none;
  width: 150px;
  font-size: 13px;
  color: var(--text-1);
}

.zoom-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(9, 11, 16, 0.65);
  border: 1px solid var(--border);
}
.zoom-step {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.zoom-step:hover { background: var(--bg-hover); color: var(--text-1); }
.zoom-slider { width: 82px; accent-color: var(--accent); cursor: pointer; }

.pill-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 12px;
}
.pill-strip::-webkit-scrollbar { display: none; }
.dir-pill {
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.dir-pill:hover, .dir-pill.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

.floating-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  margin-bottom: 12px;
}
.clip-bar {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.35);
}
.bar-label { font-size: 13px; font-weight: 600; }
.bar-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.drop-banner {
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  padding: 11px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 12px;
  transition: all 0.16s;
}
.drop-banner.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-1);
}

.upload-queue { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.upload-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
}
.upload-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.upload-track { height: 5px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; }
.upload-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width 0.2s; }

/* Modern List View */
.list-head-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 96px 148px 54px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}
.list-head-row .sortable { text-align: left; font-weight: 500; color: var(--text-3); }
.list-head-row .sortable:hover { color: var(--text-1); }
.lh-check { display: flex; justify-content: center; }

.file-rows { display: flex; flex-direction: column; }
.file-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 96px 148px 54px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 11px;
  margin-top: 2px;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}
.file-row:hover { background: rgba(255, 255, 255, 0.045); }
.file-row.selected { background: rgba(59, 130, 246, 0.15); }
.file-row.is-cut { opacity: 0.42; }

.fr-check { display: flex; justify-content: center; }
.fr-check input, .grid-check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.fr-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding-right: 10px;
}
.fr-thumb {
  width: 42px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.fr-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-play {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(9, 11, 16, 0.78);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fr-text { min-width: 0; }
.fr-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fr-mobile-sub { display: none; font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.fr-size, .fr-time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.fr-ops { display: flex; justify-content: flex-end; }

/* Modern File Grid */
.file-grid {
  --thumb-size: 148px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size), 1fr));
  gap: 12px;
  padding-top: 4px;
}
.file-grid.dense-mode { gap: 5px; }
.file-grid.dense-mode .fg-card { padding: 3px; border-radius: 8px; }
.file-grid.dense-mode .fg-thumb { margin-bottom: 0; border-radius: 6px; }
.file-grid.dense-mode .fg-name, .file-grid.dense-mode .fg-meta { display: none; }

.fg-card {
  position: relative;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.14s;
  user-select: none;
}
.fg-card:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--border-strong); }
.fg-card.selected { background: rgba(59, 130, 246, 0.16); border-color: rgba(59, 130, 246, 0.6); }
.fg-card.is-cut { opacity: 0.42; }
.grid-check { position: absolute; top: 10px; left: 10px; z-index: 2; }
.fg-thumb {
  aspect-ratio: 4 / 3;
  width: 100%;
  border-radius: 10px;
  background: rgba(9, 11, 16, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin-bottom: 8px;
}
.fg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s; }
.fg-card:hover .fg-thumb img { transform: scale(1.03); }
.fg-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fg-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ================= Media & Photos ================= */
.segmented-tabs {
  display: inline-flex;
  background: rgba(9, 11, 16, 0.7);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  height: 30px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}
.seg-btn.active { background: var(--bg-2); color: var(--text-1); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

.media-grid {
  --thumb-size: 180px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size), 1fr));
  gap: 12px;
  margin-top: 8px;
}
.media-grid.photo-wall { gap: 6px; }
.media-grid.dense-mode { gap: 4px; }
.media-grid.dense-mode .media-tile { border-radius: 6px; }
.media-grid.dense-mode .media-caption,
.media-grid.dense-mode .media-ext { display: none; }
.media-grid.dense-mode .play-pill { width: 30px; height: 30px; }

.media-tile {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #0d111a;
  border: 1px solid var(--border);
  cursor: pointer;
  aspect-ratio: 16 / 10;
  display: block;
  width: 100%;
  text-align: left;
}
.media-grid.photo-wall .media-tile {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: none;
}
.media-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.28s ease;
}
.media-tile:hover img { transform: scale(1.04); }

.media-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 28px 10px 9px;
  background: linear-gradient(180deg, transparent 0%, rgba(5, 7, 12, 0.88) 100%);
  pointer-events: none;
}
.media-grid.photo-wall .media-caption { display: none; }
.media-title {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-sub { font-size: 11px; color: rgba(255,255,255,0.68); margin-top: 2px; display: flex; justify-content: space-between; }

.media-ext {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(9, 11, 16, 0.68);
  backdrop-filter: blur(8px);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: #e2e8f0;
}
.play-pill {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(9, 11, 16, 0.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ================= Connect & Settings ================= */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-title-row h3 { margin-bottom: 0; }
.pill-state {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-2);
}
.pill-state.on { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.pill-state.off { background: rgba(244, 63, 94, 0.16); color: #fda4af; }

.kv-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 16px; }
.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 13px;
}
.kv-row span { color: var(--text-2); }
.hint-note { margin-top: 14px; font-size: 12.5px; color: var(--text-3); line-height: 1.6; }

.addr-list, .service-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.addr-card, .service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.addr-meta { min-width: 0; flex: 1; }
.addr-label { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.addr-card code { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.service-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

/* ================= Immersive Lightbox ================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  flex-direction: column;
}
.lightbox-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.75) 0%, transparent 100%);
}
.lightbox-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lightbox-actions { display: flex; gap: 6px; }
.light-btn { background: rgba(255, 255, 255, 0.12); color: #fff; backdrop-filter: blur(10px); }
.light-btn:hover { background: rgba(255, 255, 255, 0.22); }

.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 56px 12px 20px;
}
.lightbox-stage img, .lightbox-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-arrow:hover { background: rgba(255, 255, 255, 0.24); }
.lightbox-arrow.left { left: 16px; }
.lightbox-arrow.right { right: 16px; }

/* ================= Dialog & Context Menu / Bottom Sheet ================= */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.dir-tree { max-height: 340px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 3px; }
.dir-pick {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dir-pick:hover { background: var(--bg-hover); color: var(--text-1); }
.dir-pick.active { background: rgba(59, 130, 246, 0.18); color: #93c5fd; font-weight: 600; }
.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.ctx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 84;
  background: rgba(0, 0, 0, 0.45);
}
.context-menu {
  position: fixed;
  z-index: 85;
  min-width: 190px;
  background: rgba(20, 25, 38, 0.96);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
.ctx-header {
  display: none;
  padding: 10px 14px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ctx-item {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text-1);
}
.ctx-item:hover { background: rgba(59, 130, 246, 0.2); }
.ctx-item.danger { color: #fda4af; }
.ctx-item.danger:hover { background: rgba(244, 63, 94, 0.22); }
.ctx-kbd { font-size: 11.5px; color: var(--text-3); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.empty-state {
  text-align: center;
  padding: 44px 16px;
  color: var(--text-3);
  font-size: 13.5px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  background: rgba(22, 28, 44, 0.95);
  border: 1px solid var(--border-strong);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

/* ================= Comics Shelf & Reader ================= */
.select-pill {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(9, 11, 16, 0.7);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
}
.comic-dl-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-bottom: 12px;
  font-size: 12.5px;
}
.comic-dl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cbz-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
}
.cbz-toggle input { accent-color: var(--accent); }

/* ================= v2.0 Storage, Notes, Editor & Ops Logs ================= */
.storage-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.storage-row { display: flex; flex-direction: column; gap: 5px; }
.storage-head { display: flex; justify-content: space-between; font-size: 13px; }
.storage-track { height: 6px; background: rgba(255, 255, 255, 0.07); border-radius: 99px; overflow: hidden; }
.storage-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3b82f6, #2dd4bf); }

.note-input-row { display: flex; gap: 8px; align-items: center; }
.note-field { height: 38px; flex: 1; font-size: 13.5px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 220px; overflow-y: auto; }
.note-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  font-size: 13px;
}
.note-text { word-break: break-all; flex: 1; line-height: 1.45; }
.note-ops { display: flex; gap: 4px; flex-shrink: 0; }

.log-viewer {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #06080d;
  border: 1px solid var(--border);
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.editor-card { max-width: 780px; width: 100%; height: 80vh; display: flex; flex-direction: column; }
.editor-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 14px 16px;
  background: #0a0d14;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.comic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.comic-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #0d111a;
  border: 1px solid var(--border);
  aspect-ratio: 3 / 4;
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.comic-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.28s ease;
}
.comic-card:hover img { transform: scale(1.05); }
.comic-card-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 36px 10px 10px;
  background: linear-gradient(180deg, transparent 0%, rgba(5, 7, 12, 0.92) 100%);
}
.comic-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.comic-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(9, 11, 16, 0.76);
  backdrop-filter: blur(8px);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  color: #e2e8f0;
}

.comic-detail-card { max-width: 620px; max-height: 86vh; display: flex; flex-direction: column; }
.comic-detail-hero {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.comic-detail-cover {
  width: 104px;
  height: 142px;
  border-radius: 10px;
  object-fit: cover;
  background: #0d111a;
  flex-shrink: 0;
}
.comic-detail-meta { min-width: 0; flex: 1; }
.comic-detail-meta h3 { font-size: 16px; margin-bottom: 6px; }
.comic-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.comic-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
}
.comic-desc {
  font-size: 12.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.comic-chapters {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ch-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 6px 4px 10px;
}
.ch-row.active { border-color: rgba(59, 130, 246, 0.55); background: rgba(59, 130, 246, 0.14); }
.ch-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 6px 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-dl-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ch-dl-btn:hover { background: var(--bg-hover); color: var(--accent-light); }

/* Immersive Comic Reader */
.comic-reader {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: #000;
  display: flex;
  flex-direction: column;
}
.reader-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 12, 18, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.reader-top {
  top: 0;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--border);
}
.reader-bottom {
  bottom: 0;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.comic-reader.bars-hidden .reader-top { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.comic-reader.bars-hidden .reader-bottom { transform: translateY(100%); opacity: 0; pointer-events: none; }

.reader-progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.reader-slider { flex: 1; width: auto; }
.reader-page-num { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }

.reader-stage {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.reader-stage.strip-mode {
  padding: 54px 0 84px;
}
.reader-stage.strip-mode img {
  width: 100%;
  max-width: 820px;
  height: auto;
  display: block;
}
.reader-stage.page-mode {
  overflow: hidden;
  justify-content: center;
  padding: 52px 8px 64px;
}
.reader-stage.page-mode img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.reader-next-footer {
  width: 100%;
  max-width: 820px;
  padding: 28px 16px 40px;
  text-align: center;
}

/* Reader In-place Chapter TOC Drawer (Desktop Right Drawer / Mobile Bottom Sheet) */
.reader-toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(4px);
}
.reader-toc-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 88vw;
  z-index: 91;
  background: rgba(16, 20, 31, 0.96);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  border-left: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.6);
  animation: tocSlideLeft 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tocSlideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
.toc-handle { display: none; }
.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
}
.toc-head-info { min-width: 0; flex: 1; }
.toc-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.toc-search-wrap { padding: 10px 14px 6px; }
.toc-search-input { height: 36px; font-size: 13px; border-radius: 10px; }
.toc-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 12px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toc-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid transparent;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-1);
  transition: background 0.14s, border-color 0.14s;
}
.toc-item:hover { background: rgba(255, 255, 255, 0.08); }
.toc-item.current {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.55);
  color: #93c5fd;
  font-weight: 600;
}
.toc-item-name { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-now-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .reader-toc-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 72vh;
    border-left: none;
    border-top: 1px solid var(--border-strong);
    border-radius: 22px 22px 0 0;
    animation: sheetUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .toc-handle {
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.22);
    margin: 9px auto 2px;
    flex-shrink: 0;
  }
  .toc-head { padding: 10px 14px 10px; }
}

/* ================= IPTV Live TV ================= */
.iptv-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.iptv-video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.iptv-video-box video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.iptv-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13.5px;
  background: radial-gradient(circle at center, #111827 0%, #05070c 100%);
  pointer-events: none;
}
.iptv-now-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.iptv-now-title { font-size: 15px; font-weight: 600; }
.iptv-list-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.iptv-channel-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 540px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.iptv-ch-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid transparent;
  text-align: left;
  transition: background 0.14s, border-color 0.14s;
}
.iptv-ch-btn:hover { background: rgba(255, 255, 255, 0.08); }
.iptv-ch-btn.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.55);
}
.iptv-ch-logo {
  width: 34px;
  height: 24px;
  border-radius: 5px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px;
  flex-shrink: 0;
}
.iptv-ch-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iptv-ch-lines {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}

@media (max-width: 960px) {
  .iptv-layout { grid-template-columns: 1fr; }
  .iptv-channel-list { max-height: 46vh; }
}

@media (max-width: 768px) {
  .comic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .comic-card { border-radius: 9px; }
  .comic-card-title { font-size: 11.5px; }
  .comic-chapters { grid-template-columns: 1fr; }
  .comic-detail-hero { gap: 12px; padding: 12px; }
  .comic-detail-cover { width: 82px; height: 112px; }
}

/* ================= Tablet ================= */
@media (max-width: 1080px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-launcher { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}

/* ================= Native Mobile App Experience (<= 768px) ================= */
@media (max-width: 768px) {
  .sidebar { display: none; }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: rgba(11, 14, 22, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .mobile-header-left, .mobile-header-right { display: flex; align-items: center; gap: 8px; }
  .mobile-dot { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(135deg, #38bdf8, #6366f1); }
  .mobile-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
  .chip-subtle {
    font-size: 11.5px;
    color: var(--text-3);
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 9px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
  }

  .content-scroll {
    padding: 14px 12px calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom));
  }

  .page-head { display: none; }
  .block-title { margin: 20px 0 10px; font-size: 14px; }

  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { padding: 12px; gap: 10px; border-radius: 16px; }
  .ring-wrap, .ring-svg { width: 48px; height: 48px; }
  .ring-val { font-size: 11px; }
  .metric-title { font-size: 14px; }
  .metric-label, .metric-sub { font-size: 11px; }

  .app-launcher { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .launch-tile { flex-direction: column; align-items: flex-start; padding: 14px; gap: 10px; border-radius: 16px; }
  .tile-icon { width: 42px; height: 42px; border-radius: 12px; }
  .tile-name { font-size: 14px; }
  .tile-desc { font-size: 11.5px; white-space: normal; }

  .surface-card { padding: 12px; border-radius: 16px; }
  .fm-header { gap: 10px; margin-bottom: 10px; }
  .fm-path-row { width: 100%; }
  .fm-tools { width: 100%; justify-content: space-between; }
  .search-box { flex: 1; min-width: 110px; }
  .search-box input { width: 100%; }
  .zoom-slider { width: 64px; }
  .btn-upload-trigger span { display: none; }
  .btn-upload-trigger { width: 36px; padding: 0; }
  .drop-banner { display: none; }

  /* Mobile Clean File Rows */
  .list-head-row { display: none; }
  .file-row {
    grid-template-columns: 32px minmax(0, 1fr) 38px;
    padding: 9px 4px;
  }
  .fr-size, .fr-time { display: none; }
  .fr-mobile-sub { display: block; }
  .fr-thumb { width: 44px; height: 44px; border-radius: 10px; }
  .fr-name { font-size: 14px; }

  .segmented-tabs { width: 100%; justify-content: space-between; }
  .seg-btn { flex: 1; padding: 0 6px; font-size: 12.5px; }

  /* Mobile Bottom Tab Bar */
  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(12, 16, 26, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
  }
  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 500;
  }
  .tab-item.active { color: var(--accent-light); }

  /* Mobile Bottom Action Sheet */
  .context-menu {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    min-width: 100%;
    border-radius: 22px 22px 0 0;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    border-left: none;
    border-right: none;
    border-bottom: none;
    animation: sheetUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .ctx-header { display: block; }
  .ctx-item { height: 46px; font-size: 15px; border-radius: 12px; }
  .ctx-kbd { display: none; }

  /* Lightbox on mobile: hide side arrows, use swipe */
  .lightbox-arrow { display: none !important; }
  .lightbox-stage { padding: 56px 0 16px; }
  .lightbox-stage img, .lightbox-stage video { border-radius: 0; }

  .toast { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
}
