/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 265px;
  --header-h: 54px;

  --bg:         #f4f0eb;
  --sidebar-bg: #faf8f4;
  --editor-bg:  #ffffff;
  --text:       #1c1917;
  --text-2:     #78716c;
  --text-3:     #a8a29e;
  --border:     #e7e0d8;
  --hover:      #ede8e1;
  --active-bg:  #e6faf8;
  --active-fg:  #0d9488;
  --accent:     #0d9488;
  --accent-h:   #0f766e;
  --danger:     #ef4444;
  --danger-bg:  #fef2f2;
  --warning:    #d97706;
  --success:    #10b981;
  --info:       #3b82f6;

  --r:   6px;
  --r-lg: 10px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.10), 0 4px 10px -5px rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }

/* ── Layout ─────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 18px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 1;
}

.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.logo svg, .logo img { width: 32px; height: 32px; }
.logo span {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: -0.2px;
}

/* Workspace bar */
.workspace-bar {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.workspace-selector {
  width: 100%;
  height: 30px;
  padding: 0 28px 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a8a29e' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 7px center / 14px;
  appearance: none;
  -webkit-appearance: none;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.workspace-selector:hover  { border-color: var(--text-3); }
.workspace-selector:focus  { border-color: var(--accent); }
.workspace-selector:disabled { opacity: 0.45; cursor: default; }

.header-actions { display: flex; gap: 2px; }

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; background: transparent;
  border-radius: var(--r); cursor: pointer;
  color: var(--text-2); transition: background .12s, color .12s;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon:disabled { opacity: 0.35; cursor: default; }
.btn-icon:disabled:hover { background: transparent; color: var(--text-2); }
.btn-icon svg { width: 16px; height: 16px; }

/* Search */
.search-wrapper { padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-wrapper input {
  width: 100%; height: 32px;
  padding: 0 10px 0 30px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 8px center / 14px;
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13px; font-family: var(--font); color: var(--text);
  outline: none; transition: border-color .15s;
}
.search-wrapper input:focus {
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230d9488' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
}
.search-wrapper input::placeholder { color: var(--text-3); }
.search-wrapper input:disabled { opacity: 0.5; cursor: default; background: var(--bg); }

/* Tree */
.tree { flex: 1; overflow-y: auto; padding: 6px 0; }
.tree--locked { pointer-events: none; opacity: 0.5; }
.tree::-webkit-scrollbar { width: 4px; }
.tree::-webkit-scrollbar-track { background: transparent; }
.tree::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tree-loading,
.tree-empty-msg { padding: 16px; font-size: 13px; color: var(--text-3); text-align: center; }

/* Tree items */
@keyframes treeItemIn {
  from { opacity: 0; transform: translateX(-5px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tree-item {
  display: flex; align-items: center;
  height: 28px; padding: 0 8px;
  cursor: pointer; border-radius: var(--r);
  margin: 0 6px;
  transition: background .12s;
  position: relative; user-select: none;
  animation: treeItemIn .18s ease both;
}
.tree-item:hover { background: var(--hover); }
.tree-item.active { background: var(--active-bg); box-shadow: inset 3px 0 0 var(--accent); }
.tree-item.active .tree-item-name { color: var(--active-fg); font-weight: 500; }
.tree-item.active .tree-item-icon { color: var(--accent); }

.tree-item-chevron {
  width: 13px; height: 13px; flex-shrink: 0; margin-right: 3px;
  color: var(--text-3); transition: transform .15s;
}
.tree-folder.open > .tree-item .tree-item-chevron { transform: rotate(90deg); }

.tree-item-icon { width: 15px; height: 15px; flex-shrink: 0; margin-right: 6px; color: var(--text-2); }
.tree-folder > .tree-item .tree-item-icon { color: var(--warning); }

.tree-item-name {
  flex: 1; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tree-item-actions { display: none; gap: 1px; margin-left: 4px; }
.tree-item:hover .tree-item-actions { display: flex; }

.tree-item-actions button {
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border: none; background: var(--hover); border-radius: 4px;
  cursor: pointer; color: var(--text-2);
  transition: background .1s, color .1s;
}
.tree-item-actions button:hover { background: var(--border); color: var(--text); }
.tree-item-actions button.danger:hover { background: var(--danger-bg); color: var(--danger); }
.tree-item-actions button svg { width: 12px; height: 12px; }

.folder-empty-note {
  font-size: 12px; color: var(--text-2);
  padding: 3px 8px 3px 0;
  margin: 1px 6px;
  font-style: italic;
}

/* ── Editor ─────────────────────────────────────────────────────────── */
.editor {
  flex: 1; display: flex; flex-direction: column;
  height: 100%; background: var(--editor-bg); overflow: hidden; min-width: 0;
  transition: opacity .18s ease;
}
.btn-ai-toolbar {
  height: 36px; padding: 0 12px;
  font-size: 13px; font-family: var(--font); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--r);
  cursor: pointer; flex-shrink: 0;
  transition: background .1s;
}
.btn-ai-toolbar svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-ai-toolbar:hover { background: var(--active-bg); }


.note-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 26px;
  height: 54px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#note-title {
  flex: 1;
  font-size: 22px; font-weight: 400; font-family: var(--font-display);
  color: var(--text); border: none; outline: none;
  background: transparent; padding: 0;
  line-height: 1.3;
  letter-spacing: -0.2px;
}
#note-title::placeholder { color: var(--text-3); font-weight: 400; }

.save-btn--success { background: var(--success); border-color: var(--success); opacity: 1; }

.note-actions { display: flex; align-items: center; gap: 10px; }

/* TinyMCE */
#tinymce-editor,
#template-tinymce {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
#tinymce-editor .tox.tox-tinymce,
#template-tinymce .tox.tox-tinymce {
  flex: 1; min-height: 0;
  border: none !important;
  border-radius: 0 !important;
}
#tinymce-editor .tox .tox-toolbar-overlord,
#tinymce-editor .tox .tox-toolbar,
#tinymce-editor .tox .tox-toolbar__primary,
#template-tinymce .tox .tox-toolbar-overlord,
#template-tinymce .tox .tox-toolbar,
#template-tinymce .tox .tox-toolbar__primary {
  background: var(--editor-bg) !important;
  border-bottom: 1px solid var(--border) !important;
}
#tinymce-editor .tox .tox-toolbar__group,
#template-tinymce .tox .tox-toolbar__group { border: none !important; }
#tinymce-editor .tox .tox-statusbar,
#template-tinymce .tox .tox-statusbar { border-top: 1px solid var(--border) !important; }
.tox-statusbar__wordcount { display: none !important; }
.tox-tbtn--bespoke[title^="Font size"] { width: 62px !important; min-width: 62px !important; }
.tox .tox-tbtn--select:not(.tox-tbtn--bespoke) { background-color: rgb(247, 247, 247) !important; }

/* ── Empty State ─────────────────────────────────────────────────────── */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; background: var(--editor-bg); padding: 40px; text-align: center;
}
.empty-state svg { width: 68px; height: 68px; color: #c9bfb3; }
.empty-state h2 { font-family: var(--font-display); font-size: 22px; font-weight: 400; color: var(--text-2); letter-spacing: -0.2px; }
.empty-state p { font-size: 13px; color: var(--text-3); line-height: 1.7; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  height: 36px; padding: 0 16px;
  border-radius: var(--r); font-size: 13px;
  font-family: var(--font); font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: white; color: var(--text);
  transition: background .1s, border-color .1s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:disabled:hover { background: white; }
.btn-primary:disabled:hover { background: var(--accent); }


.empty-state .btn { margin-top: 8px; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(28,25,23,.40);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .15s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: white; border-radius: var(--r-lg);
  padding: 24px; width: 360px;
  box-shadow: var(--shadow-lg);
  transform: scale(.96); opacity: 0;
  transition: transform .15s, opacity .15s;
}
.modal-overlay.open .modal { transform: scale(1); opacity: 1; }

.modal h3 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.2px;
  margin-bottom: 14px;
  color: var(--text);
}

.modal input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: 14px; font-family: var(--font); color: var(--text);
  outline: none; transition: border-color .15s;
}
.modal input:focus { border-color: var(--accent); }

.modal-error { font-size: 12px; color: var(--danger); min-height: 16px; margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Context Menu ────────────────────────────────────────────────────── */
.context-menu {
  position: fixed; background: white;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 4px; min-width: 170px;
  box-shadow: var(--shadow-lg); z-index: 200;
  display: none;
  opacity: 0;
  transform: scale(.96) translateY(-4px);
  transform-origin: top left;
}
.context-menu.open {
  display: block;
  animation: ctxIn .12s ease forwards;
}
@keyframes ctxIn {
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.ctx-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--r);
  font-size: 13px; color: var(--text); cursor: pointer;
  transition: background .1s;
}
.ctx-item:hover { background: var(--hover); }
.ctx-item svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-2); }
.ctx-item.ctx-danger { color: var(--danger); }
.ctx-item.ctx-danger svg { color: var(--danger); }
.ctx-item.ctx-danger:hover { background: var(--danger-bg); }

