/* 习得/REAP 后台 —— 复用 demo 暖纸 token，布局更密、更工具化 */
@import url("/demo/assets/tokens.css");

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* 布局：左侧栏 + 主区 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: none;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-serif); font-weight: 700; font-size: 19px; margin-bottom: 24px; padding: 0 6px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(145deg, var(--brand), var(--brand-strong)); color: var(--brand-foreground); display: grid; place-items: center; font-weight: 700; }
.brand .en { font-size: 11px; color: var(--muted-foreground); font-weight: 500; letter-spacing: .08em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 10px 12px; border-radius: var(--radius-md); font-size: 14px; color: var(--muted-foreground); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--secondary); color: var(--foreground); }
.nav a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.sidebar .publish-zone { position: absolute; bottom: 20px; left: 14px; right: 14px; }
.user-zone { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.user-name { font-size: 12px; color: var(--muted-foreground); margin-bottom: 6px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-actions { display: flex; gap: 6px; }
.user-actions .btn { flex: 1; }

.main { flex: 1; min-width: 0; padding: 28px 32px; max-width: 1100px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-serif); font-size: 24px; font-weight: 700; }
.page-head .spacer { flex: 1; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; font-size: 14px; font-weight: 500; border: 1px solid transparent; border-radius: var(--radius-md); transition: filter .15s, background .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-brand { background: linear-gradient(145deg, var(--brand), var(--brand-strong)); color: var(--brand-foreground); box-shadow: 0 2px 8px oklch(0.5 0.18 32 / .28); }
.btn-brand:hover { filter: brightness(1.06); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--secondary); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--secondary); color: var(--foreground); }
.btn-danger { background: transparent; border-color: var(--border); color: var(--destructive); }
.btn-danger:hover { background: oklch(from var(--destructive) l c h / .1); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }

/* 卡片/表格 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); font-family: var(--font-serif); font-size: 16px; font-weight: 700; background: var(--secondary); }
.card > .field, .card > .grid-2, .card > div:not(.card-head) { padding: 0 20px; }
.card > .field:last-child, .card > div:last-child:not(.card-head) { padding-bottom: 20px; }
.card > div:first-child:not(.card-head) { padding-top: 20px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted-foreground); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--secondary); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--secondary); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted-foreground); margin-top: 4px; }
.input, .textarea, .select { width: 100%; padding: 9px 12px; border: 1px solid var(--input); border-radius: var(--radius-md); background: var(--background); color: var(--foreground); font-size: 14px; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--ring); }
.textarea { resize: vertical; line-height: 1.7; min-height: 90px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; font-size: 11px; font-weight: 600; border-radius: 999px; background: var(--secondary); color: var(--secondary-foreground); }
.badge-pub { background: oklch(0.9 0.08 150); color: oklch(0.35 0.1 150); }
.badge-draft { background: var(--secondary); color: var(--muted-foreground); }
.badge-brand { background: var(--brand-soft); color: var(--brand-strong); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: oklch(0 0 0 / .4); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); font-family: var(--font-serif); font-size: 18px; font-weight: 700; display: flex; align-items: center; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 杂项 */
.muted { color: var(--muted-foreground); }
.empty { text-align: center; color: var(--muted-foreground); padding: 60px 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: oklch(0.28 0.012 50); color: #fff; padding: 12px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 200; font-size: 14px; }
.toast.err { background: var(--destructive); }
.drag-handle { cursor: grab; color: var(--muted-foreground); user-select: none; }
.report { font-size: 13px; line-height: 1.8; }
.report .err-line { color: var(--destructive); }
.report .warn-line { color: oklch(0.55 0.12 75); }
.cover-thumb { width: 40px; height: 53px; border-radius: 4px; object-fit: cover; box-shadow: var(--shadow-sm); background: var(--secondary); }

/* 登录页 */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--background); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 32px 28px; }
.login-brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-serif); font-weight: 700; font-size: 19px; margin-bottom: 24px; justify-content: center; }
.login-brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(145deg, var(--brand), var(--brand-strong)); color: var(--brand-foreground); display: grid; place-items: center; font-weight: 700; }
.login-brand .en { font-size: 11px; color: var(--muted-foreground); font-weight: 500; letter-spacing: .08em; }
.login-title { font-family: var(--font-serif); font-size: 22px; font-weight: 700; margin-bottom: 8px; text-align: center; }
.login-hint { font-size: 13px; color: var(--muted-foreground); margin-bottom: 20px; text-align: center; }
.login-btn { width: 100%; margin-top: 6px; height: 42px; }
.login-err { margin-top: 14px; padding: 10px 12px; background: oklch(from var(--destructive) l c h / .1); color: var(--destructive); border-radius: var(--radius-md); font-size: 13px; text-align: center; }

