/* Hallmark · macrostructure: Workbench · tone: technical · anchor hue: cool-blue */

@import url("tokens.css");

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

html, body {
  overflow: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

html:fullscreen,
html:-webkit-full-screen {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  overflow: hidden !important;
  background: var(--color-ink);
  writing-mode: horizontal-tb;
}

html:fullscreen body,
html:-webkit-full-screen body,
html.is-fs body {
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  writing-mode: horizontal-tb;
}

body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  background: var(--color-ink);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-ui);
  line-height: 1.4;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

h1, h2, h3, .brand {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 700;
  overflow-wrap: anywhere;
  min-width: 0;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip:focus {
  left: var(--space-3);
  top: var(--space-3);
  z-index: 40;
  padding: var(--space-2) var(--space-3);
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.menubar {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 20;
  min-height: var(--menu-h);
  height: var(--menu-h);
  padding: 0 var(--space-2);
  overflow: visible;
  background: var(--color-ink);
  border-bottom: var(--rule) solid var(--color-line);
}

.menubar-left {
  display: flex;
  align-items: stretch;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.menubar-left > * {
  pointer-events: auto;
}

.menubar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  max-width: 48%;
  padding: 0 var(--space-3);
  overflow: hidden;
  transform: translate(-50%, -50%);
}

.menu {
  position: relative;
  height: 100%;
}

.menu > button {
  height: 100%;
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--color-text);
  white-space: nowrap;
  cursor: pointer;
}

.menu > button:hover,
.menu.open > button {
  background: var(--color-surface);
}

.menu-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  min-width: 268px;
  padding: var(--space-1) 0;
  background: var(--color-surface);
  border: var(--rule) solid var(--color-line);
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.28);
}

.menu.open > .menu-panel,
.menu-panel:focus-within {
  display: block;
}

.menu-panel button,
.menu-panel a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
  padding: 7px var(--space-4);
  border: 0;
  background: transparent;
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.menu-panel button:hover,
.menu-panel a:hover {
  background: var(--color-surface-hi);
}

.menu-panel button:disabled {
  color: var(--color-mute);
  cursor: default;
}

.menu-panel .kbd {
  flex: none;
  color: var(--color-mute);
  font-size: var(--text-small);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.menu-sep {
  height: var(--rule);
  margin: var(--space-1) 0;
  background: var(--color-line);
}

.brand {
  flex: none;
  margin: 0;
  font-size: 1.375rem;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#title {
  width: 440px;
  max-width: 100%;
  min-width: 0;
  height: 26px;
  padding: 0 var(--space-2);
  background: var(--color-field);
  border: var(--rule) solid var(--color-line);
  color: var(--color-text);
}

.file-bar {
  display: flex;
  flex-wrap: nowrap;
  flex: 1 1 0;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-1);
  z-index: 2;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.file-bar > * {
  pointer-events: auto;
}

.toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  height: var(--toolbar-h);
  padding: 0 var(--space-3);
  border-bottom: var(--rule) solid var(--color-line);
}

.tools, .cables {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.hint {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-dim);
  font-size: var(--text-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cable-lab {
  padding: 0 var(--space-2) 0 var(--space-3);
  color: var(--color-text-dim);
  font-size: var(--text-small);
}

.cable-sep {
  flex: none;
  width: 1px;
  height: 16px;
  margin: 0 var(--space-2);
  background: var(--color-line);
}

.swatch {
  width: 20px;
  height: 20px;
  margin-left: var(--space-2);
  border: var(--rule) solid oklch(0% 0 0 / 0.35);
  border-radius: 50%;
  cursor: pointer;
}

.workbench {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.workbench.has-ai-split {
  grid-template-columns: var(--rail-w) minmax(280px, 1fr) 6px minmax(320px, var(--ai-panel-w, 1fr));
}

.workbench.ai-split-maximized {
  grid-template-columns: var(--rail-w) 0px 0px minmax(0, 1fr);
}

.workbench.ai-split-maximized .canvas-host,
.workbench.ai-split-maximized .ai-split-resizer {
  display: none !important;
}

.rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--color-ink);
  border-right: var(--rule) solid var(--color-line);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex: none;
  padding: var(--space-3) var(--space-3) 0;
}

.rail h2 {
  margin: 0;
  padding: 0;
  font-size: var(--text-ui);
}

.rail .sub {
  margin: 0;
  padding: 0 var(--space-3) var(--space-2);
  color: var(--color-text-dim);
  font-size: var(--text-small);
  flex: none;
}

#lib-search {
  position: relative;
  z-index: 1;
  flex: none;
  margin: 0 var(--space-3) var(--space-2);
  height: 32px;
  padding: 0 var(--space-2);
  background: var(--color-surface);
  border: var(--rule) solid var(--color-line);
}

