/* HOMELAB */

:root {
  /* Default to light if no theme attribute is present */
  --bg: #ffffff;
  --bg-elev: #f7f8fa;
  --text: #1f2328;
  --muted: #6a737d;
  --border: #d0d7de;
  --accent: #0969da;
  --btn-bg: #f6f8fa;
  --btn-bg-hover: #eef1f4;
  --danger: #d1242f;
  --danger-soft: rgba(209, 36, 47, 0.12);
  --danger-soft-hover: rgba(209, 36, 47, 0.2);
  --header-h: 52px; /* default, JS passt an */
  --versions-w: 0px;
  --wysiwyg-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Light */
body[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f7f8fa;
  --text: #1f2328;
  --muted: #6a737d;
  --border: #d0d7de;
  --accent: #0969da;
  --btn-bg: #f6f8fa;
  --btn-bg-hover: #eef1f4;
  --danger: #d1242f;
  --danger-soft: rgba(209, 36, 47, 0.12);
  --danger-soft-hover: rgba(209, 36, 47, 0.2);
}

/* Dark */
body[data-theme="dark"] {
  --bg: #0d1117;
  --bg-elev: #151b23;
  --text: #e6edf3;
  --muted: #9aa6b2;
  --border: #30363d;
  --accent: #4493f8;
  --btn-bg: #161b22;
  --btn-bg-hover: #202833;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.18);
  --danger-soft-hover: rgba(255, 107, 107, 0.26);
}

/* Pitch Black */
body[data-theme="black"] {
  --bg: #000000;
  --bg-elev: #0a0a0a;
  --text: #f5f5f5;
  --muted: #c0c0c0;
  --border: #222222;
  --accent: #4da3ff;
  --btn-bg: #0f0f0f;
  --btn-bg-hover: #151515;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.22);
  --danger-soft-hover: rgba(255, 107, 107, 0.3);
}

/* High Contrast */
body[data-theme="high-contrast"] {
  --bg: #000000;
  --bg-elev: #000000;
  --text: #ffff00;
  --muted: #ffe066;
  --border: #ffffff;
  --accent: #ff8c00;
  --btn-bg: #000000;
  --btn-bg-hover: #1a1a1a;
  --danger: #ff4d00;
  --danger-soft: rgba(255, 77, 0, 0.28);
  --danger-soft-hover: rgba(255, 77, 0, 0.38);
}

/* Sepia */
body[data-theme="sepia"] {
  --bg: #f6f1e7;
  --bg-elev: #efe8dd;
  --text: #3b3024;
  --muted: #6e6256;
  --border: #e0d6c8;
  --accent: #b36b00;
  --btn-bg: #efe8dd;
  --btn-bg-hover: #e7dfd3;
  --danger: #b5392f;
  --danger-soft: rgba(181, 57, 47, 0.16);
  --danger-soft-hover: rgba(181, 57, 47, 0.24);
}

/* Solarized Light */
body[data-theme="solarized-light"] {
  --bg: #fdf6e3;
  --bg-elev: #f5edd7;
  --text: #657b83;
  --muted: #93a1a1;
  --border: #eee8d5;
  --accent: #268bd2;
  --btn-bg: #f5edd7;
  --btn-bg-hover: #efe4c8;
  --danger: #cb4b16;
  --danger-soft: rgba(203, 75, 22, 0.18);
  --danger-soft-hover: rgba(203, 75, 22, 0.26);
}

/* Solarized Dark */
body[data-theme="solarized-dark"] {
  --bg: #002b36;
  --bg-elev: #073642;
  --text: #93a1a1;
  --muted: #b3c2c3;
  --border: #0b3a46;
  --accent: #268bd2;
  --btn-bg: #073642;
  --btn-bg-hover: #0a4753;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.22);
  --danger-soft-hover: rgba(255, 107, 107, 0.32);
}

/* Terminal Classic Green */
body[data-theme="terminal-green"] {
  --bg: #000000;
  --bg-elev: #0a0a0a;
  --text: #33ff33;
  --muted: #22cc22;
  --border: #1a661a;
  --accent: #00ff00;
  --btn-bg: #0d0d0d;
  --btn-bg-hover: #1a331a;
  --danger: #ff3333;
  --danger-soft: rgba(255, 51, 51, 0.2);
  --danger-soft-hover: rgba(255, 51, 51, 0.3);
}

/* Terminal Matrix */
body[data-theme="terminal-matrix"] {
  --bg: #000000;
  --bg-elev: #001a00;
  --text: #00ff41;
  --muted: #00cc33;
  --border: #003300;
  --accent: #00ff00;
  --btn-bg: #001100;
  --btn-bg-hover: #003311;
  --danger: #ff0066;
  --danger-soft: rgba(255, 0, 102, 0.22);
  --danger-soft-hover: rgba(255, 0, 102, 0.32);
}

/* Terminal Modern */
body[data-theme="terminal-modern"] {
  --bg: #1e1e1e;
  --bg-elev: #252526;
  --text: #d4d4d4;
  --muted: #9da5b4;
  --border: #3e3e42;
  --accent: #4ec9b0;
  --btn-bg: #2d2d30;
  --btn-bg-hover: #3e3e42;
  --danger: #f48771;
  --danger-soft: rgba(244, 135, 113, 0.2);
  --danger-soft-hover: rgba(244, 135, 113, 0.3);
}

/* Terminal Colorful */
body[data-theme="terminal-colorful"] {
  --bg: #282a36;
  --bg-elev: #313340;
  --text: #f8f8f2;
  --muted: #a7a9be;
  --border: #6272a4;
  --accent: #bd93f9;
  --btn-bg: #383a59;
  --btn-bg-hover: #44475a;
  --danger: #ff5555;
  --danger-soft: rgba(255, 85, 85, 0.2);
  --danger-soft-hover: rgba(255, 85, 85, 0.3);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, Noto Sans, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
}
body.onboarding-open { overflow: hidden; }

.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "branding branding branding"
    "left center right";
  align-items: center;
  column-gap: 6px;
  row-gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky; top: 0; z-index: 100;
}
.app-header .branding {
  grid-area: branding;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.app-header .left,
.app-header .center,
.app-header .right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-header .left { grid-area: left; justify-self: start; }
.app-header .center { grid-area: center; justify-self: center; justify-content: center; }
.app-header .right { grid-area: right; justify-self: end; }
.logo { font-size: 18px; }
.logo-img {
  height: 24px;
  width: auto;
  border-radius: 6px;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.title { font-weight: 600; }
.file-name {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.primary-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  flex-wrap: nowrap;
  margin-right: 16px;
}
.primary-actions .menu-group { margin: 0; }

@media (max-width: 1200px) {
  .app-header {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "branding branding"
      "left right"
      "center center";
  }
  .app-header .left,
  .app-header .right { justify-content: center; }
  .center.file-actions { justify-content: center; }
}

@media (max-width: 900px) {
  .app-header { row-gap: 6px; padding: 8px; }
  .app-header .left,
  .app-header .right { justify-content: center; }
  .center.file-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    justify-content: flex-start;
    padding-bottom: 4px;
    margin: 0 -4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .center.file-actions > * { flex: 0 0 auto; min-width: auto; }
  .center.file-actions .primary-actions { padding: 5px 8px; flex: 0 0 auto; margin-right: 8px; }
  .center.file-actions .btn-label,
  .center.file-actions .ai-actions .btn-label { display: none; }
  .file-actions .ai-actions { margin-left: 0; gap: 6px; }
  .center.file-actions button { padding: 6px; }
  .center.file-actions .menu-group > button { padding: 6px; }
}

@media (max-width: 640px) {
  .center.file-actions {
    gap: 6px;
    padding-bottom: 2px;
  }
  .center.file-actions button,
  .center.file-actions .menu-group > button { padding: 5px; }
  .app-header .branding { flex-direction: column; text-align: center; }
  .center.file-actions .primary-actions { gap: 6px; padding: 4px 6px; margin-right: 6px; }
}

/* Buttons with icons */
.has-icon { display: inline-flex; align-items: center; gap: 6px; }
.has-icon iconify-icon { font-size: 16px; line-height: 0; }
.icon-only { display: inline-flex; align-items: center; justify-content: center; }
.icon-only iconify-icon { font-size: 18px; }
.btn-label { display: inline-block; }

button {
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
button:hover { background: var(--btn-bg-hover); }
button.active { outline: 2px solid var(--accent); }
button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
button.secondary {
  background: var(--btn-bg);
  border-color: var(--border);
}
button.secondary:hover { background: var(--btn-bg-hover); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { filter: brightness(1.05); }
button.primary:focus { color: #fff; }
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button:disabled:hover {
  background: var(--btn-bg);
}

.view-toggle button { padding: 6px 8px; }
.view-toggle .toolbar-menu { left: auto; right: 0; }
.file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.ai-actions { display: inline-flex; align-items: center; gap: 8px; }
.file-actions .ai-actions { margin-left: 40px; }
.ai-actions .menu-group { height: 100%; }
.ai-actions button { white-space: nowrap; }
.theme-select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); }
.theme-select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-switcher { display: inline-flex; align-items: center; gap: 6px; }
.theme-switcher .icon-only iconify-icon { font-size: 18px; }
.theme-switcher { position: relative; }
.theme-menu { position: absolute; top: calc(100% + 6px); right: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); padding: 6px; z-index: 200; }
.theme-menu.hidden { display: none; }
.theme-menu button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; border: 1px solid transparent; background: transparent; text-align: left; }
.theme-menu button:hover { background: var(--btn-bg-hover); border-color: var(--border); }
.theme-menu .current { outline: 2px solid var(--accent); }
.theme-menu-divider { margin: 6px 0; border-top: 1px solid var(--border); }
.theme-menu .theme-check { margin-left: auto; display: inline-flex; align-items: center; font-weight: 600; color: var(--accent); opacity: 0; transition: opacity 0.2s ease; }
.theme-menu button.checked .theme-check { opacity: 1; }

.menu-group,
.import-group,
.heading-menu-group { position: relative; display: inline-flex; }
.toolbar-menu { position: absolute; top: calc(100% + 6px); left: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; min-width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); padding: 6px; z-index: 200; display: flex; flex-direction: column; gap: 4px; }
.toolbar-menu.hidden { display: none; }
.toolbar-menu button { width: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; border: 1px solid transparent; background: transparent; text-align: left; justify-content: flex-start; }
.toolbar-menu button:hover { background: var(--btn-bg-hover); border-color: var(--border); }
.toolbar-menu .menu-badge {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--btn-bg);
}
.toolbar-menu .menu-badge.default {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(99,102,241,0.08);
}
.toolbar-menu .badge { margin-left: auto; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  justify-content: center; /* center buttons horizontally */
  position: relative;
}
.sticky-tools .toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 49;
}
.toolbar .sep { width: 1px; background: var(--border); margin: 0 4px; }
.toolbar button { font-size: 13px; }
/* ensure icon+label are centered inside the button */
.toolbar .has-icon { justify-content: center; }
/* align icons nicely on the text baseline */
.toolbar iconify-icon { line-height: 1; vertical-align: middle; }
.toolbar-color-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.snow-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.snow-canvas.hidden { display: none; }

