* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Native <button> elements default to cursor:default (not pointer) in every
   browser — Radix's buttons, segmented-control items, dialog triggers etc.
   are all real <button>s underneath, so this covers them app-wide. */
button:not(:disabled),
[role="button"]:not([aria-disabled="true"]) {
    cursor: pointer;
}

/* Thin, unobtrusive scrollbar for the sidebar/note-list/editor scroll regions,
   instead of the chunky OS-default one. */
.scroll-region {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-a7) transparent;
}

.scroll-region::-webkit-scrollbar {
    width: 8px;
}

.scroll-region::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-region::-webkit-scrollbar-thumb {
    background-color: var(--gray-a7);
    border-radius: 8px;
}

.scroll-region::-webkit-scrollbar-thumb:hover {
    background-color: var(--gray-a8);
}

/* ---- Auth pages (plain PHP forms, no React — styled to match the Radix
   Themes palette via its CSS custom properties so the login/setup screens
   feel consistent with the app without needing a client-side framework) ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-1);
    color: var(--gray-12);
    padding: 16px;
    box-sizing: border-box;
}

.auth-card {
    width: 100%;
    max-width: 340px;
    background: var(--color-panel-solid);
    border: 1px solid var(--gray-a5);
    border-radius: var(--radius-4);
    padding: 32px;
    box-shadow: var(--shadow-4);
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 24px;
    }
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 22px;
}

.auth-sub {
    color: var(--gray-a11);
    font-size: 13px;
    margin: 0 0 20px;
}

.auth-error {
    background: var(--red-a3);
    color: var(--red-a11);
    padding: 8px 12px;
    border-radius: var(--radius-3);
    font-size: 13px;
    margin-bottom: 16px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-card label {
    font-size: 12px;
    color: var(--gray-a11);
    margin-top: 10px;
}

.auth-card input {
    padding: 10px 12px;
    border-radius: var(--radius-3);
    border: 1px solid var(--gray-a6);
    background: var(--color-surface);
    color: inherit;
    outline: none;
    font-size: 14px;
    font-family: inherit;
}

.auth-card input:focus {
    border-color: var(--accent-9);
    box-shadow: 0 0 0 1px var(--accent-9);
}

.auth-card button {
    margin-top: 20px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-3);
    background: var(--accent-9);
    color: var(--accent-contrast);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.auth-card button:hover {
    background: var(--accent-10);
}

/* ---- App (React + Radix Themes) ---- */
.note-title-input {
    border: none;
    background: none;
    outline: none;
    color: inherit;
    font-family: inherit;
    font-size: 26px;
    font-weight: 700;
    padding: 14px 20px 6px;
    width: 100%;
}

.editor-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 40px;
}

.lexical-editor {
    outline: none;
    min-height: 100%;
    font-size: 15px;
    line-height: 1.6;
}

.lexical-editor h2 {
    font-size: 22px;
    margin: 18px 0 8px;
}

.lexical-editor h3 {
    font-size: 18px;
    margin: 16px 0 8px;
}

.lexical-editor blockquote {
    border-left: 3px solid var(--accent-9);
    margin: 10px 0;
    padding: 4px 0 4px 14px;
    color: var(--gray-a11);
}

.lexical-editor ul, .lexical-editor ol {
    margin: 8px 0;
    padding-left: 26px;
}

.lexical-editor ul ul, .lexical-editor ul ol,
.lexical-editor ol ul, .lexical-editor ol ol {
    margin-top: 0;
    margin-bottom: 0;
}

/* Nested lists (via Tab/Shift+Tab, or the toolbar's indent buttons) cycle
   through marker styles per level, same convention as Word/Evernote, so
   sibling levels stay visually distinguishable. */
.lexical-editor ul ul {
    list-style-type: circle;
}

.lexical-editor ul ul ul {
    list-style-type: square;
}

.lexical-editor ul ul ul ul {
    list-style-type: disc;
}

.lexical-editor ol ol {
    list-style-type: lower-alpha;
}

.lexical-editor ol ol ol {
    list-style-type: lower-roman;
}

.lexical-editor ol ol ol ol {
    list-style-type: decimal;
}

/* Indenting the last item(s) in a list (with no earlier sub-list to merge
   into) makes Lexical wrap them in a new <li> that holds only the nested
   <ul>/<ol> and has no text of its own — a structural container, not a real
   bullet point. Hide its marker so it doesn't show as a stray empty bullet. */
.lexical-editor li:has(> ul:only-child),
.lexical-editor li:has(> ol:only-child) {
    list-style: none;
}

.lexical-editor a {
    color: var(--accent-11);
}

.lexical-editor p {
    margin: 0 0 10px;
}

