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

:root {
  --color-bg: #0f1117;
  --color-surface: #1a1d27;
  --color-surface-hover: #222633;
  --color-border: #2a2e3a;
  --color-text: #e4e6ed;
  --color-text-secondary: #8b8fa3;
  --color-text-muted: #5a5e70;
  --color-accent: #6366f1;
  --color-accent-hover: #818cf8;
  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#loading-screen {
  position: fixed; inset: 0;
  background: var(--color-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#home-screen {
   display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
   min-height: 100vh; padding: 80px 2rem 2rem;
 }
#home-screen.hidden { display: none; }
.home-logo { font-size: 3rem; margin-bottom: 0.5rem; }
.home-title { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.home-subtitle { color: var(--color-text-secondary); margin-bottom: 2rem; font-size: 1.05rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-surface-hover); }
.btn-danger { background: transparent; color: var(--color-danger); border: 1px solid var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.home-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.home-tips {
  margin-top: 3rem; padding: 1.5rem;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 12px; max-width: 480px; width: 100%;
}
.home-tips h3 { font-size: 0.9rem; color: var(--color-text-secondary); margin-bottom: 0.75rem; }
.home-tips ul { list-style: none; }
.home-tips li { font-size: 0.85rem; color: var(--color-text-muted); padding: 0.3rem 0; }
.home-tips li::before { content: "• "; color: var(--color-accent); }

#note-screen { display: none; flex-direction: column; height: 100vh; }
#note-screen.active { display: flex; }

.toolbar {
   display: flex; align-items: center; gap: 0.5rem;
   padding: 0.6rem 1rem;
   background: var(--color-surface); border-bottom: 1px solid var(--color-border);
   flex-shrink: 0; flex-wrap: wrap;
 }
 .toolbar-left { display: flex; align-items: center; gap: 0.5rem; }
.toolbar-center { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-wrap: wrap; }
  .toolbar-center.collapsed { width: 0; height: 0; overflow: hidden; opacity: 0; flex-shrink: 0; margin-left: 0; padding: 0; }
  .toolbar-center.collapsed ~ .toolbar-right { margin-left: auto; }
  .toolbar-right { display: flex; align-items: center; gap: 0.5rem; position: relative; }
 .toolbar-logo { font-size: 1.2rem; text-decoration: none; }
 .toolbar-title {
   font-weight: 600; font-size: 0.95rem;
   max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
 }
 .toolbar-divider { width: 1px; height: 24px; background: var(--color-border); margin: 0 0.25rem; }

 .note-name-input {
   padding: 0.35rem 0.75rem;
   background: var(--color-bg);
   color: var(--color-text);
   border: 1px solid var(--color-border);
   border-radius: 8px;
   font-size: 0.85rem;
   font-family: inherit;
   outline: none;
   width: 200px;
   transition: border-color 0.15s;
 }
 .note-name-input:focus {
   border-color: var(--color-accent);
 }
 .note-name-input::placeholder {
   color: var(--color-text-muted);
 }
 .note-name-save-btn {
   white-space: nowrap;
 }

 .my-notes-name {
   font-weight: 600;
   color: var(--color-text);
 }
 .my-notes-name:hover { text-decoration: underline; }

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

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-text-muted); flex-shrink: 0;
}
.status-dot.connected { background: var(--color-success); }
.status-dot.disconnected { background: var(--color-danger); }

.save-status { font-size: 0.75rem; color: var(--color-text-muted); }

.online-users { display: flex; align-items: center; gap: 0.25rem; }
.user-avatar {
   width: 28px; height: 28px; border-radius: 50%;
   display: flex; align-items: center; justify-content: center;
   font-size: 0.7rem; font-weight: 600; color: #fff;
   border: 2px solid var(--color-surface);
   margin-left: -6px;
   cursor: default; flex-shrink: 0;
 }
 .user-avatar:first-child { margin-left: 0; }
 .user-avatar.more { font-size: 0.6rem; }
.online-count {
  font-size: 0.75rem; color: var(--color-text-secondary);
  margin-left: 0.4rem;
}

.info-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
    width: auto; height: 28px; border: 1px solid var(--color-border);
    border-radius: 6px; background: var(--color-surface);
    color: var(--color-text-secondary); font-size: 0.85rem;
    cursor: pointer; transition: all 0.15s; flex-shrink: 0;
    padding: 0 0.5rem;
}
.info-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }

.export-wrapper {
    position: relative;
}
.export-menu {
    display: none; position: absolute; top: 100%; right: 0; z-index: 70;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 8px; padding: 0.25rem;
    box-shadow: var(--color-shadow); min-width: 120px;
}
.export-menu.visible { display: block; }
.export-option {
    display: block; width: 100%; padding: 0.4rem 0.75rem;
    background: none; border: none; border-radius: 5px;
    color: var(--color-text); font-size: 0.85rem; cursor: pointer;
    text-align: left; font-family: inherit;
}
.export-option:hover { background: var(--color-surface-hover); }

.markdown-tip {
    display: none; position: absolute; top: 100%; right: 0; z-index: 70;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 10px; padding: 1rem 1.25rem;
    box-shadow: var(--color-shadow); min-width: 280px;
    font-size: 0.8rem; line-height: 1.8; color: var(--color-text-secondary);
}
.markdown-tip strong { color: var(--color-text); font-size: 0.85rem; }
.markdown-tip code {
    background: var(--color-surface-hover); padding: 0.1rem 0.3rem;
    border-radius: 3px; font-size: 0.75rem; color: var(--color-accent);
}
.markdown-tip.visible { display: block; }

.home-topbar {
   position: fixed; top: 0; left: 0; right: 0;
   display: flex; align-items: center; justify-content: space-between;
   padding: 16px 24px; z-index: 10;
   flex-wrap: wrap;
   background: var(--color-surface);
   border-bottom: 1px solid var(--color-border);
 }
 .topbar-right { display: flex; align-items: center; gap: 0.5rem; }
 .home-back-btn { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--color-border); color: var(--color-text-secondary); text-decoration: none; transition: all 0.15s; flex-shrink: 0; background: var(--color-surface); }
 .home-back-btn:hover { color: var(--color-text); border-color: var(--color-text-muted); background: var(--color-surface-hover); }
 .nav-auth-btn { display: inline-flex; align-items: center; padding: 0.4rem 1rem; border-radius: 8px; font-size: 0.85rem; font-weight: 500; text-decoration: none; cursor: pointer; transition: all 0.15s; border: none; font-family: inherit; }
 .nav-auth-btn-outline { background: transparent; color: var(--color-text-sec); border: 1px solid var(--color-border); }
 .nav-auth-btn-outline:hover { color: var(--color-text); border-color: var(--color-text-mut); }
 .nav-auth-btn-primary { background: var(--color-accent); color: #fff; margin-left: 0.4rem; }
 .nav-auth-btn-primary:hover { background: var(--color-accent-h); }
 .nav-user { position: relative; display: flex; align-items: center; }
 .nav-user-menu-btn { display: flex; align-items: center; gap: 4px; background: none; border: none; color: var(--color-text-sec); font-size: 0.85rem; cursor: pointer; padding: 0.4rem 0.6rem; border-radius: 6px; transition: all 0.15s; font-family: inherit; white-space: nowrap; }
 .nav-user-menu-btn:hover { color: var(--color-text); background: var(--color-surface-hover); }
 .nav-user-dropdown { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; min-width: 140px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.3); z-index: 100; overflow: hidden; }
 .nav-user-dropdown.show { display: block; }
 .nav-user-dropdown-item { display: block; width: 100%; padding: 8px 14px; font-size: 0.8rem; color: var(--color-text-sec); text-decoration: none; background: none; border: none; text-align: left; cursor: pointer; transition: all 0.15s; font-family: inherit; }
 .nav-user-dropdown-item:hover { background: var(--color-surface-hover); color: var(--color-text); }
 .nav-user-dropdown-logout { color: var(--color-danger); }
 .nav-user-dropdown-logout:hover { background: rgba(239,68,68,0.1); }
 .anon-tip { text-align: center; padding: 0.5rem; font-size: 0.8rem; color: var(--color-warn); }
 .login-dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 200; }
 .login-dialog-overlay.active { display: flex; }
 .login-dialog { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; padding: 2rem; max-width: 400px; width: 90%; box-shadow: var(--color-shadow); }
 .login-dialog h2 { margin-bottom: 0.75rem; font-size: 1.1rem; }
 .login-dialog p { color: var(--color-text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
 .login-dialog-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

 #home-screen {
   display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
   min-height: 100vh; padding: 80px 2rem 2rem;
 }

.theme-toggle-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-secondary); flex-shrink: 0;
}
.theme-toggle-btn:hover {
  color: var(--color-text); background: var(--color-surface-hover); border-color: var(--color-border);
}
.theme-toggle-btn svg { width: 16px; height: 16px; }

