/* ============================================
   NOTED. — Minimalist Note-Taking App
   Design: White, Black, Sharp, Swiss
   ============================================ */

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

/* Force hidden attribute to work even on flex/inline-block elements */
[hidden] {
    display: none !important;
}

:root {
    --black: #000000;
    --white: #FFFFFF;
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #E5E5E5;
    --gray-300: #D4D4D4;
    --gray-400: #A3A3A3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-800: #262626;
    --gray-900: #171717;
    --accent: #000000;
    --danger: #E03131;
    --sidebar-w: 260px;
    --notelist-w: 320px;
    --toolbar-h: 52px;
    --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Helvetica Neue', 'Arial', sans-serif;
    background: var(--white);
    color: var(--black);
    line-height: 1.5;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
}

/* --- Screens --- */
.screen {
    width: 100%;
    height: 100dvh;
}

/* ============================================
   AUTH SCREEN
   ============================================ */
#auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-container {
    width: 100%;
    max-width: 380px;
    padding: 2rem;
}

.auth-brand {
    margin-bottom: 3rem;
    text-align: left;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--black);
    color: var(--white);
    font-family: 'Georgia', serif;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 1.5rem;
}

.auth-brand h1 {
    font-family: 'Georgia', serif;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.auth-tagline {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-600);
}

.auth-form input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid var(--black);
    background: var(--white);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.auth-form input:focus {
    border-color: var(--gray-400);
}

.auth-form input::placeholder {
    color: var(--gray-400);
}

.auth-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: -0.25rem;
}

.btn-primary {
    padding: 0.85rem 1.5rem;
    background: var(--black);
    color: var(--white);
    border: 2px solid var(--black);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.btn-primary:hover {
    background: var(--white);
    color: var(--black);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-text {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.5rem 0;
    transition: color var(--transition);
}

.btn-text:hover {
    color: var(--black);
}

.btn-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-400);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.dev-notice {
    margin-top: 2rem;
    padding: 0.75rem 1rem;
    background: #FFF3BF;
    border: 1px solid #FFE066;
    font-size: 0.8rem;
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */
#app-screen {
    display: flex;
    height: 100dvh;
    overflow: hidden;
}

/* --- Sidebar --- */
#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100dvh;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition), opacity var(--transition);
    z-index: 10;
}

#sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-w));
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    height: var(--toolbar-h);
    min-height: var(--toolbar-h);
}

.brand-small {
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    gap: 0.5rem;
}

.user-email {
    font-size: 0.72rem;
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.btn-text-sm {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    cursor: pointer;
    transition: color var(--transition);
    white-space: nowrap;
}

.btn-text-sm:hover {
    color: var(--danger);
}

/* --- Nav items --- */
.sidebar-nav {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 1.25rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--black);
}

.nav-item.active {
    background: var(--black);
    color: var(--white);
}

.nav-item svg {
    flex-shrink: 0;
}

/* --- Folders --- */
/* --- Nav count badge --- */
.nav-count {
    font-size: 0.65rem;
    color: var(--gray-400);
    margin-left: auto;
    font-weight: 400;
}

/* --- Todo panel (main area) --- */
.todo-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.todo-panel-header {
    display: flex;
    align-items: center;
    padding: 0 2rem;
    border-bottom: 1px solid var(--gray-200);
    height: var(--toolbar-h);
    min-height: var(--toolbar-h);
}

.todo-panel-header h2 {
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    font-weight: 400;
}

.todo-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.todo-panel-footer {
    border-top: 1px solid var(--gray-200);
    padding: 0.75rem 2rem;
    flex-shrink: 0;
}

.todo-panel-footer input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition);
}

.todo-panel-footer input:focus {
    border-color: var(--black);
}

.todo-panel-footer input::placeholder {
    color: var(--gray-400);
}

.todo-list {
    padding: 0;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 2rem;
    transition: background var(--transition);
    border-bottom: 1px solid var(--gray-100);
}

.todo-item:hover {
    background: var(--gray-50);
}

.todo-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--gray-400);
    background: var(--white);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: all var(--transition);
}

.todo-item input[type="checkbox"]:checked {
    background: var(--black);
    border-color: var(--black);
}

.todo-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 0px;
    left: 3px;
    color: var(--white);
    font-size: 0.72rem;
    font-weight: 700;
}

