*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow: hidden; overscroll-behavior: none; }

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f0f0f2;
  --surface3: #e5e5ea;
  --border: rgba(0,0,0,0.08);
  --text: #1c1c1e;
  --text-muted: #8e8e93;
  --accent: #6c5ce7;
  --radius: 14px;
  --dot-color: rgba(0,0,0,0.08);
  --hover-bg: rgba(0,0,0,0.03);
  --subtle-bg: rgba(0,0,0,0.04);
  --dashed-border: rgba(0,0,0,0.12);
  --shadow-card: rgba(0,0,0,0.08);
  --shadow-modal: rgba(0,0,0,0.15);
  --overlay-bg: rgba(0,0,0,0.5);
}

[data-theme="dark"] {
  --bg: #0c0c12;
  --surface: #14141e;
  --surface2: #1c1c28;
  --surface3: #242434;
  --border: rgba(255,255,255,0.07);
  --text: #e8e8f0;
  --text-muted: #5e5e78;
  --accent: #7c6fcd;
  --dot-color: rgba(255,255,255,0.07);
  --hover-bg: rgba(255,255,255,0.03);
  --subtle-bg: rgba(255,255,255,0.06);
  --dashed-border: rgba(255,255,255,0.1);
  --shadow-card: rgba(0,0,0,0.35);
  --shadow-modal: rgba(0,0,0,0.55);
  --overlay-bg: rgba(0,0,0,0.6);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

/* TOP BAR */
#topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#topbar-row1 {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

#app-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-right: 8px;
}

.topbar-icon-btn {
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
.topbar-icon-btn:hover { background: var(--surface3); }

/* More menu hidden on desktop */
#topbar-more-btn { display: none; }

/* More menu dropdown */
#topbar-more-menu {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 0;
  box-shadow: 0 4px 16px var(--shadow-modal);
  min-width: 200px;
}
.more-menu-item {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
  color: var(--text);
}
.more-menu-item:hover { background: var(--hover-bg); }

#tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
}

.tab-btn {
  padding: 6px 18px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--surface3);
  color: var(--text);
}

#btn-new-project {
  margin-left: auto;
  padding: 7px 16px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
#btn-new-project:hover { opacity: 0.85; }

/* MAIN CONTENT */
#content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-view { display: none; width: 100%; height: 100%; }
.tab-view.active { display: flex; flex-direction: column; }

/* CANVAS TAB */
#canvas-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: default;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}

#canvas-world {
  position: absolute;
  top: 0; left: 0;
  width: 1px; height: 1px;
  transform-origin: 0 0;
}

/* ZOOM CONTROLS */
#zoom-controls {
  position: absolute;
  bottom: 68px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  z-index: 20;
}

.zoom-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: none;
  background: var(--surface3);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}
.zoom-btn:hover { background: var(--accent); }

#zoom-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 38px;
  text-align: center;
}

/* LIST TABS */
.list-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.list-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
  margin: 0 auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 220px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 8px;
}
.empty-state .es-icon { font-size: 38px; }

/* CARDS */
.project-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.18s;
  position: relative;
}
.project-card:hover {
  box-shadow: 0 4px 24px var(--shadow-card);
}

/* Canvas cards: absolutely positioned */
.canvas-card {
  position: absolute;
  min-width: 320px;
  min-height: 120px;
}

.card-accent-bar {
  height: 3px;
  flex-shrink: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px 12px;
  cursor: move;
  flex-shrink: 0;
  user-select: none;
  touch-action: none;
}
.task-cb, .task-del-btn, .add-task-btn, .add-task-input,
.card-menu-btn, .img-thumb, .img-upload-label, .resize-handle,
.file-btn, .file-del-btn,
.link-add-btn, .link-copy-btn, .link-del-btn, .link-form-save, .link-form-cancel,
.secret-add-btn {
  touch-action: manipulation;
}

.list-card .card-header { cursor: default; }

.card-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }

.card-title {
  flex: 1;
  font-size: 39px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.5px;
  word-break: break-word;
}

.card-menu-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.card-menu-btn:hover { background: var(--surface3); color: var(--text); }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 12px 10px;
  min-height: 0;
}

.canvas-card.has-height .card-body {
  overflow-y: auto;
}

.card-progress-wrap {
  margin-bottom: 8px;
  flex-shrink: 0;
}
.card-progress-bar-bg {
  height: 4px;
  border-radius: 99px;
  background: var(--surface3);
  overflow: hidden;
  margin-bottom: 4px;
}
.card-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.2s;
}
.card-progress-label {
  font-size: 10px;
  color: var(--text-muted);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 2px;
  border-radius: 6px;
  position: relative;
}
.task-item:hover { background: var(--hover-bg); }

