/* ============================================================
   数据大屏聚合系统 · 样式
   深色 / 浅色双主题，全部走 CSS 变量
   ============================================================ */

:root,
:root[data-theme='dark'] {
  --bg: #070b14;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #0d1b30 0%, #070b14 60%);
  --panel: #0f1626;
  --panel-2: #141d30;
  --panel-3: #1a2438;
  --border: #1e2a3f;
  --border-strong: #2c3c58;
  --text: #e6edf7;
  --text-2: #8a99b0;
  --text-3: #55647c;
  --accent: #38bdf8;
  --accent-ink: #04121f;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --mask: rgba(3, 7, 14, 0.72);
  --stage-bg: #04070d;
}

:root[data-theme='light'] {
  --bg: #f2f5fa;
  --bg-grad: radial-gradient(1200px 600px at 20% -10%, #e8f0fb 0%, #f2f5fa 60%);
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --panel-3: #eef2f8;
  --border: #e2e8f1;
  --border-strong: #c8d3e2;
  --text: #0f172a;
  --text-2: #55637a;
  --text-3: #8a96a8;
  --accent: #1677ff;
  --accent-ink: #ffffff;
  --ok: #12b76a;
  --warn: #f59e0b;
  --danger: #e5484d;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --mask: rgba(15, 23, 42, 0.42);
  --stage-bg: #0b1220;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  background-image: var(--bg-grad);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-clip: content-box; background-color: var(--text-3); }

/* ────────── 骨架布局 ────────── */

#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
}
.brand-mark svg { width: 16px; height: 16px; display: block; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }

.brand-text { min-width: 0; }
.brand-title {
  font-size: 14px; font-weight: 600; letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

/* 搜索 */
.search {
  display: flex; align-items: center; gap: 8px;
  width: 220px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2);
  transition: border-color 0.16s, width 0.18s;
}
.search:focus-within { border-color: var(--accent); width: 260px; }
.search svg { width: 14px; height: 14px; color: var(--text-3); flex: 0 0 auto; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 13px;
}
.search input::placeholder { color: var(--text-3); }
.search kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 4px; background: var(--panel-3);
}