.todo-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--black);
    line-height: 1.5;
    min-width: 0;
}

.todo-item.done .todo-text {
    text-decoration: line-through;
    color: var(--gray-400);
}

.todo-delete {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.todo-delete:hover {
    color: #E03131;
}

.todo-item:hover .todo-delete {
    display: inline-flex;
}

/* --- Sidebar folders --- */
.sidebar-folders {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.folders-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem 0.25rem;
}

.folders-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--gray-400);
}

.btn-icon-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid transparent;
    font-size: 1rem;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-icon-sm:hover {
    border-color: var(--gray-300);
    color: var(--black);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    transition: color var(--transition);
}

.btn-icon:hover {
    color: var(--black);
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1.25rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.folder-item:hover {
    background: var(--gray-100);
    color: var(--black);
}

.folder-item.active {
    background: var(--gray-200);
    color: var(--black);
    font-weight: 600;
}

.folder-item .folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item .folder-count {
    font-size: 0.7rem;
    color: var(--gray-400);
    min-width: 20px;
    text-align: right;
}

.folder-item .folder-rename-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: color var(--transition);
}

.folder-item .folder-rename-btn:hover {
    color: var(--black);
}

.folder-item:hover .folder-rename-btn {
    display: inline-flex;
}

.folder-item:hover .folder-count {
    display: none;
}

.folder-icon {
    flex-shrink: 0;
    font-size: 0.85rem;
}

/* --- Sidebar search --- */
.sidebar-search {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.sidebar-search-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--gray-400);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.sidebar-search-btn:hover {
    border-color: var(--black);
    color: var(--gray-600);
}

.sidebar-search-btn svg {
    flex-shrink: 0;
}

.sidebar-search-btn span {
    flex: 1;
}

.sidebar-search-btn kbd {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.6rem;
    padding: 0.15rem 0.35rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    color: var(--gray-400);
    flex-shrink: 0;
}

/* --- Sidebar import/export dropdown --- */
.user-email-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.user-email-btn:hover .user-email {
    color: var(--black);
}

.user-email-btn:hover .user-chevron {
    color: var(--black);
}

.user-chevron {
    flex-shrink: 0;
    color: var(--gray-400);
    transition: transform var(--transition), color var(--transition);
}

.user-chevron.open {
    transform: rotate(180deg);
}

.user-dropdown {
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
    padding: 0.25rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 1.25rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.dropdown-item:hover {
    background: var(--gray-50);
    color: var(--black);
}

.dropdown-item svg {
    flex-shrink: 0;
}

/* --- Export modal --- */
.export-modal {
    max-width: 480px;
}

.export-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.export-modal-header h3 {
    font-family: 'Georgia', serif;
    font-size: 1rem;
    font-weight: 400;
}

.export-options {
    padding: 0.5rem 0;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    border-bottom: 1px solid var(--gray-100);
    background: var(--white);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition);
}

.export-option:hover {
    background: var(--gray-50);
}

.export-option:last-child {
    border-bottom: none;
}

.export-option-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--black);
    color: var(--white);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.export-option-info strong {
    display: block;
    font-size: 0.88rem;
    color: var(--black);
    margin-bottom: 0.2rem;
}

.export-option-info small {
    font-size: 0.72rem;
    color: var(--gray-500);
    line-height: 1.4;
}

/* --- Open sidebar btn --- */
.btn-open-sidebar {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-open-sidebar:hover {
    border-color: var(--black);
    color: var(--black);
}

/* --- Note list collapsed --- */
#note-list-panel {
    transition: width var(--transition), min-width var(--transition), opacity var(--transition), border var(--transition);
}

#note-list-panel.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    overflow: hidden;
    border-right: none;
    pointer-events: none;
}

/* ============================================
   SEARCH OVERLAY
   ============================================ */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    animation: fadeInOverlay 0.15s ease;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.search-modal {
    width: 100%;
    max-width: 580px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.18s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.search-modal-header svg {
    flex-shrink: 0;
    color: var(--gray-400);
}

.search-modal-header input {
    flex: 1;
    border: none;
    background: none;
    font-size: 1rem;
    font-family: inherit;
    color: var(--black);
    outline: none;
}

.search-modal-header input::placeholder {
    color: var(--gray-400);
}

.search-kbd {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.6rem;
    padding: 0.2rem 0.45rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
}

.search-result-item {
    display: block;
    width: 100%;
    padding: 0.85rem 1.25rem;
    border: none;
    border-bottom: 1px solid var(--gray-100);
    background: var(--white);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition);
}