/* ============================================================
   新增：导航分组 / 抽屉 / 主题切换
   ============================================================ */
.nav-group {
  font-size: 11px; font-weight: 600; letter-spacing: .12em;
  color: var(--muted-foreground); padding: 14px 12px 4px; text-transform: uppercase;
}
.nav-group:first-child { padding-top: 0; }
.btn-block { width: 100%; }

/* 移动端抽屉按钮（窄屏才显示） */
.drawer-btn {
  display: none; position: absolute; top: 18px; left: 10px;
  width: 36px; height: 36px; border: none; background: transparent;
  font-size: 20px; color: var(--foreground); border-radius: var(--radius-md);
}
.drawer-btn:hover { background: var(--secondary); }
.drawer-mask {
  position: fixed; inset: 0; background: oklch(0 0 0 / .4); z-index: 50;
}

/* ============================================================
   新增：凭证配置状态徽章
   ============================================================ */
.cfg-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  font-size: 10px; font-weight: 600; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.cfg-on { background: oklch(0.9 0.08 150); color: oklch(0.35 0.1 150); }
.cfg-off { background: var(--secondary); color: var(--muted-foreground); }
.dark .cfg-on { background: oklch(0.32 0.08 150); color: oklch(0.82 0.1 150); }

/* 折叠的「规划中」项 */
.planned-fold { padding: 8px 0; }
.planned-fold > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; padding: 6px 0;
  color: var(--muted-foreground); list-style: none;
}
.planned-fold > summary::-webkit-details-marker { display: none; }
.planned-fold > summary::before { content: '▸ '; color: var(--muted-foreground); }
.planned-fold[open] > summary::before { content: '▾ '; }
.tag-planned {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: oklch(0.9 0.06 75); color: oklch(0.4 0.1 75); margin-left: 8px;
}
.dark .tag-planned { background: oklch(0.34 0.05 75); color: oklch(0.8 0.09 75); }

/* ============================================================
   新增：文稿双栏编辑 + 预览
   ============================================================ */
.transcript-stats { font-size: 12px; margin-bottom: 10px; }
.transcript-stats .auto-saved { margin-left: 8px; opacity: .7; }
.transcript-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tcol-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.transcript-ta { min-height: 320px; }
.preview-box {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px; min-height: 320px; max-height: 50vh; overflow: auto;
  background: var(--secondary);
}
.preview-para { font-size: 14px; line-height: 1.75; margin-bottom: 10px; padding-left: 24px; position: relative; }
.preview-i {
  position: absolute; left: 0; top: 2px; font-size: 11px; font-weight: 600;
  color: var(--brand-strong); background: var(--brand-soft); border-radius: 4px;
  padding: 0 5px; min-width: 18px; text-align: center;
}
.preview-empty { text-align: center; padding: 40px 0; }

/* ============================================================
   新增：拖拽排序视觉反馈
   ============================================================ */
.table tr.dragging td { opacity: .45; background: var(--brand-soft) !important; }
.table tr.drag-over td { box-shadow: inset 0 2px 0 0 var(--brand); }
.table tr[draggable]:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ring); }

/* ============================================================
   新增：确认弹窗 + toast 关闭
   ============================================================ */
.confirm-msg { font-size: 14px; line-height: 1.7; color: var(--foreground); }
.toast { display: flex; align-items: center; gap: 12px; cursor: default; max-width: 90vw; }
.toast.err { cursor: pointer; }
.toast-close { font-size: 18px; line-height: 1; opacity: .8; }

/* ============================================================
   新增：响应式
   ============================================================ */
@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .layout.drawer .sidebar { transform: translateX(0); }
  .drawer-btn { display: inline-flex; align-items: center; justify-content: center; }
  .main { padding: 56px 16px 24px; }
  .page-head { padding-left: 44px; }
  .grid-2 { grid-template-columns: 1fr; }
  .transcript-split { grid-template-columns: 1fr; }
  .transcript-ta { min-height: 220px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 600px; }
  .modal { width: 100%; max-width: 92vw; max-height: 90vh; }
}
/* 暗色主题下的微调（token 已覆盖大部分，此处补个别） */
.dark .card-head { background: var(--muted); }
.dark .preview-box { background: var(--muted); }
.dark .drawer-btn { color: var(--foreground); }
