/* Notes PWA — adapted from desktop app for mobile/web */
:root {
  --bg: #faf9f6;
  --bg-sidebar: #f0ede5;
  --bg-list: #f5f3ec;
  --bg-editor: #ffffff;
  --bg-toolbar: #fafaf6;
  --text: #1a1a1c;
  --text-dim: #6e6e73;
  --text-faint: #a0a0a5;
  --accent: #e8a91f;
  --accent-hover: #d4961a;
  --accent-soft: rgba(232, 169, 31, 0.12);
  --accent-glow: rgba(232, 169, 31, 0.35);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --hover: rgba(0, 0, 0, 0.04);
  --danger: #e24d4d;
  --success: #2eb573;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.18);
  --topbar-bg: #eeeae0;
  --editor-font-size: 16px;
  --code-bg: #f3f2ed;
}
body.theme-dark {
  --bg: #0f0f10;
  --bg-sidebar: #161618;
  --bg-list: #1a1a1c;
  --bg-editor: #1e1e20;
  --bg-toolbar: #1a1a1c;
  --text: #f0f0f2;
  --text-dim: #9c9ca0;
  --text-faint: #5c5c60;
  --accent: #ffc857;
  --accent-hover: #ffd578;
  --accent-soft: rgba(255, 200, 87, 0.14);
  --accent-glow: rgba(255, 200, 87, 0.35);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --hover: rgba(255, 255, 255, 0.04);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
  --topbar-bg: #131315;
  --code-bg: #141416;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", "Inter", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
  overflow: hidden; -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv02", "cv11";
  touch-action: manipulation;
}
button { cursor: pointer; font-family: inherit; transition: background .15s, transform .1s, color .15s, box-shadow .15s, opacity .15s; border: none; }
button:active { transform: scale(0.97); }
input, textarea, select { font-family: inherit; color: var(--text); font-size: 16px; }
input:focus, textarea:focus { outline: none; }
.hidden { display: none !important; }

/* ============== TOPBAR ============== */
#topbar {
  height: 44px; background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px; flex-shrink: 0; padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.tb-left, .tb-right { display: flex; gap: 2px; align-items: center; }
.tb-title { font-size: 13px; color: var(--text-dim); font-weight: 600; letter-spacing: 0.01em; }
.tb-btn {
  background: transparent; color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn.active { background: var(--accent-soft); color: var(--accent); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); margin: 0 8px; }
.sync-dot.syncing { background: var(--accent); animation: pulse 1s infinite; }
.sync-dot.ok { background: var(--success); }
.sync-dot.err { background: var(--danger); }
.sync-dot.offline { background: var(--text-faint); }

/* ============== AUTH SCREEN ============== */
#authScreen {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  padding: 24px; padding-top: calc(44px + env(safe-area-inset-top));
}
.auth-card {
  background: var(--bg-editor); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px 28px;
  max-width: 400px; width: 100%; box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; font-size: 42px; margin-bottom: 8px; }
.auth-card h2 { margin: 0 0 6px; font-weight: 800; letter-spacing: -0.02em; text-align: center; font-size: 24px; }
.auth-sub { color: var(--text-dim); text-align: center; margin: 0 0 24px; font-size: 13px; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 10px 0 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.auth-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); border-radius: 10px; font-size: 15px;
}
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 10px 0 4px; }
.auth-card .primary-btn { width: 100%; padding: 13px; font-size: 15px; margin-top: 8px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--text-dim); margin-top: 16px; }
.auth-switch a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }
.auth-server {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-faint); text-align: center;
}
.auth-server input {
  margin-top: 4px; padding: 7px 10px; font-size: 12px; background: var(--bg);
  border-radius: 7px; text-align: center;
}

