/*
 * PeakPix 管理后台 · 素材与对话（只读观察页，2026-10 改版）
 * 观察服务只提供 index.html / app.js / style.css / workspace.css 四个文件，
 * 因此设计变量与外壳样式在此独立复制一份，不依赖主后台的 /layout.css。
 * 符合 CSP：无内联样式、无外部字体；只改外观，不改 app.js 行为。
 */

:root {
  color-scheme: light;
  --pp-bg: #f5f6f8;
  --pp-surface: #ffffff;
  --pp-surface-2: #f9fafb;
  --pp-surface-3: #f2f4f7;
  --pp-border: #e4e7ec;
  --pp-border-strong: #d0d5dd;
  --pp-text: #101828;
  --pp-text-2: #3f4756;
  --pp-text-3: #5b6476;
  --pp-muted: #98a2b3;
  --pp-primary: #2e4fd8;
  --pp-primary-hover: #2440b8;
  --pp-primary-ink: #1e3ab8;
  --pp-primary-soft: #eef2ff;
  --pp-primary-line: #c7d2fe;
  --pp-primary-wash: #f5f7ff;
  --pp-orange: #f79009;
  --pp-orange-soft: #fff4e5;
  --pp-orange-ink: #a54a06;
  --pp-orange-line: #f6d9b0;
  --pp-green: #12a15a;
  --pp-green-soft: #e8f7ef;
  --pp-green-ink: #0b6e3e;
  --pp-green-line: #b7e4cb;
  --pp-red-soft: #fdeeec;
  --pp-red-ink: #b42318;
  --pp-red-line: #fecdca;
  --pp-radius-lg: 14px;
  --pp-radius: 12px;
  --pp-radius-sm: 8px;
  --pp-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --pp-shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
  --pp-shadow-lg: 0 24px 56px rgba(16, 24, 40, .20);
  --pp-font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pp-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --pp-ease: cubic-bezier(.2, .8, .2, 1);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--pp-bg); color: var(--pp-text); font: 14px/1.6 var(--pp-font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 34px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
h3 { font-size: 14px; line-height: 22px; font-weight: 600; }
a { color: var(--pp-primary); text-decoration: none; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--pp-primary); outline-offset: 2px; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 按钮 ---------- */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--pp-primary); border-radius: var(--pp-radius-sm);
  background: var(--pp-primary); color: #fff;
  font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
