/* 短视频智能体中控平台 · 扁平化 H5 设计系统 */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e6e8ec;
  --line-2: #f0f1f4;
  --ink: #14161a;
  --ink-2: #3d4249;
  --sub: #7a8089;
  --accent: #fe2c55;
  --accent-ink: #ffffff;
  --accent-soft: #fff1f4;
  --dark: #161823;
  --green: #12a150;
  --amber: #ff7a00;
  --blue: #2e6bff;
  --sbw: 236px;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 14px; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------------- 登录 ---------------- */
.login-mask {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.login-mask.hide { display: none; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px 28px;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center; letter-spacing: -1px;
}
.logo-mark.dark { background: var(--dark); }
.login-title { font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.login-sub { color: var(--sub); font-size: 12.5px; margin: 8px 0 22px; line-height: 1.7; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--sub); margin-bottom: 7px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; outline: none; transition: border-color .18s, background .18s;
}
textarea.input { height: auto; padding: 10px 13px; line-height: 1.7; resize: vertical; }
.input:focus { border-color: var(--accent); background: #fff; }
.btn {
  height: 42px; padding: 0 18px; border-radius: 9px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: opacity .16s, background .16s, border-color .16s; white-space: nowrap;
}
.btn:hover { opacity: .86; }
.btn:active { transform: scale(.995); }
.btn-ghost { border: 1px solid var(--line); background: #fff; color: var(--ink-2); }
.btn-ghost:hover { border-color: #d3d6dc; opacity: 1; }
.btn-dark { background: var(--dark); color: #fff; }
.btn-danger { background: var(--accent); color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-err { color: var(--accent); font-size: 12.5px; min-height: 18px; margin-top: 8px; }

/* ---------------- 骨架 ---------------- */
.app { display: flex; min-height: 100vh; }

/* 侧边栏 + 平滑折叠 + 可调宽度 */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sbw); z-index: 30;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .3s cubic-bezier(.4, 0, .2, 1), transform .3s cubic-bezier(.4, 0, .2, 1);
}
.sidebar.collapsed { width: 66px; }
.sidebar-head {
  display: flex; align-items: center; gap: 9px; padding: 0 16px; height: 58px;
  flex: 0 0 auto; border-bottom: 1px solid var(--line-2); overflow: hidden;
}
.sidebar-head .logo-mark { flex: 0 0 auto; }
.sidebar-title { min-width: 0; }
.sidebar-title strong { display: block; font-size: 14px; letter-spacing: .2px; white-space: nowrap; }
.sidebar-title span { display: block; font-size: 11px; color: var(--sub); margin-top: 2px; white-space: nowrap; }
.sidebar.collapsed .sidebar-title { opacity: 0; pointer-events: none; }

.nav { position: relative; padding: 10px 8px 16px; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #e2e4e8; border-radius: 4px; }

/* 滑动式选中指示器 */
.nav-ind {
  position: absolute; left: 8px; width: calc(100% - 16px); height: 38px; top: 0;
  background: var(--accent); border-radius: 9px;
  transition: transform .32s cubic-bezier(.34, 1.2, .5, 1), height .32s cubic-bezier(.34, 1.2, .5, 1), background .2s;
  pointer-events: none; z-index: 0;
}
.nav-ind.soft { background: var(--accent-soft); }
.nav-item {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px; border-radius: 9px; color: var(--ink-2);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: color .18s, background .18s;
}
.nav-item:hover { background: #f7f8fa; }
.nav-item.active { color: #fff; font-weight: 600; }
.nav-item.active:hover { background: transparent; }
.nav-item .ico { flex: 0 0 auto; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; opacity: .72; }
.nav-item.active .ico { opacity: 1; }
.nav-item .label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.nav-item .chev { width: 14px; transition: transform .28s cubic-bezier(.4, 0, .2, 1); opacity: .55; }
.nav-item.open .chev { transform: rotate(90deg); }
.sidebar.collapsed .nav-item .label,
.sidebar.collapsed .nav-item .chev { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }

/* 手风琴子菜单 */
.sub-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.4, 0, .2, 1); }
.sub-wrap.open { grid-template-rows: 1fr; }
.sub-inner { overflow: hidden; min-height: 0; }
.submenu { padding: 3px 0 4px; }
.sub-item {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 40px;
  border-radius: 8px; color: var(--sub); font-size: 12.5px; cursor: pointer;
  transition: color .16s, background .16s;
}
.sub-item:hover { background: #f7f8fa; color: var(--ink); }
.sub-item .dot { width: 4px; height: 4px; border-radius: 2px; background: #c5c9d0; }
.sub-item.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.sub-item.active .dot { background: var(--accent); }
.sidebar.collapsed .sub-wrap { display: none; }
.drag-hint { font-size: 10.5px; color: #b6bac2; padding: 10px 12px 4px; letter-spacing: .4px; }
.sidebar.collapsed .drag-hint { display: none; }

.sidebar-foot {
  flex: 0 0 auto; border-top: 1px solid var(--line-2); padding: 12px;
  display: flex; align-items: center; gap: 9px; overflow: hidden;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--dark); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  flex: 0 0 auto;
}
.sidebar-foot .who { min-width: 0; }
.sidebar-foot .who b { display: block; font-size: 12.5px; }
.sidebar-foot .who span { font-size: 11px; color: var(--sub); }
.sidebar.collapsed .who { display: none; }
.sidebar.collapsed .sidebar-foot { justify-content: center; padding: 12px 0; }

/* 可调整宽度抓手 */
.resizer {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 40; background: transparent;
}
.resizer::after {
  content: ""; position: absolute; top: 0; right: 3px; width: 1px; height: 100%;
  background: transparent; transition: background .2s;
}
.resizer:hover::after, .resizer.dragging::after { background: var(--accent); }
.sidebar.collapsed .resizer { display: none; }

/* ---------------- 主区 ---------------- */
.main { flex: 1 1 auto; min-width: 0; margin-left: var(--sbw); transition: margin-left .3s cubic-bezier(.4, 0, .2, 1); }
body.collapsed .main { margin-left: 66px; }

.topbar {
  position: sticky; top: 0; z-index: 25; height: 58px;
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: rgba(244, 245, 247, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: var(--ink-2); border: 1px solid var(--line); background: #fff;
  transition: border-color .18s, background .18s;
}
.icon-btn:hover { border-color: #d3d6dc; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--sub); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1 1 auto; }
.pill {
  height: 28px; padding: 0 11px; border-radius: 14px; border: 1px solid var(--line);
  background: #fff; font-size: 12px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.dot-live { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* 悬浮式二级导航 */
.float-nav {
  position: sticky; top: 70px; z-index: 22; margin: 14px 0 -4px;
  display: flex; align-items: center; gap: 2px; max-width: max-content;
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 12px; padding: 4px;
  transition: opacity .25s, transform .25s;
}
.float-nav.hidden { opacity: 0; pointer-events: none; transform: translateY(-8px); }
.tab {
  position: relative; height: 32px; padding: 0 14px; border-radius: 8px; font-size: 12.5px;
  color: var(--sub); display: flex; align-items: center; white-space: nowrap; z-index: 1;
  transition: color .2s;
}
.tab.active { color: var(--ink); font-weight: 600; }
.tab-ind {
  position: absolute; top: 4px; height: 32px; background: var(--accent-soft); border-radius: 8px;
  transition: transform .3s cubic-bezier(.34, 1.2, .5, 1), width .3s cubic-bezier(.34, 1.2, .5, 1);
  z-index: 0; top: 6px; height: 32px;
}

.page { padding: 18px 18px 40px; max-width: 1440px; }

/* ---------------- 通用组件 ---------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line-2); min-height: 52px;
}
.panel-head h3 { margin: 0; font-size: 13.5px; font-weight: 700; letter-spacing: .2px; }
.panel-head .sub { color: var(--sub); font-size: 11.5px; }
.panel-head .spacer { flex: 1 1 auto; }
.panel-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }

.kpi { padding: 15px 16px 13px; }
.kpi .k { font-size: 11.5px; color: var(--sub); display: flex; align-items: center; justify-content: space-between; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.4px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 12px; font-weight: 500; color: var(--sub); margin-left: 3px; }
.kpi .t { font-size: 11.5px; margin-top: 6px; color: var(--sub); }
.tag-up { color: var(--accent); }
.mono { font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px;
  font-size: 11.5px; font-weight: 500;
}
.chip-gray { background: #f2f3f6; color: var(--sub); }
.chip-green { background: #eaf7ef; color: var(--green); }
.chip-red { background: var(--accent-soft); color: var(--accent); }
.chip-amber { background: #fff4e6; color: var(--amber); }
.chip-blue { background: #eef2ff; color: var(--blue); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--sub);
  padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); font-size: 13px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.t-title { font-weight: 600; display: block; margin-bottom: 2px; }
.t-sub { font-size: 11.5px; color: var(--sub); }

.empty { padding: 40px 16px; text-align: center; color: var(--sub); font-size: 12.5px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { height: 32px; padding: 0 13px; font-size: 12.5px; color: var(--sub); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--dark); color: #fff; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--sub); line-height: 1.6; margin-top: 6px; }

/* 结果区 */
.score-wrap { display: flex; align-items: center; gap: 16px; }
.score-ring {
  width: 92px; height: 92px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.score-ring::after {
  content: ""; position: absolute; inset: 9px; background: #fff; border-radius: 50%;
}
.score-ring .num { position: relative; z-index: 1; font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-ring .num i { font-size: 11px; font-style: normal; color: var(--sub); }
.score-bars { flex: 1 1 auto; display: grid; gap: 7px; }
.sbar { display: grid; grid-template-columns: 52px 1fr 34px; gap: 8px; align-items: center; font-size: 11.5px; color: var(--sub); }
.bar-bg { height: 5px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s cubic-bezier(.4,0,.2,1); }

.beat {
  border: 1px solid var(--line); border-radius: 9px; padding: 12px;
  display: grid; gap: 6px; margin-bottom: 9px; background: #fff;
}
.beat-top { display: flex; align-items: center; gap: 8px; }
.beat-time { font-size: 11.5px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.beat-name { font-size: 12.5px; font-weight: 600; }
.beat p { margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--ink-2); }
.beat p b { color: var(--sub); font-weight: 500; }
.voice-box {
  background: #fbfbfd; border: 1px dashed #dcdfe5; border-radius: 9px; padding: 13px;
  font-size: 13.5px; line-height: 1.8; color: var(--ink);
}
.copy-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.risk-item { display: flex; gap: 8px; font-size: 12px; color: #8a5a00; background: #fffaf0; border: 1px solid #ffe8c4; border-radius: 8px; padding: 9px 11px; margin-bottom: 7px; line-height: 1.6; }
.risk-ok { color: var(--green); background: #f2fbf5; border-color: #cfecda; }

/* 生成动效 */
.gen-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(20, 22, 26, .55);
  backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gen-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 26px 26px 22px; }
.gen-card h4 { margin: 0 0 4px; font-size: 16px; }
.gen-card .gs { color: var(--sub); font-size: 12px; margin-bottom: 18px; }
.step-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; color: #b7bbc3; transition: color .3s; }
.step-row .sd { width: 16px; height: 16px; border-radius: 50%; border: 1px solid #dfe2e8; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.step-row.on { color: var(--ink); }
.step-row.on .sd { border-color: var(--accent); background: var(--accent); }
.step-row.done { color: var(--ink-2); }
.step-row.done .sd { border-color: var(--green); background: var(--green); }
.step-row .sx { margin-left: auto; font-size: 11px; color: var(--green); }

/* 列表 / 卡片 */
.card-list { display: grid; gap: 12px; }
.topic-card { padding: 15px 16px; display: grid; gap: 9px; }
.topic-top { display: flex; align-items: flex-start; gap: 10px; }
.topic-title { font-size: 13.5px; font-weight: 600; line-height: 1.55; flex: 1 1 auto; }
.topic-meta { display: flex; align-items: center; gap: 14px; font-size: 11.5px; color: var(--sub); flex-wrap: wrap; }
.heat-bar { width: 84px; height: 5px; background: #eef0f3; border-radius: 3px; overflow: hidden; }
.heat-fill { height: 100%; background: linear-gradient(90deg, #ff7a00, #fe2c55); }

.agent-card { padding: 15px; display: flex; gap: 11px; align-items: flex-start; }
.agent-ava { width: 36px; height: 36px; border-radius: 9px; flex: 0 0 auto; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.agent-card b { font-size: 13px; display: block; }
.agent-card span { font-size: 11.5px; color: var(--sub); line-height: 1.6; display: block; margin-top: 3px; }
.agent-state { margin-left: auto; }

.badge-line { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-pill { height: 24px; padding: 0 9px; border-radius: 12px; background: #f3f4f7; color: var(--ink-2); font-size: 11.5px; display: inline-flex; align-items: center; }

/* 响应式 */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); width: 260px !important; box-shadow: none; }
  .sidebar.drawer-open { transform: translateX(0); }
  .resizer { display: none; }
  .main { margin-left: 0 !important; }
  .topbar { padding: 0 12px; height: 54px; }
  .page { padding: 12px 12px 40px; }
  .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .float-nav { top: 62px; max-width: 100%; overflow-x: auto; }
  .float-nav::-webkit-scrollbar { display: none; }
  .table-wrap { overflow-x: auto; }
  .score-wrap { gap: 12px; }
  .score-ring { width: 78px; height: 78px; }
  .kpi .v { font-size: 23px; }
  .panel-head { flex-wrap: wrap; }
}
.drawer-mask {
  position: fixed; inset: 0; background: rgba(20,22,26,.4); z-index: 28; opacity: 0;
  pointer-events: none; transition: opacity .28s;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }

@media (max-width: 640px) {
  #statusPill { display: none; }
  .topbar { gap: 8px; }
  .crumb { font-size: 12px; max-width: 52vw; display: block; line-height: 54px; }
  .crumb span, .crumb b { display: inline; }
  #datePill { padding: 0 9px; font-size: 11.5px; }
  .float-nav { margin: 10px 0 0; }
  .page { padding-top: 10px; }
  .panel-body { padding: 13px; }
  .gen-card { padding: 20px 18px 16px; }
}

/* 拖拽排序视觉 */
.nav-item.dragging { opacity: .45; }
.drop-line {
  position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent);
  border-radius: 2px; pointer-events: none; z-index: 3; display: none;
}
.drop-line.show { display: block; }
.drag-ghost { opacity: .5; }
.grab { cursor: grab; }
.grab:active { cursor: grabbing; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 12.5px; z-index: 130; opacity: 0; transition: opacity .22s, transform .22s;
  pointer-events: none; max-width: 86vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--accent); }
