:root {
  --bg: #0f1117;
  --bg-surface: #181a24;
  --bg-card: #1e2030;
  --bg-input: #252839;
  --border: #2e3148;
  --border-focus: #5b6aff;
  --text: #e2e4f0;
  --text-muted: #8a8ea8;
  --accent: #5b6aff;
  --accent-hover: #7580ff;
  --danger: #ff5572;
  --danger-hover: #ff7a93;
  --success: #3ddc84;
  --orange: #f0a050;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand { display: flex; align-items: baseline; gap: 0.6rem; }
.logo { font-size: 1.25rem; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
.logo-sub { font-size: 0.8rem; color: var(--text-muted); }
.header-nav { display: flex; gap: 0.25rem; }

.nav-link {
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-card); }
.nav-link.active { color: var(--accent); background: rgba(91, 106, 255, 0.1); }

.app-content {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:hover { border-color: var(--text-muted); background: var(--bg-input); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: rgba(255, 85, 114, 0.1); }

.btn-small { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* ── Inputs ── */

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.input-small { width: 80px; }
.input-wide { width: 100%; max-width: 400px; }
.select-small { padding: 0.35rem 0.6rem; }
.select-model { width: 100%; max-width: 400px; padding: 0.45rem 0.7rem; }

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
}

.placeholder-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
}

/* ── Workspace List ── */

.ws-list-panel { display: flex; flex-direction: column; gap: 1.25rem; }

.ws-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ws-list-header h2 { font-size: 1.3rem; font-weight: 600; }

.ws-list-actions { display: flex; gap: 0.5rem; align-items: center; }
.btn-import-label { cursor: pointer; }

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

.ws-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ws-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(91, 106, 255, 0.08);
}

.ws-card-title { font-size: 1.05rem; font-weight: 600; }

.ws-card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.ws-card-date { font-size: 0.78rem; color: var(--text-muted); }

.ws-card-country {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(91, 106, 255, 0.12);
  color: var(--accent);
  white-space: nowrap;
}