.search-result-item:hover,
.search-result-item.selected {
    background: var(--gray-50);
}

.search-result-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.search-result-title .fav-dot {
    font-size: 0.6rem;
}

.search-result-preview {
    font-size: 0.75rem;
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-preview mark {
    background: #FFE066;
    color: var(--black);
    padding: 0 0.15rem;
}

.search-result-meta {
    font-size: 0.65rem;
    color: var(--gray-400);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================
   NOTE LIST
   ============================================ */
#note-list-panel {
    width: var(--notelist-w);
    min-width: var(--notelist-w);
    height: 100dvh;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    background: var(--white);
}

.note-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    height: var(--toolbar-h);
    min-height: var(--toolbar-h);
}

.note-list-header h2 {
    font-family: 'Georgia', serif;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-primary-sm {
    padding: 0.45rem 0.85rem;
    background: var(--black);
    color: var(--white);
    border: 1px solid var(--black);
    font-size: 0.7rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary-sm:hover {
    background: var(--white);
    color: var(--black);
}

.note-list {
    flex: 1;
    overflow-y: auto;
}

.note-card {
    display: block;
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    border-bottom: 1px solid var(--gray-100);
    background: var(--white);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition);
}

.note-card:hover {
    background: var(--gray-50);
}

.note-card.active {
    background: var(--gray-100);
    border-left: 3px solid var(--black);
}

.note-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.note-card-title .fav-dot {
    font-size: 0.6rem;
    color: var(--black);
}

.note-card-preview {
    font-size: 0.75rem;
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.35rem;
}

.note-card-date {
    font-size: 0.65rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.empty-state {
    padding: 3rem 1.25rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* ============================================
   EDITOR
   ============================================ */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-width: 0;
    overflow: hidden;
    background: var(--white);
}

.empty-state-editor {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-editor-content {
    text-align: center;
    color: var(--gray-300);
}

.empty-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--gray-50);
    color: var(--gray-300);
    font-family: 'Georgia', serif;
    font-size: 36px;
    margin-bottom: 1rem;
}

.empty-editor-content p {
    font-size: 0.85rem;
}

/* --- Editor toolbar --- */

#editor-active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    height: var(--toolbar-h);
    min-height: var(--toolbar-h);
    gap: 0.5rem;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.btn-back-list {
    display: none;
}

.note-title-input {
    flex: 1;
    border: none;
    background: none;
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--black);
    outline: none;
    min-width: 0;
}

.note-title-input::placeholder {
    color: var(--gray-400);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.toolbar-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-size: 0.72rem;
    font-family: inherit;
    color: var(--gray-600);
    cursor: pointer;
    outline: none;
    max-width: 140px;
}

.btn-danger:hover {
    color: var(--danger) !important;
    border-color: var(--danger) !important;
}

/* --- Format toolbar --- */
.format-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    overflow-x: auto;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.format-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.fmt-select {
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-size: 0.72rem;
    font-family: inherit;
    color: var(--gray-700);
    cursor: pointer;
    outline: none;
}

.fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: 1px solid transparent;
    font-family: 'Georgia', serif;
    font-size: 0.85rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition);
}

.fmt-btn:hover {
    border-color: var(--gray-300);
    color: var(--black);
}

.fmt-btn:active,
.fmt-btn.active {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
}

.fmt-color {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-300);
    padding: 0;
    cursor: pointer;
    background: none;
}

.fmt-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.fmt-color::-webkit-color-swatch {
    border: none;
}

/* Preset color dots */
.format-colors-preset {
    gap: 0.15rem;
    flex-wrap: wrap;
    max-width: 200px;
}

.color-dot {
    width: 16px;
    height: 16px;
    border: none;
    cursor: pointer;
    transition: transform var(--transition);
    padding: 0;
}

.color-dot:hover {
    transform: scale(1.3);
}

/* --- Content area --- */
.note-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    outline: none;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--black);
    min-height: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    -webkit-overflow-scrolling: touch;
}