.ctx-separator { height: 1px; background: var(--border); margin: 4px 0; }
.hidden { display: none !important; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 500;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 380px;
  padding: 12px 14px;
  background: white;
  border-radius: var(--r-lg);
  border-left: 4px solid var(--danger);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toast-in .2s ease;
}
.toast.hiding { animation: toast-out .2s ease forwards; }
.toast--info { border-left-color: var(--info); }
.toast--info .toast-icon { color: var(--info); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); }     to { opacity: 0; transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin-icon { animation: spin 0.7s linear infinite; display: inline-block; }

.toast-icon { flex-shrink: 0; color: var(--danger); margin-top: 1px; }
.toast-icon svg { width: 16px; height: 16px; }
.toast-body { flex: 1; }
.toast-msg  { font-size: 13px; color: var(--text); line-height: 1.45; }
.toast-close {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 0; line-height: 1;
  transition: color .1s;
}
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 14px; height: 14px; }

/* ── Settings Panel ──────────────────────────────────────────────────────────── */
#settings-panel {
  flex: 1; display: flex; flex-direction: column;
  height: 100%; background: var(--editor-bg); overflow: hidden; min-width: 0;
}

.settings-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 24px 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-back-btn {
  width: auto;
  padding: 0 10px 0 6px;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.settings-back-btn:hover { color: var(--text); }

.settings-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.2px;
}