.lexical-editor code {
    background: var(--gray-a3);
    border-radius: 4px;
    padding: 0.1em 0.4em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.lexical-editor .editor-code-block {
    display: block;
    background: var(--gray-a3);
    border: 1px solid var(--gray-a5);
    border-radius: var(--radius-3);
    padding: 12px 14px;
    margin: 10px 0;
    white-space: pre-wrap;
    font-size: 0.85em;
    line-height: 1.5;
    tab-size: 2;
}

.lexical-editor hr {
    border: none;
    border-top: 1px solid var(--gray-a6);
    margin: 20px 0;
}

.lexical-editor table {
    border-collapse: collapse;
    margin: 10px 0;
    width: auto;
}

.editor-image-wrapper {
    display: inline-block;
    max-width: 100%;
}

.editor-image-resizer {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.lexical-editor .editor-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-3);
    margin: 10px 0;
}

.editor-image-resize-handle {
    position: absolute;
    right: 4px;
    bottom: 14px;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--gray-12);
    border: 2px solid var(--gray-1);
    opacity: 0;
    cursor: se-resize;
    touch-action: none;
}

.editor-image-resizer:hover .editor-image-resize-handle,
.editor-image-resize-handle.is-resizing {
    opacity: 0.85;
}

/* Drag handles rendered by TableCellResizer.js (portaled to <body>, so this
   is intentionally outside the .lexical-editor scope). */
.TableCellResizer__resizer {
    position: absolute;
    touch-action: none;
    z-index: 10;
}

@media (pointer: coarse) {
    .TableCellResizer__resizer {
        background-color: #adf;
        mix-blend-mode: color;
    }
}

/* Only rendered at all while hovering a table (see TableHoverActionsPlugin.js),
   so no extra show/hide styling needed here beyond how they look. */
.table-hover-add-button {
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-2);
    background: var(--gray-a4);
    color: var(--gray-11);
    font-size: 14px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.1s;
}

.table-hover-add-button:hover {
    background: var(--accent-9);
    color: var(--accent-contrast);
}

/* Right-click-a-cell menu (see TableCellContextMenuPlugin.js) for inserting
   a row/column at an arbitrary position, not just the table's end. */
.table-context-menu {
    position: fixed;
    z-index: 20;
    min-width: 190px;
    background: var(--color-panel-solid);
    border: 1px solid var(--gray-a5);
    border-radius: var(--radius-3);
    box-shadow: var(--shadow-5);
    padding: 4px;
}

.table-context-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--gray-12);
    font-size: 13px;
    padding: 7px 10px;
    border-radius: var(--radius-2);
    cursor: pointer;
}

.table-context-menu-item:hover {
    background: var(--accent-a4);
}

.table-context-menu-item--danger {
    color: var(--red-11);
}

.table-context-menu-item--danger:hover {
    background: var(--red-a4);
}

.table-context-menu-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--gray-a5);
}

.lexical-editor table td,
.lexical-editor table th {
    border: 1px solid var(--gray-a6);
    padding: 6px 10px;
    min-width: 60px;
    vertical-align: top;
}

.lexical-editor table th {
    background: var(--gray-a3);
    font-weight: 600;
    text-align: left;
}

.editor-checklist {
    padding-left: 0;
}

.editor-listitem-checked,
.editor-listitem-unchecked {
    position: relative;
    list-style-type: none;
    margin-left: 4px;
    padding-left: 28px;
    outline: none;
}

.editor-listitem-checked {
    color: var(--gray-a11);
    text-decoration: line-through;
}

.editor-listitem-checked::before,
.editor-listitem-unchecked::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    width: 16px;
    height: 16px;
    border: 1px solid var(--gray-a8);
    border-radius: 4px;
    cursor: pointer;
    background: var(--color-surface);
}

.editor-listitem-checked::before {
    background: var(--gray-12);
    border-color: var(--gray-12);
}

.editor-listitem-checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 6px;
    width: 6px;
    height: 10px;
    border-right: 2px solid var(--gray-1);
    border-bottom: 2px solid var(--gray-1);
    transform: rotate(45deg);
}

/* Radix Themes 3.3.0's bundled CSS never hides the native scrollbar on its
   internal ScrollArea viewport (the rule only exists for tab lists/textareas
   in this version) — that viewport is `overflow: scroll` unconditionally, so
   every menu (ContextMenu, DropdownMenu, Select) shows OS scrollbars in both
   axes even with zero actual overflow, since `scroll` always draws them
   regardless of content size. Radix's own custom thumb is meant to render
   over a hidden native one; without this, you get both. */
[data-radix-scroll-area-viewport] {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
[data-radix-scroll-area-viewport]::-webkit-scrollbar {
    display: none;
}
