/* ============================================================
 * 桐灼 GEO · components 层
 * 由 design-tokens.css 静态拆出（2026-08-24），级联顺序等价，零视觉变化。
 * 加载顺序：tokens → components → theme → layout → demo
 * ============================================================ */

/* --- 第 4 节（原 design-tokens.css） --- */
/* ============ 4. 按钮统一 ============ */
.primary-button,
.secondary-button,
.soft-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: .01em;
  transition: all .18s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

/* 小号按钮回退（保持原紧凑尺寸，不被统一 40px 顶大） */
.primary-button.button-small,
.secondary-button.button-small,
.soft-button.button-small,
.ghost-button.button-small,
.danger-button.button-small {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 12px;
  gap: 5px;
}

.primary-button {
  color: #fff;
  border: 0;
  background: var(--blue);
  box-shadow: 0 2px 6px rgba(184, 68, 47, .22);
}
.primary-button:hover { filter: brightness(1.05); box-shadow: 0 3px 10px rgba(184, 68, 47, .28); }
.primary-button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.secondary-button {
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: #fff;
}
.secondary-button:hover { color: var(--ink); border-color: #c4beb2; background: var(--panel-soft); }
.secondary-button:disabled { opacity: .55; cursor: not-allowed; }

.soft-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}
.soft-button:hover { color: var(--blue); border-color: var(--line-strong); background: var(--panel-soft); }

.ghost-button {
  color: var(--blue);
  border: 1px solid transparent;
  background: transparent;
}
.ghost-button:hover { background: var(--blue-soft); }

.danger-button {
  color: #fff;
  border: 1px solid transparent;
  background: linear-gradient(100deg, #e25c4a, #ef7d5f);
}
.danger-button:hover { filter: brightness(1.05); }
.danger-button:disabled { opacity: .55; cursor: not-allowed; }

.link-button,
.text-button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--blue);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s ease;
}
.link-button:hover,
.text-button:hover { background: var(--blue-soft); }

/* 危险链接（删除/解绑类） */
.link-button.danger-link,
.text-button.danger-link {
  color: var(--red);
}
.link-button.danger-link:hover,
.text-button.danger-link:hover {
  color: #c24b39;
  background: var(--red-soft);
}

/* 表格中的并排操作需要明确的按钮边界，避免多个文字链接连成一串。 */
#view .data-table .table-actions .link-button {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
#view .data-table .table-actions .link-button:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
  text-decoration: none;
}
#view .data-table .table-actions .link-button.danger-link,
#view .data-table .table-actions .link-button.danger-text {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 35%, var(--line-strong));
  background: var(--panel);
}
#view .data-table .table-actions .link-button.danger-link:hover,
#view .data-table .table-actions .link-button.danger-text:hover {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-soft);
}

/* Dashboard action links also carry the generic table-link class. The more
   specific generic rule above must not turn the primary action into white on
   white; keep the theme primary treatment explicit and readable. */
#view.route-dashboard .dashboard-table-actions .dashboard-table-action-primary {
  color: #fff !important;
  border-color: var(--blue) !important;
  background: var(--blue) !important;
  box-shadow: 0 2px 5px color-mix(in srgb, var(--blue) 18%, transparent);
}
#view.route-dashboard .dashboard-table-actions .dashboard-table-action-primary:hover {
  color: #fff !important;
  border-color: var(--blue-hover) !important;
  background: var(--blue-hover) !important;
}

.icon-button {
  min-width: 36px;
  min-height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.icon-button:hover { background: var(--blue-soft); color: var(--blue); }

/* 按钮内的 spinner（阶段 2 配套） */
.button-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: tz-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes tz-spin { to { transform: rotate(360deg); } }


/* --- 第 5 节（原 design-tokens.css） --- */
/* ============ 5. 卡片统一 ============ */
#view .card,
.app-shell .card {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow-sm);
}
#view .card:hover { box-shadow: var(--shadow-md); }
#view .keyword-foundation-grid > .card .card-header {
  padding-left: 62px;
}
#view .card-header h3 { color: var(--ink-strong); font-size: 15px; font-weight: 700; }
#view .card-header p { color: var(--muted); font-size: 12px; }


/* --- 第 6 节（原 design-tokens.css） --- */
/* ============ 6. 输入框统一 ============ */
#view .input,
#view .textarea,
#view .field input,
#view .field textarea {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#view .input:focus,
#view .textarea:focus,
#view .field input:focus,
#view .field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(184, 68, 47, .12);
}
#view .input.input-error,
#view .field input.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(226, 92, 74, .12);
}
#view .input::placeholder,
#view .field input::placeholder { color: var(--muted-2); }