.settings-body {
  flex: 1; overflow-y: auto; padding: 28px 36px;
}
.settings-body::-webkit-scrollbar { width: 4px; }
.settings-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.settings-section { max-width: 680px; }
.settings-section--sep { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }

.ws-default-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  color: var(--accent);
  background: var(--active-bg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.settings-section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 10px;
}

.settings-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.1px;
}

.settings-section-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Template list */

.list-empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 16px 2px; gap: 10px; text-align: center;
}
.list-empty-state svg { color: var(--text-3); width: 32px; height: 32px; }
.list-empty-state p { font-size: 13px; color: var(--text-3); line-height: 1.5; }

.settings-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r);
  margin-bottom: 8px;
  background: var(--bg);
  position: relative;
  cursor: default;
}
.settings-list-item:hover { background: var(--hover); }
.settings-list-item.dragging { opacity: 0.35; pointer-events: none; }

.settings-list-item.drop-before::before,
.settings-list-item.drop-after::after {
  content: '';
  position: absolute;
  left: 0; right: 0; height: 2px;
  background: var(--accent); border-radius: 1px;
  pointer-events: none; z-index: 10;
}
.settings-list-item.drop-before::before { top: -1px; }
.settings-list-item.drop-after::after   { bottom: -1px; }

.template-drag-handle {
  cursor: grab; color: var(--text-3); flex-shrink: 0;
  margin-right: 8px;
  width: 10px; height: 16px;
  user-select: none;
}
.template-drag-handle:active { cursor: grabbing; }

