/*
 * Design tokens — copied from the marketing site
 * (website-work/ai-marketing-platform-astro/src/styles/global.css, @theme block)
 * so the portal and the site read as one product. Keep the two in sync by hand.
 * Bootstrap stays; its CSS variables are remapped onto these tokens below.
 */
:root {
  --c-bg: #ffffff;
  --c-surface: #f7f8fb;
  --c-surface-2: #eef0f6;
  --c-line: #e3e6ee;
  --c-line-strong: #cfd4e1;

  --c-ink: #0b1220;
  --c-ink-2: #3a4459;
  --c-ink-3: #5b6478;

  --c-accent: #4f46e5;
  --c-accent-strong: #4338ca;
  --c-accent-soft: #eef0ff;
  --c-accent-line: #c9ceff;

  --c-ok: #0f7a4d;
  --c-ok-soft: #e5f6ee;
  --c-warn: #93590a;
  --c-warn-soft: #fdf1dc;
  --c-danger: #b42318;
  --c-danger-soft: #fdecea;

  --radius-card: 1rem;
  --shadow-card: 0 1px 2px rgb(11 18 32 / 0.04), 0 8px 24px -12px rgb(11 18 32 / 0.12);
  --shadow-pop: 0 2px 4px rgb(11 18 32 / 0.05), 0 24px 48px -20px rgb(11 18 32 / 0.25);

  /* Geist has no CJK glyphs — fall back to each platform's native UI font, same as the site's :lang(zh) rule. */
  --font-sans: "Geist Variable", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", ui-sans-serif, system-ui, sans-serif;

  /* ---- Bootstrap remap ---- */
  --bs-font-sans-serif: var(--font-sans);
  --bs-body-font-family: var(--font-sans);
  /* --bs-body-bg is also what form controls/list items/cards paint with, so it stays white;
     the page's gray backdrop is set on body directly. */
  --bs-body-bg: var(--c-bg);
  --bs-body-color: var(--c-ink);
  --bs-body-color-rgb: 11, 18, 32;
  --bs-emphasis-color: var(--c-ink);
  --bs-secondary-color: var(--c-ink-3);
  --bs-secondary-bg: var(--c-surface-2);
  --bs-tertiary-bg: var(--c-surface);
  --bs-border-color: var(--c-line);
  --bs-border-color-translucent: var(--c-line);
  --bs-border-radius: 0.625rem;
  --bs-border-radius-sm: 0.5rem;
  --bs-border-radius-lg: var(--radius-card);
  --bs-primary: var(--c-accent);
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: var(--c-accent);
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: var(--c-accent-strong);
  --bs-link-hover-color-rgb: 67, 56, 202;
  --bs-secondary-rgb: 91, 100, 120;
  --bs-focus-ring-color: rgb(79 70 229 / 0.25);
}

body {
  background-color: var(--c-surface);
  color: var(--c-ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--c-accent-soft);
}

h1, h2, h3, h4, h5, h6 {
  color: var(--c-ink);
  font-weight: 600;
}

.text-muted {
  color: var(--c-ink-3) !important;
}

/* The site's focus style: a crisp accent outline instead of Bootstrap's blurry glow. */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ---------- Top bar (mirrors the site's Navbar.astro) ---------- */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgb(255 255 255 / 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgb(227 230 238 / 0.8);
}

.app-topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 4rem;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  color: var(--c-ink);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
}

.app-brand:hover {
  color: var(--c-ink);
}

.app-brand-mark {
  flex-shrink: 0;
}

.app-brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-brand-company {
  color: var(--c-ink-3);
  font-weight: 500;
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.app-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--c-ink-2);
  font-size: 0.875rem;
}

/* User menu: the avatar + name is a button opening .app-umenu. */
.app-user-menu {
  position: relative;
}

button.app-user {
  border: 0;
  background: transparent;
  padding: 0.125rem 0.5rem 0.125rem 0.125rem;
  border-radius: 9999px;
  cursor: pointer;
}

button.app-user:hover,
button.app-user[aria-expanded="true"] {
  background: var(--c-surface-2);
  color: var(--c-ink);
}

button.app-user:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.app-user-caret {
  color: var(--c-ink-3);
  transition: transform .15s;
}

button.app-user[aria-expanded="true"] .app-user-caret {
  transform: rotate(180deg);
}

.app-umenu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 1050;
  min-width: 13rem;
  padding: 0.375rem;
  border: 1px solid var(--c-line);
  border-radius: 0.875rem;
  background: var(--c-bg);
  box-shadow: var(--shadow-card);
}

.app-umenu[hidden] {
  display: none;
}

.app-umenu-head {
  padding: 0.5rem 0.625rem 0.625rem;
  border-bottom: 1px solid var(--c-line);
  margin-bottom: 0.375rem;
}

.app-umenu-name {
  font-weight: 600;
  color: var(--c-ink);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-umenu-sub {
  font-size: 0.75rem;
  color: var(--c-ink-3);
}

.app-umenu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--c-ink-2);
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.app-umenu-item:hover,
.app-umenu-item:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
  outline: none;
}

.app-umenu-count {
  min-width: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.6875rem;
  line-height: 1.25rem;
  text-align: center;
}

.app-umenu-sep {
  height: 1px;
  margin: 0.375rem 0;
  background: var(--c-line);
}

/* Mail icon → 客户互动; the red count wiggles while 私信 / 评论 / 官网留资 await someone. */
.app-leads-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  margin-right: 0.5rem; /* room for the "New" that sticks out on the right */
  color: var(--c-ink-2);
}