.lib-list {
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  height: auto;
  padding: 0 var(--space-2) var(--space-2);
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--color-line) var(--color-ink);
}

.lib-list::-webkit-scrollbar {
  width: 10px;
}

.lib-list::-webkit-scrollbar-track {
  background: var(--color-ink);
}

.lib-list::-webkit-scrollbar-thumb {
  background: var(--color-line);
  border-radius: 6px;
}

.lib-list::-webkit-scrollbar-thumb:hover {
  background: var(--color-mute);
}

.lib-cat {
  margin: 8px var(--space-1) 2px;
  color: var(--color-text-dim);
  font-size: var(--text-small);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lib-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 32px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.lib-row:hover {
  background: var(--color-surface);
}

.lib-row.active {
  background: var(--color-pick);
  box-shadow: inset 3px 0 0 var(--color-accent);
}

.lib-row canvas {
  width: 22px;
  height: 22px;
}

.lib-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-row .chip {
  padding: 2px 6px;
  background: var(--color-surface);
  color: var(--color-text-dim);
  font-size: var(--text-small);
}

.lib-row.active .chip,
.lib-row:hover .chip {
  background: var(--color-ink);
}

.canvas-host {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--color-paper);
}

#topo {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--color-paper);
  touch-action: none;
}

.status {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-height: 28px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  white-space: nowrap;
  writing-mode: horizontal-tb;
  cursor: pointer;
}

.btn:hover, .btn.is-hover { background: var(--color-surface-hi); }
.btn:active, .btn.is-active { transform: translateY(1px); }
.btn:focus-visible, .btn.is-focus {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.btn:disabled, .btn.is-disabled {
  color: var(--color-mute);
  cursor: default;
  transform: none;
}
.btn[data-state="loading"] { opacity: 0.7; }
.btn[data-state="error"] { box-shadow: inset 0 0 0 1px var(--color-error); }
.btn[data-state="success"] { box-shadow: inset 0 0 0 1px var(--color-success); }

.btn.primary, .btn.selected {
  background: var(--color-accent);
  color: var(--color-on-accent);
  box-shadow: inset 0 0 0 1px var(--color-accent-rim);
}
.btn.primary:hover, .btn.selected:hover { background: var(--color-accent-hi); }
.btn.primary:active { background: var(--color-accent-press); }

.btn.danger {
  background: var(--color-danger);
  color: var(--color-on-accent);
}
.btn.danger:hover { background: var(--color-danger-hi); }
.btn.danger:active { background: var(--color-danger-press); }

.btn.quiet { background: var(--color-surface); }
.btn.ghost { background: var(--color-surface); }

.btn.wide { width: 100%; height: 32px; }

.btn.warn,
.rail-head .btn {
  width: auto;
  height: 26px;
  padding: 0 10px;
  background: #e67e22;
  color: #fff;
}

.btn.warn:hover,
.btn.warn.is-hover,
.rail-head .btn:hover,
.rail-head .btn.is-hover {
  background: #f39c12;
}

.btn.warn:active,
.rail-head .btn:active {
  background: #d35400;
}

.ctx {
  display: none;
  position: fixed;
  z-index: 40;
  min-width: 200px;
  padding: var(--space-1) 0;
  background: var(--color-surface);
  border: var(--rule) solid var(--color-line);
}

.ctx.open { display: block; }

.ctx button {
  display: block;
  width: 100%;
  padding: 7px var(--space-4);
  border: 0;
  background: transparent;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}

.ctx button:hover { background: var(--color-surface-hi); }

dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: var(--rule) solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-card);
  color: var(--color-text);
  box-shadow: 0 18px 48px var(--color-shadow);
}

dialog:focus {
  outline: none;
}

dialog::backdrop {
  background: var(--color-overlay);
}

.dlg {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
}

.dlg h3 {
  margin: 0;
  font-size: 1rem;
}

.dlg p, .dlg .mute {
  margin: 0;
  color: var(--color-mute);
}

.dlg label {
  display: grid;
  gap: var(--space-1);
  color: var(--color-text-dim);
}

.dlg input, .dlg select, .dlg textarea {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 var(--space-2);
  background: var(--color-field);
  border: var(--rule) solid var(--color-field-border);
}

.dlg textarea { height: 72px; padding: var(--space-2); resize: vertical; }

.dlg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--space-4);
}

.preview-card {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: var(--space-4);
  background: var(--color-paper);
}

