:root {
    --ink: #1c1915;
    --ink-soft: #5e584e;
    --paper: #f4f0e8;
    --paper-2: #e9e2d4;
    --card: #fffcf7;
    --line: rgba(28, 25, 21, 0.12);
    --moss: #1f4d3a;
    --moss-hover: #16382b;
    --moss-soft: rgba(31, 77, 58, 0.1);
    --on-moss: #f6f1e7;
    --danger: #9a4033;
    --shadow: 0 18px 50px rgba(40, 30, 16, 0.08);
    --focus: rgba(31, 77, 58, 0.45);
    --hover: rgba(28, 25, 21, 0.05);
    --input: #fff;
    --glow: rgba(31, 77, 58, 0.14);
    --serif: "Fraunces", "Iowan Old Style", Palatino, serif;
    --text: "Literata", "Iowan Old Style", Palatino, serif;
    --ui: "Outfit", "Avenir Next", sans-serif;
    color-scheme: light;
}

html[data-theme="dark"] {
    --ink: #f3eee6;
    --ink-soft: #b7ad9e;
    --paper: #141210;
    --paper-2: #0e0d0b;
    --card: #1e1b17;
    --line: rgba(243, 238, 230, 0.12);
    --moss: #9dccb0;
    --moss-hover: #7eaf96;
    --moss-soft: rgba(157, 204, 176, 0.16);
    --on-moss: #102119;
    --danger: #f0a598;
    --shadow: 0 22px 50px rgba(0, 0, 0, 0.38);
    --focus: rgba(157, 204, 176, 0.7);
    --hover: rgba(243, 238, 230, 0.06);
    --input: #171511;
    --glow: rgba(157, 204, 176, 0.12);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

html { background: var(--paper); }

body {
    color: var(--ink);
    background:
        radial-gradient(900px 420px at 100% -10%, var(--glow), transparent 60%),
        radial-gradient(800px 380px at -10% -20%, color-mix(in srgb, var(--card) 80%, transparent), transparent 55%),
        var(--paper);
    font-family: var(--ui);
    font-weight: 400;
    line-height: 1.45;
}

::selection { background: var(--moss-soft); color: var(--ink); }

a { color: inherit; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.brand {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 640;
    letter-spacing: -0.04em;
    text-decoration: none;
}

.brand span { color: var(--moss); }

.hero, .features, .site-footer, .auth-wrap {
    width: min(1080px, calc(100% - 2.5rem));
    margin-inline: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
}

.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(1080px, calc(100% - 2.5rem));
    margin-inline: auto;
    padding: 0.85rem 0;
}

.site-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: flex-end; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    font: 500 0.92rem/1 var(--ui);
    letter-spacing: -0.01em;
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    color: var(--ink);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-solid { background: var(--moss); color: var(--on-moss); }
.btn-solid:hover { background: var(--moss-hover); }
.btn-quiet { border-color: var(--line); background: color-mix(in srgb, var(--card) 75%, transparent); }
.btn-quiet:hover { background: var(--card); }
.btn-large { padding: 0.8rem 1.15rem; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--card) 80%, transparent);
    color: var(--ink);
    cursor: pointer;
}

.theme-toggle:hover { background: var(--hover); }
.theme-toggle.is-mobile-only { display: none; }
.theme-icon { width: 1.05rem; height: 1.05rem; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }

.hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 3.5rem;
    align-items: center;
    padding: 4.2rem 0 3.2rem;
}

.eyebrow {
    display: inline-flex;
    margin: 0 0 1rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    background: var(--moss-soft);
    color: var(--moss);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1, h2 { font-family: var(--serif); font-weight: 520; letter-spacing: -0.035em; }

.hero h1 {
    margin: 0;
    font-size: clamp(3.1rem, 6.4vw, 5.1rem);
    line-height: 0.94;
}

.lede {
    max-width: 36rem;
    margin: 1.25rem 0 0;
    color: var(--ink-soft);
    font-family: var(--text);
    font-size: 1.16rem;
    line-height: 1.6;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.7rem; }

.preview { position: relative; }

.preview::before {
    content: "";
    position: absolute;
    inset: 16px -10px -12px 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: color-mix(in srgb, var(--moss) 12%, var(--card));
    transform: rotate(3.5deg);
}

.sheet {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 1.35rem 1.55rem 1.45rem;
    transform: rotate(-1.1deg);
}

.sheet-top, .sheet-muted {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--ink-soft);
    font-size: 0.8rem;
}

.sheet-pin {
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: var(--moss-soft);
    color: var(--moss);
    font-weight: 600;
}

.sheet h2 { margin: 1.15rem 0 0.55rem; font-size: 1.7rem; }
.sheet p { margin: 0; font-family: var(--text); line-height: 1.6; }
.sheet-muted { margin-top: 1.25rem; }

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.9rem;
    padding-bottom: 3rem;
}

.features article {
    background: color-mix(in srgb, var(--card) 78%, transparent);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.15rem 1.15rem 1.25rem;
    transition: transform 0.16s ease, border-color 0.16s ease;
}

.features article:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--moss) 40%, var(--line));
}

.features h2 {
    margin: 0 0 0.45rem;
    font-size: 1.45rem;
}

.features h2::before {
    content: "";
    display: block;
    width: 1.5rem;
    height: 3px;
    margin-bottom: 0.75rem;
    border-radius: 99px;
    background: var(--moss);
}

