/* =====================================================================
   网盘 — 面板样式表
   =====================================================================
   Built on 3x-ui's design language rather than its surface. The parts
   that were actually copied, and why:

   1. The page is NOT white. A tinted page (#e6e8ec / #1a1b1f / #000)
      with white-ish cards floating on it is what makes a panel read as a
      panel. Cards on a white page look like nothing.
   2. Three themes, not two: light / dark / ultra (true black). 3x-ui
      ships an explicit toggle instead of only following the OS, so the
      brand row carries one and the choice is persisted.
   3. Every page is the same three beats: summary strip → action card →
      data card. Nothing floats loose on the background.
   4. Inside a card, grouping is done with 1px rules between cells, never
      with nested boxes.
   5. A strict type ladder does the hierarchy work:
        kicker  11px UPPERCASE .08em  — the label above any value
        sub     10px UPPERCASE .06em  — the label inside a split cell
        value   19px/600               — a normal figure
        hero    34px/600 -.02em        — the one big figure on a card
      and every numeral is tabular-nums so columns of figures line up.
   6. One accent, plus threshold colouring shared by rings, values and
      the health line: <80% accent, 80–90% amber, ≥90% red.
   ===================================================================== */

/* ---------- tokens: light ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --bg-page: #e6e8ec;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --bg-sider: #ffffff;
  --bg-soft: #f4f5f7;
  --bg-hover: rgba(0, 0, 0, 0.025);

  --text: rgba(0, 0, 0, 0.88);
  --text-2: rgba(0, 0, 0, 0.62);
  --text-3: rgba(0, 0, 0, 0.48);

  --line: #d9d9d9;
  --line-2: rgba(0, 0, 0, 0.07);

  /* Two primaries on purpose: antd's #1677ff for text/rings, and a
     darker #0958d9 for solid buttons, which is what 3x-ui switches to in
     light mode so white-on-blue clears contrast. */
  --primary: #1677ff;
  --primary-solid: #0958d9;
  --primary-solid-hover: #2468e5;
  --primary-soft: rgba(22, 119, 255, 0.1);

  --warn: #d48806;
  --crit: #cf1322;
  --ok: #237804;
  --warn-soft: rgba(250, 173, 20, 0.14);
  --crit-soft: rgba(255, 77, 79, 0.12);
  --ok-soft: rgba(82, 196, 26, 0.14);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.08);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.14);

  --r-card: 12px;
  --r: 8px;
  --r-sm: 6px;
  --gap: 12px;
  --pad: 20px;
  --sider-w: 208px;
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-page: #1a1b1f;
    --bg-card: #23252b;
    --bg-elevated: #2d2f37;
    --bg-sider: #15161a;
    --bg-soft: #1f2126;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --text: rgba(255, 255, 255, 0.9);
    --text-2: rgba(255, 255, 255, 0.62);
    --text-3: rgba(255, 255, 255, 0.45);
    --line: #34373f;
    --line-2: rgba(255, 255, 255, 0.06);
    --primary: #1677ff;
    --primary-solid: #1677ff;
    --primary-solid-hover: #4096ff;
    --primary-soft: rgba(22, 119, 255, 0.16);
    --warn: #faad14;
    --crit: #ff4d4f;
    --ok: #52c41a;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg-page: #1a1b1f;
  --bg-card: #23252b;
  --bg-elevated: #2d2f37;
  --bg-sider: #15161a;
  --bg-soft: #1f2126;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --text: rgba(255, 255, 255, 0.9);
  --text-2: rgba(255, 255, 255, 0.62);
  --text-3: rgba(255, 255, 255, 0.45);
  --line: #34373f;
  --line-2: rgba(255, 255, 255, 0.06);
  --primary: #1677ff;
  --primary-solid: #1677ff;
  --primary-solid-hover: #4096ff;
  --primary-soft: rgba(22, 119, 255, 0.16);
  --warn: #faad14;
  --crit: #ff4d4f;
  --ok: #52c41a;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* ---------- tokens: ultra dark ---------- */