/* ============== LAYOUT ============== */
#app {
  display: grid; grid-template-columns: 240px 300px 1fr;
  height: calc(100dvh - 44px - env(safe-area-inset-top));
  transition: grid-template-columns 0.22s cubic-bezier(0.3, 0.8, 0.4, 1);
}
body.sidebar-hidden #app { grid-template-columns: 0 300px 1fr; }
body.noteslist-hidden #app { grid-template-columns: 240px 0 1fr; }
body.sidebar-hidden.noteslist-hidden #app { grid-template-columns: 0 0 1fr; }
body.sidebar-hidden #sidebar, body.noteslist-hidden #notesList {
  overflow: hidden; min-width: 0; border-right: none;
}
body.sidebar-hidden #sidebar > *, body.noteslist-hidden #notesList > * {
  opacity: 0; pointer-events: none;
}

/* Mobile — stack panels, swipe between them */
@media (max-width: 900px) {
  #app {
    grid-template-columns: 100% !important;
    grid-template-rows: 1fr;
  }
  #sidebar, #notesList, #editorPane {
    grid-column: 1; grid-row: 1;
    transition: transform 0.25s cubic-bezier(0.3, 0.8, 0.4, 1);
  }
  #sidebar { transform: translateX(-100%); }
  #notesList { transform: translateX(0); }
  #editorPane { transform: translateX(100%); }
  body.mob-view-sidebar #sidebar { transform: translateX(0); }
  body.mob-view-sidebar #notesList { transform: translateX(100%); }
  body.mob-view-sidebar #editorPane { transform: translateX(200%); }
  body.mob-view-list #sidebar { transform: translateX(-100%); }
  body.mob-view-list #notesList { transform: translateX(0); }
  body.mob-view-list #editorPane { transform: translateX(100%); }
  body.mob-view-editor #sidebar { transform: translateX(-100%); }
  body.mob-view-editor #notesList { transform: translateX(-100%); }
  body.mob-view-editor #editorPane { transform: translateX(0); }

  body.sidebar-hidden #app { grid-template-columns: 100% !important; }
  body.noteslist-hidden #app { grid-template-columns: 100% !important; }

  .tt-editor .ProseMirror { padding: 20px 18px 100px; }
  .editor-header { padding: 12px 16px 6px !important; }
  #noteTitle { font-size: 22px !important; }
  .tt-toolbar { padding: 6px 10px !important; overflow-x: auto; flex-wrap: nowrap; }
}

/* ============== SIDEBAR ============== */
#sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-actions { padding: 14px 14px 8px; }
.ghost-btn {
  width: 100%; background: transparent; border: 1px solid var(--border-strong);
  color: var(--text); padding: 10px 12px; border-radius: 9px;
  font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; justify-content: center;
}
.ghost-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.icon-plus { font-size: 15px; font-weight: 600; line-height: 1; }
.section-label {
  padding: 14px 18px 6px; font-size: 10px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700;
}
.folders { list-style: none; padding: 0 8px; margin: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.folder-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 14px; user-select: none; margin-bottom: 2px; color: var(--text); position: relative;
}
.folder-item:hover { background: var(--hover); }
.folder-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder-item.active::before { content: ''; position: absolute; left: -8px; top: 20%; bottom: 20%; width: 3px; background: var(--accent); border-radius: 0 2px 2px 0; }
.folder-name { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-right { display: flex; align-items: center; gap: 6px; }
.folder-item .count { font-size: 11px; color: var(--text-faint); background: var(--hover); padding: 2px 7px; border-radius: 8px; min-width: 20px; text-align: center; }
.folder-item.active .count { background: var(--accent); color: #1a1a1c; }
.folder-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.folder-item:hover .folder-actions, .folder-item:focus-within .folder-actions { opacity: 1; }
.folder-actions button { background: transparent; padding: 3px 5px; border-radius: 4px; font-size: 11px; color: inherit; line-height: 1; }
.folder-actions button:hover { background: var(--border-strong); }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.footer-btn {
  width: 100%; background: transparent; color: var(--text-dim);
  font-size: 12px; padding: 9px 12px; border-radius: 7px;
  text-align: left; display: flex; align-items: center; gap: 8px;
}
.footer-btn:hover { background: var(--hover); color: var(--text); }
.footer-user { font-size: 11px; color: var(--text-faint); padding: 6px 12px 0; overflow: hidden; text-overflow: ellipsis; }

/* ============== NOTES LIST ============== */
#notesList { background: var(--bg-list); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.notes-header { padding: 12px; display: flex; gap: 8px; border-bottom: 1px solid var(--border); }
.search-wrap { flex: 1; position: relative; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--text-faint); pointer-events: none; }
#searchInput {
  width: 100%; background: var(--bg-editor); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 9px 10px 9px 30px; font-size: 14px;
}
#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#newNoteBtn {
  background: var(--accent); color: #1a1a1c;
  width: 40px; height: 40px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}