.lang-switch {
  display: flex; align-items: center; gap: 0.25rem;
  background: var(--color-surface); color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.5rem; border-radius: 0.5rem;
  font-size: 0.7rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
}
.lang-switch:hover { background: var(--color-surface-hover); color: var(--color-text); }

.editor-container {
  flex: 1; display: flex; position: relative; overflow: hidden;
}
.editor-wrapper {
  flex: 1; position: relative; display: flex;
}
#editor {
    flex: 1; width: 100%;
    padding: 1.5rem 2rem;
    background: var(--color-bg); color: var(--color-text);
    border: none; outline: none; resize: none;
    font-size: 1rem; line-height: 1.75; font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    tab-size: 2;
    min-height: 100%;
    overflow-y: auto;
    position: relative;
}
#editor::placeholder { color: var(--color-text-muted); }
#editor[contenteditable="true"] {
    white-space: pre-wrap;
    word-wrap: break-word;
}
#editor.drag-over {
    outline: 2px dashed var(--color-accent);
    outline-offset: -2px;
    background: var(--color-surface);
  }
  #editor.empty::before {
    content: attr(data-placeholder);
    color: var(--color-text-muted);
    pointer-events: none;
    position: absolute;
    top: 1.5rem;
    left: 2rem;
    font-size: 1rem;
    line-height: 1.75;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    white-space: pre-wrap;
  }
#editor:not(.empty)::before { display: none; }
#editor h1, #editor h2, #editor h3 { font-size: 1.8rem; font-weight: 700; margin: 0; padding: 0.2rem 0; }
#editor ul, #editor ol { padding-left: 2rem; }
#editor li { margin: 0.25rem 0; }
#editor img { max-width: 100%; max-height: 400px; border-radius: 6px; margin: 4px 0; cursor: pointer; }
#editor img:hover { outline: 2px solid var(--color-accent); }

.format-toolbar {
    display: none;
    position: absolute;
    top: -52px;
    left: 0;
    z-index: 60;
    flex-direction: row;
    align-items: center;
    gap: 3px;
    padding: 6px 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--color-shadow);
    white-space: nowrap;
}
.format-toolbar.visible { display: flex; }
.fmt-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border: none; border-radius: 5px;
    background: transparent; color: var(--color-text-secondary);
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}
.fmt-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.fmt-btn.active { color: var(--color-accent); }
.fmt-divider { width: 1px; height: 22px; background: var(--color-border); margin: 0 3px; }

.cursors-layer {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  padding: 1.5rem 2rem;
}
.remote-cursor {
  position: absolute; transition: top 0.1s, left 0.1s;
}
.cursor-caret {
  width: 2px; height: 1.75em;
  border-radius: 1px;
}
.todo-checkbox {
  margin-right: 6px;
  cursor: pointer;
  accent-color: var(--color-accent);
}

.cursor-label {
  position: absolute; top: -1.4em; left: -2px;
  padding: 0.1rem 0.4rem; border-radius: 4px;
  font-size: 0.65rem; font-weight: 500;
  color: #fff; white-space: nowrap;
}

.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 1rem;
  background: var(--color-surface); border-top: 1px solid var(--color-border);
  font-size: 0.7rem; color: var(--color-text-muted);
  flex-shrink: 0;
}
.footer-left { display: flex; align-items: center; gap: 1rem; }
.footer-right { display: flex; align-items: center; gap: 0.5rem; }

.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem; border-radius: 10px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  box-shadow: var(--color-shadow); font-size: 0.85rem;
  animation: toast-in 0.2s ease-out;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.dialog-overlay.active { display: flex; }