:root[data-theme="ultra"] {
  --bg-page: #000000;
  --bg-card: #101013;
  --bg-elevated: #1a1a1e;
  --bg-sider: #050507;
  --bg-soft: #131317;
  --bg-hover: rgba(255, 255, 255, 0.035);
  --text: rgba(255, 255, 255, 0.9);
  --text-2: rgba(255, 255, 255, 0.6);
  --text-3: rgba(255, 255, 255, 0.42);
  --line: #2a2a30;
  --line-2: rgba(255, 255, 255, 0.04);
  --primary: #1677ff;
  --primary-solid: #1677ff;
  --primary-solid-hover: #4096ff;
  --primary-soft: rgba(22, 119, 255, 0.16);
  --warn: #faad14;
  --crit: #ff4d4f;
  --ok: #52c41a;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.025);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.85);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5715;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; font-size: inherit; font-weight: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-solid-hover); }
svg { width: 16px; height: 16px; flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(0.9); opacity: 0.5; } 100% { transform: scale(2.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================================================
   type ladder — the backbone of the whole layout
   ===================================================================== */
.kicker {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.kicker-icon { display: flex; align-items: center; gap: 7px; }
.kicker-icon svg { width: 14px; height: 14px; }
.sub {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.value {
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hero {
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* =====================================================================
   shell
   ===================================================================== */
.app { display: flex; min-height: 100vh; }

.sider {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--sider-w);
  height: 100vh;
  background: var(--bg-sider);
  border-inline-end: 1px solid var(--line-2);
}

.sider-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 58px;
  flex: none;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line-2);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  user-select: none;
}
.sider-brand a { color: inherit; }
.sider-brand a:hover { color: inherit; }
.brand-actions { display: inline-flex; align-items: center; gap: 2px; }
.brand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, transform 0.15s;
}
.brand-btn:hover, .brand-btn:focus-visible {
  background: var(--primary-soft);
  color: var(--primary);
  transform: scale(1.08);
}

.sider-nav { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.sider-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 14px;
  transition: background-color 0.2s, color 0.2s;
}
.sider-nav a:hover { background: var(--bg-hover); color: var(--text); }
.sider-nav a.on { background: var(--primary-soft); color: var(--primary); }
.sider-nav a.on svg { color: var(--primary); }

.sider-foot {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sider-foot form { margin: 0; }
.sider-foot button, .sider-foot .foot-line {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.sider-foot button:hover { background: var(--bg-hover); color: var(--text); }
.foot-line { cursor: default; color: var(--text-3); font-family: var(--mono); font-size: 12px; }
.foot-user { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.shell { flex: 1; min-width: 0; }
/* Capped: past ~1600px the name column just grows and leaves the size
   and date columns stranded against the right edge with a wide empty
   gap between them and the filename. */
.content { padding: 24px; max-width: 1600px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }

/* =====================================================================
   card
   ===================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line-2);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.25s ease, border-color 0.2s ease;
}
.card-hover:hover { box-shadow: var(--shadow-hover); }
.card-pad { padding: var(--pad); }
.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--line-2);
}
.card-title { font-size: 16px; font-weight: 600; }
.spacer { flex: 1; }

/* =====================================================================
   action bar — 3x-ui's status pill row above the dials
   ===================================================================== */
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
}
.state-dot {
  position: relative;
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
  color: var(--ok);
}
.state-dot::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid currentColor;
  animation: pulse 1.6s infinite ease-out;
}
.state-bad { border-color: color-mix(in srgb, var(--crit) 45%, transparent); color: var(--crit); }
.state-bad .state-dot { background: var(--crit); color: var(--crit); }
.bar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* redirect-carried result banner on the settings page */
.notice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-size: 13.5px;
}
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.notice.err { background: var(--crit-soft); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 28%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.notice svg { width: 16px; height: 16px; }
/* A notice used inside a dialog (rename/new-file error) rather than as a
   top-level .stack child -- .stack's gap doesn't reach inside a .modal-box,
   so this is its own margin instead. */
.modal-box .notice { margin-bottom: 14px; }

/* The action row at the foot of a form card: separated from the fields
   by the same hairline used everywhere else for grouping. */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
}
.form-note { margin: 0; }
.bar-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }

.health { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.health-mark { width: 14px; height: 1px; background: currentColor; flex: none; }
.health.warn { color: var(--warn); }
.health.crit { color: var(--crit); }

/* A rule that fades out at both ends — 3x-ui uses it to separate the
   action bar from the dials without drawing a hard line across the page. */
.rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(to right, transparent, var(--line-2) 48px,
    var(--line-2) calc(100% - 48px), transparent);
}

/* =====================================================================
   dial gauges
   =====================================================================
   Geometry copied from antd's <Progress type="dashboard">: a circle with
   a 75° gap centred at the bottom, so the track reads as a dial rather
   than a pie. r=45 in a 100×100 box, circumference 282.74, of which
   282.74 × 285/360 = 223.8 is drawable. The arc is rotated by
   90 + 75/2 = 127.5° so its start sits just clockwise of the gap.
   The filled length is set from data-pct by app.js, because a CSP
   without 'unsafe-inline' blocks style="" attributes.
   ===================================================================== */
.dials {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: var(--pad) 0;
}
.dial {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  animation: rise 340ms ease both;
}
.dials .dial:nth-child(2) { animation-delay: 50ms; }
.dials .dial:nth-child(3) { animation-delay: 100ms; }
.dials .dial:nth-child(4) { animation-delay: 150ms; }
.dial + .dial { border-inline-start: 1px solid var(--line-2); }

.ring { position: relative; width: 96px; height: 96px; }
.ring svg { width: 96px; height: 96px; transform: none; }
.ring circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transform: rotate(127.5deg);
  transform-origin: 50% 50%;
}
.ring .track { stroke: var(--line-2); stroke-dasharray: 223.8 282.74; }
.ring .arc {
  stroke: var(--primary);
  stroke-dasharray: 0 282.74;
  transition: stroke-dasharray 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dial[data-tone="warn"] .arc { stroke: var(--warn); }
.dial[data-tone="crit"] .arc { stroke: var(--crit); }

.ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.dial[data-tone="warn"] .ring-text { color: var(--warn); }
.dial[data-tone="crit"] .ring-text { color: var(--crit); }

.dial-cap { text-align: center; font-size: 13px; color: var(--text-2); }
.dial-cap b { color: var(--text); font-weight: 600; }
.dial-cap .dial-detail { font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .dials { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 0; }
  .dial:nth-child(3) { border-inline-start: none; }
}
@media (max-width: 560px) {
  .dials { grid-template-columns: minmax(0, 1fr); }
  .dial + .dial { border-inline-start: none; }
}

/* =====================================================================
   info strip — cells split by rules, each with kicker + split values
   ===================================================================== */
.strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: var(--pad); }
.strip-cell + .strip-cell { border-inline-start: 1px solid var(--line-2); padding-inline-start: 16px; }
.strip-split { display: flex; align-items: stretch; gap: 14px; }
.strip-split > div { min-width: 0; }
.strip-sep { width: 1px; background: var(--line-2); margin-top: 8px; flex: none; }
.strip-cell .sub { margin-top: 8px; }
.strip-cell .sub + .value { margin-top: 2px; }
.strip-cell .value { margin-top: 6px; }
/* min-width:0 because these sit inside a flex row; without it a flex
   item refuses to shrink below its content and never ellipsises. */
.strip-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip-cell:nth-child(3) { border-inline-start: none; padding-inline-start: 0; }
}
@media (max-width: 560px) {
  .strip { grid-template-columns: minmax(0, 1fr); }
  .strip-cell + .strip-cell { border-inline-start: none; padding-inline-start: 0; padding-top: 14px; border-top: 1px solid var(--line-2); }
}