/* File inputs need an explicit theme treatment because the browser's native
   selector button otherwise falls back to a platform-gray control. Keep the
   native filename affordance, but make its container and button use the same
   warm surface, border, typography, and focus signal as the rest of the app. */
#view .input[type="file"],
#modal-root .input[type="file"] {
  min-height: 40px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--panel);
  cursor: pointer;
}
#view .input[type="file"]::file-selector-button,
#modal-root .input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-soft);
  font: inherit;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
#view .input[type="file"]:hover,
#modal-root .input[type="file"]:hover {
  border-color: var(--blue);
}
#view .input[type="file"]:hover::file-selector-button,
#modal-root .input[type="file"]:hover::file-selector-button {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}
#view .input[type="file"]:focus-visible,
#modal-root .input[type="file"]:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(184, 68, 47, .12);
}

/* Monitoring's suggestion selector is an explicitly compact control. Keep
   its 30px geometry after the shared 40px form primitive without changing
   the shared input/select/textarea contract. */
#view .monitoring-suggestion-control .select {
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

/* Shared form primitives: compact checkboxes remain compact; radios stay circular
   even when legacy markup carries the checkbox helper class. */
#view .checkbox,
#modal-root .checkbox {
  width: 17px;
  height: 17px;
  border-color: var(--line-strong);
  border-radius: 5px;
}
#view .keyword-chip > .checkbox { width: 15px; height: 15px; }
#view input[type="radio"],
#modal-root input[type="radio"] {
  appearance: none;
  width: 17px;
  height: 17px;
  margin: 0;
  flex: 0 0 17px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel);
  cursor: pointer;
}
#view input[type="radio"]:checked,
#modal-root input[type="radio"]:checked {
  border-color: var(--blue);
  background: radial-gradient(circle, var(--blue) 0 4px, var(--panel) 4.5px 100%);
}
#view input[type="checkbox"]:disabled,
#view input[type="radio"]:disabled,
#modal-root input[type="checkbox"]:disabled,
#modal-root input[type="radio"]:disabled { cursor: not-allowed; opacity: .55; }

/* Keyboard focus uses the same warm brand signal on every route. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(184, 68, 47, .2);
  outline-offset: 2px;
}


/* --- 第 7 节（原 design-tokens.css） --- */
/* ============ 7. 表格统一 ============ */
#view .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#view .data-table thead th {
  padding: 12px 16px;
  color: var(--muted);
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
#view .data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}
#view .data-table tbody tr:hover td { background: var(--panel-soft); }
#view .table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }


/* --- 第 8 节（原 design-tokens.css） --- */
/* ============ 8. 标签徽章统一 ============ */
#view .status-badge,
#view .source-tag,
#view .small-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 620;
  line-height: 1.25;
  white-space: nowrap;
}
#view .status-badge.status-approved,
#view .status-badge.status-published,
#view .status-badge.status-success,
#view .status-badge.status-online { color: var(--green); background: var(--green-soft); }
#view .status-badge.status-draft,
#view .status-badge.status-archived { color: var(--muted); background: rgba(0, 0, 0, .055); }
#view .status-badge.status-review,
#view .status-badge.status-pending,
#view .status-badge.status-running,
#view .status-badge.status-queued,
#view .status-badge.status-publishing { color: var(--amber); background: var(--amber-soft); }
#view .status-badge.status-error,
#view .status-badge.status-failed,
#view .status-badge.status-warning,
#view .status-badge.status-login { color: #c24b39; background: var(--red-soft); }
#view .source-tag { color: var(--blue); background: var(--blue-soft); }
#view .small-tag { color: var(--blue); background: var(--blue-soft); }

/* Modal badges use the same semantic map as route content. */
#modal-root .status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 620;
  line-height: 1.25;
  white-space: nowrap;
}
#modal-root .status-badge.status-approved,
#modal-root .status-badge.status-success,
#modal-root .status-badge.status-online { color: var(--green); background: var(--green-soft); }
#modal-root .status-badge.status-draft,
#modal-root .status-badge.status-archived { color: var(--muted); background: rgba(0, 0, 0, .055); }
#modal-root .status-badge.status-review,
#modal-root .status-badge.status-pending,
#modal-root .status-badge.status-running,
#modal-root .status-badge.status-queued,
#modal-root .status-badge.status-publishing { color: var(--amber); background: var(--amber-soft); }
#modal-root .status-badge.status-error,
#modal-root .status-badge.status-failed,
#modal-root .status-badge.status-warning,
#modal-root .status-badge.status-login { color: #c24b39; background: var(--red-soft); }