.color-menu { min-width: 260px; gap: 8px; }
.color-menu-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 6px;
}
.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 32px);
  gap: 6px;
  padding: 0 6px 8px;
}
.color-menu .color-swatch {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--swatch-color, transparent);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.color-menu .color-swatch:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.color-menu .color-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.color-menu .color-swatch[data-color="#ffffff"] {
  box-shadow: inset 0 0 0 1px var(--border);
}
.color-menu #colorCustomBtn {
  margin-top: 4px;
}

/* Inline AI panel */
.sticky-tools .ai-inline { padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-elev); position: sticky; top: calc(var(--header-h) + var(--toolbar-only-h, 44px)); z-index: 39; }
.ai-inline { padding: 10px 14px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-elev); box-shadow: 0 2px 10px rgba(0,0,0,0.04) inset; }
.ai-inline.hidden { display: none; }
.ai-inline .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.ai-inline .row:last-child { margin-bottom: 0; }
.ai-inline input[type="text"] { flex: 1; min-width: 260px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.ai-inline button { padding: 8px 10px; }
.ai-inline button.secondary { background: var(--btn-bg); }
.ai-inline .preset-picker { position: relative; display: flex; align-items: stretch; gap: 10px; min-width: 260px; }
.ai-inline .preset-picker-label { display: flex; align-items: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.ai-inline .preset-toggle { display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); min-width: 240px; box-shadow: 0 1px 0 rgba(0,0,0,0.02); transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; }
.ai-inline .preset-toggle:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.ai-inline .preset-toggle:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.25); }
.ai-inline .preset-toggle-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.ai-inline .preset-active-name { font-weight: 600; color: var(--text); line-height: 1.2; }
.ai-inline .preset-active-details {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.ai-inline .preset-active-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ai-inline .preset-active-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.ai-inline .preset-active-icon iconify-icon {
  width: 14px;
  height: 14px;
}
.ai-inline .preset-active-separator {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  font-weight: 500;
}
.ai-inline .preset-toggle[data-selected="false"] .preset-active-name { color: var(--muted); }
.ai-inline .preset-menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 40; min-width: 320px; max-width: min(520px, calc(100vw - 32px)); max-height: 360px; overflow: auto; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev); box-shadow: 0 16px 36px rgba(15,23,42,0.16); display: flex; flex-direction: column; gap: 16px; }
.ai-inline .preset-menu.hidden { display: none; }
.ai-inline .preset-menu::-webkit-scrollbar { width: 8px; }
.ai-inline .preset-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.ai-inline .preset-group { display: flex; flex-direction: column; gap: 8px; }
.ai-inline .preset-group-header { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
.ai-inline .preset-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.ai-inline .preset-group-icon iconify-icon {
  width: 18px;
  height: 18px;
}
.ai-inline .preset-group-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.ai-inline .preset-option { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); text-align: left; cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; }
.ai-inline .preset-option:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(15,23,42,0.12); transform: translateY(-1px); }
.ai-inline .preset-option:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.25); }
.ai-inline .preset-option.is-active { border-color: var(--accent); background: rgba(99,102,241,0.08); }
.ai-inline .preset-option-name { font-weight: 600; }
.ai-inline .preset-option-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.ai-inline .preset-menu-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }
.ai-inline .chip { border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.ai-inline .chip:hover { background: var(--btn-bg-hover); }
.ai-inline label { display: inline-flex; align-items: center; gap: 6px; }
.ai-inline input[type="range"] { accent-color: var(--accent); }
.ai-inline select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - (var(--header-h, 52px) + var(--toolbar-total-h, 44px) + var(--status-h, 32px)));
}
.layout.layout-edit { grid-template-columns: 1fr 0; }
.layout.layout-reader { grid-template-columns: 0 1fr; }
.layout.layout-wysiwyg { grid-template-columns: 0 1fr; }
/* Hide the inactive pane to avoid any overlay capturing events */
.layout.layout-edit .preview-pane { display: none; }
.layout.layout-reader .editor-pane { position: relative; width: 0; overflow: hidden; border: 0; }
.layout.layout-reader #editor { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.layout.layout-wysiwyg .editor-pane { position: relative; width: 0; overflow: hidden; border: 0; }
.layout.layout-wysiwyg #editor { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.editor-pane, .preview-pane { min-width: 0; }
.editor-pane { border-right: 1px solid var(--border); }