.template-list-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.settings-section-header .btn-primary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}
.settings-section-header .btn-primary:hover {
  background: var(--active-bg);
}

.template-list-actions { display: flex; gap: 6px; flex-shrink: 0; }
.template-list-actions .btn { height: 30px; padding: 0 12px; font-size: 12px; }
.template-list-actions .btn:not(.btn-danger):not(.btn-success) { background: transparent; border-color: var(--accent); color: var(--accent); }
.template-list-actions .btn:not(.btn-danger):not(.btn-success):hover { background: var(--active-bg); }
.template-list-actions .btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.template-list-actions .btn-danger:hover {
  background: var(--danger-bg);
}
.template-list-actions .btn-success {
  background: transparent;
  color: var(--success);
  border-color: var(--success);
  min-width: 76px;
}
.template-list-actions .btn-success:hover { background: var(--active-bg); }

/* Template Editor Panel */
#template-editor-panel,
#backup-editor-panel {
  flex: 1; display: flex; flex-direction: column;
  height: 100%; background: var(--editor-bg); overflow: hidden; min-width: 0;
}

.template-panel-header {
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 16px 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 8px;
}
.panel-close-btn { margin-left: 4px; }

.template-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.2px;
  white-space: nowrap; flex-shrink: 0;
}

#template-name-input {
  flex: 1;
  font-size: 17px; font-weight: 600; font-family: var(--font);
  color: var(--text); border: none; outline: none;
  background: transparent; padding: 0;
}
#template-name-input::placeholder { color: var(--text-3); font-weight: 400; }

.template-panel-actions { display: flex; gap: 8px; flex-shrink: 0; }



/* Modal template select */
#modal-template-row { margin-top: 10px; }

.modal-select-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--text-2); margin-bottom: 5px;
}

#modal-template-select {
  width: 100%; height: 38px; padding: 0 10px;
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: 13px; font-family: var(--font); color: var(--text);
  background: white; outline: none; cursor: pointer;
  transition: border-color .15s;
}
#modal-template-select:focus { border-color: var(--accent); }

/* ── Drag and Drop ───────────────────────────────────────────────────────────── */
.tree-item[draggable="true"] { cursor: pointer; }
.tree-item[draggable="true"]:active { cursor: grabbing; }
.tree-item.dragging { opacity: 0.35; pointer-events: none; }

.tree-item.drop-inside {
  background: var(--active-bg) !important;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

#tree-drop-line {
  position: fixed;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  pointer-events: none;
  display: none;
  z-index: 50;
}

.tree-end-zone {
  min-height: 0;
  margin: 1px 6px;
  border-radius: var(--r);
}

/* ── Tooltips ────────────────────────────────────────────────────────────────── */
#tree-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1c1917;
  color: #faf8f4;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 400;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  opacity: 0;
  transition: opacity .14s ease;
}
#tree-tooltip.visible { opacity: 1; }

/* ── Backup Editor ───────────────────────────────────────────────────── */
.backup-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 680px;
}

.backup-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.backup-form-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.backup-form-hint-inline {
  font-weight: 400;
  color: var(--text-3);
  font-size: 12px;
}

.backup-form-input,
.backup-form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--editor-bg);
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  outline: none;
  box-sizing: border-box;
}

.backup-form-input:focus,
.backup-form-textarea:focus { border-color: var(--accent); }

.backup-form-textarea {
  resize: vertical;
  min-height: 90px;
}

.backup-keep-input {
  width: 80px !important;
}

.backup-form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: -4px;
}

.backup-list-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.backup-list-path--dest { color: var(--text-3); }

.backup-path-row {
  display: flex; align-items: center; gap: 4px; min-width: 0;
}
.backup-list-path {
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
  font-family: 'Consolas', ui-monospace, monospace;
}
.btn-copy-path {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0;
  border: none; background: transparent; border-radius: 3px;
  cursor: pointer; color: var(--text-3);
  opacity: 0; transition: opacity .15s, color .15s;
}
.btn-copy-path svg { width: 11px; height: 11px; }
.backup-path-row:hover .btn-copy-path { opacity: 1; }
.btn-copy-path:hover { color: var(--accent); }
.btn-copy-path--ok { color: var(--success) !important; opacity: 1 !important; }