/* Specialized editor controls are still inputs/textareas and share the same
   warm keyboard and focus ring as the base form primitive. */
#view .studio-title-input:focus,
#view .studio-composer-input:focus,
#view .studio-agent-select:focus,
#view .analysis-follow-up textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(184, 68, 47, .12);
}
#view .studio-editor-body:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(184, 68, 47, .12);
}
#view .input:focus-visible,
#view .select:focus-visible,
#view .textarea:focus-visible,
#view .field input:focus-visible,
#view .field select:focus-visible,
#view .field textarea:focus-visible,
#view .effect-demo-input input:focus-visible,
#view .effect-demo-input select:focus-visible,
#view .effect-demo-input textarea:focus-visible {
  outline: 3px solid rgba(184, 68, 47, .2);
  outline-offset: 2px;
}
#modal-root .input:focus-visible,
#modal-root .select:focus-visible,
#modal-root .textarea:focus-visible,
#modal-root .field input:focus-visible,
#modal-root .field select:focus-visible,
#modal-root .field textarea:focus-visible {
  outline: 3px solid rgba(184, 68, 47, .2);
  outline-offset: 2px;
}
#view .plan-platform-hints summary:focus-visible,
#view .public-citation-setting input:focus-visible + i {
  outline: 3px solid rgba(184, 68, 47, .2);
  outline-offset: -3px;
}
.production-auth-card .production-password-toggle:focus-visible {
  outline: 3px solid rgba(184, 68, 47, .2);
  outline-offset: 2px;
}


/* --- 第 9 节（原 design-tokens.css） --- */
/* ============ 9. 弹窗统一 ============ */
.modal-backdrop {
  backdrop-filter: blur(3px);
  background: rgba(23, 24, 47, .38);
}
.modal-dialog {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: tz-modal-in .22s cubic-bezier(.2, .7, .2, 1);
}
@keyframes tz-modal-in {
  from { opacity: 0; transform: translate(-50%, -50%) translateY(12px) scale(.985); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
.modal-head { min-height: 64px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { color: var(--ink-strong); font-size: 16px; font-weight: 720; }
.modal-head p { color: var(--muted); font-size: 12px; }
.modal-body { padding: 22px 24px; }
.modal-foot {
  min-height: 62px;
  padding: 0 24px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}
.modal-foot-right { display: flex; align-items: center; gap: 10px; }


/* --- 第 10 节（原 design-tokens.css） --- */
/* ============ 10. 空状态统一 ============ */
#view .empty-state,
#view .empty-copy,
#view .monitor-real-empty,
#view .diagnostic-empty,
#view .effect-search-empty,
#view .asset-publication-empty {
  display: grid;
  min-height: 140px;
  place-items: center;
  padding: 28px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-soft);
  text-align: center;
}
#view .empty-state h3,
#view .empty-copy h3 { color: var(--ink); font-size: 15px; margin-bottom: 8px; }
#view .empty-state p,
#view .empty-copy p { font-size: 12px; color: var(--muted); line-height: 1.6; }


/* --- 第 11 节（原 design-tokens.css） --- */
/* ============ 11. 加载态 ============ */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #efecf9;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  animation: tz-skeleton 1.4s ease infinite;
}
@keyframes tz-skeleton { to { transform: translateX(100%); } }

/* AI 对话「思考中」动画 */
.studio-thinking-dots { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; vertical-align: middle; }
.studio-thinking-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); opacity: .35; animation: tz-blink 1.2s ease infinite; }
.studio-thinking-dots i:nth-child(2) { animation-delay: .2s; }
.studio-thinking-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes tz-blink { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.studio-message.is-thinking-message .studio-message-card { color: var(--muted); font-style: italic; }

/* 页面切换顶部进度条 */
.tz-route-progress {
  position: fixed;
  z-index: 300;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--blue);
  box-shadow: 0 1px 6px rgba(184, 68, 47, .32);
  transition: width .3s ease;
}