#editor {
  width: 100%; height: 100%;
  border: none; outline: none; resize: none;
  padding: 16px; background: var(--bg); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, Liberation Mono, monospace;
  font-size: 14px; line-height: 1.6;
  pointer-events: auto;
}

#preview {
  padding: 16px 20px 40px; overflow: auto; height: 100%;
}

#wysiwygEditor {
  padding: 16px 20px 40px; overflow: auto; height: 100%;
  display: none;
  outline: none;
  cursor: text;
}

.layout.layout-wysiwyg #preview {
  display: none;
}

.layout.layout-wysiwyg #wysiwygEditor {
  display: block;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 60px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--wysiwyg-shadow);
}

.layout.layout-wysiwyg .preview-pane {
  background: var(--bg-elev);
}

#preview .embedded-video,
.markdown-body .embedded-video {
  width: 100%;
  max-width: 100%;
  display: block;
  margin: 16px 0;
  border: 0;
}

#preview iframe.embedded-video,
.markdown-body iframe.embedded-video {
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
}

#preview video.embedded-video,
.markdown-body video.embedded-video {
  height: auto;
}

.statusbar {
  display: flex; align-items: center; gap: 16px;
  padding: 6px 12px; border-top: 1px solid var(--border);
  background: var(--bg-elev); color: var(--muted);
  font-size: 12px; height: 32px;
}

.updates-group {
  display: grid;
  gap: 16px;
}

.updates-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.updates-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.updates-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.updates-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.updates-item:hover {
  border-color: var(--border);
  background: var(--btn-bg-hover);
}

.updates-item-message {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, Liberation Mono, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 0;
}

.updates-item-meta {
  font-size: 12px;
  color: var(--muted);
}

.updates-item-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  align-self: flex-start;
}

.updates-item-link:hover,
.updates-item-link:focus {
  text-decoration: underline;
}

.updates-reload {
  align-self: flex-start;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.updates-reload:hover {
  background: var(--btn-bg-hover);
}

.updates-reload iconify-icon {
  font-size: 16px;
}

.blog-feed-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.blog-feed-header .updates-reload {
  margin-left: auto;
}

.blog-feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blog-feed-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.blog-feed-item h5 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.blog-feed-link {
  color: var(--text);
  text-decoration: none;
}

.blog-feed-link:hover,
.blog-feed-link:focus {
  color: var(--accent);
  text-decoration: underline;
}

.blog-feed-thumb {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

.blog-feed-thumb img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  aspect-ratio: 16 / 9;
}

.blog-feed-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.blog-feed-excerpt {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.blog-feed-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.blog-feed-empty {
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

#blogFeedTimestamp {
  font-size: 12px;
  margin-top: -6px;
}

/* Markdown body tweaks */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.markdown-body pre, .markdown-body code { background: var(--bg-elev); }
.markdown-body pre { border: 1px solid var(--border); padding: 12px; border-radius: 6px; overflow: auto; }
.markdown-body blockquote { color: var(--muted); border-left: 4px solid var(--border); margin: 0; padding: 0 12px; }
.markdown-body .md-align-left,
.markdown-body .md-align-center,
.markdown-body .md-align-right {
  margin: 16px 0;
}
.markdown-body .md-align-left { text-align: left; }
.markdown-body .md-align-center { text-align: center; }
.markdown-body .md-align-right { text-align: right; }
.markdown-body table { border-collapse: collapse; width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 8px; }
.markdown-body .mermaid {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  overflow-x: auto;
  display: block;
  color: var(--text);
}
.markdown-body .mermaid svg {
  width: 100%;
  height: auto;
  color: var(--text);
}
.markdown-body .mermaid svg text {
  fill: currentColor;
}
body[data-theme="high-contrast"] .markdown-body .mermaid {
  background: var(--bg);
  border-color: var(--accent);
}

/* Drag & drop cue */
body.dragging #workspace { outline: 3px dashed var(--accent); outline-offset: -6px; }

/* Reader mode: hide toolbar for clean reading */
/* keep tools visible in reader mode */

/* When chat is open, reserve space so content is not covered */
body.chat-open #workspace,
body.versions-open #workspace {
  margin-right: calc(var(--chat-w, 0px) + var(--versions-w, 0px));
}
body.chat-open .statusbar,
body.versions-open .statusbar {
  padding-right: calc(12px + var(--chat-w, 0px) + var(--versions-w, 0px));
}
body.chat-open #workspace .ai-inline,
body.versions-open #workspace .ai-inline {
  margin-right: calc(var(--chat-w, 0px) + var(--versions-w, 0px));
}

/* Responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .layout.layout-edit { grid-template-columns: 1fr; }
  .layout.layout-reader { grid-template-columns: 1fr; }
  .layout.layout-wysiwyg { grid-template-columns: 1fr; }
  .editor-pane { border-right: none; border-bottom: 1px solid var(--border); height: 45vh; }
  .layout.layout-wysiwyg #wysiwygEditor {
    padding: 20px 16px;
    max-width: 100%;
  }
}

/* Print: show only preview to export as PDF */
@media print {
  .app-header, .toolbar, .statusbar, .editor-pane { display: none !important; }
  .layout { grid-template-columns: 1fr !important; height: auto !important; }
  .preview-pane { display: block !important; }
  body { background: #ffffff !important; color: #000 !important; }
  #preview { padding: 0 !important; }
  .markdown-body pre { break-inside: avoid; }
}

/* Onboarding tutorial */
.onboarding {
  position: fixed;
  inset: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 23, 0.65);
  backdrop-filter: blur(4px);
  z-index: 120;
}
.onboarding.hidden { display: none; }
.onboarding-dialog {
  background: var(--bg);
  color: var(--text);
  border-radius: 16px;
  padding: 24px;
  width: min(520px, 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 20px;
}
.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.onboarding-counter {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.onboarding-body { display: grid; gap: 12px; }
.onboarding-body h2 { margin: 0; font-size: 24px; }
.onboarding-description { margin: 0; font-size: 15px; color: var(--muted); }
.onboarding-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  font-size: 14px;
}
.onboarding-dots { display: flex; justify-content: center; gap: 8px; }
.onboarding-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: transform 0.2s ease, background 0.2s ease;
}
.onboarding-dot.active {
  background: var(--accent);
  transform: scale(1.25);
}
.onboarding-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.onboarding-actions .spacer { flex: 1; }

@media (max-width: 640px) {
  .onboarding-dialog {
    padding: 20px;
    width: min(92vw, 480px);
  }
  .onboarding-body h2 { font-size: 20px; }
}

/* Chat panel */
.chat-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.15); backdrop-filter: none; z-index: 30; pointer-events: auto; }
.chat-panel { position: fixed; top: calc(var(--header-h) + var(--toolbar-only-h, 44px)); right: 0; width: min(560px, 100%); height: calc(100% - (var(--header-h) + var(--toolbar-only-h, 44px))); background: var(--bg-elev); color: var(--text); border-left: 1px solid var(--border); z-index: 60; display: flex; flex-direction: column; }
.chat-panel.hidden, .chat-overlay.hidden { display: none; }
.chat-panel[data-chat-view="assistant"] .chat-only { display: none; }
.chat-panel .chat-header { position: relative; }
.chat-panel .chat-header .spacer { display: none; }
.chat-panel #chatSuggestionsToggle { margin-left: auto; }
.chat-panel[data-chat-view="assistant"] #chatCloseBtn { margin-left: auto; }
.chat-panel .chat-model-badge {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(60%, 280px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.chat-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--btn-bg);
}
.chat-mode-toggle button {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.chat-mode-toggle button.active {
  background: var(--accent);
  color: #fff;
  outline: none;
}
.chat-mode-toggle button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-view.hidden { display: none; }
#chatConversationView .chat-intro {
  margin: 10px 12px 0;
  font-size: 12px;
  color: var(--muted);
}
#chatAssistantView .assistant-intro {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}
.chat-intro.hidden,
.assistant-intro.hidden { display: none; }
#chatAssistantView { overflow: auto; }
.chat-panel .ai-inline {
  position: static;
  padding: 14px 14px 18px;
  border: none;
  background: transparent;
  box-shadow: none;
}
.chat-panel .ai-inline .row { margin-bottom: 12px; }
.chat-panel .ai-inline .row:last-child { margin-bottom: 0; }
.chat-panel #chatAssistantView .ai-inline {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
  gap: 12px;
}
.chat-panel #chatAssistantView .assistant-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}
.chat-panel #chatAssistantView .assistant-primary {
  display: block;
}
.chat-panel #chatAssistantView .assistant-primary textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  max-height: 40vh;
}
.chat-panel #chatAssistantView .assistant-secondary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.chat-panel #chatAssistantView .assistant-secondary .preset-picker {
  min-width: 0;
  width: 100%;
}
.chat-panel #chatAssistantView .assistant-secondary .preset-toggle {
  width: 100%;
  justify-content: space-between;
}
.chat-panel #chatAssistantView .assistant-secondary .preset-menu {
  top: auto;
  bottom: calc(100% + 8px);
  max-height: min(360px, 40vh);
}
.chat-panel #chatAssistantView .assistant-actions {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}
.chat-panel #chatAssistantView .assistant-actions .chk {
  justify-self: start;
}
.chat-panel #chatAssistantView .assistant-actions button { width: 100%; }
.chat-panel #chatAssistantView .chat-attachments { margin-bottom: 4px; }
@media (max-width: 520px) {
  .chat-panel #chatAssistantView .assistant-secondary,
  .chat-panel #chatAssistantView .assistant-actions {
    grid-template-columns: 1fr;
  }
}