.app-leads-link:hover {
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

.app-leads-new {
  position: absolute;
  top: -0.35rem;
  right: -0.9rem;
  padding: 0.05rem 0.35rem;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.3;
  animation: app-leads-shake 2.4s ease-in-out infinite;
}

/* A short wiggle, then still for the rest of the cycle. */
@keyframes app-leads-shake {
  0%, 20%, 100% { transform: rotate(0); }
  4% { transform: rotate(-12deg); }
  8% { transform: rotate(10deg); }
  12% { transform: rotate(-8deg); }
  16% { transform: rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .app-leads-new {
    animation: none;
  }
}

/* LinkedIn accounts to authorize/renew — stays until they're renewed (not cleared by a visit). */
.app-li-due {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background: #fef2f2;
  color: #b42318;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.app-li-due:hover {
  background: #fee2e2;
  color: #912018;
}

.app-li-due-count {
  min-width: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.6875rem;
  line-height: 1.25rem;
  text-align: center;
  animation: app-leads-shake 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .app-li-due-count {
    animation: none;
  }
}

.app-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
}

@media (max-width: 575.98px) {
  .app-user-name,
  .app-brand-company,
  .app-user-caret {
    display: none;
  }
}

/* Let the brand shrink (its text ends in "…") so the top bar fits a phone. */
.app-brand {
  min-width: 0;
}

/* ---------- Buttons (the site's Button.tsx: pill shape, accent primary) ---------- */

.btn {
  --bs-btn-border-radius: 9999px;
  --bs-btn-font-weight: 500;
  --bs-btn-padding-x: 1rem;
  --bs-btn-focus-box-shadow: none;
  white-space: nowrap;
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s;
}

.btn-sm {
  --bs-btn-border-radius: 9999px;
  --bs-btn-padding-x: 0.75rem;
}

.btn-primary {
  --bs-btn-bg: var(--c-accent);
  --bs-btn-border-color: var(--c-accent);
  --bs-btn-hover-bg: var(--c-accent-strong);
  --bs-btn-hover-border-color: var(--c-accent-strong);
  --bs-btn-active-bg: var(--c-accent-strong);
  --bs-btn-active-border-color: var(--c-accent-strong);
  --bs-btn-disabled-bg: var(--c-accent);
  --bs-btn-disabled-border-color: var(--c-accent);
  box-shadow: 0 1px 2px rgb(79 70 229 / 0.4);
}

.btn-outline-primary {
  --bs-btn-color: var(--c-accent-strong);
  --bs-btn-bg: var(--c-bg);
  --bs-btn-border-color: var(--c-accent-line);
  --bs-btn-hover-color: var(--c-accent-strong);
  --bs-btn-hover-bg: var(--c-accent-soft);
  --bs-btn-hover-border-color: var(--c-accent);
  --bs-btn-active-color: var(--c-accent-strong);
  --bs-btn-active-bg: var(--c-accent-soft);
  --bs-btn-active-border-color: var(--c-accent);
  --bs-btn-disabled-color: var(--c-accent);
  --bs-btn-disabled-border-color: var(--c-accent-line);
}

/* The site's "secondary" button: white, hairline border, darkens on hover. */
.btn-outline-secondary,
.btn-secondary {
  --bs-btn-color: var(--c-ink);
  --bs-btn-bg: var(--c-bg);
  --bs-btn-border-color: var(--c-line-strong);
  --bs-btn-hover-color: var(--c-ink);
  --bs-btn-hover-bg: var(--c-surface);
  --bs-btn-hover-border-color: var(--c-ink);
  --bs-btn-active-color: var(--c-ink);
  --bs-btn-active-bg: var(--c-surface-2);
  --bs-btn-active-border-color: var(--c-ink);
  --bs-btn-disabled-color: var(--c-ink-3);
  --bs-btn-disabled-bg: var(--c-bg);
  --bs-btn-disabled-border-color: var(--c-line);
}

/* The site's "ghost" button: no border until hovered. */
.btn-ghost {
  --bs-btn-color: var(--c-ink-2);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--c-ink);
  --bs-btn-hover-bg: var(--c-surface-2);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--c-ink);
  --bs-btn-active-bg: var(--c-surface-2);
  --bs-btn-active-border-color: transparent;
}

.btn-outline-danger {
  --bs-btn-color: var(--c-danger);
  --bs-btn-bg: var(--c-bg);
  --bs-btn-border-color: #f1c4bf;
  --bs-btn-hover-color: var(--c-danger);
  --bs-btn-hover-bg: var(--c-danger-soft);
  --bs-btn-hover-border-color: var(--c-danger);
  --bs-btn-active-color: var(--c-danger);
  --bs-btn-active-bg: var(--c-danger-soft);
  --bs-btn-active-border-color: var(--c-danger);
}

.btn-danger {
  --bs-btn-bg: var(--c-danger);
  --bs-btn-border-color: var(--c-danger);
  --bs-btn-hover-bg: #912018;
  --bs-btn-hover-border-color: #912018;
  --bs-btn-active-bg: #912018;
  --bs-btn-active-border-color: #912018;
}

.btn-link {
  --bs-btn-color: var(--c-accent);
  --bs-btn-hover-color: var(--c-accent-strong);
  --bs-btn-active-color: var(--c-accent-strong);
}

/* ---------- Forms ---------- */

.form-label {
  color: var(--c-ink-2);
  font-weight: 500;
}

.form-text {
  color: var(--c-ink-3);
}

.form-control,
.form-select {
  border-color: var(--c-line-strong);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.15);
}

.form-control:disabled,
.form-select:disabled {
  background-color: var(--c-surface);
  color: var(--c-ink-3);
}

.form-check-input:checked {
  background-color: var(--c-accent);
  border-color: var(--c-accent);
}

.form-check-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.15);
}

/* ---------- Surfaces ---------- */