.note-content:empty::before {
    content: attr(data-placeholder);
    color: var(--gray-400);
    font-style: italic;
    pointer-events: none;
}

.note-content a {
    color: var(--black);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity var(--transition);
}

.note-content a:hover {
    opacity: 0.6;
}

.note-content ul,
.note-content ol {
    margin: 0.4rem 0 0.4rem 1.5rem;
    padding: 0;
}

.note-content ul {
    list-style-type: disc;
}

.note-content ol {
    list-style-type: decimal;
}

.note-content li {
    margin-bottom: 0.15rem;
    line-height: 1.6;
}

.note-content ul ul,
.note-content ol ol,
.note-content ul ol,
.note-content ol ul {
    margin-top: 0.15rem;
    margin-bottom: 0.15rem;
}

.note-content ul ul {
    list-style-type: circle;
}

.note-content ul ul ul {
    list-style-type: square;
}

.note-content blockquote {
    border-left: 3px solid var(--black);
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: var(--gray-600);
}

/* --- Status bar --- */
.editor-status {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    font-size: 0.65rem;
    flex-shrink: 0;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.status-indicator {
    transition: opacity var(--transition);
}

.status-count {
    margin-left: auto;
}

/* ============================================
   CONTEXT MENU
   ============================================ */
.context-menu {
    position: fixed;
    z-index: 1000;
    background: var(--white);
    border: 1px solid var(--gray-200);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    min-width: 160px;
    padding: 0.25rem 0;
}

.context-menu button {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--gray-700);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
}

.context-menu button:hover {
    background: var(--gray-50);
    color: var(--black);
}

.context-menu button[data-ctx="delete"]:hover {
    color: var(--danger);
}

/* ============================================
   TOAST
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
}

.toast {
    padding: 0.65rem 1.25rem;
    background: var(--black);
    color: var(--white);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

.toast.toast-error {
    background: var(--danger);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* --- Sidebar backdrop (mobile) --- */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --notelist-w: 280px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Sidebar = fixed drawer with transform animation */
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 200;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
        transition: transform 0.25s ease;
        transform: translateX(0);
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
        margin-left: 0;
    }

    .btn-open-sidebar {
        display: inline-flex !important;
    }

    /* Note list = always full width */
    #note-list-panel,
    #note-list-panel.collapsed {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        opacity: 1 !important;
        overflow: visible !important;
        border-right: none !important;
        transition: none !important;
    }

    /* Editor = full-screen overlay, slides in from right */
    .editor-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100dvh;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        background: var(--white);
    }

    .editor-panel.mobile-open {
        transform: translateX(0);
    }

    /* Make editor scroll properly on mobile */
    .editor-panel.mobile-open #editor-active {
        display: flex;
        flex-direction: column;
        height: calc(100dvh - 0px);
        min-height: 0;
        overflow: hidden;
    }

    .editor-toolbar {
        flex-shrink: 0;
        padding: 0 0.75rem;
    }

    .btn-back-list {
        display: inline-flex !important;
    }

    /* Format toolbar: horizontal scroll, no wrap */
    .format-toolbar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        padding: 0.35rem 0.75rem;
        flex-shrink: 0;
    }

    .format-group {
        flex-shrink: 0;
    }

    .format-colors-preset {
        display: none;
    }

    /* Content area: must scroll */
    .note-content {
        flex: 1;
        min-height: 0;
        padding: 1rem 1.25rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .editor-status {
        flex-shrink: 0;
    }

    .toolbar-actions {
        gap: 0.25rem;
    }

    .note-title-input {
        font-size: 0.95rem;
    }

    /* Todo panel */
    .todo-panel {
        width: 100%;
    }

    .todo-item {
        padding: 0.6rem 1.25rem;
    }

    .todo-panel-footer {
        padding: 0.75rem 1.25rem;
    }

    /* Search overlay */
    .search-modal {
        width: 95%;
        max-height: 80dvh;
    }
}

/* ============================================
   SCROLLBAR (Webkit)
   ============================================ */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    #sidebar, #note-list-panel, .editor-toolbar, .format-toolbar, .editor-status {
        display: none !important;
    }
    .editor-panel {
        position: static !important;
        width: 100% !important;
    }
    .note-content {
        padding: 0 !important;
    }
}