/* summary strip variant used on secondary pages (kicker + one value) */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; padding: 16px var(--pad); }
.summary-cell .value { margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.summary-cell .value svg { width: 16px; height: 16px; color: var(--text-3); }

/* =====================================================================
   controls
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.btn:hover { color: var(--primary); border-color: var(--primary); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--primary-solid);
  border-color: var(--primary-solid);
  color: #fff;
  box-shadow: 0 2px 0 rgba(5, 145, 255, 0.1);
}
.btn-primary:hover { background: var(--primary-solid-hover); border-color: var(--primary-solid-hover); color: #fff; }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { color: #fff; filter: brightness(1.08); }
.btn-lg { height: 40px; font-size: 15px; padding: 0 20px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.iconbtn:hover { background: var(--primary-soft); color: var(--primary); }
.iconbtn.danger:hover { background: var(--crit-soft); color: var(--crit); }
.inline { display: inline-flex; margin: 0; }

input[type="text"], input[type="password"], select {
  width: 100%;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder { color: var(--text-3); }
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
select {
  appearance: none;
  padding-inline-end: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select.auto { width: auto; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; }
.field-hint { font-size: 12.5px; color: var(--text-3); }

/* Name input + fixed, non-editable extension chip, used by the new-file
   dialog: the button that opened the dialog already decided .txt vs .md,
   so the extension is shown, not typed. */
.input-suffix { display: flex; align-items: stretch; gap: 8px; }
.input-suffix input { flex: 1; min-width: 0; }
.suffix-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 13px;
  font-family: var(--mono);
  white-space: nowrap;
  user-select: none;
}