.ws-card-notes {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.ws-card-actions { display: flex; gap: 0.35rem; margin-top: auto; }

/* ── Workspace Categories ── */

.ws-categories-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.ws-category-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ws-category-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Workspace View ── */

.ws-panel { display: flex; flex-direction: column; gap: 1rem; }

.ws-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ws-title-input {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
}
.ws-title-input:focus { border-color: var(--border); background: var(--bg-input); }

.ws-country-select {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  min-width: 170px;
  flex-shrink: 0;
}

.ws-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.ws-tab {
  padding: 0.6rem 1.2rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.ws-tab:hover { color: var(--text); }
.ws-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-badge {
  font-size: 0.7rem;
  background: var(--bg-input);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  color: var(--text-muted);
}
.ws-tab.active .tab-badge { background: rgba(91, 106, 255, 0.15); color: var(--accent); }

.ws-tab-content { min-height: 300px; }

/* ── Notes List ── */

.notes-panel { display: flex; flex-direction: column; gap: 1rem; padding-top: 1rem; }
.notes-toolbar { display: flex; gap: 0.5rem; }

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.note-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(91, 106, 255, 0.06);
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-card-title { font-size: 0.95rem; font-weight: 600; }

.card-badge {
  font-size: 0.7rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(91, 106, 255, 0.15);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
}

.note-card-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.note-card-preview code {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.card-date { font-size: 0.75rem; color: var(--text-muted); }
.card-actions { display: flex; gap: 0.35rem; }

/* ── Note Editor ── */

.note-editor-panel { display: flex; flex-direction: column; gap: 1rem; flex: 1; min-height: 0; }

.note-editor-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.note-editor-actions { display: flex; gap: 0.5rem; align-items: center; margin-left: auto; }

.note-editor-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

.note-textarea {
  flex: 1;
  min-height: 200px;
  resize: none;
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 1rem;
  border-radius: var(--radius-lg);
  font-family: var(--font);
}

/* ── AI Presets (Note Editor) ── */

.note-ai-presets {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
}

.ai-presets-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ai-presets-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-preset {
  background: rgba(91, 106, 255, 0.1);
  border-color: rgba(91, 106, 255, 0.3);
  color: var(--accent);
}
.btn-preset:hover:not(:disabled) {
  background: rgba(91, 106, 255, 0.2);
  border-color: var(--accent);
}

.ai-presets-country {
  font-size: 0.78rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(91, 106, 255, 0.12);
  color: var(--accent);
  white-space: nowrap;
  margin-left: auto;
}

.ai-presets-hint {
  font-size: 0.78rem;
  color: var(--orange);
  margin-top: 0.35rem;
}

/* ── Code Editor Overlay (syntax highlighting) ── */

.code-editor-wrap {
  display: grid;
  grid-template: 1fr / 1fr;
  flex: 1;
  min-height: 350px;
}

.code-editor-wrap > * {
  grid-area: 1 / 1;
}

.code-editor-wrap > textarea.spin-textarea {
  color: transparent;
  caret-color: var(--text);
  background: transparent;
  border-color: transparent;
  z-index: 2;
  resize: none;
  min-height: 0;
}

.code-editor-wrap > textarea.spin-textarea:focus {
  border-color: transparent;
}

.code-editor-wrap > textarea.spin-textarea:focus ~ .code-highlight {
  border-color: var(--border-focus);
}

.code-editor-wrap > textarea.spin-textarea::placeholder {
  color: var(--text-muted);
}

.code-editor-wrap > textarea.spin-textarea::selection {
  background: rgba(91, 106, 255, 0.35);
}

.code-highlight {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  pointer-events: none;
  color: var(--text);
  z-index: 1;
}

.hl-bracket { color: #8a8ea8; }
.hl-tag { color: #ff6b8a; }
.hl-attr { color: #f0a050; }
.hl-value { color: #3ddc84; }
.hl-comment { color: #555a75; font-style: italic; }

.note-editor-body .code-editor-wrap {
  min-height: 200px;
}

/* Note editor: only activate overlay in HTML mode */
.note-editor-highlight:not(.mode-html) > .code-highlight {
  display: none;
}

.note-editor-highlight.mode-html > textarea.note-textarea {
  font-family: var(--mono);
  color: transparent;
  caret-color: var(--text);
  background: transparent;
  border-color: transparent;
  z-index: 2;
}

.note-editor-highlight.mode-html > textarea.note-textarea:focus {
  border-color: transparent;
}

.note-editor-highlight.mode-html > textarea.note-textarea:focus ~ .code-highlight {
  border-color: var(--border-focus);
}

.note-editor-highlight.mode-html > textarea.note-textarea::placeholder {
  color: var(--text-muted);
}

.note-editor-highlight.mode-html > textarea.note-textarea::selection {
  background: rgba(91, 106, 255, 0.35);
}

.preview-label { font-size: 0.85rem; color: #666; margin-bottom: 0.5rem; }

/* ── Combined Preview (Note Editor) ── */

.note-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.note-preview.hidden { display: none; }

.note-preview-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.note-preview-header .preview-label {
  color: var(--text-muted);
  margin-bottom: 0;
}

.spin-combinations {
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(61, 220, 132, 0.12);
  color: var(--success);
  font-weight: 600;
  white-space: nowrap;
}
.spin-combinations.hidden { display: none; }

.note-preview-content {
  border-radius: var(--radius);
  max-height: 350px;
  overflow-y: auto;
}

.note-preview-content.text-mode {
  background: var(--bg-input);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
}

.note-preview-content.html-mode {
  background: #fff;
  color: #222;
  overflow-wrap: break-word;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

.note-preview-content.html-mode ul,
.note-preview-content.html-mode ol {
  padding-left: 1.5rem;
}

/* ── AI Panel ── */

.ai-panel { display: flex; flex-direction: column; gap: 1.25rem; padding-top: 1rem; }

.ai-notice {
  background: rgba(240, 160, 80, 0.1);
  border: 1px solid rgba(240, 160, 80, 0.3);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--orange);
  font-size: 0.9rem;
}

.ai-context-section { display: flex; flex-direction: column; gap: 0.6rem; }
.ai-context-section h4 { font-size: 0.9rem; font-weight: 600; }

.ai-context-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.ai-context-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.88rem;
}
.ai-context-item:hover { background: var(--bg-input); }

.ai-ctx-badge {
  font-size: 0.65rem;
  width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
  flex-shrink: 0;
}
.ai-ctx-badge.note { background: rgba(91, 106, 255, 0.15); color: var(--accent); }

.ai-ctx-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ai-select-actions { display: flex; gap: 0.5rem; }

.ai-prompt-section { display: flex; flex-direction: column; gap: 0.5rem; }
.ai-prompt-section h4 { font-size: 0.9rem; font-weight: 600; }

.ai-prompt-textarea {
  min-height: 120px;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-lg);
  font-family: var(--font);
}

.ai-actions { display: flex; align-items: center; gap: 1rem; }
.ai-status { font-size: 0.85rem; color: var(--text-muted); }

.ai-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ai-result.hidden { display: none; }
.ai-result h4 { font-size: 0.9rem; font-weight: 600; }

.ai-result-content {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

.ai-result-actions { display: flex; gap: 0.5rem; }

/* ── Settings ── */

.settings-panel { display: flex; flex-direction: column; gap: 1.75rem; max-width: 640px; }
.settings-panel h2 { font-size: 1.3rem; font-weight: 600; }

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.settings-section h3 { font-size: 1rem; font-weight: 600; }
.settings-hint { font-size: 0.85rem; color: var(--text-muted); }

.settings-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.settings-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.settings-preview { font-size: 0.9rem; color: var(--text-muted); }
.settings-preview code {
  font-family: var(--mono);
  color: var(--accent);
  background: var(--bg-input);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.settings-actions { display: flex; gap: 0.5rem; }

/* ── Server status (settings + banner) ── */

.server-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
}
.server-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.server-status--ok .server-status-dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.server-status--ok { color: var(--success); }
.server-status--off .server-status-dot { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.server-status--off { color: var(--orange); }

.server-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #2a2030;
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin: 0 1rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
}
.server-banner-text { flex: 1; }
.server-banner-text strong { color: var(--orange); }
.server-banner-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.server-banner-link:hover { color: var(--accent-hover); }
.server-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.server-banner-close:hover { color: var(--text); }

.btn-muted {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-muted:hover {
  background: var(--border);
  color: var(--text);
}

/* ── Categories in Settings ── */

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  padding: 0.25rem;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.category-row-dragging {
  opacity: 0.4;
}

.category-row-over {
  box-shadow: 0 -2px 0 0 var(--accent);
}

.category-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem;
  user-select: none;
  flex-shrink: 0;
}
.category-drag-handle:active { cursor: grabbing; }

.category-name-input {
  flex: 1;
  font-size: 0.9rem;
  padding: 0.4rem 0.7rem;
}

.categories-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.input-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 0.15rem;
}
.input-hint code {
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--bg-input);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.ai-test-row {
  align-items: center;
}

.ai-test-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.ai-test-status.success { color: var(--success); }
.ai-test-status.error { color: var(--danger); }

/* ── Section Header with Toggle ── */

.settings-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.settings-section-header > div { flex: 1; min-width: 0; }

.settings-section.section-disabled {
  opacity: 0.55;
}
.settings-section.section-disabled .settings-section-header { opacity: 1; }

.settings-section-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Toggle Switch ── */

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* ── Workspace Settings ── */

.ws-settings-panel { display: flex; flex-direction: column; gap: 1.25rem; padding-top: 1rem; }

.ws-settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ws-settings-header h4 { font-size: 0.95rem; font-weight: 600; }
.ws-settings-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.45;
}

.ws-category-select {
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  max-width: 300px;
}

.ws-ai-instructions-textarea {
  min-height: 160px;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-lg);
  font-family: var(--font);
}

.ws-settings-footer {
  display: flex;
  align-items: center;
  min-height: 1.4rem;
}

.ws-settings-status {
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: opacity 0.2s;
}
.ws-settings-status.saved { color: var(--success); }

/* ── Macros Editor ── */

.macros-panel { display: flex; flex-direction: column; gap: 1rem; padding-top: 1rem; }

.macros-header h4 { font-size: 0.95rem; font-weight: 600; }
.macros-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.45;
}
.macros-hint code {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--bg-input);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  color: var(--accent);
}

.macro-delimiters-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.macro-delimiters-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.macro-delim-input {
  width: 60px;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}
.macro-delimiters-preview {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  user-select: none;
}

.macros-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.macro-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s;
}
.macro-row:hover { border-color: var(--text-muted); }

.macro-key-group {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.macro-brace {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}
.macro-key-input {
  width: 150px;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  text-align: center;
}
.macro-separator {
  color: var(--text-muted);
  flex-shrink: 0;
}
.macro-desc-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
  min-width: 0;
}

.macros-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.macros-presets-dropdown {
  position: relative;
}
.macros-presets-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  z-index: 50;
  min-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.macros-presets-menu.hidden { display: none; }

.macros-preset-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: background 0.1s;
  white-space: nowrap;
}
.macros-preset-item:hover { background: var(--bg-input); }
.macros-preset-item code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(91, 106, 255, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  flex-shrink: 0;
}
.macros-preset-item span { color: var(--text-muted); }
.macros-preset-item span:first-child { color: var(--text); flex: 1; }

.macros-copy-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.macros-copy-empty {
  display: block;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Notification Center ── */

.notify-center {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}

.notify-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  transform: translateX(calc(100% + 1rem));
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.notify-item.visible {
  transform: translateX(0);
  opacity: 1;
}
.notify-item.success  { border-color: var(--success); }
.notify-item.error    { border-color: var(--danger); }
.notify-item.warning  { border-color: var(--orange); }
.notify-item.warning .notify-icon { color: var(--orange); }
.notify-item.progress { border-color: var(--accent); }

.notify-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.notify-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: notify-spin 0.7s linear infinite;
}
@keyframes notify-spin {
  to { transform: rotate(360deg); }
}

.notify-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.notify-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.notify-close:hover { color: var(--text); }

/* ── Utilities ── */

.hidden { display: none !important; }

/* ── Responsive ── */

@media (max-width: 768px) {
  .app-header { padding: 0 1rem; flex-wrap: wrap; height: auto; gap: 0.5rem; padding-block: 0.5rem; }
  .app-content { padding: 1rem; }
  .ws-grid { grid-template-columns: 1fr; }
  .settings-row { flex-direction: column; }
  .note-editor-header { flex-direction: column; align-items: stretch; }
  .note-editor-actions { margin-left: 0; }
}
