body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, sans-serif;
    line-height: 1.5;
    background: #f5f5f5;
    color: #1f2937;
}

.site-header {
    background: #111827;
    color: #f9fafb;
}

.site-header .wrap {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.site-header h1 {
    margin: 0;
    font-size: 1.25rem;
}

.site-header a {
    color: inherit;
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-left: auto;
    font-size: 0.875rem;
}

.nav-search {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.nav-search input {
    font-size: 0.8rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    border: 1px solid #4b5563;
    background: #1f2937;
    color: #f9fafb;
    width: 10rem;
}

.nav-search button {
    font-size: 0.8rem;
    padding: 0.1rem 0.4rem;
}

.site-nav a {
    color: #d1d5db;
}

.wrap {
    max-width: 48rem;
    margin: 0 auto;
    padding: 1rem;
}

.meta {
    color: #6b7280;
}

.panel {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
}

.auth-card {
    max-width: 30rem;
}

.stack {
    display: grid;
    gap: 0.75rem;
}

input,
button {
    font: inherit;
}

input[type="text"],
input[type="email"] {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
}

button {
    padding: 0.6rem 1rem;
}

.document-list {
    padding-left: 1.25rem;
}

.document-body {
    border-top: 1px solid #e5e7eb;
    margin-top: 1rem;
    padding-top: 1rem;
}

pre {
    overflow-x: auto;
    padding: 1rem;
    background: #111827;
    color: #f9fafb;
    border-radius: 0.5rem;
}

code {
    font-family: ui-monospace, SFMono-Regular, monospace;
}

a {
    color: #1d4ed8;
}

.tag-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.tag-list li {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 1rem;
    padding: 0.125rem 0.6rem;
    font-size: 0.875rem;
}

.tag-list li a {
    color: #1d4ed8;
    text-decoration: none;
}

.tags {
    border-top: 1px solid #e5e7eb;
    margin-top: 1rem;
    padding-top: 0.75rem;
}

.tags h3 {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.inline-form input {
    width: auto;
    flex: 1;
    padding: 0.3rem 0.5rem;
    font-size: 0.875rem;
}

.inline-form button {
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.875rem;
    line-height: 1;
}

.link-button:hover {
    color: #dc2626;
}

button.danger {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
    border-radius: 0.25rem;
}

button.danger:hover {
    background: #fca5a5;
}

article footer {
    border-top: 1px solid #e5e7eb;
    margin-top: 1rem;
    padding-top: 0.75rem;
}

textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.75rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.9rem;
    resize: vertical;
}

label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #374151;
}

button[type="submit"] {
    background: #1d4ed8;
    color: white;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
}

button[type="submit"]:hover {
    background: #1e40af;
}

.share-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0.5rem;
}

.share-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    padding: 0.2rem 0;
    font-size: 0.875rem;
}

.share-label {
    flex: 1;
}

.share-link-wrap {
    display: flex;
    width: 100%;
    align-items: stretch;
}