#newNoteBtn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }
.notes-list-title { padding: 12px 16px 6px; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; }
.notes-items { list-style: none; padding: 0 8px 12px; margin: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.note-item {
  padding: 12px 14px; border-radius: 10px; cursor: pointer; margin-bottom: 3px;
  border: 1px solid transparent; transition: all 0.15s ease;
}
.note-item:hover { background: var(--hover); }
.note-item.active { background: var(--bg-editor); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.note-item .note-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; color: var(--text); display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.01em; }
.note-item .note-preview { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.note-item .note-date { font-size: 11px; color: var(--text-faint); font-weight: 500; }
.note-item .pin { color: var(--accent); font-size: 10px; }
.empty-state { position: absolute; inset: 60px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; text-align: center; color: var(--text-dim); gap: 12px; }
.empty-icon { font-size: 40px; opacity: 0.5; }
.empty-text { font-size: 13px; }

/* ============== EDITOR PANE ============== */
#editorPane { background: var(--bg-editor); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.editor-header { display: flex; align-items: center; padding: 14px 28px 8px; gap: 8px; }
.back-btn { display: none; }
@media (max-width: 900px) { .back-btn { display: flex; } }
#noteTitle {
  flex: 1; border: none; background: transparent; color: var(--text);
  font-size: 24px; font-weight: 700; padding: 4px 0; letter-spacing: -0.02em; font-family: inherit; min-width: 0;
}
#noteTitle::placeholder { color: var(--text-faint); font-weight: 600; }
.editor-actions { display: flex; gap: 2px; }
.icon-btn { background: transparent; padding: 8px 10px; border-radius: 7px; color: var(--text-dim); display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { background: rgba(226, 77, 77, 0.15); color: var(--danger); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }

/* ============== TIPTAP TOOLBAR ============== */
.tt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  padding: 8px 18px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--bg-toolbar); row-gap: 4px;
}
.tt-subtoolbar { background: var(--accent-soft); border-top: none !important; border-bottom: 1px solid var(--border) !important; }
.tt-label { font-size: 11px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-right: 8px; }
.tt-group { display: flex; gap: 2px; align-items: center; }
.tt-sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 4px; }
.tt-toolbar button { background: transparent; color: var(--text-dim); padding: 5px 8px; border-radius: 6px; min-width: 32px; height: 32px; font-size: 13px; font-weight: 500; display: flex; align-items: center; justify-content: center; }
.tt-toolbar button:hover { background: var(--hover); color: var(--text); }
.tt-toolbar button.active { background: var(--accent-soft); color: var(--accent); }
.tt-toolbar button.danger:hover { background: rgba(226,77,77,0.15); color: var(--danger); }
.tt-toolbar select { background: transparent; border: 1px solid var(--border-strong); color: var(--text); border-radius: 6px; padding: 4px 8px; font-size: 12px; height: 32px; cursor: pointer; }
.tt-toolbar select:hover { border-color: var(--accent); }
.color-picker { position: relative; }
.color-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3px 7px !important; min-width: 34px !important; gap: 1px; }
.color-letter { font-size: 13px; font-weight: 700; line-height: 1; }
.color-indicator { width: 14px; height: 3px; border-radius: 1px; background: var(--accent); border: 1px solid var(--border-strong); }
.color-palette { position: absolute; top: calc(100% + 4px); left: 0; z-index: 100; background: var(--bg-editor); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px; box-shadow: var(--shadow-lg); min-width: 200px; display: none; }
.color-palette.open { display: block; animation: pop-in 0.15s ease; }
.palette-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; font-weight: 700; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border-strong); padding: 0; }
.swatch:hover { transform: scale(1.1); box-shadow: 0 0 0 2px var(--accent); }
.palette-action { width: 100%; background: transparent; color: var(--text-dim); padding: 5px 8px; border-radius: 6px; font-size: 12px; }
.palette-action:hover { background: var(--hover); color: var(--text); }

