/* Same look as CogniCards: lines and type, no shadows, structure from thin rules and whitespace. */
:root {
    --text: #141618;
    --muted: #6b7076;
    --line: #e1e4e7;
    --line-strong: #141618;
    --bg: #ffffff;
    --shade: #f4f7f6;
    --accent: #0b6e66;
    --accent-soft: #e7f2f0;
    --danger: #b3261e;
    --danger-soft: #fbeceb;
    --warn-soft: #fbf3e2;
    --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --sidebar: 16rem;
}
@media (prefers-color-scheme: dark) {
    :root {
        --text: #e8eaec;
        --muted: #989ea5;
        --line: #2a2e32;
        --line-strong: #c9cdd1;
        --bg: #0f1112;
        --shade: #171b1c;
        --accent: #5cc8b8;
        --accent-soft: #15302d;
        --danger: #ff8a80;
        --danger-soft: #3a1b19;
        --warn-soft: #2e2715;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
body {
    margin: 0;
    padding: 0 1rem 4rem;
    font: 1rem/1.6 var(--sans);
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover, button.link:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 2.1rem; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; margin: .5rem 0 1.25rem; text-wrap: balance; overflow-wrap: anywhere; }
.muted, small { color: var(--muted); }
.error { color: var(--danger); }
p { margin: .75rem 0; }
code { font: .85em var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Header */
nav.site { display: flex; align-items: center; gap: .75rem; padding: 1rem 0; max-width: 72rem; margin: 0 auto; }
nav.site form { margin: 0; }
nav.site .search { flex: 1; max-width: 20rem; margin-left: auto; }
nav.site .search input { padding: .35rem .65rem; font-size: .9rem; }
nav.site button.new-thought { padding: .35rem .8rem; font-size: .9rem; }
nav.site button.link { color: var(--muted); font-size: .9rem; }
.brand { font: 500 .85rem var(--mono); letter-spacing: .02em; color: var(--text); }
.crumbs { font: .8rem var(--mono); color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 .35rem; }

/* Sidebar tree next to the page; on narrow screens only the page, and folder pages do the navigating */
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); gap: 3rem; max-width: 72rem; margin: 0 auto; }
.layout > main { max-width: 44rem; min-width: 0; }
.sidebar { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow: auto; font-size: .9rem; padding-right: .5rem; }
.sidebar-top { margin: .6rem 0 .5rem; }
.sidebar a { color: var(--text); }
.sidebar .current > a, .sidebar .current > details > summary > a, .sidebar a.current { color: var(--accent); font-weight: 500; }
ul.tree { list-style: none; margin: 0; padding: 0; }
ul.tree ul.tree { padding-left: .9rem; border-left: 1px solid var(--line); margin-left: .3rem; }
ul.tree li { padding: .1rem 0; overflow-wrap: anywhere; }
ul.tree details > summary { color: var(--text); font-size: inherit; list-style: none; }
ul.tree details > summary::-webkit-details-marker { display: none; }
/* A small chevron: points right when closed, down when open */
ul.tree details > summary::before {
    content: ""; display: inline-block; width: .38rem; height: .38rem; margin: 0 .5rem .12rem .1rem;
    border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg);
}
ul.tree details[open] > summary::before { transform: rotate(45deg); margin-bottom: .2rem; }
ul.tree details[open] > summary { margin-bottom: .1rem; }
ul.tree > li:not(:has(details)) { padding-left: 1rem; }
@media (max-width: 800px) {
    .layout { display: block; }
    .sidebar { display: none; }
}

/* Forms */
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
    width: 100%;
    padding: .55rem .7rem;
    font: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: block; }
label > span { display: block; font: .75rem var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .3rem; }
label > small { display: block; margin: -.2rem 0 .3rem; font-size: .85rem; }
label.check { display: flex; gap: .5rem; align-items: center; }
form.inline { display: inline; margin: 0; }
.stack { display: grid; gap: 1rem; }
.stack > p { margin: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row input[type=text], .row input[type=search] { flex: 1; width: auto; min-width: 10rem; }

/* Buttons: outlined by default, solid ink for the main action, plain text for small actions */
button, .btn {
    display: inline-block; vertical-align: middle;
    font: 500 .95rem/1.4 var(--sans);
    padding: .5rem 1.05rem;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-soft); text-decoration: none; }
button.primary, .btn.primary { color: var(--bg); background: var(--text); border-color: var(--text); }
button.primary:hover, .btn.primary:hover { background: var(--accent); border-color: var(--accent); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.link { display: inline; vertical-align: baseline; border: 0; padding: 0; background: none; font: inherit; color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
    button, .btn { transition: background-color .15s, border-color .15s; }
}

/* Collapsible sections */
details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details > summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: .75rem; }
details.settings { margin-top: 3rem; }
details.settings form + form { margin-top: 1.5rem; }