.card {
  --bs-card-border-color: var(--c-line);
  --bs-card-border-radius: var(--radius-card);
  --bs-card-inner-border-radius: calc(var(--radius-card) - 1px);
  box-shadow: var(--shadow-card);
}

.list-group {
  --bs-list-group-border-color: var(--c-line);
  --bs-list-group-border-radius: var(--radius-card);
  --bs-list-group-action-hover-bg: var(--c-surface);
  --bs-list-group-action-hover-color: var(--c-ink);
  --bs-list-group-action-active-bg: var(--c-surface-2);
}

.alert {
  --bs-alert-border-radius: 0.75rem;
}

.alert-danger {
  --bs-alert-color: var(--c-danger);
  --bs-alert-bg: var(--c-danger-soft);
  --bs-alert-border-color: #f1c4bf;
}

.alert-success {
  --bs-alert-color: var(--c-ok);
  --bs-alert-bg: var(--c-ok-soft);
  --bs-alert-border-color: #b9e3cf;
}

.alert-warning {
  --bs-alert-color: var(--c-warn);
  --bs-alert-bg: var(--c-warn-soft);
  --bs-alert-border-color: #f3d9a8;
}

.link-secondary {
  color: var(--c-ink-3) !important;
  text-decoration: none;
}

.link-secondary:hover {
  color: var(--c-ink) !important;
}

/* ---------- Badges (the site's Badge.tsx: soft pill tones) ----------
 * Semantic tones instead of Bootstrap's solid text-bg-* colors:
 *   badge-neutral  platform / type / counts / 草稿 / 未发出
 *   badge-accent   已审核 / 评分 / 加热中
 *   badge-solid    预发布 (one step past 已审核, so a filled accent to tell them apart)
 *   badge-ok       已发布 / 已激活 / 已发出
 *   badge-warn     待审核 / 置顶 / 未激活
 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25;
}

.badge.badge-neutral { background: var(--c-surface-2); color: var(--c-ink-2); }
.badge.badge-accent  { background: var(--c-accent-soft); color: var(--c-accent-strong); }
.badge.badge-solid   { background: var(--c-accent); color: #fff; }
.badge.badge-ok      { background: var(--c-ok-soft); color: var(--c-ok); }
.badge.badge-warn    { background: var(--c-warn-soft); color: var(--c-warn); }

/* Live pulse for "加热中" — same keyframes as the site's .pulse-dot. */
.pulse-dot {
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--c-accent);
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgb(79 70 229 / 0.45); }
  70%, 100% { box-shadow: 0 0 0 7px rgb(79 70 229 / 0); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot { animation: none; }
}

/* ---------- Segmented tabs (replaces nav-tabs; same pill links as the site's navbar) ---------- */

.app-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--c-surface-2);
  border-radius: 9999px;
}

.app-tabs .nav-link {
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  color: var(--c-ink-2);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color .15s, background-color .15s;
}

.app-tabs .nav-link:hover {
  color: var(--c-ink);
}

.app-tabs .nav-link.active {
  background: var(--c-bg);
  color: var(--c-ink);
  box-shadow: 0 1px 2px rgb(11 18 32 / 0.08);
}

/* ---------- Filter toolbar ---------- */

.app-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.app-toolbar > .app-search {
  flex: 1 1 240px;
}

.app-toolbar > .form-select {
  flex: 0 1 180px;
}

/* Wide enough that "按公司筛选（仅管理员可见）" stays on one line. */
.app-toolbar > .app-toolbar-field {
  flex: 0 1 240px;
}

.app-toolbar .form-label {
  margin-bottom: 0.25rem;
}

@media (max-width: 575.98px) {
  .app-toolbar > .form-select,
  .app-toolbar > .app-toolbar-field {
    flex: 1 1 140px;
  }
}

.app-search {
  position: relative;
}

.app-search > svg {
  position: absolute;
  top: 50%;
  left: 0.8rem;
  transform: translateY(-50%);
  color: var(--c-ink-3);
  pointer-events: none;
}

.app-search > .form-control {
  padding-left: 2.25rem;
}

/* ---------- Card list (list-group rows as separate cards) ----------
 * Only direct children become cards, so nested list-groups (an account's topics
 * panel) keep the normal joined look. Row filtering sets style.display = 'none',
 * which drops the row out of the flex gap cleanly. */

.app-card-list {
  gap: 0.75rem;
  border-radius: 0;
}

.app-card-list > .list-group-item {
  padding: 1rem 1.25rem;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-card);
  transition: border-color .15s, box-shadow .15s;
}

.app-card-list > .list-group-item + .list-group-item {
  border-top-width: 1px;
  margin-top: 0;
}

.app-card-list > .list-group-item-action:hover,
.app-card-list > .list-group-item-action:focus-visible {
  background: var(--c-bg);
  border-color: var(--c-line-strong);
  box-shadow: var(--shadow-card);
}

.app-card-list .post-title {
  font-size: 1rem;
  font-weight: 600;
}

.app-card-list .post-meta strong {
  color: var(--c-ink-2);
  font-weight: 500;
}

.account-name-link h6 {
  transition: color .15s;
}

.account-name-link:hover h6 {
  color: var(--c-accent);
}

/* Nested topic rows inside an account card. */
.list-group-item-secondary {
  --bs-list-group-bg: var(--c-surface);
  --bs-list-group-color: var(--c-ink);
  --bs-list-group-border-color: var(--c-line);
}

.app-count {
  color: var(--c-ink-3);
  font-size: 0.8125rem;
}

.app-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--c-ink-3);
  background: var(--c-bg);
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--radius-card);
}

/* ---------- Login (brand panel + form, like the site's split hero) ---------- */