.features p { margin: 0; color: var(--ink-soft); font-family: var(--text); line-height: 1.55; }

.site-footer { padding: 0.4rem 0 2.4rem; color: var(--ink-soft); font-size: 0.92rem; }

.auth-wrap { padding: 3.2rem 0 4rem; }

.auth-card {
    width: min(440px, 100%);
    margin-inline: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 1.7rem 1.5rem 1.35rem;
    box-shadow: var(--shadow);
}

.auth-card h1 { margin: 0; font-size: 2.25rem; }
.auth-lead { margin: 0.45rem 0 1.15rem; color: var(--ink-soft); font-family: var(--text); }

.auth-card label {
    display: block;
    margin: 0.9rem 0 0.35rem;
    font-size: 0.84rem;
    font-weight: 600;
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--input);
    border-radius: 12px;
    padding: 0.78rem 0.85rem;
    font: 400 1rem/1.3 var(--ui);
    color: var(--ink);
}

.auth-card input:focus, .search input:focus {
    outline: 2px solid var(--focus);
    border-color: var(--moss);
}

.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.check input { accent-color: var(--moss); }

.auth-card .btn { width: 100%; margin-top: 1.2rem; }
.auth-switch { text-align: center; color: var(--ink-soft); }
.auth-switch a { color: var(--moss); font-weight: 600; }
.field-error { margin: 0.35rem 0 0; color: var(--danger); font-size: 0.88rem; }

body.app {
    background: var(--paper-2);
    overflow: hidden;
}

.shell {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    height: 100dvh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--paper);
    border-right: 1px solid var(--line);
}

.sidebar-top, .sidebar-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    padding: 0.85rem 0.9rem;
}

.sidebar-actions { display: flex; align-items: center; gap: 0.45rem; }

.search { padding: 0 0.9rem 0.75rem; }
.search input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--input);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.62rem 0.9rem;
    font: 400 0.95rem/1.2 var(--ui);
}

.search input::placeholder, .note-heading::placeholder, .note-form textarea::placeholder { color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }

.note-list {
    list-style: none;
    margin: 0;
    padding: 0 0.55rem 0.7rem;
    overflow: auto;
    flex: 1;
}

.note-list a {
    display: block;
    margin-bottom: 0.2rem;
    padding: 0.72rem 0.75rem 0.65rem;
    border-radius: 12px;
    text-decoration: none;
}

.note-list a:hover { background: var(--hover); }
.note-list a.is-active, .note-list a.is-active:hover { background: var(--moss-soft); }
.note-title { display: flex; gap: 0.35rem; align-items: baseline; font-weight: 600; letter-spacing: -0.01em; }
.note-excerpt, .note-list time { display: block; color: var(--ink-soft); font-size: 0.8rem; }
.note-excerpt {
    margin-top: 0.18rem;
    font-family: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pin-mark { color: var(--moss); font-size: 0.68rem; }
.note-empty { padding: 1rem 0.75rem; color: var(--ink-soft); }

.sidebar-foot { border-top: 1px solid var(--line); }
.sidebar-foot button, .editor-bar button, .back {
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    font: 500 0.9rem/1 var(--ui);
    cursor: pointer;
    text-decoration: none;
}
.sidebar-foot button:hover, .editor-bar button:hover, .back:hover { color: var(--ink); }
.who { font-weight: 600; letter-spacing: -0.01em; }

.editor {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--card);
}

.editor-bar {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid var(--line);
}

.save-status { margin: 0 auto 0 0; color: var(--ink-soft); font-size: 0.84rem; }
.back { display: none; }
.danger { color: var(--danger); }

.note-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: min(720px, 100%);
    min-height: 0;
    margin-inline: auto;
    padding: 1.4rem 1.5rem 2rem;
}

.note-heading, .note-form textarea {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink);
    resize: none;
}

.note-heading:focus, .note-form textarea:focus { outline: none; }

.note-heading {
    font-family: var(--serif);
    font-size: clamp(2rem, 4vw, 2.7rem);
    font-weight: 520;
    letter-spacing: -0.035em;
    padding: 0;
}

.note-form textarea {
    flex: 1;
    margin-top: 0.55rem;
    font-family: var(--text);
    font-size: 1.12rem;
    line-height: 1.7;
}

.editor-blank {
    margin: auto;
    max-width: 28rem;
    text-align: center;
    color: var(--ink-soft);
    padding: 2rem;
}

.editor-blank h1 { color: var(--ink); font-size: 2.15rem; margin-bottom: 0.4rem; }

@media (max-width: 860px) {
    .hero, .features { grid-template-columns: 1fr; }
    .hero { padding-top: 2.2rem; gap: 2.2rem; }
    .preview::before, .sheet { transform: none; }
    .preview::before { inset: 10px 8px -10px 8px; }
    .bar { align-items: flex-start; }

    body.app { overflow: auto; }
    .shell { display: block; height: auto; }
    .sidebar, .editor { min-height: 100dvh; }
    .shell.has-selection .sidebar { display: none; }
    .shell:not(.has-selection) .editor { display: none; }
    .back { display: inline; }
    .theme-toggle.is-mobile-only { display: inline-flex; }
    .note-form { padding: 1rem 1.1rem 1.6rem; }
    .sidebar-top { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    .features article, .btn { transition: none; }
}