.dialog {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 16px; padding: 2rem; max-width: 400px; width: 90%;
  box-shadow: var(--color-shadow);
}
.dialog h2 { margin-bottom: 0.75rem; font-size: 1.2rem; }
.dialog p { color: var(--color-text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.dialog-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

[data-theme="light"] {
  --color-bg: #f8f9fc;
  --color-surface: #ffffff;
  --color-surface-hover: #f0f2f8;
  --color-border: #e2e5ed;
  --color-text: #1a1d2e;
  --color-text-secondary: #5a5e70;
  --color-text-muted: #9ca3b8;
  --color-accent: #4f46e5;
  --color-accent-hover: #6366f1;
  --color-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
    .toolbar { padding: 0.5rem; }
    #editor { padding: 1rem; font-size: 0.95rem; }
    .cursors-layer { padding: 1rem; }
    .toolbar-title { max-width: 100px; }
    .toolbar-center { display: flex; flex-wrap: wrap; }
    .note-name-input { width: 120px; font-size: 0.75rem; padding: 0.25rem 0.5rem; }
    .note-name-save-btn { font-size: 0.7rem; padding: 0.25rem 0.5rem; }
    .home-title { font-size: 1.5rem; }
    .home-logo { font-size: 2.5rem; }
    .footer { flex-direction: column; gap: 0.25rem; align-items: flex-start; }
    .home-topbar { padding: 12px 16px; }
  }

/* ========== Permission Dialog ========== */
.permission-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.permission-overlay.active {
  display: flex;
}
.permission-dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--color-shadow);
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.permission-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.permission-dialog-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.permission-dialog-close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.permission-dialog-close:hover {
  color: var(--color-text);
}
.permission-dialog-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.permission-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}
.perm-section h3 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--color-text);
}
.perm-mode-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.perm-radio {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}
.perm-radio:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}
.perm-radio input[type="radio"] {
  accent-color: var(--color-accent);
}
.perm-default-selector {
  margin-bottom: 1rem;
}
.perm-default-selector label {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.4rem;
}
.perm-select {
  padding: 0.4rem 0.75rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}
.perm-select:focus {
  border-color: var(--color-accent);
}
.perm-user-search {
  margin-bottom: 1rem;
  position: relative;
}
.perm-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}
.perm-search-input:focus {
  border-color: var(--color-accent);
}
.perm-search-results {
  margin-top: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}