.login-shell {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 920px;
  margin: 2rem auto 0;
  overflow: hidden;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-pop);
}

@media (min-width: 768px) {
  .login-shell {
    grid-template-columns: 1.1fr 1fr;
    margin-top: 4rem;
  }
}

/* layout.html renders the login error above the page content; keep it the same width as the card. */
.alert:has(+ .login-shell) {
  max-width: 920px;
  margin: 2rem auto -1rem;
}

.login-brand {
  display: none;
  position: relative;
  padding: 2.5rem;
  background:
    radial-gradient(120% 90% at 0% 0%, #e4e6ff 0%, transparent 60%),
    radial-gradient(90% 80% at 100% 100%, #eef0ff 0%, transparent 55%),
    var(--c-accent-soft);
  border-right: 1px solid var(--c-line);
}

@media (min-width: 768px) {
  .login-brand {
    display: flex;
    flex-direction: column;
  }
}

.login-brand h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.75rem;
  line-height: 1.3;
}

.login-brand p {
  color: var(--c-ink-2);
  margin-bottom: 1.5rem;
}

.login-points {
  list-style: none;
  padding: 0;
  margin: auto 0 0;
  display: grid;
  gap: 0.625rem;
}

.login-points li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--c-ink-2);
  font-size: 0.9375rem;
}

.login-points svg {
  flex-shrink: 0;
  color: var(--c-accent);
}

.login-form {
  padding: 2.5rem 2rem;
}

@media (min-width: 768px) {
  .login-form {
    padding: 3rem 2.5rem;
  }
}

/* Brand above the form on phones only — from 768px .login-brand shows it instead. */
.login-form-brand {
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .login-form-brand {
    display: none;
  }
}

.login-form h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-form .btn {
  height: 2.75rem;
}

/* ---------- Dialogs (header styled like the site's AppWindow title bar) ---------- */

.app-dialog-header h5 {
  font-size: 1rem;
  font-weight: 600;
}

.app-dialog .btn-close {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 9999px;
  background-size: 0.75rem;
  opacity: 0.55;
}

.app-dialog .btn-close:hover {
  opacity: 0.9;
  background-color: var(--c-surface-2);
}

.app-dialog .btn-close:focus {
  box-shadow: none;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-line);
}

.app-note {
  padding: 0.625rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
}

.app-note-danger {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.app-note-info {
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

.app-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.app-stat {
  padding: 0.75rem 1rem;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 0.75rem;
}

.app-stat-label {
  color: var(--c-ink-3);
  font-size: 0.8125rem;
}

.app-stat-value {
  color: var(--c-ink);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.app-stat-value.is-zero {
  color: var(--c-danger);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.app-dialog[open] {
  animation: dialog-in 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .app-dialog[open] { animation: none; }
}

/* ---------- Detail / form pages ---------- */

.app-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--c-ink-3);
  font-size: 0.875rem;
  text-decoration: none;
}

.app-back:hover {
  color: var(--c-ink);
}

.app-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.app-page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.3;
}

.app-page-header p {
  margin: 0.25rem 0 0;
  color: var(--c-ink-3);
  font-size: 0.9375rem;
}

/* A titled card grouping related fields. */
.app-section {
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

@media (min-width: 768px) {
  .app-section {
    padding: 1.5rem;
  }
}

/* 私信 page (messages.html): thread list left, conversation right. */
.dm-layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .dm-layout { grid-template-columns: 1fr; } }
.dm-list { max-height: 75vh; overflow-y: auto; }
.dm-item { display: block; padding: .625rem .75rem; border-radius: .625rem; color: inherit; text-decoration: none; }
.dm-item + .dm-item { margin-top: .25rem; }
.dm-item:hover { background: var(--c-surface); }
.dm-item.active { background: var(--c-accent-soft); }
/* Unread threads (per user): a dot before the name, the last message in full ink. */
.dm-item.unread .dm-item-text { color: var(--c-ink); font-weight: 600; }
.dm-unread-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--c-danger); margin-right: .375rem; vertical-align: middle; }
.dm-item-head { display: flex; justify-content: space-between; gap: .5rem; }
.dm-item-time { font-size: .75rem; color: var(--c-ink-3); white-space: nowrap; }
.dm-item-text { font-size: .875rem; color: var(--c-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-item-meta { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin-top: .25rem; }
.dm-messages { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; padding: .25rem; }
.dm-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 80%; }
.dm-msg.own { align-self: flex-end; align-items: flex-end; }
.dm-bubble { background: var(--c-surface-2); border-radius: .875rem; padding: .5rem .75rem; }
.dm-msg.own .dm-bubble { background: var(--c-accent-soft); }
.dm-msg.dm-queued .dm-bubble { background: transparent; border: 1px dashed var(--c-line); }
.dm-msg-meta { font-size: .75rem; color: var(--c-ink-3); margin-top: .125rem; }

/* Comments on the platform (post page, #platform-comments). */
.pc-thread { border-top: 1px solid var(--c-line); padding: .75rem 0; }
.pc-thread:first-child { border-top: 0; padding-top: 0; }
.pc-item + .pc-item { margin-top: .5rem; }
.pc-reply { margin-left: 1.5rem; padding-left: .75rem; border-left: 2px solid var(--c-line); }
.pc-meta { font-size: .8125rem; color: var(--c-ink-3); }
.pc-text { white-space: pre-wrap; word-break: break-word; margin-top: .125rem; }
.pc-reply-box { margin-top: .5rem; }
.pc-handled-btn { margin-top: .5rem; font-size: .8125rem; color: var(--c-ink-3); text-decoration: none; }
.pc-handled-btn:hover { color: var(--c-accent); }
.pc-reply-box summary { cursor: pointer; font-size: .8125rem; color: var(--c-accent); width: max-content; }

.app-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  color: var(--c-ink);
  font-size: 0.9375rem;
  font-weight: 600;
}