.task-cb {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--text-muted);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.task-cb:checked {
  background: var(--cb-color, var(--accent));
  border-color: var(--cb-color, var(--accent));
}
.task-cb:checked::after {
  content: '';
  position: absolute;
  left: 2px; top: -1px;
  width: 5px; height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.task-text {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}
.task-text.done { text-decoration: line-through; color: var(--text-muted); }

.task-del-btn {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
  flex-shrink: 0;
}
.task-item:hover .task-del-btn { opacity: 1; }
.task-del-btn:hover { background: rgba(248,113,113,0.15); color: #f87171; }

.add-task-row {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: auto;
  flex-shrink: 0;
  padding-top: 4px;
}

.add-task-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.add-task-input::placeholder { color: var(--text-muted); }
.add-task-input:focus { border-color: var(--accent); }

.add-task-btn {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: none;
  background: var(--surface3);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.add-task-btn:hover { background: var(--accent); color: #fff; }

/* CARD OVERFLOW & EXPAND */
.card-overflow-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 8px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.card-overflow-text {
  opacity: 0.7;
}
.card-expand-btn {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.card-expand-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* RESIZE HANDLE */
.resize-handle {
  position: absolute;
  bottom: 0; right: 0;
  width: 20px; height: 20px;
  cursor: nwse-resize;
  display: flex; align-items: flex-end; justify-content: flex-end;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 3px;
  opacity: 0.4;
  transition: opacity 0.15s;
  user-select: none;
  z-index: 5;
}
.canvas-card:hover .resize-handle { opacity: 1; }

/* ── SPACES ── */
.space-el {
  position: absolute;
  border-radius: 20px;
  border: 2px dashed var(--dashed-border);
  background: var(--hover-bg);
  min-width: 280px;
  min-height: 180px;
  z-index: 0;
  transition: border-color 0.2s, background 0.2s;
  --sc: #7c6fcd;
}
.space-el:hover { border-color: var(--sc); background: var(--hover-bg); }
.space-el.drop-target { border-color: var(--sc); border-style: solid; background: var(--subtle-bg); }
.space-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  cursor: move;
  touch-action: none;
  user-select: none;
}
.space-color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--sc);
  box-shadow: 0 0 8px var(--sc);
  flex-shrink: 0;
}
.space-title-input {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  padding: 0;
  letter-spacing: -0.2px;
  cursor: text;
  min-width: 60px;
}
.space-title-input::placeholder { color: var(--text-muted); font-weight: 500; }
.space-title-text {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  min-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.space-menu-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
  opacity: 0;
  flex-shrink: 0;
}
.space-el:hover .space-menu-btn { opacity: 1; }
.space-menu-btn:hover { background: var(--subtle-bg); color: var(--text); }
@media (hover: none) { .space-menu-btn { opacity: 0.7; } }
.space-resize-handle {
  position: absolute;
  bottom: 0; right: 0;
  width: 28px; height: 28px;
  cursor: nwse-resize;
  display: flex; align-items: flex-end; justify-content: flex-end;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px 5px;
  opacity: 0.2;
  transition: opacity 0.15s;
  touch-action: none;
}
.space-el:hover .space-resize-handle { opacity: 0.7; }
.space-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
  flex-shrink: 0;
}

/* ── IMAGES ── */
.card-images { padding: 0 12px 12px; flex-shrink: 0; }
.card-images-sep { height: 1px; background: var(--border); margin: 4px 0 10px; }
.img-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.img-thumb {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 9px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}
.img-thumb:hover { box-shadow: 0 0 0 2px var(--accent); }
.img-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform 0.2s;
}
.img-thumb:hover img { transform: scale(1.07); }
.img-thumb-del {
  position: absolute; top: 3px; right: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: rgba(0,0,0,0.75);
  border: none; color: #fff;
  font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0; transition: opacity 0.12s;
  padding: 0;
}
.img-thumb:hover .img-thumb-del { opacity: 1; }

.img-upload-label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1.5px dashed var(--dashed-border);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  background: none;
  font-family: inherit;
  white-space: nowrap;
}
.img-upload-label:hover { border-color: var(--accent); color: var(--accent); }

