/* ============================================================
   现挂 · 统一主题层 v2
   在 styles.css / styles-voice.css 之后加载，负责：
   设计变量、外壳布局、按钮/徽章/面板/弹窗/表格、响应式
   ============================================================ */

:root {
  --bg: #f6f4ef;
  --bg-deep: #efebe2;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --surface-3: #f2efe7;
  --ink: #1e1c19;
  --ink-2: #585349;
  --ink-3: #8e8779;
  --line: #e7e1d3;
  --line-strong: #d8d0bf;
  --accent: #4f6b46;
  --accent-deep: #3d5536;
  --accent-soft: #edf3ea;
  --warn: #a9742a;
  --warn-soft: #fbf2e4;
  --danger: #a8433c;
  --danger-soft: #fbefed;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --shadow-1: 0 1px 2px rgba(30, 28, 25, 0.05);
  --shadow-2: 0 10px 30px rgba(30, 28, 25, 0.07);
  --shadow-3: 0 24px 60px rgba(30, 28, 25, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shell-pad: 28px;
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0.005em;
}

/* ---------------- 侧边栏 ---------------- */

.sidebar {
  background: linear-gradient(180deg, #f2efe7 0%, #efeade 100%);
  border-right: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand small {
  color: var(--ink-3);
  letter-spacing: 0.18em;
  font-weight: 500;
}

.navbtn {
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease;
}

.navbtn:hover {
  background: rgba(79, 107, 70, 0.07);
  color: var(--ink);
}

.navbtn.active {
  background: var(--surface);
  color: var(--accent-deep);
  font-weight: 650;
  box-shadow: var(--shadow-1);
}

.sidenote {
  color: var(--ink-3);
  line-height: 1.9;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  background: rgba(246, 244, 239, 0.86);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.crumb {
  color: var(--ink-3);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.topactions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.topactions .textbtn {
  white-space: nowrap;
}

/* ---------------- 内容区 ---------------- */

.content {
  padding: var(--shell-pad) var(--shell-pad) 56px;
}

.pagehead {
  gap: 18px;
  align-items: flex-start;
}

.eyebrow {
  color: var(--ink-3);
  letter-spacing: 0.16em;
  font-size: 10.5px;
  font-weight: 600;
}

h1 {
  letter-spacing: -0.015em;
  line-height: 1.22;
  font-weight: 700;
}

.pagehead .sub {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.8;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.sectionhead h2,
.sidetitle {
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

.hint,
.muted {
  color: var(--ink-3);
  line-height: 1.75;
}

.notice {
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: var(--radius);
  line-height: 1.8;
}

/* ---------------- 按钮 ---------------- */

.primary,
.secondary,
.textbtn,
.filter,
.ghost {
  font-family: var(--font);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    transform 0.12s ease;
}

.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(79, 107, 70, 0.18);
}

.primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.secondary {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 500;
}

.secondary:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.textbtn {
  color: var(--ink-2);
  border-radius: 999px;
  font-size: 12.5px;
}

.textbtn:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.primary:active,
.secondary:active {
  transform: translateY(1px);
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------- 徽章 ---------------- */

.pill {
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--ink-2);
}

.pill.green {
  background: var(--accent-soft);
  border-color: #cfdcc9;
  color: var(--accent-deep);
}

.pill.warn {
  background: var(--warn-soft);
  border-color: #ecd9bb;
  color: var(--warn);
}

/* ---------------- 弹窗 ---------------- */

.modalback {
  backdrop-filter: blur(4px);
  background: rgba(30, 28, 25, 0.42);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
  max-height: 88vh;
  overflow-y: auto;
  width: min(680px, 94vw);
}

.modalhead h2 {
  letter-spacing: -0.01em;
  font-weight: 700;
}

.modal .close {
  border-radius: 999px;
  color: var(--ink-3);
  transition: background 0.16s ease, color 0.16s ease;
}

.modal .close:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.modal .footer {
  position: sticky;
  bottom: -1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 22%);
  padding-top: 12px;
}

/* ---------------- 表格 ---------------- */

.adminTable th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--ink-3);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line-strong);
}

.adminTable tbody tr:hover {
  background: var(--surface-2);
}

.adminTable input[type="number"],
.keyrow input,
.dlg textarea,
#adminToken {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font);
}

/* ---------------- 提示条 ---------------- */

#toast,
.toast {
  background: rgba(30, 28, 25, 0.94);
  color: #fff;
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  padding: 10px 18px;
  font-size: 12.5px;
  left: auto;
  right: 24px;
  transform: none;
  bottom: auto;
  top: 74px;
  max-width: min(460px, 88vw);
  text-align: left;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1180px) {
  :root {
    --shell-pad: 20px;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .aside {
    position: static;
  }
}

@media (max-width: 860px) {
  :root {
    --shell-pad: 14px;
  }

  .sidebar {
    display: none;
  }

  .shell {
    margin-left: 0;
    padding-bottom: 84px;
  }

  .topbar {
    padding: 10px 12px;
  }

  .crumb {
    display: none;
  }

  .topactions {
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .topactions::-webkit-scrollbar {
    display: none;
  }

  .topactions .textbtn {
    padding: 8px 10px;
    font-size: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
  }

  .topactions .textbtn .btnlabel {
    display: none;
  }

  .topactions .textbtn .icon {
    margin: 0;
  }

  .content {
    padding: 16px 12px 40px;
  }

  h1 {
    font-size: 26px;
  }

  .pagehead {
    flex-direction: column;
    gap: 12px;
  }

  .pagehead > .primary {
    width: 100%;
  }

  .steps {
    gap: 6px;
  }

  .steps span {
    font-size: 11px;
    padding: 6px 9px;
  }

  .bottomnav {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bottomnav button {
    font-size: 10.5px;
    color: var(--ink-3);
  }

  .bottomnav button.active {
    color: var(--accent-deep);
  }

  .modal {
    width: 96vw;
    border-radius: var(--radius-lg);
    padding: 16px;
  }

  .toast {
    bottom: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* 全局修复：hidden 属性必须真的隐藏（曾被 display:flex/inline-flex 覆盖） */
[hidden] {
  display: none !important;
}

/* ---------- 手机端现场页：底部导航不再压住操作坞 ---------- */
@media (max-width: 860px) {
  body.on-session .bottomnav { display: none; }
  body.on-session .content { padding-bottom: 10px; }
  body.on-session .topbar { padding: 8px 12px; }
  body.on-session .mondock {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  body.on-session .mondock [data-mon="end"] { grid-column: 1 / -1; }
  body.on-session .mondock .primary { height: 46px; }
  /* 顶栏收敛：AI 徽章和双端方案在手机上没意义 */
  .topactions .pill.green { display: none; }
  .topactions [data-action="devices"] { display: none; }
  .topactions .textbtn { padding: 8px; }
  .topactions .pill { font-size: 11px; padding: 4px 9px; }
}