.app-section-title .app-section-hint {
  color: var(--c-ink-3);
  font-size: 0.8125rem;
  font-weight: 400;
}

.app-section > :last-child {
  margin-bottom: 0;
}

/* AI assist block: tinted so it reads as a tool, not a field to fill. */
.app-ai-panel {
  background: linear-gradient(180deg, var(--c-accent-soft) 0%, var(--c-bg) 100%);
  border-color: var(--c-accent-line);
}

.app-ai-panel .app-section-title svg {
  color: var(--c-accent);
}

/* Save/cancel row that stays reachable at the bottom of long forms. */
.app-actions-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0.75rem 0;
  background: rgb(247 248 251 / 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--c-line);
}

.app-actions-bar .app-actions-note {
  margin-left: auto;
  color: var(--c-ink-3);
  font-size: 0.8125rem;
}

/* Post detail */

.post-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.app-inline-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 0.75rem;
}

.post-detail-title {
  margin: 1.25rem 0 0.75rem;
  font-size: 1.375rem;
  line-height: 1.4;
}

.post-detail-body {
  color: var(--c-ink-2);
  font-size: 1rem;
  line-height: 1.8;
}

.app-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-line);
  font-size: 0.875rem;
}

.app-meta dt {
  color: var(--c-ink-3);
  font-size: 0.75rem;
  font-weight: 500;
}

.app-meta dd {
  margin: 0.125rem 0 0;
  color: var(--c-ink);
}

/* Attachment tiles on the edit form: the "删除" checkbox tints the tile red when ticked. */
.attachment-tile {
  padding: 0.375rem;
  border: 1px solid var(--c-line);
  border-radius: 0.875rem;
  background: var(--c-bg);
  transition: border-color .15s, background-color .15s;
}

.attachment-tile:has(.form-check-input:checked) {
  border-color: var(--c-danger);
  background: var(--c-danger-soft);
}

.attachment-tile:has(.form-check-input:checked) .attachment-media {
  opacity: 0.5;
}

.attachment-tile .form-check-input:checked {
  background-color: var(--c-danger);
  border-color: var(--c-danger);
}

a .attachment-media {
  transition: opacity .15s;
}

a:hover .attachment-media {
  opacity: 0.9;
}

.btn-warning {
  --bs-btn-color: var(--c-warn);
  --bs-btn-bg: var(--c-warn-soft);
  --bs-btn-border-color: #f3d9a8;
  --bs-btn-hover-color: var(--c-warn);
  --bs-btn-hover-bg: #fbe6c2;
  --bs-btn-hover-border-color: var(--c-warn);
  --bs-btn-active-color: var(--c-warn);
  --bs-btn-active-bg: #fbe6c2;
  --bs-btn-active-border-color: var(--c-warn);
}

.btn-outline-success {
  --bs-btn-color: var(--c-ok);
  --bs-btn-bg: var(--c-bg);
  --bs-btn-border-color: #b9e3cf;
  --bs-btn-hover-color: var(--c-ok);
  --bs-btn-hover-bg: var(--c-ok-soft);
  --bs-btn-hover-border-color: var(--c-ok);
  --bs-btn-active-color: var(--c-ok);
  --bs-btn-active-bg: var(--c-ok-soft);
  --bs-btn-active-border-color: var(--c-ok);
}

/* ---------- 内容日历 ---------- */

.cal-month-label {
  min-width: 6.5rem;
  text-align: center;
  font-weight: 600;
  color: var(--c-ink);
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.8125rem;
  color: var(--c-ink-2);
}

.cal-dot {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  margin-right: 0.3rem;
  border-radius: 3px;
  vertical-align: -1px;
}