.preview-card canvas { width: 96px; height: 96px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

#msg-body {
  white-space: pre-wrap;
  line-height: 1.55;
}

.dlg a {
  color: var(--color-accent-hi);
  text-underline-offset: 3px;
}

.dlg a:hover {
  color: var(--color-accent);
}

.help-body {
  white-space: pre-wrap;
  line-height: 1.55;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
}

.list-table th, .list-table td {
  padding: 8px 6px;
  border-bottom: var(--rule) solid var(--color-line);
  text-align: left;
}

.list-table tr.active { background: var(--color-surface); }

.list-table tr { cursor: pointer; }

.list-table td.act {
  width: 1%;
  text-align: right;
  white-space: nowrap;
  padding-right: 0;
}

.list-table td.act .btn {
  min-height: 26px;
  padding: 0 10px;
}

.list-table .editing-mark {
  margin-left: 6px;
  color: var(--color-mute);
  font-size: var(--text-small);
}

.btn.danger:disabled,
.btn.danger.is-disabled,
.btn.danger:disabled:hover,
.btn.danger.is-disabled:hover {
  background: var(--color-surface);
  color: var(--color-mute);
  box-shadow: none;
}

.color-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.hidden-file { display: none; }

@media (max-width: 768px) {
  body {
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .menubar {
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2) var(--space-2);
  }
  .menubar-left { height: 32px; z-index: auto; }
  .menubar-center {
    position: static;
    left: auto;
    top: auto;
    max-width: none;
    transform: none;
    justify-content: center;
    order: -1;
    padding: var(--space-1) 0;
  }
  .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: 220px minmax(0, 1fr);
  }
  .rail { border-right: 0; border-bottom: var(--rule) solid var(--color-line); }
  .toolbar { grid-template-columns: 1fr; height: auto; padding: var(--space-2); }
  .file-bar { width: 100%; height: auto; min-width: 0; flex-wrap: wrap; z-index: auto; }
  .dlg-grid { grid-template-columns: 1fr; }
  #title { width: 320px; max-width: 90vw; }
}

html:fullscreen .menubar,
html:-webkit-full-screen .menubar,
html.is-fs .menubar {
  display: flex;
  height: var(--menu-h);
  min-height: var(--menu-h);
  gap: 0;
  padding: 0 var(--space-2);
  overflow: visible;
}

html:fullscreen .menubar-left,
html:-webkit-full-screen .menubar-left,
html.is-fs .menubar-left {
  height: 100%;
}

html:fullscreen .menubar-center,
html:-webkit-full-screen .menubar-center,
html.is-fs .menubar-center {
  position: absolute;
  left: 50%;
  top: 50%;
  order: 0;
  max-width: 48%;
  padding: 0 var(--space-3);
  transform: translate(-50%, -50%);
}

html:fullscreen .file-bar,
html:-webkit-full-screen .file-bar,
html.is-fs .file-bar {
  width: auto;
  height: 100%;
  min-width: 0;
  flex-wrap: nowrap;
}

html:fullscreen .toolbar,
html:-webkit-full-screen .toolbar,
html.is-fs .toolbar {
  grid-template-columns: auto auto minmax(0, 1fr);
  height: var(--toolbar-h);
  padding: 0 var(--space-3);
}

html:fullscreen .workbench,
html:-webkit-full-screen .workbench,
html.is-fs .workbench {
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* AI 分析按钮与弹窗样式 */
.rail-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rail-head .btn.ai-btn {
  background: linear-gradient(135deg, #6c5ce7 0%, #8e44ad 100%);
  color: #ffffff;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(108, 92, 231, 0.35);
  border: none;
}

.rail-head .btn.ai-btn:hover {
  background: linear-gradient(135deg, #5b4bd8 0%, #7d3c98 100%);
  box-shadow: 0 3px 10px rgba(108, 92, 231, 0.55);
}

.rail-head .btn.ai-btn:active {
  background: #4834d4;
}

.ai-split-resizer {
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: var(--color-line);
  position: relative;
  transition: background 0.15s ease;
  user-select: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-split-resizer[hidden] {
  display: none !important;
}

.ai-split-resizer:hover,
.ai-split-resizer.is-dragging {
  background: var(--color-accent);
}

.ai-split-resizer::after {
  content: "";
  display: block;
  width: 2px;
  height: 32px;
  background: var(--color-mute);
  border-radius: 1px;
}

.ai-split-resizer:hover::after,
.ai-split-resizer.is-dragging::after {
  background: #ffffff;
}

.ai-split-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--color-card);
  border-left: var(--rule) solid var(--color-line);
  box-shadow: -4px 0 24px var(--color-shadow);
  z-index: 5;
}

.ai-split-panel[hidden] {
  display: none !important;
}

.dlg-ai-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.dlg-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: var(--rule) solid var(--color-line);
  background: var(--color-surface);
  flex: none;
}

.dlg-ai-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dlg-ai-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.4);
}