.search { position: relative; flex: 1; min-width: 140px; max-width: 320px; }
.search svg {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  color: var(--text-3);
  pointer-events: none;
}
.search input { padding-inline-start: 30px; }

.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-soft); }
.seg button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.seg button svg { width: 14px; height: 14px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-card); }

/* =====================================================================
   tags — soft-tinted pills, antd style
   ===================================================================== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.tag svg { width: 12px; height: 12px; }
.tag-primary { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.tag-crit { background: var(--crit-soft); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 25%, transparent); }
.tag-count { min-width: 22px; justify-content: center; font-variant-numeric: tabular-nums; }

/* =====================================================================
   table
   ===================================================================== */
.tbl { width: 100%; }
.tbl-head {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 12px var(--pad);
  border-bottom: 1px solid var(--line-2);
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.tbl-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--line-2);
  transition: background-color 0.2s;
  animation: rise 280ms ease both;
}
.tbl-row:last-child { border-bottom: none; }
.tbl-row:hover { background: var(--bg-hover); }
.tbl-row[hidden] { display: none; }

/* file table column ruler, shared by head and rows */
.cols-files { grid-template-columns: minmax(0, 1fr) 110px 180px 104px; }
.cols-files > :nth-child(2) { text-align: end; }
/* shares table */
.cols-shares { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) 220px 104px; }
/* import table */
.cols-import { grid-template-columns: minmax(0, 1fr) 110px 180px 120px; }
.cols-import > :nth-child(2) { text-align: end; }