.perm-search-empty {
  padding: 0.75rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.perm-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  gap: 0.5rem;
}
.perm-search-item:last-child {
  border-bottom: none;
}
.perm-user-name {
  font-size: 0.85rem;
  color: var(--color-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.perm-user-perm {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}
.perm-perm-editor { background: rgba(33,150,243,0.2); color: #2196f3; }
.perm-perm-viewer { background: rgba(158,158,158,0.2); color: #9e9e9e; }
.perm-perm-invisible { background: rgba(239,68,68,0.2); color: #ef4444; }
.perm-user-list {
  margin-top: 1rem;
}
.perm-user-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}
.perm-user-item:last-child {
  border-bottom: none;
}
.perm-remove-btn {
  margin-left: auto;
  flex-shrink: 0;
}
.perm-empty {
  text-align: center;
  padding: 1rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.editor-readonly {
  background: var(--color-bg-secondary, #f5f5f5) !important;
  cursor: not-allowed;
  opacity: 0.7;
}
   .toolbar { gap: 0.25rem; padding: 0.4rem 0.5rem; }
   .toolbar-right { gap: 0.25rem; flex-wrap: wrap; justify-content: flex-end; }
   .toolbar-title { max-width: 80px; font-size: 0.8rem; }
   .btn-sm { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
.lang-switch { padding: 0.2rem 0.4rem; font-size: 0.65rem; }
    .online-count { display: none; }
    .save-status { display: none; }
    .toolbar-divider { display: none; }
    .btn-sm { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
    .info-btn { width: auto; height: 32px; padding: 0 0.6rem; }
    .home-topbar { padding: 10px 12px; gap: 0.5rem; }
    .topbar-right { gap: 0.25rem; flex-wrap: wrap; }
    .home-actions { flex-direction: column; align-items: center; }
    .home-actions .btn { width: 100%; max-width: 260px; justify-content: center; }

#nav-auth-area-note { display: inline-flex; align-items: center; gap: 8px; }

.my-notes-search {
  display: flex;
  gap: 0.5rem;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
}
.my-notes-search-input {
  flex: 1;
  padding: 0.4rem 0.75rem;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.my-notes-search-input:focus {
  border-color: var(--color-accent);
}
.my-notes-search-input::placeholder {
  color: var(--color-text-muted);
}

#nav-my-notes-btn { margin-right: 8px; }

/* ========== My Notes Modal ========== */
.my-notes-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.my-notes-overlay.active { display: flex; }
.my-notes-modal {
  background: var(--color-surface);
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.my-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.my-notes-header h2 { font-size: 1.2rem; }
.my-notes-close {
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
}
.my-notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.my-notes-table {
   width: 100%;
   border-collapse: collapse;
   font-size: 0.8rem;
 }
 .my-notes-table th, .my-notes-table td {
   padding: 5px 10px;
   text-align: left;
   border-bottom: 1px solid var(--color-border);
   font-size: 0.8rem;
 }
 .my-notes-table th {
   font-weight: 600;
   font-size: 0.75rem;
   color: var(--color-text-secondary);
 }
 .my-notes-name {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.8rem;
  }
   .my-notes-name:hover { text-decoration: underline; }
   .my-notes-title {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.8rem;
  }
   .my-notes-title:hover { text-decoration: underline; }
 .my-notes-perm {
   padding: 2px 8px;
   border-radius: 4px;
   font-size: 0.7rem;
   font-weight: 600;
 }
.my-notes-perm-owner { background: rgba(255,193,7,0.2); color: #ffc107; }
.my-notes-perm-editor { background: rgba(33,150,243,0.2); color: #2196f3; }
.my-notes-perm-viewer { background: rgba(158,158,158,0.2); color: #9e9e9e; }
.my-notes-table th:nth-child(4),
.my-notes-table td:nth-child(4),
.my-notes-table th:nth-child(5),
.my-notes-table td:nth-child(5) {
   min-width: 90px;
 }
.my-notes-table th:nth-child(6),
.my-notes-table td:nth-child(6) {
   min-width: 70px;
 }
.my-notes-table th:nth-child(7),
.my-notes-table td:nth-child(7) {
   min-width: 80px;
 }
.my-notes-delete-btn {
   padding: 3px 8px;
   font-size: 0.7rem;
 }
 .my-notes-delete-btn-disabled,
 .my-notes-delete-btn[disabled] {
   opacity: 0.4;
   cursor: not-allowed;
   pointer-events: none;
 }
 .my-notes-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}
.my-notes-empty {
  text-align: center;
  padding: 40px;
  color: var(--color-text-secondary);
}
.empty-state .icon { font-size: 2rem; margin-bottom: 8px; }
.my-notes-select-all-row { display: none; }
.editor-readonly {
  background: var(--color-bg-secondary, #f5f5f5) !important;
  cursor: not-allowed;
  opacity: 0.7;
}

@media (max-width: 600px) {
  .my-notes-select-all-row { display: block; }
  .my-notes-select-all-row td { display: block; text-align: center; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
  .my-notes-select-all-row td::before { content: "Select All"; font-weight: 600; color: var(--color-text-secondary); font-size: 0.75rem; text-transform: uppercase; margin-right: 12px; }
  .my-notes-modal { width: 95%; max-height: 90vh; border-radius: 0; }
  .my-notes-overlay { align-items: flex-end; }
  .my-notes-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
  .my-notes-header { padding: 12px 16px; }
  .my-notes-header h2 { font-size: 1rem; }
  .my-notes-list { padding: 12px 16px; }
  .my-notes-table { display: block; }
  .my-notes-table thead { display: none; }
  .my-notes-table tbody { display: block; }
  .my-notes-table tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
  }
.my-notes-table td {
     display: flex;
     justify-content: space-between;
     align-items: center;
     padding: 3px 0;
     border-bottom: none;
     font-size: 0.75rem;
   }
   .my-notes-table td::before {
     content: attr(data-label);
     font-weight: 600;
     color: var(--color-text-secondary);
     font-size: 0.7rem;
     text-transform: uppercase;
     margin-right: 12px;
     min-width: 60px;
   }
  .my-notes-table td:first-child { font-weight: 600; }
  .my-notes-actions { flex-direction: column; padding: 12px 16px; }
  .my-notes-actions .btn { width: 100%; justify-content: center; }
  .my-notes-empty { padding: 24px 16px; }
}