button:hover:not(:disabled) { background: var(--pp-primary-hover); border-color: var(--pp-primary-hover); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { border-color: var(--pp-border); background: var(--pp-surface-3); color: var(--pp-muted); cursor: not-allowed; }
.secondary { border-color: var(--pp-border-strong); background: var(--pp-surface); color: var(--pp-text); font-weight: 500; }
.secondary:hover:not(:disabled) { border-color: #b7bfcc; background: var(--pp-surface-2); }
.text { min-height: 32px; padding: 0 8px; border: 0; background: transparent; color: var(--pp-primary); font-weight: 500; }
.text:hover:not(:disabled) { background: var(--pp-primary-wash); color: var(--pp-primary-ink); }

/* ---------- 外壳 ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; background: var(--pp-surface); border-right: 1px solid var(--pp-border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; color: var(--pp-text); font-size: 16px; font-weight: 700; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--pp-text-3); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--pp-primary); color: #fff; font-size: 16px; font-weight: 700; flex: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { padding: 12px 10px 6px; font-size: 12px; font-weight: 600; color: var(--pp-text-3); letter-spacing: .04em; }
.nav-group:first-child { padding-top: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: var(--pp-radius-sm); color: var(--pp-text-2); font-weight: 500; transition: background .15s, color .15s; }
.nav-link .ico { color: var(--pp-text-3); }
.nav-link:hover { background: var(--pp-surface-2); color: var(--pp-text); }
.nav-link.active { background: var(--pp-primary-soft); color: var(--pp-primary-ink); font-weight: 600; }
.nav-link.active .ico { color: var(--pp-primary); }
.side-note { margin-top: auto; display: flex; gap: 10px; padding: 12px; border: 1px solid var(--pp-green-line); border-radius: var(--pp-radius); background: var(--pp-green-soft); color: var(--pp-green-ink); font-size: 12px; line-height: 1.6; }
.side-note .ico { margin-top: 1px; }

.page { min-width: 0; display: flex; flex-direction: column; }
.bar { position: sticky; top: 0; z-index: 20; min-height: 64px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 12px clamp(16px, 2.5vw, 32px); background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--pp-border); backdrop-filter: saturate(1.4) blur(8px); }
.crumb { display: flex; align-items: center; gap: 8px; color: var(--pp-text-3); font-size: 13px; }
.crumb strong { color: var(--pp-text); font-weight: 600; }
.readonly-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 12px; border-radius: 15px; background: var(--pp-green-soft); color: var(--pp-green-ink); font-size: 12px; font-weight: 600; }
.readonly-pill .ico { width: 15px; height: 15px; }

main { width: 100%; max-width: 1480px; margin: 0 auto; padding: 28px clamp(16px, 2.5vw, 32px) 48px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- 标题 ---------- */
.heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; animation: pp-rise .45s var(--pp-ease) both; }
.heading > div:first-child { display: flex; flex-direction: column; gap: 6px; }
.heading .eyebrow { display: none; }
.heading p { color: var(--pp-text-3); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .1em; color: var(--pp-text-3); }
.live { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 12px; border-radius: 15px; background: var(--pp-surface); border: 1px solid var(--pp-border); color: var(--pp-text-2); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.live i { width: 8px; height: 8px; border-radius: 4px; background: var(--pp-green); animation: pp-pulse 2s ease-out infinite; }

/* ---------- 筛选 ---------- */
#filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px; background: var(--pp-surface); border: 1px solid var(--pp-border); border-radius: var(--pp-radius-lg); box-shadow: var(--pp-shadow); animation: pp-rise .45s var(--pp-ease) .05s both; }
#filters label { display: grid; gap: 6px; font-size: 12px; font-weight: 500; color: var(--pp-text-3); }
#filters label:first-child { flex: 1 1 280px; }
#filters label:nth-child(2) { flex: 0 1 200px; }
input, select { width: 100%; min-width: 0; min-height: 40px; padding: 0 12px; border: 1px solid var(--pp-border-strong); border-radius: var(--pp-radius-sm); background: var(--pp-surface); color: var(--pp-text); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { outline: none; border-color: var(--pp-primary); box-shadow: 0 0 0 3px rgba(46, 79, 216, .15); }
select { padding-right: 28px; }
#notice { min-height: 0; font-size: 13px; color: var(--pp-red-ink); }
#notice:not(:empty) { padding: 10px 14px; border: 1px solid var(--pp-red-line); border-radius: var(--pp-radius-sm); background: var(--pp-red-soft); }

/* ---------- 双栏 ---------- */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.layout > aside, .task-panel { min-width: 0; padding: 18px; background: var(--pp-surface); border: 1px solid var(--pp-border); border-radius: var(--pp-radius-lg); box-shadow: var(--pp-shadow); animation: pp-rise .45s var(--pp-ease) .1s both; }
.layout > aside { position: sticky; top: 80px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title > span { font-size: 12px; color: var(--pp-text-3); }
.hint { font-size: 12px; line-height: 1.6; color: var(--pp-text-3); }

/* 用户列表（app.js 每 15 秒整体重绘列表，因此列表项不做入场动画，避免闪动） */
#users { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.user { flex: none; display: block; width: 100%; min-height: 0; padding: 10px 12px 10px 14px; position: relative; text-align: left; white-space: normal; border: 1px solid transparent; border-radius: var(--pp-radius-sm); background: var(--pp-surface-2); color: var(--pp-text); font-weight: 400; }
.user:hover:not(:disabled) { background: var(--pp-surface-3); border-color: var(--pp-border); }
.user.active, .user.active:hover:not(:disabled) { border-color: var(--pp-primary-line); background: var(--pp-primary-soft); }
.user.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--pp-primary); }
.user strong { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.user small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--pp-text-3); }

/* 任务卡片 */
#tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.task { position: relative; min-width: 0; padding: 16px 18px 16px 20px; border: 1px solid var(--pp-border); border-radius: var(--pp-radius); background: var(--pp-surface); overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.task::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--pp-border-strong); }
.task:has(.badge.running)::before { background: var(--pp-primary); }
.task:has(.badge.queued)::before { background: var(--pp-muted); }
.task:has(.badge.review)::before { background: var(--pp-orange); }
.task:has(.badge.completed)::before { background: var(--pp-green); }
.task:has(.badge.failed)::before { background: var(--pp-red-ink); }
.task:hover { border-color: var(--pp-primary-line); box-shadow: var(--pp-shadow-md); transform: translateY(-1px); }
.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-top > div { min-width: 0; }
.task h3 { margin: 0 0 2px; font-size: 16px; line-height: 24px; overflow-wrap: anywhere; }
.task p { margin: 10px 0 4px; font-size: 13px; line-height: 1.6; color: var(--pp-text-2); }
.task small { display: block; font-size: 12px; color: var(--pp-text-3); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.task-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--pp-border); }

/* 状态徽标 */
.badge { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 24px; padding: 0 10px; border-radius: 12px; background: var(--pp-surface-3); color: var(--pp-text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.badge.running { background: var(--pp-primary-soft); color: var(--pp-primary-ink); }
.badge.running::before { animation: pp-blink 1.2s ease-in-out infinite; }
.badge.review { background: var(--pp-orange-soft); color: var(--pp-orange-ink); }
.badge.completed { background: var(--pp-green-soft); color: var(--pp-green-ink); }
.badge.failed { background: var(--pp-red-soft); color: var(--pp-red-ink); }

progress { width: 100%; height: 6px; accent-color: var(--pp-primary); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; font-size: 13px; color: var(--pp-text-3); font-variant-numeric: tabular-nums; }
.empty { grid-column: 1 / -1; padding: 40px 20px; border: 1px dashed var(--pp-border-strong); border-radius: var(--pp-radius); background: var(--pp-surface-2); color: var(--pp-text-3); text-align: center; font-size: 14px; }

/* ---------- 动画 ---------- */
@keyframes pp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pp-pulse { 0% { box-shadow: 0 0 0 0 rgba(18, 161, 90, .45); } 70% { box-shadow: 0 0 0 7px rgba(18, 161, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 161, 90, 0); } }
@keyframes pp-blink { 50% { opacity: .3; } }
@keyframes pp-dialog-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes pp-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 响应式（无脚本：窄屏时导航改为横向滚动条） ---------- */
@media (max-width: 1080px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--pp-border); overflow: visible; }
  .brand small, .nav-group, .side-note { display: none; }
  .side-nav { flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-link { flex: none; min-height: 40px; white-space: nowrap; }
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .brand > span:last-child { display: none; }
  .bar { min-height: 52px; }
  .readonly-pill { font-size: 11px; }
  main { padding: 20px 16px 32px; }
  h1 { font-size: 22px; line-height: 30px; }
  #filters { padding: 14px; }
  #filters label:first-child, #filters label:nth-child(2) { flex-basis: 100%; }
  #filters button { flex: 1; }
  .layout { grid-template-columns: 1fr; }
  .layout > aside { position: static; max-height: 300px; overflow: auto; }
  #tasks { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