.keep-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.keep-toggle input { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.hint-gap { margin-top: 12px; }

.cell-r { text-align: end; }
.cell-dim { color: var(--text-2); font-size: 13px; }
.cell-actions { display: flex; justify-content: flex-end; gap: 2px; }

.fname { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fname-link { min-width: 0; color: var(--text); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname-link:hover { color: var(--primary); }

.ficon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--r);
  color: var(--text-3);
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.ficon svg { width: 17px; height: 17px; }
.ficon[data-kind="image"] { color: #13a8a8; }
.ficon[data-kind="video"] { color: #722ed1; }
.ficon[data-kind="audio"] { color: #eb2f96; }
.ficon[data-kind="archive"] { color: #d48806; }
.ficon[data-kind="pdf"] { color: #cf1322; }
.ficon[data-kind="doc"] { color: #1677ff; }
.ficon[data-kind="sheet"] { color: #389e0d; }
.ficon[data-kind="slide"] { color: #d4380d; }
.ficon[data-kind="code"] { color: #08979c; }
.ficon[data-kind="text"] { color: #8c8c8c; }
:root[data-theme="dark"] .ficon[data-kind="image"], :root[data-theme="ultra"] .ficon[data-kind="image"] { color: #36cfc9; }
:root[data-theme="dark"] .ficon[data-kind="video"], :root[data-theme="ultra"] .ficon[data-kind="video"] { color: #b37feb; }
:root[data-theme="dark"] .ficon[data-kind="sheet"], :root[data-theme="ultra"] .ficon[data-kind="sheet"] { color: #95de64; }
:root[data-theme="dark"] .ficon[data-kind="pdf"], :root[data-theme="ultra"] .ficon[data-kind="pdf"] { color: #ff7875; }
:root[data-theme="dark"] .ficon[data-kind="code"], :root[data-theme="ultra"] .ficon[data-kind="code"] { color: #5cdbd3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .ficon[data-kind="image"] { color: #36cfc9; }
  :root:not([data-theme]) .ficon[data-kind="video"] { color: #b37feb; }
  :root:not([data-theme]) .ficon[data-kind="sheet"] { color: #95de64; }
  :root:not([data-theme]) .ficon[data-kind="pdf"] { color: #ff7875; }
  :root:not([data-theme]) .ficon[data-kind="code"] { color: #5cdbd3; }
}

/* grid view */
.tbl.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 12px; padding: var(--pad); }
.tbl.grid .tbl-head { display: none; }
.tbl.grid .tbl-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  text-align: center;
}
.tbl.grid .tbl-row[hidden] { display: none; }
.tbl.grid .fname { flex-direction: column; gap: 10px; width: 100%; }
.tbl.grid .fname-link { width: 100%; text-align: center; }
.tbl.grid .ficon { width: 48px; height: 48px; border-radius: 14px; }
.tbl.grid .ficon svg { width: 24px; height: 24px; }
.tbl.grid .cell-r, .tbl.grid .cell-dim { text-align: center; }
.tbl.grid .cell-actions { justify-content: center; }
.tbl.grid .col-date { display: none; }

/* =====================================================================
   empty state
   ===================================================================== */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 56px 24px; text-align: center; animation: fade 400ms ease both; }
/* Required, not redundant: the UA's `[hidden] { display: none }` is a
   user-agent rule, and ANY author declaration outranks it regardless of
   specificity. Without this, `hidden` does nothing to a .empty block and
   the "no files" and "no search matches" panels stack up together. */
.empty[hidden] { display: none; }
.empty-actions { margin-top: 14px; }
.empty-art {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 6px;
  border-radius: 16px;
  background: var(--bg-soft);
  color: var(--text-3);
}
.empty-art svg { width: 26px; height: 26px; }
.empty-title { font-size: 15px; font-weight: 600; }
.empty-text { font-size: 13px; color: var(--text-2); max-width: 360px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px 20px; border-top: 1px solid var(--border); }

/* =====================================================================
   drag & drop, upload tray
   ===================================================================== */
.drop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  padding: 28px;
  background: color-mix(in srgb, var(--bg-page) 80%, transparent);
  backdrop-filter: blur(6px);
}
.drop.on { display: grid; animation: fade 120ms ease both; }
.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(520px, 100%);
  padding: 52px 32px;
  border: 2px dashed var(--primary);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-pop);
  text-align: center;
  animation: pop 160ms ease both;
}
.drop-inner svg { width: 38px; height: 38px; }
.drop-title { font-size: 17px; font-weight: 600; color: var(--text); }

.tray {
  position: fixed;
  inset-inline-end: 20px;
  bottom: 20px;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line-2);
  border-radius: var(--r-card);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: pop 180ms ease both;
}
.tray[hidden] { display: none; }
.tray-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 600;
}
.tray-list { max-height: 244px; overflow-y: auto; padding: 6px; }
.tray.min .tray-list { display: none; }
.tray-item { padding: 8px; border-radius: var(--r-sm); animation: rise 200ms ease both; }
.tray-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; font-size: 12.5px; }
.tray-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-pct { flex: none; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tray-item.done .tray-pct { color: var(--ok); }
/* Body sent, server still finishing: the bar is full but the work is
   not, so it pulses instead of sitting inert at 100%. */
.tray-item.finishing .tray-pct { color: var(--primary); }
.tray-item.finishing .bar-track > i { animation: barPulse 1.1s ease-in-out infinite; }
@keyframes barPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.tray-item.err { background: var(--crit-soft); }
.tray-item.err .tray-pct, .tray-item.err .tray-name { color: var(--crit); }
.tray-item.err .bar-track > i { background: var(--crit); }
.tray-retry {
  flex: none;
  padding: 1px 8px;
  border: 1px solid var(--crit);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--crit);
  font-size: 11.5px;
  cursor: pointer;
}
.tray-retry:hover { background: var(--crit-soft); }

.bar-track { height: 4px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.bar-track > i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 140ms ease; }

/* =====================================================================
   modal + toasts
   ===================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.45);
  animation: fade 130ms ease both;
}
.modal[hidden] { display: none; }
.modal-box {
  width: min(416px, 100%);
  padding: 20px 24px 20px;
  border-radius: var(--r-card);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-pop);
  animation: pop 170ms ease both;
}
.modal-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.modal-title svg { width: 20px; height: 20px; color: var(--warn); }
.modal-text { margin-top: 8px; padding-inline-start: 30px; font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

.toasts {
  position: fixed;
  top: 20px;
  inset-inline: 0;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  animation: pop 180ms ease both;
}
.toast svg { width: 16px; height: 16px; color: var(--ok); }
.toast.err svg { color: var(--crit); }
.toast.out { animation: fade 200ms ease both reverse; }

/* =====================================================================
   share links
   ===================================================================== */
.link-url {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
}
.link-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.meta-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* =====================================================================
   verify verdict
   ===================================================================== */
.verdict { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 24px 28px; text-align: center; }
.verdict-ring {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}
.verdict.bad .verdict-ring { background: var(--crit-soft); color: var(--crit); }
.verdict-ring svg { width: 30px; height: 30px; }
.verdict-title { font-size: 17px; font-weight: 600; }
.verdict-text { font-size: 14px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.hashline-gap { margin-top: 8px; }
.hashline {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* =====================================================================
   text editor / preview
   ===================================================================== */
.editor-textarea {
  display: block;
  width: 100%;
  min-height: 60vh;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
  tab-size: 4;
}
.editor-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.text-body {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Rendered Markdown. Reuses the page's own tokens rather than a
   third colour palette, so a preview reads as part of the panel and not
   as an embedded document viewer. */
.md-body { line-height: 1.7; overflow-wrap: anywhere; }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 {
  margin: 22px 0 10px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.md-body h1 { font-size: 22px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2); }
.md-body h2 { font-size: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--line-2); }
.md-body h3 { font-size: 16px; }
.md-body h4, .md-body h5, .md-body h6 { font-size: 14px; }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body pre, .md-body table { margin: 10px 0; }
.md-body ul, .md-body ol { padding-inline-start: 24px; }
.md-body li + li { margin-top: 4px; }
.md-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.md-body code { padding: 2px 5px; border-radius: 4px; background: var(--bg-soft); font-family: var(--mono); font-size: 0.9em; }
.md-body pre { padding: 12px 14px; border-radius: var(--r-sm); background: var(--bg-soft); overflow-x: auto; }
.md-body pre code { padding: 0; background: none; }
.md-body blockquote { padding: 2px 14px; border-inline-start: 3px solid var(--line); color: var(--text-2); }
.md-body table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; }
.md-body th, .md-body td { padding: 6px 10px; border: 1px solid var(--line-2); text-align: start; }
.md-body th { background: var(--bg-soft); font-weight: 600; }
.md-body img { max-width: 100%; border-radius: var(--r-sm); }
.md-body hr { height: 1px; border: 0; background: var(--line-2); margin: 18px 0; }

/* =====================================================================
   login / public download — 3x-ui's glass card over gradient blobs
   ===================================================================== */
body.solo {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  --blob-1: rgba(22, 119, 255, 0.5);
  --blob-2: rgba(236, 72, 153, 0.42);
  --blob-3: rgba(20, 184, 166, 0.4);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-line: rgba(255, 255, 255, 0.6);
  background: linear-gradient(135deg, #eef2ff 0%, #fdf2f8 50%, #ecfeff 100%);
}
:root[data-theme="dark"] body.solo,
:root[data-theme="ultra"] body.solo {
  --blob-1: rgba(96, 165, 250, 0.4);
  --blob-2: rgba(59, 130, 246, 0.4);
  --blob-3: rgba(37, 99, 235, 0.32);
  --glass: rgba(28, 30, 36, 0.6);
  --glass-line: rgba(255, 255, 255, 0.1);
  background: radial-gradient(ellipse at 25% 20%, #152038 0%, #0d1117 60%);
}
:root[data-theme="ultra"] body.solo { background: radial-gradient(ellipse at 25% 20%, #0a0a1a 0%, #000 60%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) body.solo {
    --blob-1: rgba(96, 165, 250, 0.4);
    --blob-2: rgba(59, 130, 246, 0.4);
    --blob-3: rgba(37, 99, 235, 0.32);
    --glass: rgba(28, 30, 36, 0.6);
    --glass-line: rgba(255, 255, 255, 0.1);
    background: radial-gradient(ellipse at 25% 20%, #152038 0%, #0d1117 60%);
  }
}
body.solo::before, body.solo::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
body.solo::before { width: 460px; height: 460px; top: -140px; inset-inline-start: -120px; background: var(--blob-1); }
body.solo::after { width: 400px; height: 400px; bottom: -160px; inset-inline-end: -110px; background: var(--blob-2); }

.solo-card {
  position: relative;
  z-index: 1;
  width: min(392px, 100%);
  padding: 32px 30px;
  border: 1px solid var(--glass-line);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 18px 50px rgba(22, 119, 255, 0.16);
  animation: pop 340ms ease both;
}
.solo-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; text-align: center; }
.solo-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(140deg, var(--primary), #36cfc9);
  color: #fff;
  box-shadow: 0 4px 14px -4px var(--primary);
}
.solo-mark svg { width: 24px; height: 24px; }
.solo-title { font-size: 19px; font-weight: 600; letter-spacing: 0.5px; }
.solo-sub { font-size: 13px; color: var(--text-2); }
.solo-form { display: flex; flex-direction: column; gap: 16px; }
.solo-form input { height: 38px; }
.solo-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-3); }
.solo-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--crit) 30%, transparent);
  border-radius: var(--r-sm);
  background: var(--crit-soft);
  color: var(--crit);
  font-size: 13px;
}
.solo-alert svg { width: 15px; height: 15px; }

.dl-card { text-align: center; }
.dl-card .ficon { width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px; }
.dl-card .ficon svg { width: 29px; height: 29px; }
.dl-name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.dl-size { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.dl-form { margin-top: 20px; }
.dl-alert { margin-top: 16px; margin-bottom: 0; }

/* =====================================================================
   responsive shell
   ===================================================================== */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sider {
    position: static;
    flex-direction: row;
    align-items: center;
    width: 100%;
    height: auto;
    border-inline-end: none;
    border-bottom: 1px solid var(--line-2);
  }
  .sider-brand { border-bottom: none; padding-inline-end: 8px; }
  .sider-nav { flex-direction: row; flex: 1; padding: 8px; }
  .sider-nav a { height: 34px; }
  .sider-foot { margin: 0; flex-direction: row; border-top: none; padding-inline-end: 12px; }
  .sider-foot .foot-line, .sider-foot .foot-user { display: none; }
  .sider-foot button { width: auto; }
  .content { padding: 12px; }
  .card-head, .card-pad, .summary, .strip { padding-inline: 14px; }
  .tbl-head { display: none; }
  .tbl-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name act" "meta act";
    gap: 4px 12px;
    padding: 12px 14px;
  }
  .cols-files > :nth-child(1), .cols-shares > :nth-child(1), .cols-import > :nth-child(1) { grid-area: name; }
  .cols-import > :nth-child(2) { grid-area: meta; text-align: start; padding-inline-start: 46px; }
  .cols-import > :nth-child(3) { display: none; }
  .cols-files > :nth-child(2) { grid-area: meta; text-align: start; padding-inline-start: 46px; }
  .cols-files > :nth-child(3), .cols-shares > :nth-child(3) { display: none; }
  .cols-shares > :nth-child(2) { grid-area: meta; }
  .cell-actions { grid-area: act; align-self: center; }
  .tbl.grid .tbl-row { grid-template-areas: none; }
  .tbl.grid .cols-files > :nth-child(2) { padding-inline-start: 0; }
  .tray { inset-inline: 12px; bottom: 12px; width: auto; }
}