/* ── FILE ATTACHMENTS ── */
.card-files {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  min-width: 0;
}
.file-item-icon { font-size: 15px; flex-shrink: 0; }
.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.file-btn {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--dashed-border);
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
  font-family: inherit;
  white-space: nowrap;
}
.file-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-del-btn {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--subtle-bg);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.file-del-btn:hover { background: rgba(248,113,113,0.18); color: #f87171; }

/* ── FILE PREVIEW MODAL ── */
#file-preview-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.93);
  z-index: 3100;
  display: none;
  flex-direction: column;
  align-items: center;
}
#file-preview-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#file-preview-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#file-preview-close {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#file-preview-body {
  flex: 1;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#file-preview-iframe {
  width: 100%; height: 100%;
  border: none;
  flex: 1;
}
#file-preview-md {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  color: var(--text);
  line-height: 1.65;
}
#file-preview-md h1, #file-preview-md h2, #file-preview-md h3 {
  margin: 1em 0 0.4em;
  line-height: 1.25;
}
#file-preview-md h1 { font-size: 1.7em; }
#file-preview-md h2 { font-size: 1.35em; }
#file-preview-md h3 { font-size: 1.1em; }
#file-preview-md p { margin: 0.6em 0; }
#file-preview-md ul, #file-preview-md ol { padding-left: 1.5em; margin: 0.6em 0; }
#file-preview-md li { margin: 0.2em 0; }
#file-preview-md code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'Courier New', monospace;
}
#file-preview-md pre {
  background: var(--surface2);
  padding: 14px 18px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0.8em 0;
}
#file-preview-md pre code { background: none; padding: 0; }
#file-preview-md blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.8em 0;
  padding: 4px 14px;
  color: var(--text-muted);
}
#file-preview-md a { color: var(--accent); }
#file-preview-md hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
#file-preview-md table { border-collapse: collapse; width: 100%; margin: 0.8em 0; }
#file-preview-md th, #file-preview-md td { border: 1px solid var(--border); padding: 6px 10px; }
#file-preview-md th { background: var(--surface2); font-weight: 600; }
/* ── LINKS IN CARD ── */
.card-links {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--border);
}
.card-links-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.card-links-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.link-add-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1.5px dashed var(--dashed-border);
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.link-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.link-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.link-row-icon { font-size: 13px; flex-shrink: 0; }
.link-row-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  cursor: pointer;
  text-decoration: none;
}
.link-row-open:hover .link-row-title { color: var(--accent); }
.link-row-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.12s;
}
.link-row-url {
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-copy-btn, .link-del-btn {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 6px;
  border: none;
  background: var(--subtle-bg);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.link-copy-btn:hover { background: rgba(124,111,205,0.18); color: var(--accent); }
.link-del-btn:hover { background: rgba(248,113,113,0.18); color: #f87171; }

/* Link add inline form */
.link-add-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.link-form-input {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.link-form-input:focus { border-color: var(--accent); }
.link-form-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}
.link-form-save {
  padding: 4px 12px;
  border-radius: 7px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.link-form-save:hover { opacity: 0.85; }
.link-form-cancel {
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.link-form-cancel:hover { color: var(--text); }

/* ── SECRETS IN CARD ── */
.card-secrets {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--border);
}
.card-secrets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.card-secrets-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.secret-add-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1.5px dashed var(--dashed-border);
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.secret-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.secret-row:hover { border-color: rgba(124,111,205,0.45); background: var(--surface3); }
.secret-row-icon { font-size: 13px; flex-shrink: 0; opacity: 0.7; }
.secret-row-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.secret-row-count { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }

/* ── SECRET MODAL ── */
#secret-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 3200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#secret-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px var(--shadow-modal);
  overflow: hidden;
}
#secret-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#secret-panel-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.secret-panel-icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.secret-panel-icon-btn:hover { border-color: var(--accent); color: var(--text); }
.secret-panel-icon-btn.danger:hover { border-color: #f87171; color: #f87171; }
#secret-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* View mode */
.secret-view-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.secret-field-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.03em;
}
.secret-field-value-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 10px;
}
.secret-field-value {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  font-family: 'Courier New', monospace;
  word-break: break-all;
  min-width: 0;
  letter-spacing: 0.04em;
}
.secret-field-value.masked { letter-spacing: 0.12em; }
.secret-field-btn {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 7px;
  border: none;
  background: var(--subtle-bg);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.secret-field-btn:hover { background: rgba(124,111,205,0.2); color: var(--accent); }
.secret-field-btn.copied { background: rgba(52,211,153,0.18); color: #34d399; }
/* Edit mode */
.secret-edit-field-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr auto;
  gap: 6px;
  align-items: center;
}
.secret-edit-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.secret-edit-input:focus { border-color: var(--accent); }
.secret-edit-input.val { font-family: 'Courier New', monospace; }
.secret-field-del-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: none;
  background: var(--subtle-bg);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.secret-field-del-btn:hover { background: rgba(248,113,113,0.18); color: #f87171; }
.secret-edit-add-field {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1.5px dashed var(--dashed-border);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  align-self: flex-start;
  margin-top: 2px;
}
.secret-edit-add-field:hover { border-color: var(--accent); color: var(--accent); }
#secret-panel-footer {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.secret-save-btn {
  flex: 1;
  padding: 9px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.secret-save-btn:hover { opacity: 0.85; }
.secret-edit-title-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 4px;
}
.secret-edit-title-input:focus { border-color: var(--accent); }
.secret-fields-edit-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.secret-copy-toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface3);
  border: 1px solid rgba(52,211,153,0.3);
  color: #34d399;
  padding: 8px 18px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 9999;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s;
}

.img-uploading-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }

/* ── LIGHTBOX ── */
#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.93);
  z-index: 3000;
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  gap: 14px;
}
#lightbox-img {
  max-width: 90vw; max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 60px rgba(0,0,0,0.7);
  user-select: none;
}
#lightbox-bar {
  display: flex; align-items: center; gap: 14px;
}
.lb-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.07);
  color: #fff; font-size: 22px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}