/* 分段控制器 */
.segmented {
  display: flex; gap: 2px; padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.segmented a, .segmented button {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 6px;
  font-size: 12.5px; color: var(--text-2);
  border: 0; background: transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background 0.14s, color 0.14s;
}
.segmented a:hover, .segmented button:hover { color: var(--text); }
.segmented .on { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.segmented svg { width: 13px; height: 13px; }

/* 通用按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.btn:hover { border-color: var(--border-strong); background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 500;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-sm svg { width: 12px; height: 12px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  border-radius: 8px;
}
.btn-icon.btn-sm { width: 27px; height: 27px; border-radius: 6px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* 主内容 */
.page { flex: 1; min-height: 0; }
.page-inner {
  max-width: none;
  margin: 0 auto;
  padding: 22px 24px 60px;
}

/* 示例提示 */
.demo-banner {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--warn) 42%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  font-size: 12.5px;
  color: var(--warn);
}
.demo-banner svg { width: 15px; height: 15px; flex: 0 0 auto; }
.demo-banner .btn { margin-left: auto; }

/* ────────── 门户 ────────── */

.portal-head {
  display: block;
  margin-bottom: 12px;
}
.portal-title { font-size: 20px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.3; margin: 0; text-align: center; }
.portal-desc { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.portal-stats { margin-left: auto; display: flex; gap: 22px; }
.stat { text-align: right; }
.stat-num {
  font-size: 19px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat-label { font-size: 11px; color: var(--text-3); }

/* 分组筛选 */
.filters {
  display: flex; align-items: center; gap: 7px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 29px; padding: 0 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.14s;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill .cnt {
  font-size: 11px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.pill.on {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}
.pill.on .cnt { color: var(--accent); opacity: 0.7; }
.filters-note { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* 卡片网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

/* PC 窄窗口逐级降列；手机端（≤860px）由移动端规则接管 */
@media (max-width: 1500px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1180px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.card:hover {
  border-color: color-mix(in srgb, var(--c, var(--accent)) 55%, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card.is-off { opacity: 0.55; }

/* 封面 */
.cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background-color: var(--stage-bg);
  background-image:
    linear-gradient(color-mix(in srgb, var(--border) 70%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border) 70%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.cover-art {
  position: absolute; inset: 0;
  padding: 12px 13px 0;
  display: flex; align-items: flex-end; gap: 5px;
  opacity: 0.75;
}
.cover-art i {
  flex: 1;
  background: var(--c, var(--accent));
  border-radius: 3px 3px 0 0;
  opacity: 0.32;
}
.cover::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 45%, color-mix(in srgb, var(--stage-bg) 78%, transparent) 100%);
  pointer-events: none;
}
.cover-glyph {
  position: absolute;
  top: 12px; left: 13px;
  font-size: 13px; font-weight: 600;
  letter-spacing: 2px;
  color: var(--c, var(--accent));
  opacity: 0.85;
  text-transform: uppercase;
}
.cover-ratio {
  position: absolute;
  bottom: 9px; left: 13px;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: color-mix(in srgb, var(--text) 55%, transparent);
  z-index: 2;
}
.cover-preview {
  position: absolute; inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.22s;
}
.cover-preview.on { opacity: 1; }
.cover-preview iframe { border: 0; background: transparent; }
.cover-preview .fit-stage {
  width: 100%; height: 100%; position: relative; overflow: hidden;
}

.badge {
  position: absolute; top: 9px; right: 9px;
  display: inline-flex; align-items: center; gap: 4px;
  height: 19px; padding: 0 7px;
  border-radius: 5px;
  font-size: 10.5px;
  background: color-mix(in srgb, var(--stage-bg) 72%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 50%, transparent);
  color: var(--c, var(--accent));
  backdrop-filter: blur(4px);
  z-index: 2;
}

/* 卡片悬停操作层 */
.card-actions {
  position: absolute; inset: 0;
  z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: color-mix(in srgb, var(--stage-bg) 62%, transparent);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.18s;
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; }
.card-actions .btn {
  height: 30px;
  background: color-mix(in srgb, var(--text) 92%, transparent);
  border-color: transparent;
  color: var(--stage-bg);
  font-weight: 500;
}
.card-actions .btn:hover { background: var(--text); }
.card-actions .btn-ghost-act {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--text) 34%, transparent);
  color: #fff;
}
.card-actions .btn-ghost-act:hover {
  background: color-mix(in srgb, #fff 16%, transparent);
  border-color: color-mix(in srgb, #fff 60%, transparent);
}

.card-body { padding: 11px 13px 13px; }
.card-name {
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-desc {
  margin-top: 2px;
  font-size: 11.5px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-height: 17px;
}

/* 空态 */
.empty {
  padding: 70px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text-3);
}
.empty-icon {
  width: 46px; height: 46px;
  margin: 0 auto 14px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  display: grid; place-items: center;
  color: var(--text-3);
}
.empty h3 { font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.empty p { margin: 0 0 16px; font-size: 12.5px; }

/* ────────── 缩放舞台 ────────── */

.fit-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: var(--stage-bg);
}
.fit-layer { transform-origin: 0 0; }
/* 手势拦截层：iframe 会吞掉触摸/指针事件，捏合缩放与拖拽平移靠这层接收。
   是否拦截由 fit.js 依据触屏/溢出/交互模式动态控制（gesture-on）。 */
.fit-gesture-overlay {
  position: absolute; inset: 0; z-index: 5;
  pointer-events: none;
  touch-action: none;
  background: transparent;
}
.fit-stage.gesture-on .fit-gesture-overlay { pointer-events: auto; }
.fit-stage.is-draggable { cursor: grab; }
.fit-stage.is-panning { cursor: grabbing; }
.fit-stage.is-panning iframe { pointer-events: none; }

/* ────────── 聚焦态（单屏全屏） ────────── */

.focus {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
}
.focus-stage-wrap { flex: 1; min-height: 0; position: relative; }

.focus-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 12;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  transition: opacity 0.26s, transform 0.26s;
}
.focus.idle .focus-bar {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}
.focus-bar .btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  backdrop-filter: blur(8px);
}
.focus-bar .btn:hover { background: rgba(255, 255, 255, 0.2); }
.focus-bar .btn.on {
  background: rgba(255, 255, 255, 0.92);
  color: #0b1220;
  border-color: transparent;
}
.focus-title {
  display: flex; align-items: baseline; gap: 9px;
  margin-right: 4px;
  min-width: 0;
}
.focus-title b {
  font-size: 13.5px; font-weight: 500; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.focus-title span {
  font-size: 11.5px; color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}
.focus-bar-spacer { flex: 1; }
.focus-zoom {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.focus-hint {
  position: absolute;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 11;
  display: flex; gap: 14px;
  padding: 7px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.66);
  transition: opacity 0.3s;
  pointer-events: none;
}
.focus.idle .focus-hint { opacity: 0; }
.focus-hint kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.8);
}

.focus-shell {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.focus-shell .fit-stage { width: 100%; height: 100%; background: #000; }

/* 嵌入失败兜底 */
.embed-fallback {
  position: absolute; inset: 0;
  z-index: 8;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  background: rgba(6, 10, 18, 0.9);
  backdrop-filter: blur(6px);
  text-align: center;
  padding: 20px;
}
.embed-fallback h3 { font-size: 15px; color: #e6edf7; }
.embed-fallback p {
  margin: 0; font-size: 12.5px; color: rgba(255, 255, 255, 0.55);
  max-width: 420px; line-height: 1.7;
}
.embed-fallback .row { display: flex; gap: 8px; margin-top: 6px; }
.embed-fallback .btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.embed-fallback .btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}

/* ────────── 轮播墙 ────────── */

.wall-view {
  position: fixed; inset: 0;
  z-index: 90;
  background: #04070d;
  display: flex; flex-direction: column;
}
.wall-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.66);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  transition: opacity 0.26s;
  z-index: 3;
}
.wall-view.idle .wall-bar { opacity: 0; }
.wall-bar .btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.wall-bar .btn:hover { background: rgba(255, 255, 255, 0.18); }
.wall-bar .sep { width: 1px; height: 18px; background: rgba(255, 255, 255, 0.14); margin: 0 4px; }
.wall-progress {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  max-width: 220px;
}
.wall-progress span {
  display: block; height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.4s linear;
}
.wall-grid {
  flex: 1;
  display: grid;
  gap: 3px;
  padding: 3px;
  min-height: 0;
}
.wall-cell {
  position: relative;
  background: #000;
  overflow: hidden;
  border-radius: 3px;
  cursor: zoom-in;
}
.wall-cell .fit-stage { background: #000; }
.wall-cell-tag {
  position: absolute;
  top: 7px; left: 8px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.wall-cell:hover .wall-cell-tag { opacity: 1; }
.wall-cell-skip {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
  background: #080d18;
}

/* ────────── 后台管理 ────────── */

.admin-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-head h2 { font-size: 18px; font-weight: 600; margin-right: 4px; }
.admin-head .spacer { flex: 1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.tbl-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  white-space: nowrap;
  position: sticky; top: 0;
  z-index: 2;
}
.tbl tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl tbody tr.is-off { opacity: 0.5; }

.tbl .col-handle { width: 30px; cursor: grab; color: var(--text-3); }
.tbl .col-handle:active { cursor: grabbing; }
.tbl .col-cover { width: 74px; }
.tbl .col-actions { width: 168px; text-align: right; }

.thumb {
  width: 62px; height: 35px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--stage-bg);
  border: 1px solid var(--border);
  display: block;
  object-fit: cover;
}
.thumb-art {
  display: flex; align-items: flex-end; gap: 2px;
  padding: 5px 5px 0;
}
.thumb-art i { flex: 1; background: var(--c); opacity: 0.4; border-radius: 1px 1px 0 0; }

.name-cell { display: flex; flex-direction: column; gap: 1px; min-width: 130px; }
.name-cell b { font-weight: 500; }
.name-cell small { font-size: 11px; color: var(--text-3); }

.url-cell {
  max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-2);
}

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-2);
  white-space: nowrap;
}
.tag-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 42%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 42%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 42%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.tag.mute { color: var(--text-3); }

.row-actions { display: flex; gap: 5px; justify-content: flex-end; }

.switch {
  position: relative;
  width: 34px; height: 19px;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
  flex: 0 0 auto;
  padding: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform 0.16s, background 0.16s;
}
.switch.on { background: color-mix(in srgb, var(--accent) 70%, transparent); border-color: var(--accent); }
.switch.on::after { transform: translateX(15px); background: #fff; }

/* 表单 */
.form-grid { display: grid; gap: 13px; }
.form-row { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: start; }
.form-row > label {
  font-size: 12.5px; color: var(--text-2);
  text-align: right;
  padding-top: 7px;
  line-height: 1.4;
}
.form-row > label .req { color: var(--danger); }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.input, .select, .textarea {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.6; font-family: inherit; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input.mono, .textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.select { appearance: none; background-image: none; cursor: pointer; }
.input-err { border-color: var(--danger) !important; }
.field-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.field-err { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* 色彩选择 */
.swatches { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  outline: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.on { outline: 2px solid var(--text); outline-offset: 1px; }
.swatch-custom {
  width: 44px; height: 24px; padding: 0 4px;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel-2); cursor: pointer;
}

/* 模态 */
.modal-mask {
  position: fixed; inset: 0;
  z-index: 200;
  background: var(--mask);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadein 0.16s ease;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: slidein 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal.wide { max-width: 760px; }
@keyframes slidein { from { opacity: 0; transform: translateY(12px) scale(0.99) } to { opacity: 1; transform: none } }
.modal-head {
  display: flex; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 14.5px; font-weight: 600; }
.modal-head .close {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 0; background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid; place-items: center;
}
.modal-head .close:hover { background: var(--panel-3); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 0 0 14px 14px;
}
.modal-foot .spacer { flex: 1; }

/* 批量导入 */
.import-area {
  width: 100%;
  min-height: 170px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px dashed var(--border-strong);
  background: var(--panel-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text);
  outline: none;
  resize: vertical;
}
.import-area:focus { border-color: var(--accent); border-style: solid; }

/* Toast */
.toast-wrap {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--text);
  animation: toastin 0.2s ease;
  max-width: 380px;
}
.toast svg { width: 15px; height: 15px; flex: 0 0 auto; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger); }
.toast.info svg { color: var(--accent); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* 存储模式角标 */
.storage-flag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px;
  border-radius: 5px;
  font-size: 10.5px;
  border: 1px solid var(--border);
  color: var(--text-3);
  background: var(--panel-2);
  white-space: nowrap;
  flex: 0 0 auto;
}
.storage-flag.file { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.storage-flag.local { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

/* 未导出提示条 */
.dirty-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.dirty-bar .btn { margin-left: auto; }

/* ────────── 响应式 ────────── */

/* 焦点态与轮播墙占满视口，锁掉页面滚动 */
body[data-view='focus'],
body[data-view='wall'] { overflow: hidden; }

/* 聚焦态工具栏里的分段控制器（深色底上） */
.focus-bar .segmented button {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
  padding: 3px 9px;
}
.focus-bar .segmented button:hover { color: #fff; }
.focus-bar .segmented button.on {
  background: rgba(255, 255, 255, 0.92);
  color: #0b1220;
}

/* 表格拖拽排序落点 */
.tbl tbody tr.drop-target { box-shadow: inset 0 2px 0 var(--accent); }
.tbl tbody tr[draggable='true'] { cursor: default; }
.tbl tbody tr.dragging { opacity: 0.4; }

/* 示例提示条里的按钮 */
.demo-banner .btn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  border-color: color-mix(in srgb, var(--warn) 46%, transparent);
  color: var(--warn);
}
.demo-banner .btn:hover {
  background: color-mix(in srgb, var(--warn) 26%, transparent);
  border-color: var(--warn);
}

@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .search { width: 150px; }
  .search:focus-within { width: 180px; }
  .portal-stats { display: none; }
  .form-row { grid-template-columns: 1fr; gap: 5px; }
  .form-row > label { text-align: left; padding-top: 0; }
  .form-cols, .form-cols-3 { grid-template-columns: 1fr; }
  .focus-hint { display: none; }
  .brand-sub { display: none; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .page-inner { padding: 16px 12px 40px; }
  .search { display: none; }
  .segmented button span { display: none; }
}

/* ────────── 登录页 ────────── */

.login-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 75% 10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 65%),
    radial-gradient(700px 500px at 15% 90%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    var(--bg);
  background-color: var(--bg);
  overflow: auto;
  z-index: 200;
}

.login-deco i {
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 50%;
  opacity: 0.5;
  pointer-events: none;
}
.login-deco i:nth-child(1) { width: 420px; height: 420px; top: -140px; right: -120px; }
.login-deco i:nth-child(2) { width: 280px; height: 280px; bottom: -90px; left: -70px; }
.login-deco i:nth-child(3) { width: 140px; height: 140px; top: 22%; left: 12%; opacity: 0.3; }

.login-card {
  position: relative;
  width: min(400px, 100%);
  padding: 34px 32px 22px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.login-card.shake { animation: login-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes login-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed));
  color: var(--accent-ink);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}
.login-brand .login-logo svg { width: 28px; height: 28px; }
.login-brand img.login-logo { object-fit: cover; padding: 0; }
.login-brand h1 { margin: 14px 0 4px; font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: 0.5px; }
.login-brand p { margin: 0; font-size: 12.5px; color: var(--text-3); }

.login-field { display: block; margin-bottom: 15px; }
.login-field > span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
}
.login-field svg { width: 14px; height: 14px; }
.login-field .input { width: 100%; height: 42px; font-size: 14px; }

.login-error {
  min-height: 18px;
  margin: 2px 0 6px;
  font-size: 12.5px;
  color: var(--danger);
}

.login-submit {
  width: 100%;
  height: 44px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 6px;
  text-indent: 6px;
  border-radius: 10px;
}

.login-hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--warn);
  text-align: center;
}

.login-foot {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.login-foot a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-3);
}
.login-foot a:hover { color: var(--accent); }
.login-foot svg { width: 13px; height: 13px; }