.cal-dot.is-pre { background: var(--c-accent-soft); border: 1px solid var(--c-accent); }
.cal-dot.is-pub { background: var(--c-ok-soft); border: 1px solid #b9e3cf; }

/* Seven columns don't fit a phone: scroll sideways instead of squashing. */
.cal-wrap {
  overflow-x: auto;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  min-width: 840px;
}

.cal-head {
  padding: 0.5rem 0.625rem;
  color: var(--c-ink-3);
  font-size: 0.75rem;
  font-weight: 500;
  background: #fbfbfd;
  border-bottom: 1px solid var(--c-line);
}

.cal-day {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 7.5rem;
  padding: 0.375rem;
  border-right: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
  transition: background-color .12s;
}

.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-out { background: #fbfbfd; }
.cal-day.is-out .cal-date { color: var(--c-line-strong); }
.cal-day.is-past:not(.is-out) { background: #fcfcfd; }
.cal-day.is-today { background: var(--c-accent-soft); }

.cal-day.is-drop-target {
  background: #e4e6ff;
  box-shadow: inset 0 0 0 2px var(--c-accent);
}

.cal-date {
  color: var(--c-ink-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

.cal-today {
  margin-left: 0.25rem;
  color: var(--c-accent-strong);
  font-size: 0.6875rem;
  font-weight: 500;
}

.cal-item {
  display: flex;
  gap: 0.3rem;
  width: 100%;
  padding: 0.2rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.cal-item .cal-time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cal-item .cal-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-item.is-pub { background: var(--c-ok-soft); color: var(--c-ok); }
.cal-item.is-pub:hover { border-color: #b9e3cf; }
.cal-item.is-pre { background: var(--c-accent-soft); color: var(--c-accent-strong); }
.cal-item.is-pre:hover { border-color: var(--c-accent-line); }

.cal-item.is-movable {
  border: 1px dashed var(--c-accent);
  cursor: grab;
}

.cal-item.is-movable:active { cursor: grabbing; }
.cal-item.is-dragging { opacity: 0.4; }

.cal-more > summary {
  color: var(--c-ink-3);
  font-size: 0.75rem;
  cursor: pointer;
  list-style: none;
}

.cal-more > summary::-webkit-details-marker { display: none; }
.cal-more > summary:hover { color: var(--c-accent); }

.cal-more[open] {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cal-unscheduled-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.cal-unscheduled-list .cal-item {
  width: auto;
  max-width: 280px;
}

/* ---------- 机器人排期日历 (robot_calendar.html) ---------- */

.rc-label { min-width: 9rem; }
.rc-views { display: inline-flex; border: 1px solid var(--c-line); border-radius: 9999px; overflow: hidden; }
.rc-view { padding: 0.2rem 0.75rem; font-size: 0.8125rem; color: var(--c-ink-2); text-decoration: none; }
.rc-view + .rc-view { border-left: 1px solid var(--c-line); }
.rc-view:hover { background: var(--c-surface); color: var(--c-ink); }
.rc-view.active { background: var(--c-accent); color: #fff; }
.rc-date-link { text-decoration: none; }
.rc-date-link:hover { color: var(--c-accent); }

.rc-dot { display: inline-block; width: 0.625rem; height: 0.625rem; margin-right: 0.3rem; border-radius: 3px; vertical-align: -1px; }
.rc-dot.is-plan    { background: var(--c-accent-soft); border: 1px solid var(--c-accent); }
.rc-dot.is-every   { background: repeating-linear-gradient(45deg, #e0f2fe, #e0f2fe 3px, #f0f9ff 3px, #f0f9ff 6px); border: 1px solid #7dd3fc; }
.rc-dot.is-success { background: var(--c-ok-soft); border: 1px solid #b9e3cf; }
.rc-dot.is-failed  { background: var(--c-danger-soft); border: 1px solid #f5b5ae; }
.rc-dot.is-running { background: var(--c-warn-soft); border: 1px solid #f1d39d; }
.rc-dot.is-post    { background: #f5edff; border: 1px solid #c9a7f5; }
.rc-dot.is-grey    { background: var(--c-surface-2); border: 1px dashed var(--c-line-strong); }

/* one item: month cells, all-day row */
.rc-item {
  display: flex; gap: 0.3rem; width: 100%; padding: 0.2rem 0.4rem;
  border: 1px solid transparent; border-radius: 0.375rem;
  font-size: 0.75rem; line-height: 1.35; text-align: left;
  white-space: nowrap; overflow: hidden; cursor: pointer;
}
.rc-item .rc-time, .rc-ev .rc-time { flex-shrink: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.rc-item .rc-text { overflow: hidden; text-overflow: ellipsis; }

.rc-item.is-plan, .rc-ev.is-plan       { background: var(--c-accent-soft); color: var(--c-accent-strong); border-color: var(--c-accent-line); }
.rc-item.is-every                      { background: repeating-linear-gradient(45deg, #e0f2fe, #e0f2fe 4px, #f0f9ff 4px, #f0f9ff 8px); color: #075985; border-color: #bae6fd; }
.rc-item.is-success, .rc-ev.is-success { background: var(--c-ok-soft); color: var(--c-ok); border-color: #b9e3cf; }
.rc-item.is-failed, .rc-ev.is-failed   { background: var(--c-danger-soft); color: var(--c-danger); border-color: #f5b5ae; font-weight: 600; }
.rc-item.is-running, .rc-ev.is-running,
.rc-item.is-stopped, .rc-ev.is-stopped { background: var(--c-warn-soft); color: var(--c-warn); border-color: #f1d39d; }
.rc-item.is-post, .rc-ev.is-post       { background: #f5edff; color: #6b21a8; border-color: #ddc6fa; }
.rc-item.is-grey, .rc-ev.is-grey       { background: var(--c-surface-2); color: var(--c-ink-3); border: 1px dashed var(--c-line-strong); font-weight: 400; }
.rc-item:hover, .rc-ev:hover           { filter: brightness(0.97); box-shadow: 0 0 0 1px currentColor inset; }

/* week / day timeline */
.rc-tl {
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}
.rc-tl-head, .rc-tl-allday, .rc-tl-body {
  display: grid;
  grid-template-columns: 3.5rem repeat(var(--rc-days), minmax(110px, 1fr));
  min-width: calc(3.5rem + var(--rc-days) * 110px);
}
.rc-tl-head { border-bottom: 1px solid var(--c-line); background: #fbfbfd; }
.rc-tl-dayhead { padding: 0.5rem 0.625rem; font-size: 0.8125rem; font-weight: 600; color: var(--c-ink-2); text-decoration: none; border-left: 1px solid var(--c-line); }
.rc-tl-dayhead.is-today { color: var(--c-accent-strong); background: var(--c-accent-soft); }
.rc-tl-allday { border-bottom: 1px solid var(--c-line); }
.rc-tl-corner { padding: 0.375rem; font-size: 0.6875rem; }
.rc-tl-allday-cell { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.25rem; border-left: 1px solid var(--c-line); min-height: 1.75rem; min-width: 0; }
.rc-tl-scroll { max-height: 640px; overflow-y: auto; }
.rc-tl-hour {
  height: var(--rc-hour); padding-right: 0.375rem; text-align: right;
  font-size: 0.6875rem; color: var(--c-ink-3); font-variant-numeric: tabular-nums;
  transform: translateY(-0.45em);
}
.rc-tl-hour:first-child { visibility: hidden; }
.rc-tl-col {
  position: relative;
  height: calc(var(--rc-hour) * 24);
  border-left: 1px solid var(--c-line);
  background-image: linear-gradient(to bottom, var(--c-line) 1px, transparent 1px);
  background-size: 100% var(--rc-hour);
}
.rc-tl-col.is-today { background-color: #fafaff; }
.rc-band {
  position: absolute; left: 0; right: 0; z-index: 1;
  padding: 0.125rem 0.25rem; border: 0; border-left: 3px solid #7dd3fc;
  background: repeating-linear-gradient(45deg, rgb(224 242 254 / 0.75), rgb(224 242 254 / 0.75) 6px, rgb(240 249 255 / 0.75) 6px, rgb(240 249 255 / 0.75) 12px);
  color: #075985; font-size: 0.6875rem; text-align: left; overflow: hidden; cursor: pointer;
}
.rc-band.is-grey { border-left-color: var(--c-line-strong); background: repeating-linear-gradient(45deg, var(--c-surface-2), var(--c-surface-2) 6px, var(--c-surface) 6px, var(--c-surface) 12px); color: var(--c-ink-3); }
.rc-ev {
  position: absolute; z-index: 2;
  display: block; padding: 0.125rem 0.3rem;
  border: 1px solid transparent; border-radius: 0.375rem;
  font-size: 0.6875rem; line-height: 1.3; text-align: left;
  overflow: hidden; cursor: pointer;
}
.rc-ev .rc-text { word-break: break-all; }
.rc-now { position: absolute; left: 0; right: 0; z-index: 3; height: 0; border-top: 2px solid var(--c-danger); pointer-events: none; }
.rc-now::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-danger); }
.rc-dlg-lines { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.875rem; white-space: pre-wrap; word-break: break-word; }

/* ---------- 效果数据 ---------- */

.badge.badge-danger { background: var(--c-danger-soft); color: var(--c-danger); }

/* AI 流程 view: the steps in a row with arrows, stacked on narrow screens. */
.flow-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1rem; }
.flow-step {
  position: relative; display: flex; flex-direction: column; gap: .375rem; align-items: flex-start; text-align: left;
  padding: .875rem; background: var(--bs-card-bg, #fff); border: 1px solid var(--c-line); border-radius: var(--radius-card); color: inherit;
}
.flow-step:hover { border-color: var(--c-accent-line); }
.flow-step.active { border-color: var(--c-accent); background: var(--c-accent-soft); }
.flow-step:not(:last-child)::after {
  content: "\2192"; position: absolute; right: -1.05rem; top: 50%; transform: translateY(-50%); color: var(--c-ink-3);
}
.flow-step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--c-accent); color: #fff; font-size: .75rem; font-weight: 600;
}
.flow-step-title { font-weight: 600; line-height: 1.3; }
.flow-step-stat { font-size: .75rem; color: var(--c-ink-3); }
.flow-items { list-style: none; padding: 0; }
.flow-item { display: flex; gap: .625rem; align-items: flex-start; padding: .5rem 0; }
.flow-item + .flow-item { border-top: 1px solid var(--c-line); }
.flow-item-mark {
  flex: 0 0 1.375rem; height: 1.375rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; line-height: 1;
}
.flow-item-done .flow-item-mark { background: var(--c-ok-soft); color: var(--c-ok); }
.flow-item-action .flow-item-mark { background: var(--c-danger-soft); color: var(--c-danger); }
.flow-item-todo .flow-item-mark { background: var(--c-warn-soft); color: var(--c-warn); }
.flow-item-info .flow-item-mark { background: var(--c-accent-soft); color: var(--c-accent); }
.flow-item-off .flow-item-mark { background: var(--c-line); color: var(--c-ink-3); }
.flow-item-off .flow-item-body { color: var(--c-ink-3); }
.flow-item-action .flow-item-body a { font-weight: 600; }
@media (max-width: 860px) {
  .flow-steps { grid-template-columns: 1fr; gap: 1rem; }
  .flow-step:not(:last-child)::after { content: "\2193"; right: auto; left: 1rem; top: auto; bottom: -1.1rem; transform: none; }
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}

.metric {
  padding: 0.625rem 0.875rem;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 0.75rem;
}

.metric-derived {
  background: var(--c-accent-soft);
  border-color: var(--c-accent-line);
}

.metric-label {
  color: var(--c-ink-3);
  font-size: 0.75rem;
}

.metric-hint {
  display: block;
  font-size: 0.6875rem;
  color: var(--c-ink-3);
  opacity: 0.8;
}

.metric-value {
  color: var(--c-ink);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.metric-value-sm {
  font-size: 0.9375rem;
}

.metric-history > summary {
  color: var(--c-accent);
  font-size: 0.875rem;
  cursor: pointer;
}

.post-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.875rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--c-line);
  color: var(--c-ink-2);
  font-size: 0.8125rem;
}

.post-metrics strong {
  color: var(--c-ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Report tables ---------- */

.app-table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--c-line);
  font-size: 0.9375rem;
}

.app-table thead th {
  color: var(--c-ink-3);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom-color: var(--c-line-strong);
}

.app-table td,
.app-table th {
  padding: 0.625rem 0.75rem;
  vertical-align: middle;
}

.app-table tbody tr:hover > * {
  background: var(--c-surface);
}

.app-table tfoot th {
  border-top: 1px solid var(--c-line-strong);
  border-bottom: 0;
}

/* Data tables with only a few columns: size to the content instead of the
   full page width, so a handful of numbers don't end up far apart. Long post
   titles are cut with "…" (full title on hover). */
.app-table-compact {
  width: auto;
  max-width: 100%;
}

.app-table-compact td,
.app-table-compact th {
  padding-left: 1rem;
  padding-right: 1rem;
}

/* max-width isn't reliably applied to a table cell itself, so the title's link
   carries the truncation. */
.app-table-compact td.cell-title a {
  display: inline-block;
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* ---------- 评论 dialog ---------- */

.app-dialog.app-dialog-wide {
  max-width: 760px;
}

.comment-composer-foot,
.comment-edit-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comment-composer-foot > .text-muted {
  margin-right: auto;
}

/* Stays pinned while the list scrolls. top cancels .app-dialog-body's padding
   so it sits flush against the header. */
.comment-toolbar {
  position: sticky;
  top: -1.25rem;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 1rem -1.25rem 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--c-bg);
  border-top: 1px solid var(--c-line);
  border-bottom: 1px solid var(--c-line);
}

.comment-filter {
  flex: 1 1 200px;
}

.comment-filter > svg {
  left: 0.7rem;
}

.comment-filter > .form-control {
  padding-left: 2rem;
}

.comment-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

/* "⋯" overflow menu built on <details> (Bootstrap's dropdown JS isn't loaded). */
.app-menu {
  position: relative;
}

.app-menu > summary {
  list-style: none;
  font-size: 1.1rem;
  line-height: 1;
  padding-top: 0.3rem;
  padding-bottom: 0.45rem;
}

.app-menu > summary::-webkit-details-marker {
  display: none;
}

.app-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 5;
  min-width: 160px;
  padding: 0.25rem;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-pop);
}

.app-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: var(--c-ink);
  font-size: 0.875rem;
  text-align: left;
}

.app-menu-item:hover {
  background: var(--c-surface-2);
}

.app-menu-item.is-danger {
  color: var(--c-danger);
}

.app-menu-item.is-danger:hover {
  background: var(--c-danger-soft);
}

.comment-list {
  gap: 0.5rem;
}

.comment-list > .comment-item {
  padding: 0.75rem 1rem;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.comment-avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--c-accent-soft);
  color: var(--c-accent-strong);
}

.comment-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--c-ink-3);
  font-size: 0.8125rem;
}

.comment-meta strong {
  color: var(--c-ink);
  font-weight: 600;
}

.comment-status {
  flex-shrink: 0;
  margin-left: auto;
}

.comment-view {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-top: 0.375rem;
  padding-left: 2rem; /* aligns under the name, past the avatar */
}

.comment-content {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--c-ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.125rem;
}

.comment-action {
  padding: 0.125rem 0.5rem;
  border: 0;
  border-radius: 9999px;
  background: none;
  color: var(--c-ink-3);
  font-size: 0.8125rem;
}

.comment-action:hover {
  background: var(--c-surface-2);
  color: var(--c-ink);
}

.comment-action.is-danger:hover {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

/* Desktop: row actions appear on hover/focus only. Touch screens can't hover, so they always show there. */
@media (hover: hover) {
  .comment-actions {
    opacity: 0;
    transition: opacity .15s;
  }

  .comment-item:hover .comment-actions,
  .comment-item:focus-within .comment-actions {
    opacity: 1;
  }
}

/* In-place edit: 编辑 hides the read view and shows the form in its spot. */
.comment-edit {
  display: none;
  margin-top: 0.5rem;
  padding-left: 2rem;
}

.comment-item.is-editing {
  border-color: var(--c-accent-line);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.08);
}

.comment-item.is-editing .comment-view {
  display: none;
}

.comment-item.is-editing .comment-edit {
  display: block;
}

.comment-empty {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--c-ink-3);
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--radius-card);
}

@media (max-width: 575.98px) {
  .comment-view,
  .comment-edit {
    padding-left: 0;
  }

  .comment-view {
    flex-direction: column;
    align-items: stretch;
  }

  .comment-actions {
    justify-content: flex-end;
  }
}

/* ---------- Page-specific (pre-existing) ---------- */

.post-content {
  white-space: pre-wrap;
}

.attachment-media {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 0.625rem;
  background: #000;
}

.app-dialog {
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  padding: 0;
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
}

/* Scoped to [open]: author CSS overrides the UA stylesheet's
   `dialog:not([open]) { display: none }` regardless of specificity, so an
   unconditional `display: flex` on .app-dialog would make every dialog
   render inline in the page even when closed. */
.app-dialog[open] {
  display: flex;
  flex-direction: column;
}

.app-dialog::backdrop {
  background: rgb(11 18 32 / 0.45);
}

.app-dialog-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--c-line);
  background: var(--c-surface);
}

.app-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.25rem;
}

/* AI 员工 window (layout.html, app/staff.go). */
.staff-fab { position: fixed; right: 20px; bottom: 20px; z-index: 1040; width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: #4f46e5; color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(15, 23, 42, .25); cursor: pointer; }
.staff-fab:hover { background: #4338ca; }
.staff-fab:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
.staff-fab[hidden] { display: none; }
.staff-fab-dot { position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; }
.staff-win { position: fixed; right: 20px; bottom: 20px; z-index: 1045; width: min(820px, calc(100vw - 40px)); height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column; background: var(--c-bg, #fff); border: 1px solid var(--c-line, #e5e7eb); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .25); overflow: hidden; }
.staff-win[hidden] { display: none; }
.staff-win-bar { flex: none; display: flex; align-items: center; gap: .5rem; padding: .375rem .5rem .375rem 1rem; background: #4f46e5; color: #fff; }
.staff-win-title { flex: 1; font-weight: 600; font-size: .9375rem; }
.staff-win-min { border: 0; background: transparent; color: #fff; width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.staff-win-min:hover { background: rgba(255, 255, 255, .15); }
.staff-win-frame { flex: 1; width: 100%; border: 0; }
@media (max-width: 599.98px) {
  .staff-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .staff-win { inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
  html.staff-open, html.staff-open body { overflow: hidden; }
}