.templates-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px); z-index: 140; }
.templates-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, 94vw);
  max-height: min(90vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.35);
  z-index: 150;
  overflow: hidden;
}
.templates-panel.hidden, .templates-overlay.hidden { display: none; }
body.templates-open { overflow: hidden; }
body.template-preview-open { overflow: hidden; }
.templates-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px;
  padding-right: 72px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 10;
}
.templates-header strong { font-size: 16px; }
.template-search { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--muted); min-width: 0; margin-left: auto; }
.template-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  margin-left: auto;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.template-ai-btn:hover {
  background: var(--btn-bg-hover);
}
.template-ai-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.template-ai-btn iconify-icon {
  font-size: 18px;
}
.template-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.template-upload-btn:hover {
  background: var(--btn-bg-hover);
  border-color: var(--accent);
}
.template-upload-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.template-upload-btn iconify-icon {
  font-size: 18px;
}
.template-ai-btn.is-busy {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}
.template-ai-btn.is-busy iconify-icon {
  animation: template-ai-spin 1s linear infinite;
}
.template-ai-btn[aria-busy="true"] {
  pointer-events: auto;
}
.template-ai-composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.template-ai-composer.hidden {
  display: none;
}
.template-ai-composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.template-ai-composer-header label {
  font-weight: 600;
  font-size: 14px;
}
.template-ai-composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 88px;
  max-height: 200px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}
.template-ai-composer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.template-ai-composer .icon-only {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.template-ai-composer .icon-only:hover {
  background: var(--btn-bg-hover);
}
.template-ai-composer .icon-only iconify-icon {
  font-size: 18px;
}
.template-ai-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.template-ai-composer.is-busy textarea {
  opacity: 0.6;
}
.template-ai-composer.is-busy .primary {
  pointer-events: none;
  opacity: 0.75;
}
.template-ai-prompt-message {
  margin: -4px 0 0;
  font-size: 13px;
}
.template-ai-prompt-message.hidden {
  display: none;
}
.template-ai-prompt-message.error {
  color: #ff6b6b;
}
.template-ai-status {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.template-ai-status.error {
  color: #ff6b6b;
}
@keyframes template-ai-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.template-search input { border: none; outline: none; background: transparent; color: var(--text); min-width: 160px; }
.template-search input::placeholder { color: var(--muted); }
.templates-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: inherit;
  padding: 0;
}
.templates-close:hover {
  background: var(--btn-bg-hover);
}
.templates-close iconify-icon {
  font-size: 18px;
}
.templates-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 22px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.template-categories { display: flex; flex-wrap: wrap; gap: 8px; max-height: 110px; overflow-y: auto; padding-right: 4px; flex: 0 0 auto; }
.template-categories button { border-radius: 999px; padding: 6px 12px; border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.template-categories button.active { background: var(--accent); color: #fff; border-color: transparent; }
.template-categories button iconify-icon { font-size: 16px; }
.templates-main { display: flex; gap: 16px; flex: 1; min-height: 0; }
.template-list-wrapper { flex: 1; min-width: 0; display: flex; }
.template-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; overflow-y: auto; padding-right: 4px; }
.template-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.template-item:hover, .template-item:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(68, 147, 248, 0.25); }
.template-item.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(68, 147, 248, 0.35); }
.template-item header { display: flex; align-items: center; gap: 8px; }
.template-item-title { font-weight: 600; flex: 1; }
.template-item.is-ai {
  border-color: rgba(68, 147, 248, 0.45);
  box-shadow: 0 0 0 1px rgba(68, 147, 248, 0.2);
}
.template-item.is-ai .template-item-badge {
  display: inline-flex;
}
.template-item-desc { color: var(--muted); font-size: 13px; margin: 0; }
.template-item-actions { display: flex; align-items: center; gap: 6px; }
.template-item button { background: transparent; border: none; color: inherit; padding: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.template-item button.active iconify-icon { color: var(--accent); }
.template-item button.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.template-item-badge {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(68, 147, 248, 0.12);
  border-radius: 999px;
  padding: 3px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.template-item-category { font-size: 12px; color: var(--muted); }
.template-item-snippet { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.4; }
.template-item-empty { padding: 12px; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: 13px; text-align: center; }
.template-item-favorite { width: 32px; height: 32px; border-radius: 50%; border: 1px solid transparent; background: transparent; }
.template-item-favorite:hover { background: var(--btn-bg-hover); }
.template-item-favorite iconify-icon { font-size: 18px; }
.template-item-rename { width: 32px; height: 32px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--muted-strong, var(--text)); }
.template-item-rename:hover { background: var(--btn-bg-hover); }
.template-item-rename iconify-icon { font-size: 18px; }
.template-item button iconify-icon { font-size: 18px; }
.template-item button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.template-preview {
  flex: 1.2;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.template-preview-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.template-preview header { display: flex; align-items: center; gap: 12px; }
.template-preview h3 { margin: 0; font-size: 18px; }
.template-preview-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.template-preview-actions .icon-only { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--border); background: var(--btn-bg); }
.template-preview-actions .icon-only.active { background: var(--accent); border-color: transparent; color: #fff; }
.template-preview-actions .icon-only.active iconify-icon { color: inherit; }
.template-preview-actions .secondary { border-radius: 999px; border: 1px solid var(--border); background: var(--btn-bg); }
.template-preview-actions .secondary:hover { background: var(--btn-bg-hover); }
.template-preview-actions .secondary iconify-icon { font-size: 18px; }
.template-preview-actions .secondary:disabled { opacity: 0.6; pointer-events: none; }
.template-preview-actions button { padding: 8px 12px; }
.template-preview-actions .template-delete-btn {
  border: 1px solid transparent;
  background: var(--danger-soft);
  color: var(--danger);
}
.template-preview-actions .template-delete-btn:hover {
  background: var(--danger-soft-hover);
  color: var(--danger);
}
.template-preview-actions .template-delete-btn:focus {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}
.template-preview-actions .template-delete-btn iconify-icon {
  color: currentColor;
}
.template-preview-actions .template-delete-btn.hidden {
  display: none;
}
.template-preview-actions .template-delete-btn:disabled {
  background: var(--btn-bg);
  border-color: var(--border);
  color: var(--muted);
  opacity: 0.5;
  pointer-events: none;
}
.template-preview-actions .template-rename-btn.hidden {
  display: none;
}
.template-preview .muted { margin: 0; }
.template-preview pre {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: none;
  font-family: 'JetBrains Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.template-preview-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; color: var(--muted); }
.template-preview-empty iconify-icon { font-size: 32px; }

@media (max-width: 1024px) {
  .templates-panel {
    width: min(760px, 96vw);
  }
  .templates-main { flex-direction: column; }
  .template-list-wrapper { max-height: 40%; }
  .template-list { max-height: 100%; }
  .template-preview { flex: 1; }
}

@media (max-width: 640px) {
  .templates-panel {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  .templates-header { flex-wrap: wrap; padding: 16px 18px; }
  .templates-body { padding: 16px 18px; gap: 16px; }
  .template-search { flex: 1 1 100%; }
  .template-search input { width: 100%; }
  .template-categories { max-height: none; overflow: visible; }
}
.template-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.template-preview-modal.hidden {
  display: none;
}
.template-preview-modal-content {
  width: min(760px, 94vw);
  max-height: min(90vh, 720px);
  background: var(--bg);
  color: var(--text);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.4);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.template-preview-modal-content header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.template-preview-modal-content header h3 {
  margin: 0;
  font-size: 20px;
}
.template-preview-modal-content .icon-only {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: inherit;
}
.template-preview-modal-content .icon-only:hover {
  background: var(--btn-bg-hover);
}
.template-preview-modal-content pre {
  margin: 0;
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 18px;
  overflow: auto;
  max-height: 70vh;
  white-space: pre-wrap;
  word-break: break-word;
}
.versions-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.1); z-index: 40; }
.versions-panel { position: fixed; top: var(--header-h); right: 0; width: min(420px, 100%); height: calc(100% - var(--header-h)); background: var(--bg); color: var(--text); border-left: 1px solid var(--border); box-shadow: -6px 0 24px rgba(0,0,0,0.18); z-index: 60; display: flex; flex-direction: column; }
.versions-panel.hidden, .versions-overlay.hidden { display: none; }
.versions-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); background: var(--bg-elev); }
.versions-header strong { font-size: 15px; }
.versions-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); align-items: flex-end; }
.versions-actions .versions-note { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.versions-actions input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.versions-actions button { white-space: nowrap; }
.versions-body { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.versions-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.versions-list li { margin: 0; }
.versions-entry { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); padding: 10px 12px; display: grid; gap: 4px; align-items: flex-start; text-align: left; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.versions-entry:hover, .versions-entry:focus { background: var(--btn-bg-hover); border-color: var(--accent); outline: none; }
.versions-entry.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.versions-entry .version-meta { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.versions-entry .version-note { font-size: 13px; color: var(--text); word-break: break-word; }
.versions-entry .version-tag { padding: 2px 6px; border-radius: 999px; background: var(--btn-bg); border: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.versions-empty { font-size: 13px; color: var(--muted); }
.versions-diff { border-top: 1px solid var(--border); padding: 12px; background: var(--bg-elev); display: grid; gap: 10px; }
.versions-diff-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.versions-diff-content { margin: 0; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--bg); color: var(--text); max-height: 240px; overflow: auto; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; white-space: pre-wrap; }
.versions-diff-actions { display: flex; justify-content: flex-end; }
.diff-eq { background: transparent; }
.diff-ins { background: rgba(46, 160, 67, 0.2); }
.diff-del { background: rgba(255, 59, 48, 0.2); text-decoration: line-through; }
.diff-line { display: inline; }

.settings-panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(920px, 95%); height: min(90vh, 720px); max-height: 90vh; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px; z-index: 61; display: grid; grid-template-rows: auto 1fr auto; box-shadow: 0 16px 40px rgba(0,0,0,0.35); overflow: hidden; }
.settings-panel.hidden { display: none; }

/* Separate overlay for settings to allow click-to-close */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); z-index: 59; }
.settings-overlay.hidden { display: none; }