.dlg-ai-titles h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.25;
}

.dlg-ai-subtitle {
  font-size: 12px;
  color: var(--color-text-dim);
}

.dlg-ai-subtitle code {
  font-family: var(--font-mono, monospace);
  padding: 1px 5px;
  background: var(--color-field);
  border-radius: 4px;
  color: #9b59b6;
}

.dlg-ai-header-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dlg-ai-tool-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  line-height: 1;
  color: var(--color-text-dim);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dlg-ai-tool-btn:hover {
  background: var(--color-surface-hi);
  color: var(--color-text);
}

.dlg-ai-tool-btn.dlg-ai-x {
  font-size: 22px;
  padding: 2px 8px;
}

.dlg-ai-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: var(--color-field);
  border-bottom: var(--rule) solid var(--color-line);
  font-size: 12px;
  color: var(--color-text-dim);
  flex: none;
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3498db;
  display: inline-block;
}

.ai-status-dot.pulsing {
  background: #2ecc71;
  box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
  animation: ai-pulse 1.6s infinite;
}

.ai-status-dot.error {
  background: #e74c3c;
  animation: none;
}

.ai-status-dot.done {
  background: #27ae60;
  animation: none;
}

@keyframes ai-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.dlg-ai-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
  background: var(--color-card);
}

.dlg-ai-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
  word-break: break-word;
}

/* Markdown 排版增强 */
.dlg-ai-content h1, .dlg-ai-content h2, .dlg-ai-content h3, .dlg-ai-content h4 {
  margin: 1.4em 0 0.6em;
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.35;
}

.dlg-ai-content h1:first-child,
.dlg-ai-content h2:first-child,
.dlg-ai-content h3:first-child {
  margin-top: 0;
}

.dlg-ai-content h3 {
  font-size: 1.05rem;
  border-bottom: var(--rule) solid var(--color-line);
  padding-bottom: 6px;
  color: #3498db;
}

[data-theme="dark"] .dlg-ai-content h3 {
  color: #5dade2;
}

.dlg-ai-content p {
  margin: 0.8em 0;
}

.dlg-ai-content ul, .dlg-ai-content ol {
  margin: 0.6em 0 0.8em 20px;
  padding: 0;
}

.dlg-ai-content li {
  margin: 0.35em 0;
}

.dlg-ai-content strong {
  font-weight: 600;
  color: #e67e22;
}

[data-theme="dark"] .dlg-ai-content strong {
  color: #f39c12;
}

.dlg-ai-content blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  border-left: 4px solid #6c5ce7;
  background: var(--color-surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-dim);
}

.dlg-ai-content code {
  font-family: var(--font-mono, monospace);
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--color-field);
  border: var(--rule) solid var(--color-line);
  border-radius: 4px;
  color: #e74c3c;
}

[data-theme="dark"] .dlg-ai-content code {
  color: #ff7675;
}

.dlg-ai-content pre {
  margin: 1em 0;
  padding: 12px 16px;
  background: var(--color-surface);
  border: var(--rule) solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.dlg-ai-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--color-text);
}

.dlg-ai-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 13px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: var(--rule) solid var(--color-line);
}

.dlg-ai-content th, .dlg-ai-content td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: var(--rule) solid var(--color-line);
  border-right: var(--rule) solid var(--color-line);
}

.dlg-ai-content th:last-child, .dlg-ai-content td:last-child {
  border-right: none;
}

.dlg-ai-content th {
  background: var(--color-field);
  font-weight: 600;
  color: var(--color-text);
}

.dlg-ai-content tr:last-child td {
  border-bottom: none;
}

.ai-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  background: #6c5ce7;
  animation: ai-blink 0.8s infinite;
}

@keyframes ai-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.dlg-ai-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: var(--rule) solid var(--color-line);
  background: var(--color-surface);
  flex: none;
}

.dlg-ai-meta {
  font-size: 12px;
  color: var(--color-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dlg-ai-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.btn.btn-ai-retry {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: #ffffff;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.4);
  transition: all 0.15s ease;
}

.btn.btn-ai-retry:hover {
  background: linear-gradient(135deg, #ff5252 0%, #d63031 100%);
  box-shadow: 0 3px 10px rgba(231, 76, 60, 0.6);
  transform: translateY(-1px);
}

.btn.btn-ai-retry:active {
  background: #c0392b;
  transform: translateY(1px);
}