.lb-btn:hover { background: rgba(255,255,255,0.18); }
.lb-btn:disabled { opacity: 0.25; cursor: default; }
#lb-counter { font-size: 13px; color: rgba(255,255,255,0.45); min-width: 52px; text-align: center; }
#lb-close {
  position: fixed; top: 16px; right: 20px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff; font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#lb-close:hover { background: rgba(255,255,255,0.22); }

/* CONTEXT MENU */
#ctx-menu {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  min-width: 170px;
  z-index: 1000;
  box-shadow: 0 8px 32px var(--shadow-modal);
  display: none;
}
#ctx-menu.show { display: block; }

.ctx-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.ctx-item:hover { background: var(--surface3); }
.ctx-item.danger { color: #f87171; }
.ctx-item.danger:hover { background: rgba(248,113,113,0.1); }

.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* MODAL */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
#modal-overlay.show { display: flex; }

#modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 16px 64px var(--shadow-modal);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 22px;
  color: var(--text);
}

.form-group {
  margin-bottom: 18px;
}
.form-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 7px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--accent); }

/* ICON GRID */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.icon-opt {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface2);
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.icon-opt:hover { background: var(--surface3); }
.icon-opt.selected { border-color: var(--accent); background: var(--surface3); }

/* COLOR PICKERS */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.color-opt {
  width: 28px; height: 28px;
  border-radius: 7px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.color-opt:hover { transform: scale(1.12); }
.color-opt.selected { border-color: #fff; }

.bg-color-opt {
  width: 34px; height: 28px;
  border-radius: 7px;
  cursor: pointer;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.12s, border-color 0.12s;
}
.bg-color-opt:hover { transform: scale(1.08); }
.bg-color-opt.selected { border-color: #fff; color: var(--text); }

/* MODAL MOVE BUTTONS */
.move-btns {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.move-btn {
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.move-btn:hover { background: var(--surface3); }
.move-btn.active-dest { border-color: var(--accent); color: var(--accent); }

/* MODAL ACTIONS */
.modal-actions {
  display: flex;
  gap: 9px;
  margin-top: 22px;
  justify-content: flex-end;
  align-items: center;
}

.btn-primary {
  padding: 9px 22px;
  border-radius: 9px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.87; }

.btn-ghost {
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  padding: 9px 16px;
  border-radius: 9px;
  border: none;
  background: rgba(248,113,113,0.12);
  color: #f87171;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  margin-right: auto;
}
.btn-danger:hover { background: rgba(248,113,113,0.22); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* NO SELECT DURING DRAG */
body.dragging { user-select: none !important; }
body.dragging * { user-select: none !important; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  /* Two-row topbar: row1 = logo + actions, row2 = tabs (injected by JS) */
  #topbar-row1 { padding: 8px 12px; gap: 8px; }
  #app-title { display: inline !important; font-size: 13px; flex-shrink: 0; }

  /* Hide secondary buttons — moved to more-menu */
  #sync-btn { display: none !important; }
  #telegram-link { display: none !important; }
  #theme-toggle-btn { display: none !important; }
  #lang-switch-btn { display: none !important; }

  /* Tabs: move to row2 (full width) */
  #tabs {
    gap: 2px;
    flex: 1;
    justify-content: center;
    padding: 2px 4px;
  }
  .tab-btn { padding: 6px 0; font-size: 12px; white-space: nowrap; flex: 1; text-align: center; }
  #topbar-row2 {
    display: flex;
    padding: 0 12px 8px;
  }
  #topbar-row2 #tabs {
    display: flex !important;
    flex: 1;
    gap: 2px;
    justify-content: center;
  }
  #topbar-row2 .tab-btn {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    font-size: 12px;
  }

  /* Show more button */
  #topbar-more-btn { display: flex; align-items: center; justify-content: center; }

  #btn-new-project { margin-left: auto; padding: 6px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }

  .list-view { padding: 12px; }
  .list-cards { max-width: 100%; }
  .card-title { font-size: 26px; }
  /* Bottom toolbar: fixed full width on mobile */
  #zoom-controls {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    border-radius: 0;
    border-bottom: none; border-left: none; border-right: none;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
    justify-content: center;
    z-index: 50;
  }
  /* Prevent canvas from being hidden behind fixed bottom bar */
  #canvas-container { padding-bottom: 56px; }
  .zoom-btn { width: 40px; height: 40px; font-size: 18px; }
  #btn-add-space { font-size: 13px !important; }
  #modal { padding: 18px 14px; }
  .icon-grid { grid-template-columns: repeat(8, 1fr); }
  .modal-actions { flex-wrap: wrap; }
  .btn-primary, .btn-ghost, .btn-danger { padding: 10px 14px; font-size: 13px; }
  .card-header { padding: 10px 10px 8px; }
  .card-icon { font-size: 24px; }
  /* Modal full width */
  #modal-overlay .modal { max-width: calc(100vw - 24px); }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .tab-btn { font-size: 11px; }
  #topbar-row2 .tab-btn { font-size: 11px; }
  #btn-new-project { font-size: 11px; padding: 5px 8px; }
  .card-title { font-size: 20px; }
  .icon-grid { grid-template-columns: repeat(6, 1fr); }
  /* Compact bottom bar */
  #zoom-controls { padding: 6px 8px; gap: 4px; }
  .zoom-btn { width: 36px; height: 36px; font-size: 16px; }
  #btn-add-space { font-size: 12px !important; padding: 0 8px !important; }
  #zoom-label { font-size: 11px; min-width: 32px; }
  /* Card adjustments */
  .card-body { padding: 8px 10px; }
  .task-item { font-size: 13px; }
  .img-upload-label { font-size: 12px; }
}

@media (max-width: 360px) {
  .tab-btn { font-size: 10px; }
  #topbar-row2 .tab-btn { font-size: 10px; }
  #btn-new-project { font-size: 10px; padding: 4px 6px; }
}

@media (hover: none) {
  /* Always show interactive elements on touch devices */
  .task-del-btn { opacity: 0.6; }
  .card-menu-btn { opacity: 1; }
  .resize-handle { opacity: 0.7; }
  .img-thumb-del { opacity: 0.8; }
  .link-del-btn { opacity: 0.8; }
}

/* AUTH SCREEN */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  text-align: center;
}
.auth-logo {
  font-size: 40px;
  margin-bottom: 8px;
}
.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.auth-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.auth-google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-google-btn:hover {
  background: var(--surface3);
  border-color: var(--dashed-border);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s;
}
.auth-input:focus {
  border-color: var(--accent);
}
.auth-error {
  display: none;
  color: #f87171;
  font-size: 13px;
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(248,113,113,0.08);
  border-radius: 8px;
  text-align: left;
}
.auth-btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 8px;
}
.auth-btn-primary:hover { opacity: 0.87; }
.auth-btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-btn-secondary:hover { color: var(--text); border-color: var(--dashed-border); }
.auth-btn-danger {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(248,113,113,0.2);
  background: rgba(248,113,113,0.08);
  color: #f87171;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-btn-danger:hover { background: rgba(248,113,113,0.15); }
.auth-lang-switch {
  margin-top: 20px;
}
.auth-lang-switch button {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
}

/* PROFILE MODAL */
#profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#profile-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  width: 420px;
  max-width: calc(100vw - 24px);
  box-shadow: 0 16px 64px var(--shadow-modal);
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.profile-name { font-size: 16px; font-weight: 600; }
.profile-email { font-size: 13px; color: var(--text-muted); }
.profile-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.profile-section { margin-bottom: 20px; }
.profile-stats {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 20px;
  background: var(--surface2);
  border-radius: 12px;
  overflow: hidden;
}
.profile-stat {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.profile-stat:last-child { border-bottom: none; }
.profile-stat-label { color: var(--text-muted); }
.profile-stat-value { font-weight: 600; }

#tab-active {
  padding-bottom: 52px;
}

/* ─── AI Chat Command Bar ─── */
.ai-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-secondary, #1a1a2e);
  border-top: 1px solid var(--border, #333);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-bar-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.ai-bar-input {
  flex: 1;
  background: var(--bg-primary, #0f0f23);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary, #e0e0e0);
  font-size: 14px;
  outline: none;
}

.ai-bar-input:focus {
  border-color: var(--accent, #7c6fcd);
}

.ai-bar-input::placeholder {
  color: var(--text-secondary, #888);
}

.ai-model-select {
  background: var(--bg-primary, #0f0f23);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text-primary, #e0e0e0);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  max-width: 160px;
}

.ai-bar-send {
  background: var(--accent, #7c6fcd);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.ai-bar-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-bar-toggle {
  background: none;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-secondary, #888);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
}

.ai-bar-toggle:hover {
  color: var(--text-primary, #e0e0e0);
}

.ai-bar-toggle.active {
  color: var(--accent, #7c6fcd);
  border-color: var(--accent, #7c6fcd);
}

/* ─── AI Response Panel ─── */
.ai-response-panel {
  position: fixed;
  bottom: 52px;
  left: 0;
  right: 0;
  z-index: 999;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--bg-secondary, #1a1a2e);
  border-top: 1px solid var(--border, #333);
  padding: 12px 16px;
  display: none;
}

.ai-response-panel.open {
  display: block;
}

.ai-msg {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 80%;
  word-wrap: break-word;
}

.ai-msg-user {
  background: var(--accent, #7c6fcd);
  color: white;
  margin-left: auto;
  text-align: right;
}

.ai-msg-ai {
  background: var(--bg-primary, #0f0f23);
  color: var(--text-primary, #e0e0e0);
}

.ai-msg-ai .ai-cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--accent, #7c6fcd);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.ai-action-badge {
  display: inline-block;
  background: rgba(124, 111, 205, 0.15);
  color: var(--accent, #7c6fcd);
  border: 1px solid rgba(124, 111, 205, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  margin: 4px 4px 4px 0;
  cursor: pointer;
}

.ai-action-badge:hover {
  background: rgba(124, 111, 205, 0.25);
}

.ai-thinking {
  color: var(--text-secondary, #888);
  font-size: 12px;
  font-style: italic;
  padding: 4px 0;
}

.ai-error {
  color: #e74c3c;
  font-size: 13px;
  padding: 6px 10px;
  background: rgba(231, 76, 60, 0.1);
  border-radius: 6px;
}

/* ─── Mobile: hide desktop bar, show mobile button ─── */
.ai-mobile-btn {
  display: none !important;
}

.ai-mobile-overlay {
  display: none;
}

@media (max-width: 768px) {
  .ai-bar { display: none; }
  .ai-response-panel { display: none !important; }

  .ai-mobile-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 18px;
    background: none;
    border: none;
    cursor: pointer;
  }

  /* ── Fullscreen overlay ── */
  .ai-mobile-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2000;
    background: var(--bg-primary, #0f0f23);
    flex-direction: column;
    overflow: hidden;
  }

  .ai-mobile-overlay.open {
    display: flex;
  }

  /* ── Header bar ── */
  .ai-mobile-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border, #333);
    gap: 10px;
    flex-shrink: 0;
    background: var(--bg-secondary, #1a1a2e);
  }

  .ai-mobile-header .ai-bar-icon {
    font-size: 20px;
    flex-shrink: 0;
  }

  .ai-mobile-header .ai-model-select {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary, #0f0f23);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-primary, #e0e0e0);
    font-size: 14px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
  }

  .ai-mobile-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    font-size: 28px;
    cursor: pointer;
    padding: 4px 0;
    flex-shrink: 0;
    line-height: 1;
  }

  /* ── Empty state ── */
  .ai-mobile-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    color: var(--text-secondary, #888);
    padding: 32px;
    text-align: center;
  }

  .ai-mobile-empty-icon {
    font-size: 48px;
    opacity: 0.4;
  }

  .ai-mobile-empty-text {
    font-size: 15px;
    line-height: 1.5;
  }

  /* ── Messages area ── */
  .ai-mobile-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .ai-mobile-messages .ai-msg {
    max-width: 88%;
    margin-bottom: 0;
    font-size: 15px;
    line-height: 1.5;
    padding: 10px 14px;
    border-radius: 16px;
    word-break: break-word;
  }

  .ai-mobile-messages .ai-msg-user {
    align-self: flex-end;
    border-radius: 16px 16px 4px 16px;
  }

  .ai-mobile-messages .ai-msg-ai {
    align-self: flex-start;
    border-radius: 16px 16px 16px 4px;
  }

  .ai-mobile-messages .ai-action-badge {
    font-size: 13px;
    padding: 6px 12px;
    margin: 2px 4px 2px 0;
  }

  .ai-mobile-messages .ai-thinking {
    font-size: 13px;
    padding: 6px 0;
  }

  .ai-mobile-messages .ai-error {
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 12px;
  }

  /* ── Input row (bottom) ── */
  .ai-mobile-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border, #333);
    background: var(--bg-secondary, #1a1a2e);
    flex-shrink: 0;
  }

  .ai-mobile-input-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary, #0f0f23);
    border: 1px solid var(--border, #333);
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--text-primary, #e0e0e0);
    font-size: 16px;
    outline: none;
    /* Prevent iOS zoom on input focus */
    font-size: 16px;
  }

  .ai-mobile-input-row input:focus {
    border-color: var(--accent, #7c6fcd);
  }

  .ai-mobile-input-row input::placeholder {
    color: var(--text-secondary, #888);
  }

  .ai-mobile-input-row .ai-bar-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
}

/* ─── Timezone modal ─── */
.tz-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); display: flex;
  align-items: center; justify-content: center;
}
.tz-modal-card {
  background: var(--card-bg, #1a1a2e); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 28px 24px; text-align: center;
  max-width: 360px; width: 90%;
}
.tz-modal-card h3 { margin: 0 0 8px; font-size: 18px; }
.tz-modal-card p { color: #888; margin: 0 0 20px; font-size: 14px; }
.tz-modal-buttons { display: flex; gap: 10px; justify-content: center; margin-bottom: 12px; }
.tz-btn-confirm {
  background: #7c6fcd; color: #fff; border: none; border-radius: 10px;
  padding: 10px 24px; cursor: pointer; font-size: 14px;
}
.tz-btn-confirm:hover { background: #6b5fba; }
.tz-btn-change {
  background: transparent; color: #888; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px; padding: 10px 24px; cursor: pointer; font-size: 14px;
}
.tz-btn-change:hover { color: #fff; border-color: rgba(255,255,255,0.3); }
.tz-offset-list {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin-top: 12px; max-height: 200px; overflow-y: auto;
}
.tz-offset-btn {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  color: #ccc; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px;
}
.tz-offset-btn:hover, .tz-offset-btn.active {
  background: #7c6fcd; color: #fff; border-color: #7c6fcd;
}

/* ─── Task clock button ─── */
.task-clock-btn {
  background: none; border: none; cursor: pointer; font-size: 12px;
  opacity: 0; transition: opacity 0.15s; padding: 2px 4px;
  position: relative; flex-shrink: 0;
}
.task-item:hover .task-clock-btn { opacity: 0.5; }
.task-clock-btn:hover { opacity: 1 !important; }
.task-clock-btn.has-deadline { opacity: 0.7; }
.task-clock-btn.soon { opacity: 1; filter: hue-rotate(-30deg) saturate(2); }
.task-clock-btn.overdue { opacity: 1; filter: hue-rotate(-60deg) saturate(3) brightness(1.2); }

/* ─── Reminder popup ─── */
.reminder-popup {
  position: fixed; z-index: 9998;
  background: var(--card-bg, #1a1a2e); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px; padding: 16px; min-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.reminder-section { margin-bottom: 12px; }
.reminder-label {
  display: block; font-size: 12px; color: #888;
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.reminder-row {
  display: flex; gap: 6px; align-items: center; margin-bottom: 6px;
}
.reminder-date-input, .reminder-time-input {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: #e8e8f0; border-radius: 8px; padding: 6px 8px; font-size: 13px;
  outline: none;
}
.reminder-date-input { flex: 1; }
.reminder-time-input { width: 90px; }
.reminder-date-input:focus, .reminder-time-input:focus {
  border-color: #7c6fcd;
}
.reminder-clear-btn {
  background: none; border: none; color: #f87171; cursor: pointer;
  font-size: 16px; padding: 4px 6px; flex-shrink: 0;
}
.reminder-clear-btn:hover { color: #ef4444; }
.reminder-add-btn {
  background: rgba(124,111,205,0.15); color: #7c6fcd; border: none;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px;
  width: 100%;
}
.reminder-add-btn:hover { background: rgba(124,111,205,0.25); }
.reminder-save-btn {
  background: #7c6fcd; color: #fff; border: none; border-radius: 10px;
  padding: 8px 20px; cursor: pointer; font-size: 14px; width: 100%;
  margin-top: 8px;
}
.reminder-save-btn:hover { background: #6b5fba; }

/* ─── FINANCE TAB ─── */
.finance-tab-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}
.finance-filters {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.finance-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.finance-filter-group label {
  font-size: 13px;
  color: var(--text-muted);
}
.finance-filter-group select {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
}
.finance-action-btn {
  margin-left: auto;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.finance-action-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.finance-summary-bar {
  display: flex;
  gap: 24px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
}
.finance-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.finance-summary-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.finance-summary-value {
  font-size: 22px;
  font-weight: 700;
}
.finance-income { color: #4ade80; }
.finance-expense { color: #f87171; }
.finance-project-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}
.finance-project-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
}
.finance-project-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.finance-project-table tr:hover td {
  background: var(--surface2);
}
.finance-category-section {
  margin-bottom: 20px;
}
.finance-category-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.finance-category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.finance-category-name {
  width: 120px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.finance-category-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--surface3);
  border-radius: 4px;
  overflow: hidden;
}
.finance-category-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.finance-category-amount {
  font-size: 13px;
  width: 100px;
  text-align: right;
  white-space: nowrap;
}
.finance-category-pct {
  font-size: 11px;
  color: var(--text-muted);
  width: 40px;
  text-align: right;
}
.finance-tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.finance-tx-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
}
.finance-tx-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.finance-tx-table tr:hover td {
  background: var(--surface2);
}
.finance-tx-delete {
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.15s;
  background: none;
  border: none;
  font-size: 14px;
  padding: 2px 4px;
}
.finance-tx-delete:hover {
  opacity: 1;
}
#finance-load-more {
  text-align: center;
  padding: 12px;
}
#finance-load-more-btn {
  padding: 8px 24px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
#finance-load-more-btn:hover {
  background: var(--surface3);
}

/* ─── FINANCE IN CARD ─── */
.card-finances {
  padding: 8px 12px 4px;
  border-top: 1px solid var(--border);
}
.card-finances-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.card-finances-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-finances-period {
  display: flex;
  gap: 2px;
}
.card-finances-period button {
  padding: 1px 6px;
  font-size: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
}
.card-finances-period button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.card-finance-totals {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 12px;
}
.card-finance-balance {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}
.card-finance-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.card-finance-add-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.card-finance-add-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ─── ADD TRANSACTION MODAL ─── */
.tx-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.tx-modal-body label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.tx-modal-body input,
.tx-modal-body select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}
.tx-modal-body .tx-modal-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tx-modal-submit {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.tx-modal-submit:hover {
  opacity: 0.9;
}

/* ─── SHARED SPACES ─── */
.space-shared-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}
.space-member-avatars {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  padding: 0 8px;
}
.space-member-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-avatar-lg {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 14px; font-weight: 500; }
.member-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-muted);
}
.member-role.owner {
  background: var(--accent);
  color: #fff;
}
.member-remove-btn {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.15s;
  padding: 4px;
}
.member-remove-btn:hover { opacity: 1; }
.invite-link-box {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 12px;
}
.invite-link-box input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
}
.invite-link-box button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

/* ─── NOTES CARD SECTION ─── */
.card-notes {
  padding: 6px 12px 4px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.card-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.card-notes-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-notes-add-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
}
.card-notes-add-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.card-notes-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 140px;
  overflow-y: auto;
}
.card-note-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.1s;
}
.card-note-item:hover { background: var(--surface2); }
.card-note-item.active { background: var(--accent); color: #fff; }
.card-note-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.card-note-item-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  white-space: nowrap;
}
.card-note-item.active .card-note-item-date { color: rgba(255,255,255,0.7); }
.card-note-item-pin { font-size: 8px; margin-right: 3px; }
.card-note-item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.card-note-item:hover .card-note-item-actions { opacity: 1; }
.card-note-item-actions button {
  background: none;
  border: none;
  font-size: 10px;
  cursor: pointer;
  padding: 1px 3px;
  opacity: 0.6;
}
.card-note-item-actions button:hover { opacity: 1; }
.card-notes-editor-wrap {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.card-notes-editor-active {
  width: 100%;
  min-height: 80px;
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  resize: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  outline: none;
  box-sizing: border-box;
  overflow-y: auto;
}
.card-notes-editor-active::placeholder { color: var(--text-muted); }
.card-notes-status {
  font-size: 10px;
  color: #4ade80;
  padding: 2px 10px 4px;
}
.card-notes-status.saving { color: #fbbf24; }
/* ─── CARD NOTES BUTTON ─── */
.card-notes-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  position: relative;
  opacity: 0.6;
}
.card-notes-btn:hover { opacity: 1; }
.card-notes-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 8px;
  line-height: 1.2;
}

/* Sync reconnect animation */
@keyframes sync-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#sync-icon[style*="f59e0b"] {
  animation: sync-pulse 1.5s ease-in-out infinite;
}

/* ─── WELCOME SCREEN ─── */
#welcome-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.welcome-card {
  text-align: center;
  max-width: 400px;
  width: 100%;
}
.welcome-logo { font-size: 64px; margin-bottom: 16px; }
.welcome-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.welcome-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.welcome-actions { display: flex; flex-direction: column; gap: 10px; }
.welcome-btn {
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}
.welcome-btn:hover { background: var(--surface2); }
.welcome-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.welcome-btn.primary:hover { opacity: 0.9; }
.welcome-template-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.welcome-template-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.welcome-template-item:hover { background: var(--surface2); border-color: var(--accent); }
.wt-icon { font-size: 24px; }
.wt-name { font-weight: 600; font-size: 14px; }
.wt-desc { font-size: 12px; color: var(--text-muted); }

/* ─── TOUR ─── */
#tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 5100;
}
#tour-highlight {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  transition: all 0.3s ease;
  pointer-events: none;
}
#tour-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  max-width: 320px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 5200;
}
#tour-text { font-size: 14px; color: var(--text); line-height: 1.5; margin-bottom: 12px; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-btn-skip { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.tour-btn-next { padding: 8px 18px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-size: 13px; cursor: pointer; }
#tour-dots { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.tour-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.tour-dot.active { background: var(--accent); }

/* ─── MOBILE LIST VIEW ─── */
#mobile-list {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 70px;
  -webkit-overflow-scrolling: touch;
}
.mobile-space-section {
  margin-bottom: 16px;
}
.mobile-space-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
}
.mobile-space-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mobile-space-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}
.mobile-space-count {
  font-size: 12px;
  color: var(--text-muted);
}
.mobile-space-toggle {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.mobile-space-toggle.collapsed { transform: rotate(-90deg); }
.mobile-space-menu-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
}
.mobile-space-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 4px;
}
.mobile-space-cards.hidden { display: none; }
.mobile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  border-left: 3px solid var(--accent);
}
.mobile-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.mobile-card-icon { font-size: 16px; }
.mobile-card-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-card-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.mobile-card-progress {
  width: 60px;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
  align-self: center;
}
.mobile-card-progress-fill { height: 100%; border-radius: 2px; }
.mobile-card-body {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}
.mobile-card.expanded .mobile-card-body { display: block; }
.mobile-card-menu {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.mobile-no-space-label {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 12px;
  margin-bottom: 6px;
}
.mobile-list-fab {
  position: fixed;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
  right: 16px;
  z-index: 100;
}
.mobile-fab-btn {
  padding: 12px 24px;
  border-radius: 24px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
@media (min-width: 769px) {
  #mobile-list { display: none !important; }
  .mobile-list-fab { display: none !important; }
}