.website-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); z-index: 80; }
.website-overlay.is-light { background: rgba(0, 0, 0, 0.35); }
.website-overlay.hidden { display: none; }
.website-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(960px, 90vw); height: min(85vh, 780px); background: var(--bg); color: var(--text); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); z-index: 81; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); }
.website-modal.hidden { display: none; }
.website-modal.is-fullscreen { top: 1.5rem; left: 50%; transform: translateX(-50%); width: min(1280px, 96vw); height: calc(100vh - 3rem); max-height: none; border-radius: 20px; }
.website-modal.is-fullscreen .chat-header { padding-block: 1.1rem; }
.website-modal.is-fullscreen .chat-header strong { font-size: 1.05rem; }
.website-modal.is-fullscreen .website-modal-body { padding-block: 1.25rem; }
.website-modal.is-fullscreen .website-modal-footer { padding-block: 1.1rem; }
.website-modal.is-fullscreen .website-preview-wrapper { border-radius: 16px; }
.website-modal.is-fullscreen .website-modal-body,
.website-modal.is-fullscreen .website-preview-wrapper { flex: 1; }
@media (max-width: 640px) {
  .website-modal.is-fullscreen { top: 0.75rem; left: 50%; transform: translateX(-50%); width: calc(100vw - 1.5rem); height: calc(100vh - 1.5rem); border-radius: 16px; }
}
@media (max-width: 540px) {
  .website-modal.is-fullscreen { top: 0; left: 0; transform: none; width: 100vw; height: 100vh; border-radius: 0; }
}
.website-modal .chat-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.website-modal-body { flex: 1; padding: 1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.website-modal-footer { padding: 0.85rem 1.25rem 1.25rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; border-top: 1px solid var(--border); background: var(--bg); }
.website-modal-footer .spacer { flex: 1; min-width: 1px; }
.website-modal-footer-group { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.website-status { min-height: 1.5em; margin: 0; font-size: 0.95rem; color: var(--muted); text-align: center; }
.website-status.error { color: #ff6b6b; }
.website-preview-wrapper { flex: 1; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-elev); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); }
#websitePreviewFrame,
#learningPreviewFrame { width: 100%; height: 100%; border: none; background: #ffffff; }
.settings-body { display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.settings-nav { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-right: 1px solid var(--border); background: var(--bg-elev); }
.settings-nav .nav-item { text-align: left; border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; width: 100%; }
.settings-nav .nav-item.has-icon { display: flex; align-items: center; gap: 8px; justify-content: flex-start; }
.settings-nav .nav-item.hidden { display: none; }
.settings-nav .nav-item iconify-icon { font-size: 18px; line-height: 0; }
.settings-nav .nav-item.active { border-color: var(--accent); background: var(--btn-bg-hover); }
.settings-nav .settings-badge {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--btn-bg);
}
.settings-nav .settings-badge-experimental {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--btn-bg-hover);
}
.settings-content { padding: 16px; overflow: auto; scrollbar-gutter: stable; min-height: 360px; }
.settings-tab.hidden { display: none; }
.settings-footer { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg-elev); }
.settings-footer .spacer { flex: 1; }
.chat-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg-elev); }
.chat-header .spacer { flex: 1; }
.chat-model-badge { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; background: var(--bg); }
.chat-model-badge.is-clickable { cursor: pointer; }
.chat-model-badge.is-clickable:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-settings { display: grid; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
/* Auto-snapshot interval input adapts to content width without stretching */
#prefAutoSnapshotInterval {
  width: 120px;
  max-width: 100%;
  margin-top: 6px;
}
/* Larger, more comfortable spacing inside the settings modal only */
.settings-panel .chat-settings { gap: 14px; padding: 14px 16px; }
.settings-panel .chat-settings label { gap: 6px; font-size: 13px; }
.settings-panel .chat-settings input,
.settings-panel .chat-settings select { padding: 10px 12px; font-size: 14px; }
.settings-panel .chat-settings textarea { padding: 10px 12px; font-size: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.settings-panel #userContextFields.is-disabled .settings-group { opacity: 0.6; transition: opacity 0.2s ease; }
.settings-panel #userContextFields.is-disabled textarea { cursor: not-allowed; }
.settings-panel input[type="range"] { accent-color: var(--accent); }
.settings-panel .settings-group { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: var(--bg); }
.settings-panel .settings-group h4 { margin: 0 0 8px 0; font-size: 14px; color: var(--muted); }
.feedback-form { display: grid; gap: 10px; margin-top: 8px; }
.feedback-form .form-row { display: grid; gap: 4px; }
.feedback-form label { font-size: 12px; color: var(--muted); }
.feedback-form input,
.feedback-form textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 14px; }
.feedback-form textarea { resize: vertical; min-height: 120px; }
.settings-panel .btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); border-radius: 6px; padding: 6px 10px; text-decoration: none; }
.settings-panel .btn:hover { background: var(--btn-bg-hover); }
.info-panel { display: grid; justify-items: center; gap: 10px; padding: 10px 0; }
.info-avatar { width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--border); object-fit: cover; background: var(--bg-elev); }
.info-name { font-weight: 600; }
.settings-panel .chat-settings .row { gap: 12px; }
.chat-settings label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.chat-settings input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.chat-settings select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.chat-settings .row { display: flex; align-items: center; gap: 8px; }
.settings-panel .row.share-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}
.settings-panel .row.share-buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 auto;
}
.settings-panel .row.share-buttons .btn-label { white-space: nowrap; }
.chat-settings .chk { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.themes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease; }
.theme-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card-preview { height: 60px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.1); position: relative; overflow: hidden; }
.theme-card-name { font-size: 13px; font-weight: 500; text-align: center; color: var(--text); }
.theme-card-desc { font-size: 11px; text-align: center; color: var(--muted); margin-top: -4px; }
.theme-card-system { position: relative; }
.theme-card-system::after { content: '🖥️'; position: absolute; top: 8px; right: 8px; font-size: 16px; opacity: 0.6; }
.theme-card-icon { display: flex; align-items: center; justify-content: center; font-size: 24px; margin-bottom: 4px; }
.ollama-status { min-height: 18px; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.shortcuts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.shortcuts li { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; padding: 2px 0; }
.shortcuts .keys { white-space: nowrap; }
.shortcuts .desc { color: var(--muted); }
kbd { display: inline-block; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; box-shadow: 0 1px 0 rgba(0,0,0,0.06); }
.chat-messages { flex: 1; overflow: auto; padding: 12px; display: grid; gap: 10px; }
.msg { position: relative; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); padding-right: 90px; }
.msg.user { border-color: var(--accent); }
.msg.assistant { }
.msg .role { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg .msg-actions { position: absolute; top: 6px; right: 6px; display: inline-flex; flex-direction: row-reverse; gap: 6px; }
.msg .msg-actions button { border: 1px solid var(--border); background: var(--btn-bg); color: var(--text); border-radius: 6px; font-size: 12px; padding: 2px 6px; opacity: 0.75; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.msg .msg-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.msg .msg-actions button iconify-icon { font-size: 14px; line-height: 1; }
.msg .msg-actions button:hover { opacity: 1; background: var(--btn-bg-hover); }
.msg .msg-actions button.speak-btn.speaking { border-color: var(--accent); color: var(--accent); }
.think-block { border: 1px dashed var(--border); border-radius: 6px; background: transparent; }
.think-block > summary { cursor: pointer; list-style: none; color: var(--muted); padding: 6px 8px; }
.think-block > summary::marker, .think-block > summary::-webkit-details-marker { display: none; }
.think-block > .think-body { padding: 0 8px 8px; }
.think-block pre { margin: 8px 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.chat-input { border-top: 1px solid var(--border); padding: 10px 12px; display: grid; gap: 8px; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chat-attachments.is-empty { display: none; }
.chat-attachment { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); color: var(--text); font-size: 12px; }
.chat-attachment .remove-btn { border: none; background: none; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.chat-attachment .remove-btn:hover { color: var(--text); }
.chat-attachment .remove-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.chat-suggestion-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.chat-suggestions-toggle {
  color: var(--muted);
}
.chat-suggestions-toggle:hover {
  color: var(--text);
}
.chat-suggestions-toggle[aria-expanded="true"] {
  color: var(--accent);
}
.chat-suggestion-toolbar.collapsed .chat-suggestion-tabs,
.chat-suggestions.collapsed {
  display: none;
}
.chat-suggestion-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.chat-suggestion-tabs button {
  border-radius: 999px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.chat-suggestion-tabs button.active,
.chat-suggestion-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.chat-suggestion-tabs button iconify-icon { font-size: 16px; }
.chat-suggestions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.chat-suggestion-category { display: none; }
.chat-suggestion-category.active {
  display: grid;
  gap: 6px;
}
.chat-suggestion-buttons { display: grid; gap: 6px; }
.chat-suggestions li {
  margin: 0;
}
.chat-suggestions button {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
}
.chat-suggestions button strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.chat-suggestions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.chat-input textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; max-height: 40vh; }
.chat-input .row { display: flex; gap: 8px; }
.chat-input .secondary { background: var(--btn-bg); }

/* Generic modal overlay */
.modal-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); z-index: 80; }
.modal-overlay.hidden { display: none; }

.table-dialog,
.mermaid-dialog,
.link-dialog { width: min(720px, 95vw); max-height: 90vh; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,0.35); display: flex; flex-direction: column; }
.link-dialog { width: min(440px, 95vw); }
.table-dialog-form,
.mermaid-dialog-form,
.link-dialog-form { display: flex; flex-direction: column; max-height: inherit; }
.table-dialog .modal-header,
.mermaid-dialog .modal-header,
.link-dialog .modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.table-dialog .modal-header h2,
.mermaid-dialog .modal-header h2,
.link-dialog .modal-header h2 { margin: 0; font-size: 18px; }
.mermaid-dialog .modal-title-group { display: flex; align-items: center; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; font-weight: 600; font-size: 12px; letter-spacing: 0.02em; padding: 2px 10px; text-transform: uppercase; }
.badge-experimental { background: var(--accent); color: var(--bg); box-shadow: 0 0 0 1px rgba(0,0,0,0.05); }
.table-dialog .modal-body,
.mermaid-dialog .modal-body,
.link-dialog .modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.table-dialog .modal-footer,
.mermaid-dialog .modal-footer,
.link-dialog .modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.mermaid-dialog .modal-body { flex: 1 1 auto; overflow-y: auto; }
.table-dialog-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.table-dialog-controls label { display: flex; flex-direction: column; font-weight: 600; font-size: 13px; gap: 4px; }
.table-dialog-controls input[type="number"] { width: 96px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.table-dialog-controls input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.table-dialog-controls .controls-spacer { flex: 1; }
.table-builder-grid { flex: 1; min-height: 180px; border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
.table-builder-grid table { width: 100%; border-collapse: collapse; }
.table-builder-grid thead th { background: var(--bg-elev); }
.table-builder-grid th, .table-builder-grid td { border: 1px solid var(--border); padding: 0; }
.table-builder-grid input { width: 100%; border: none; padding: 10px 12px; font: inherit; color: inherit; background: transparent; }
.table-builder-grid input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--bg); }
.table-builder-grid input::placeholder { color: var(--muted); }
.table-dialog .muted,
.mermaid-dialog .muted,
.link-dialog .muted { margin: 0; }

.link-dialog .modal-body label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.link-dialog .modal-body input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px; }
.link-dialog .modal-body input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.link-dialog .modal-footer { align-items: center; gap: 12px; }
.link-dialog-status { margin: 0; font-size: 12px; color: #d14343; min-height: 1em; margin-right: auto; }
.link-dialog-status:empty { display: none; }

.mermaid-dialog-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.mermaid-dialog-controls label { display: flex; flex-direction: column; font-weight: 600; font-size: 13px; gap: 4px; min-width: 180px; }
.mermaid-dialog-controls select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.mermaid-dialog-controls select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mermaid-dialog-controls button { margin-left: auto; }
.mermaid-builder { display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); }
.mermaid-builder-header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.mermaid-builder-header .builder-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.mermaid-builder-content { display: flex; flex-direction: column; gap: 16px; }
.mermaid-builder-content.builder-disabled { opacity: 0.5; pointer-events: none; user-select: none; }
.mermaid-builder .builder-section { display: flex; flex-direction: column; gap: 10px; }
.mermaid-builder .builder-section header { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 14px; }
.mermaid-builder .builder-section header strong { font-size: 14px; }
.mermaid-builder .builder-section header button { flex-shrink: 0; }
.builder-table-wrapper { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--bg); }
.builder-table-wrapper table { width: 100%; border-collapse: collapse; font-size: 13px; }
.builder-table-wrapper thead { background: var(--bg-elev); }
.builder-table-wrapper th, .builder-table-wrapper td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.builder-table-wrapper tbody tr:last-child td { border-bottom: none; }
.builder-table-wrapper td.actions { text-align: right; width: 44px; }
.builder-table-wrapper input,
.builder-table-wrapper select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-family: inherit; font-size: 13px; }
.builder-table-wrapper input:focus,
.builder-table-wrapper select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.builder-table-wrapper td.actions button { margin-left: auto; }
.builder-table-wrapper td.empty { text-align: center; color: var(--muted); font-style: italic; }
.mermaid-builder .builder-hint { font-size: 12px; margin: 0; }
.mermaid-builder .builder-section header,
.mermaid-builder .builder-section-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 14px; }
.mermaid-builder textarea,
.mermaid-builder input[type="text"],
.mermaid-builder input[type="number"] { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit; }
.mermaid-builder textarea { min-height: 140px; resize: vertical; }
.mermaid-builder input:focus,
.mermaid-builder textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.mermaid-builder input[readonly] { cursor: not-allowed; }
.mermaid-preview-panel { display: flex; flex-direction: column; gap: 8px; }
.mermaid-preview-panel header { font-weight: 600; font-size: 14px; }
.mermaid-preview { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); padding: 16px; min-height: 160px; display: flex; align-items: flex-start; justify-content: flex-start; overflow: auto; }
.mermaid-preview .mermaid { width: auto; max-width: 100%; }
.mermaid-preview-status.is-error { color: #d14343; }
.mermaid-code-field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.mermaid-code-field textarea { width: 100%; min-height: 180px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px; font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; resize: vertical; line-height: 1.4; }
.mermaid-code-field textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.mermaid-code-field textarea.read-only { cursor: not-allowed; opacity: 0.65; }
.mermaid-code-field .muted { font-weight: 400; font-size: 12px; }
/* removed diff styles */
.mermaid-builder.hidden { display: none; }