/* ============== EDITOR CONTENT ============== */
.tt-editor { flex: 1; overflow-y: auto; background: var(--bg-editor); -webkit-overflow-scrolling: touch; }
.tt-editor .ProseMirror {
  padding: 24px 44px 100px; min-height: 100%;
  font-size: var(--editor-font-size, 16px); line-height: 1.75;
  color: var(--text); outline: none; caret-color: var(--accent);
}
.tt-editor .ProseMirror:focus { outline: none; }
.tt-editor .ProseMirror > *:first-child { margin-top: 0; }
.tt-editor .ProseMirror p { margin: 0 0 0.6em; }
.tt-editor .ProseMirror h1, .tt-editor .ProseMirror h2, .tt-editor .ProseMirror h3, .tt-editor .ProseMirror h4 {
  margin: 1em 0 0.35em; letter-spacing: -0.02em; font-weight: 700;
}
.tt-editor .ProseMirror h1 { font-size: 1.75em; }
.tt-editor .ProseMirror h2 { font-size: 1.4em; }
.tt-editor .ProseMirror h3 { font-size: 1.2em; }
.tt-editor .ProseMirror h4 { font-size: 1.05em; }
.tt-editor .ProseMirror a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tt-editor .ProseMirror blockquote { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 16px; border-radius: 0 8px 8px 0; margin: 1em 0; }
.tt-editor .ProseMirror blockquote p { margin: 0.3em 0; }
.tt-editor .ProseMirror code { background: var(--code-bg); padding: 2px 6px; border-radius: 4px; font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 0.9em; border: 1px solid var(--border); }
.tt-editor .ProseMirror pre { background: var(--code-bg) !important; color: var(--text); border-radius: 10px; padding: 14px 18px; border: 1px solid var(--border); overflow-x: auto; margin: 1em 0; font-size: 14px; }
.tt-editor .ProseMirror pre code { background: none; border: none; padding: 0; font-size: inherit; }
.tt-editor .ProseMirror hr { border: none; border-top: 2px dashed var(--border-strong); margin: 1.5em 0; height: 1px; }
.tt-editor .ProseMirror ul, .tt-editor .ProseMirror ol { padding-left: 1.4em; margin: 0.4em 0 0.6em; }
.tt-editor .ProseMirror li { margin: 0.2em 0; }
.tt-editor .ProseMirror li p { margin: 0; }
.tt-editor .ProseMirror ul[data-type="taskList"] { list-style: none; padding-left: 0.3em; }
.tt-editor .ProseMirror ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: flex-start; margin: 0.25em 0; }
.tt-editor .ProseMirror ul[data-type="taskList"] li > label { flex: 0 0 auto; margin-top: 5px; user-select: none; }
.tt-editor .ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); width: 18px; height: 18px; }
.tt-editor .ProseMirror ul[data-type="taskList"] li > div { flex: 1; }
.tt-editor .ProseMirror ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--text-faint); text-decoration: line-through; }
.tt-editor .ProseMirror img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); margin: 0.5em 0; display: block; }
.tt-editor .ProseMirror img.ProseMirror-selectednode { box-shadow: 0 0 0 3px var(--accent-glow); }
.tt-editor .ProseMirror table { border-collapse: collapse; margin: 1em 0; overflow: hidden; width: 100%; table-layout: fixed; border-radius: 8px; border: 1px solid var(--border-strong); }
.tt-editor .ProseMirror table td, .tt-editor .ProseMirror table th { border: 1px solid var(--border-strong); padding: 8px 12px; vertical-align: top; position: relative; min-width: 60px; }
.tt-editor .ProseMirror table th { background: var(--accent-soft); font-weight: 700; text-align: left; color: var(--text); }
.tt-editor .ProseMirror table td > p, .tt-editor .ProseMirror table th > p { margin: 0; }
.tt-editor .ProseMirror table .selectedCell { background: var(--accent-soft); position: relative; }
.tt-editor .ProseMirror table .selectedCell::after { content: ''; position: absolute; inset: 0; background: var(--accent-soft); pointer-events: none; }
.tt-editor .ProseMirror .column-resize-handle { position: absolute; right: -2px; top: 0; bottom: -2px; width: 4px; background: var(--accent); pointer-events: none; cursor: col-resize; }
.tt-editor .ProseMirror.resize-cursor { cursor: col-resize; }
.tt-editor .ProseMirror.is-editor-empty::before, .tt-editor .ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); float: left; color: var(--text-faint); pointer-events: none; height: 0; }
.tt-editor .ProseMirror ::selection { background: var(--accent-glow); }
.tt-editor .ProseMirror mark { padding: 1px 2px; border-radius: 3px; color: #1a1a1c; }

/* ============== STATUS BAR ============== */
.status-bar { padding: 8px 22px; font-size: 11px; color: var(--text-faint); display: flex; justify-content: space-between; border-top: 1px solid var(--border); background: var(--bg-toolbar); font-weight: 500; letter-spacing: 0.02em; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.save-status { display: inline-flex; align-items: center; gap: 6px; transition: color 0.2s; }
.save-status.saving::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.save-status.saved { color: var(--success); }
.save-status.saved::before { content: '✓'; color: var(--success); font-size: 12px; font-weight: 700; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); } }