/* ── IA Settings ─────────────────────────────────────── */
.ia-settings-body { padding: 4px 0 8px; }
.ia-settings-group { display: flex; flex-direction: column; gap: 6px; max-width: 480px; }
.ia-settings-label { font-size: 13px; color: var(--text); font-weight: 500; }
.ia-key-row { display: flex; gap: 8px; }
.ia-settings-input {
  flex: 1; padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: var(--r); background: var(--editor-bg); color: var(--text);
  font-size: 13px; font-family: monospace; outline: none;
}
.ia-settings-input:focus { border-color: var(--accent); }
.ia-key-status { font-size: 12px; color: var(--text-3); }
.ia-key-status.ia-key-ok { color: var(--success); }
.ia-model-select { cursor: pointer; }

/* ── AI Panel ────────────────────────────────────────── */
#ai-panel {
  flex-shrink: 0;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--editor-bg);
}
.ai-panel-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
}
.ai-instruction-input {
  flex: 1; border: 1.5px solid var(--border); border-radius: var(--r);
  padding: 6px 10px; font-size: 15px; font-family: var(--font);
  background: var(--bg); color: var(--text); outline: none;
}
.ai-instruction-input:focus { border-color: var(--accent); }
#ai-preview-section { flex-direction: row-reverse; }
.ai-preview-header {
  display: flex; flex-direction: column; align-items: flex-start; gap: 11px;
  padding: 14px 14px 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--hover);
}
.ai-preview-actions { display: flex; align-items: center; gap: 6px; }
.ai-preview-actions .btn { height: 32px; padding: 0 16px; font-size: 13px; }
.ai-view-toggle { display: flex; }
.ai-toggle-btn {
  padding: 4px 12px; font-size: 12px; font-family: var(--font); font-weight: 500;
  border: 1px solid transparent; border-radius: 0;
  background: transparent; color: var(--text); cursor: pointer;
  transition: background .1s, color .1s, border-color .1s;
}
.ai-toggle-btn:first-child { border-radius: var(--r) 0 0 var(--r); }
.ai-toggle-btn:last-child  { border-radius: 0 var(--r) var(--r) 0; }
.ai-toggle-btn + .ai-toggle-btn { margin-left: -1px; }
.ai-toggle-btn:not(.active) { border-color: var(--text-3); background: white; }
.ai-toggle-btn.active { background: var(--accent); color: white; border-color: var(--accent); z-index: 1; }
.ai-toggle-btn.active:hover { background: var(--accent-h); border-color: var(--accent-h); }
.ai-toggle-btn:not(.active):hover { background: var(--hover); }
.ai-preview-actions .btn:not(.btn-primary):hover { border-color: var(--text-3); }
.ai-preview-content {
  flex: 1; min-width: 0;
  max-height: 260px; overflow-y: auto;
  padding: 14px 26px;
  font-family: Inter, sans-serif; font-size: 14px; line-height: 1.5; color: var(--text);
  border-top: 1px solid var(--border);
}
.ai-preview-content p { margin: 0; }

/* Modo Perguntar — ocultar elementos de transform */
#ai-preview-section[data-mode="ask"] .ai-view-toggle,
#ai-preview-section[data-mode="ask"] #ai-apply-btn { display: none !important; }

/* Resposta em texto livre */
.ai-answer-text {
  font-size: 14px; line-height: 1.7;
  color: var(--text); white-space: pre-wrap;
}
.ai-diff-removed {
  background: #fef2f2;
  border-left: 3px solid #ef4444;
  padding: 2px 6px;
  color: #991b1b;
  text-decoration: line-through;
}
.ai-diff-added {
  background: #f0fdf4;
  border-left: 3px solid var(--success);
  padding: 2px 6px;
  color: #166534;
}
.ai-diff-unchanged { padding: 2px 0; opacity: 0.5; }
.ai-diff-none { color: var(--text-3); font-size: 13px; font-style: italic; }