/* --- 第 12 节（原 design-tokens.css） --- */
/* ============ 12. Toast 分级 ============ */
.toast { border-radius: 12px; box-shadow: var(--shadow-md); }
.toast.success { border-left: 4px solid var(--green); }
.toast.warning { border-left: 4px solid var(--amber); }
.toast.warning .toast-icon,
.toast.warning [data-icon] { color: var(--amber); }
.toast.info { border-left: 4px solid var(--blue); }
.toast.info .toast-icon,
.toast.info [data-icon] { color: var(--blue); }
.toast.error { border-left: 4px solid var(--red); }


/* --- 第 13 节（原 design-tokens.css） --- */
/* ============ 13. 页头统一 ============ */
#view .page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

/* planning 分类页签：防止文字挤压溢出 */
#view .category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  overflow: visible;
}
#view .category-tabs button,
#view .category-tabs .filter-chip {
  white-space: nowrap;
  flex-shrink: 0;
}
#view .page-head h2 { color: var(--ink-strong); font-size: 26px; font-weight: 620; letter-spacing: -.6px; line-height: 1.3; }
#view .page-head p { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.65; }
#view .page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }


/* --- 第 14 节（原 design-tokens.css） --- */
/* ============ 14. 移动端断点（统一 3 档） ============ */
@media (max-width: 1180px) {
  #view .page-head { flex-wrap: wrap; }
  #view .page-actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 860px) {
  #main-content { padding: 22px 18px 44px; }
  #view .page-head { flex-direction: column; align-items: flex-start; }
  #view .page-head .page-actions { width: 100%; }
  #view .modal-dialog { margin: 24px 12px; }
  #view .card-header { padding: 0 16px; }
  #view .modal-body { padding: 18px 16px; }
  #view .modal-foot { padding: 0 16px; }
  #view .table-scroll { border-radius: 10px; }
}
@media (max-width: 640px) {
  #main-content { padding: 18px 12px 36px; }
  #view .page-actions .primary-button,
  #view .page-actions .secondary-button { width: 100%; }
  #view .data-table thead { display: none; }
  #view .data-table tbody td { display: block; padding: 9px 14px; border-bottom: 0; }
  #view .data-table tbody tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
}

/* 轻量分页 */
.light-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}


/* --- 第 15 节（原 design-tokens.css） --- */
/* ============ 15. 表格短列防竖排 ============ */
#view .data-table {
  table-layout: auto;
}
/* 短内容列（作者/版本/操作/状态等）不允许按字断行 */
#view .data-table td .table-subtext,
#view .data-table td small,
#view .data-table .article-title-cell small,
#view .data-table td .table-actions,
#view .data-table td .link-button,
#view .data-table .article-agent-cell,
#view .data-table .article-source-cell,
#view .data-table .article-title-cell b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
/* 操作列给足宽度，避免链接竖排 */
#view .data-table .table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 140px;
}
#view .data-table td:nth-last-child(1) {
  min-width: 120px;
}


/* --- 第 16 节（原 design-tokens.css） --- */
/* ============ 16. 确认弹窗样式（补 renderConfirmModal 缺失类） ============ */
.confirm-message {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.confirm-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  background: var(--red-soft);
}
.confirm-icon svg {
  width: 22px;
  height: 22px;
}
.confirm-message p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  margin: 0;
  padding-top: 9px;
}
/* 提示文字移到按钮上方 */
.modal-foot > span:first-child {
  display: block;
  font-size: 12px;
  color: var(--muted);
  padding-right: 16px;
  line-height: 1.5;
}


/* --- 第 17 节（原 design-tokens.css） --- */
/* ============ 17. 弹窗打开时隐藏浮动按钮 ============ */
body.modal-open .selection-bar,
body.modal-open .fab,
body.modal-open [data-role="fab"],
body.modal-open .floating-action-button,
body.modal-open .quick-action-fab {
  display: none !important;
}


/* --- 第 18 节（原 design-tokens.css） --- */
/* ============ 18. 侧边栏导航图标统一（消除多文件尺寸/描边冲突） ============ */
.nav-icon { display: inline-grid; width: 20px; height: 20px; margin-right: 12px; flex: 0 0 auto; place-items: center; color: inherit; }
.nav-icon svg { width: 18px; height: 18px; stroke-width: 1.7; }
.nav-effect-items .nav-icon,
.nav-effect-items .nav-icon svg { width: 17px; height: 17px; }
.nav-effect-items .nav-icon { margin-right: 10px; }
.nav-effect-toggle .nav-icon,
.nav-effect-toggle .nav-icon svg { width: 18px; height: 18px; }