/* ============== MODALS ============== */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 999; animation: fade-in 0.2s ease; padding: 20px; }
.modal-content { background: var(--bg-editor); color: var(--text); padding: 22px 26px; border-radius: 14px; min-width: 320px; max-width: 500px; width: 100%; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3, .modal-content h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.modal-content input { width: 100%; padding: 11px 12px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); border-radius: 9px; font-size: 15px; margin-top: 4px; }
.modal-content input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); gap: 20px; }
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; }
.setting-title { font-weight: 600; margin-bottom: 3px; font-size: 14px; }
.setting-desc { color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.setting-control { display: flex; gap: 6px; flex-shrink: 0; }
.primary-btn { background: var(--accent); color: #1a1a1c; padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; box-shadow: 0 2px 6px var(--accent-glow); }
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.5; pointer-events: none; }
.danger-btn { background: var(--danger); color: white; padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.danger-btn:hover { opacity: 0.9; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ============== TOAST ============== */
.toast-container { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); right: 20px; left: 20px; z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 700px) { .toast-container { left: auto; align-items: flex-end; } }
.toast { background: var(--bg-editor); border: 1px solid var(--border-strong); color: var(--text); padding: 11px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: slide-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1); display: flex; align-items: center; gap: 8px; max-width: 340px; pointer-events: auto; }
.toast.success { border-color: var(--success); }
.toast.success::before { content: '✓'; color: var(--success); font-weight: 700; }
.toast.error { border-color: var(--danger); }
.toast.error::before { content: '✕'; color: var(--danger); font-weight: 700; }
.toast.info::before { content: 'ℹ'; color: var(--accent); font-weight: 700; }
@keyframes slide-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.leaving { animation: slide-out 0.25s ease forwards; }
@keyframes slide-out { to { opacity: 0; transform: translateY(10px); } }

/* ============== SCROLLBAR ============== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
::-webkit-scrollbar-track { background: transparent; }