.share-link-scroll {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.share-link-copy {
    flex-shrink: 0;
}

.inline-form select {
    font: inherit;
    font-size: 0.875rem;
    padding: 0.3rem 0.4rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
}

.error {
    color: #b91c1c;
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

li:has(> input[type="checkbox"]),
li:has(> .task-toggle-form) {
    list-style: none;
    margin-left: -1.25rem;
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

li input[type="checkbox"] {
    margin-right: 0.4rem;
    accent-color: #1d4ed8;
}

.task-label {
    cursor: pointer;
}

.task-toggle-form {
    display: inline;
}

.task-btn {
    border: none;
    background: none;
    padding: 0;
    margin-right: 0.4rem;
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    color: #374151;
    vertical-align: baseline;
}

.task-btn:hover {
    color: #1d4ed8;
}

.task-btn-checked {
    color: #1d4ed8;
}

.attachment-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.attachment-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.prosemirror-wrapper {
    margin-bottom: 0.5rem;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-bottom: none;
    border-radius: 0.25rem 0.25rem 0 0;
}

.editor-toolbar button,
.editor-toolbar select {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 0.2rem;
    background: white;
    cursor: pointer;
    font-family: inherit;
}

.editor-toolbar button:hover {
    background: #e5e7eb;
}

.editor-mode-toggle {
    background: #f3f4f6;
    color: #374151;
}

.toolbar-spacer {
    flex: 1;
}

.toolbar-label {
    font-size: 0.8rem;
    color: #6b7280;
    align-self: center;
}

.editor-raw-textarea {
    display: block;
    border-radius: 0 0 0.25rem 0.25rem;
    border-top: none;
    min-height: 12rem;
    width: 100%;
    box-sizing: border-box;
}

.ProseMirror {
    border: 1px solid #d1d5db;
    border-radius: 0 0 0.25rem 0.25rem;
    padding: 0.6rem 0.75rem;
    min-height: 12rem;
    outline: none;
    font-family: ui-sans-serif, system-ui, sans-serif;
    line-height: 1.5;
}

.ProseMirror:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}

.ProseMirror > * + * {
    margin-top: 0.75em;
}

.ProseMirror p { margin: 0; }

.ProseMirror h1, .ProseMirror h2, .ProseMirror h3,
.ProseMirror h4, .ProseMirror h5, .ProseMirror h6 {
    margin: 0;
    line-height: 1.2;
}

.ProseMirror ul, .ProseMirror ol {
    padding-left: 1.5rem;
    margin: 0;
}

.ProseMirror li:has(> input[type="checkbox"]) {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    list-style: none;
    margin-left: -1.25rem;
}

.ProseMirror li:has(> input[type="checkbox"]) > span {
    flex: 1;
}

.ProseMirror li:has(> input[type="checkbox"]) > span > p {
    margin: 0;
}

.ProseMirror blockquote {
    border-left: 3px solid #d1d5db;
    margin: 0;
    padding-left: 0.75rem;
    color: #6b7280;
}

.ProseMirror pre {
    padding: 0;
    background: none;
    border-radius: 0;
}

.cm-code-block {
    border: 1px solid #374151;
    border-radius: 0.375rem;
    overflow: hidden;
}

span.raw-djot-node {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 3px;
    padding: 0 0.2em;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.85em;
    cursor: default;
}

/* Link popover */
.link-popover {
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.link-popover-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.link-popover-row label {
    font-size: 0.8rem;
    color: #374151;
    min-width: 2.5rem;
}

.link-popover-row input {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid #d1d5db;
    border-radius: 0.2rem;
    font-family: inherit;
}

.link-popover-btns {
    gap: 0.4rem;
}

.link-popover-btns button {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 0.2rem;
    background: white;
    cursor: pointer;
    font-family: inherit;
}

.link-popover-btns button:hover {
    background: #f3f4f6;
}

/* Image picker modal */
.image-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-picker-modal {
    background: white;
    border-radius: 0.5rem;
    width: min(90vw, 36rem);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.image-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 0.95rem;
}

.image-picker-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 0 0.2rem;
}

.image-picker-upload {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.image-picker-upload button {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.3rem;
    background: white;
    cursor: pointer;
    font-family: inherit;
}

.image-picker-upload button:hover {
    background: #f3f4f6;
}

.image-picker-divider {
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.image-picker-grid {
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 6rem;
}

.image-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 0.3rem;
    padding: 0.3rem;
    width: 6rem;
}

.image-picker-item:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}

.image-picker-item img {
    width: 5rem;
    height: 4rem;
    object-fit: cover;
    border-radius: 0.2rem;
    border: 1px solid #e5e7eb;
}

.image-picker-item span {
    font-size: 0.7rem;
    color: #6b7280;
    max-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-picker-message {
    font-size: 0.85rem;
    color: #6b7280;
    width: 100%;
    text-align: center;
    padding: 1rem 0;
    margin: 0;
}

/* Images in ProseMirror */
.ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
    border: 1px solid #e5e7eb;
}

/* Task sort */
.task-sort-empty { display: none; }

.task-sort-completed,
.task-sort-uncategorized {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, #e5e7eb);
}