/* "New note", "New folder": a button that opens a form in a panel below the row of buttons */
details.create > summary { list-style: none; color: var(--text); font-size: .95rem; }
details.create > summary::-webkit-details-marker { display: none; }
details.create[open] { order: 10; flex-basis: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem 1.25rem; }
details.create[open] > summary { border: 0; padding: 0; font-weight: 600; background: none; display: flex; justify-content: space-between; width: 100%; margin-bottom: 1rem; }
details.create[open] > summary::after { content: "×"; color: var(--muted); font-weight: 400; font-size: 1.25rem; line-height: 1; }
.page-head { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.5rem; }
.page-head h1 { flex: 1; margin: .25rem 0 0; min-width: 0; }

/* Messages */
.notice { background: var(--accent-soft); border-radius: 6px; padding: .6rem .9rem; font-size: .95rem; }
.notice.error-notice { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--warn-soft); }
.notice .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.notice .actions button { padding: .3rem .8rem; font-size: .9rem; }

/* Folder page */
ul.entries { list-style: none; padding: 0; margin: 0; }
ul.entries li { border-bottom: 1px solid var(--line); }
ul.entries li a { display: block; padding: .7rem 0; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
ul.entries li.folder a::after { content: "/"; color: var(--muted); font: 400 .9em var(--mono); margin-left: .15rem; }
ul.entries li.folder + li.note { border-top: 1px solid var(--line-strong); }
ul.entries li a:hover { background: linear-gradient(to right, transparent, var(--accent-soft) 15%, var(--accent-soft) 85%, transparent); text-decoration: none; }

/* Search */
ul.hits { list-style: none; padding: 0; margin: 0; }
ul.hits li { padding: .75rem 0; border-bottom: 1px solid var(--line); }
ul.hits a { font-weight: 500; }
ul.hits li.folder a::after { content: "/"; color: var(--muted); font: 400 .9em var(--mono); margin-left: .15rem; }
ul.hits .path { display: block; font: .75rem var(--mono); }
ul.hits .snippet { margin: .3rem 0 0; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }

/* Note: status and the editor */
.status { font: .75rem var(--mono); color: var(--muted); }
.status.problem { color: var(--danger); }
#editor {
    display: block;
    min-height: 60vh;
    padding: .9rem 1rem;
    font: 1rem/1.65 var(--sans);
    resize: none;
    overflow: hidden;
    tab-size: 4;
}

/* Rendered markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: 1.6rem; margin: 2rem 0 .75rem; }
.md h2 { font-size: 1.3rem; font-weight: 600; margin: 2rem 0 .5rem; letter-spacing: -.01em; }
.md h3, .md h4, .md h5, .md h6 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 .4rem; }
.md ul, .md ol { padding-left: 1.5rem; margin: .5rem 0; }
.md li { margin: .15rem 0; }
.md li > p { margin: .25rem 0; }
/* Task lists: no bullet, the checkbox takes its place */
.md ul:has(> li > input[type=checkbox], > li > p > input[type=checkbox]) { padding-left: 0; }
.md li ul:has(> li > input[type=checkbox], > li > p > input[type=checkbox]) { padding-left: 1.6rem; }
.md li:has(> input[type=checkbox]), .md li:has(> p > input[type=checkbox]) { list-style: none; }
.md input[type=checkbox] { width: 1rem; height: 1rem; margin: 0 .45rem 0 0; vertical-align: -.15rem; accent-color: var(--accent); }
.md input[type=checkbox]:not(:disabled) { cursor: pointer; }
.md li:has(> input[type=checkbox]:checked) { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.md li:has(> input[type=checkbox]:checked) li { text-decoration: none; }
.md blockquote { margin: 1rem 0; padding-left: 1rem; border-left: 2px solid var(--accent); color: var(--muted); }
.md pre { background: var(--shade); border-radius: 6px; padding: .75rem 1rem; overflow-x: auto; }
.md pre code { font-size: .85rem; }
.md :not(pre) > code { background: var(--shade); padding: .1rem .3rem; border-radius: 4px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: .4rem 1rem .4rem 0; text-align: left; }
.md th { border-bottom-color: var(--line-strong); font-weight: 600; }
.md img { max-width: 100%; }

/* Login */
main.login { max-width: 22rem; margin: 4rem auto 0; }
main.login .brand { display: block; margin-bottom: 1.5rem; }

@media (max-width: 480px) {
    nav.site { flex-wrap: wrap; gap: .5rem .75rem; }
    nav.site .search { order: 10; flex-basis: 100%; max-width: none; }
    nav.site .new-thought-form { margin-left: auto; }
    h1 { font-size: 1.75rem; }
    #editor { min-height: 50vh; padding: .75rem; }
}
