:root {
    --bg: #080808;
    --panel: #111;
    --panel-2: #151515;
    --line: #242424;
    --line-strong: #333;
    --text: #f4f4f4;
    --muted: #b4b4b4;
    --soft: #8b8b8b;
    --white: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
html {
    scrollbar-color: #3f3f3f #101010;
    scrollbar-width: thin;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #101010;
}

::-webkit-scrollbar-thumb {
    border: 2px solid #101010;
    border-radius: 999px;
    background: #3f3f3f;
}

::-webkit-scrollbar-thumb:hover {
    background: #565656;
}

body {
    margin: 0;
    width: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

.skip-link {
    position: fixed;
    z-index: 60;
    top: 8px;
    left: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    background: #fff;
    color: #111;
    transform: translateY(calc(-100% - 12px));
}
.skip-link:focus {
    transform: translateY(0);
    outline: 2px solid #7aa7ff;
    outline-offset: 2px;
}

/* Keep in-page destinations visible below the fixed navigation bar. */
body.is-authenticated [id] {
    scroll-margin-top: 88px;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select {
    font: inherit;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
}

.icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.nav-toggle,
.sidebar-close {
    display: none !important;
}

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 10;
    height: 64px;
    display: grid;
    grid-template-columns: 260px 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 8, 8, 0.92);
    backdrop-filter: blur(16px);
}

.brand { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }
.brand {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topnav { display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 14px; }
.topnav a,
.nav-group a,
.search-pill,
.pill,
.button,
.icon-button,
.link-button,
.back-link,
.card-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.topnav a:hover, .sidebar a:hover, .project-title:hover { color: var(--white); }
.topnav a:focus-visible,
.nav-group a:focus-visible,
.button:focus-visible,
.icon-button:focus-visible,
.link-button:focus-visible,
.pill:focus-visible,
.tag:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.86);
    outline-offset: 3px;
}
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; overflow: hidden; }
.top-actions { min-width: 0; }

.session-status {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.045);
    white-space: nowrap;
}

.session-status span {
    font-size: 12px;
    color: var(--soft);
}

.session-status strong {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.session-status.is-warning {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.1);
}

.session-status.is-expired {
    border-color: rgba(248, 113, 113, 0.55);
    background: rgba(248, 113, 113, 0.12);
}

.search-pill, .pill, .count-pill {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0 18px;
    color: var(--muted);
    background: #161616;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr 42px;
    gap: 0;
    width: min(336px, 36vw);
    align-items: center;
}

.search-form.search-pill {
    border-color: transparent;
    padding: 0;
    overflow: hidden;
    background:
        linear-gradient(#111, #0c0c0c) padding-box,
        linear-gradient(135deg, #2f2f2f, #5c5c5c 34%, #7c3aed 68%, #3b82f6) border-box;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.06),
        0 8px 24px rgba(0,0,0,0.24),
        0 0 22px rgba(124,58,237,0.08);
}

.search-form .search-input {
    width: 100%;
    height: 42px;
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 0 13px 0 16px;
    color: var(--text);
    background: transparent;
}

.search-form .search-submit.icon-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-left: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    color: #f3f4f6;
    background: transparent;
    box-shadow: none;
    transform: none;
    will-change: background-color, color;
}

.search-form .search-submit.icon-button:hover {
    border-color: rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.045);
    box-shadow: none;
}

.search-form .search-submit.icon-button:active {
    background: rgba(255,255,255,0.03);
    box-shadow: none;
}

.pill.white, .button.white {
    color: #050505;
    background: #f6f6f6;
    border-color: #f6f6f6;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    padding-top: 64px;
    min-width: 0;
    overflow: hidden;
}

.sidebar {
    --sidebar-width: 260px;
    position: fixed;
    top: 64px;
    bottom: 0;
    left: calc(-1 * var(--sidebar-width));
    width: min(var(--sidebar-width), 80vw);
    max-width: 80vw;
    overflow: auto;
    padding: 28px 8px 36px;
    border-right: 1px solid var(--line);
    background: var(--panel);
    transition: left 0.22s ease;
    visibility: hidden;
    pointer-events: none;
    z-index: 22;
}

.sidebar.is-open {
    visibility: visible;
    pointer-events: auto;
    left: 0;
}

@media (min-width: 1101px) {
    body:not(.sidebar-open) .sidebar {
        left: 0;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: 64px 0 0 0;
    z-index: 21;
    background: rgba(2, 2, 2, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.sidebar-head {
    display: none;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
}

.nav-group {
    display: grid;
    gap: 3px;
    margin-bottom: 28px;
}

.nav-group strong {
    padding: 6px 12px;
    color: #d8d8d8;
    font-size: 13px;
}

.nav-group a {
    border-radius: 7px;
    justify-content: flex-start;
    padding: 7px 12px;
    color: #d0d0d0;
    font-size: 14px;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-group a:hover {
    background: rgba(255,255,255,0.055);
    transform: translateX(2px);
}

.nav-group a.active {
    color: #fff;
    background: #303030;
}

.content {
    grid-column: 2;
    width: min(1320px, calc(100vw - 300px));
    min-width: 0;
    margin: 0 auto;
    padding: 86px 0 80px;
    overflow-x: hidden;
}

.guest-content {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

/* Recovery pages can contain several large drafts; unlike the login panel,
   they must start at the top and have a bounded width on small screens. */
.guest-content > .section-block {
    width: min(980px, 100%);
    min-width: 0;
    justify-self: center;
    align-self: start;
    margin: 0;
    overflow-wrap: anywhere;
}

.guest-content > .section-block textarea {
    display: block;
    max-width: 100%;
    margin: 8px 0 18px;
}

.login-layout {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 56px;
    align-items: center;
    position: relative;
    z-index: 1;
}

.login-ambient {
    position: fixed;
    inset: -8vh -8vw;
    width: 116vw;
    height: 116vh;
    min-width: 100vw;
    min-height: 100vh;
    pointer-events: none;
    opacity: 0.95;
    transform-origin: center;
}

.ambient-grid path {
    stroke-dasharray: 620 920;
    stroke-dashoffset: 0;
    animation: ambient-flow 14s ease-in-out infinite alternate;
}

.ambient-grid path:nth-child(2) { animation-duration: 17s; animation-delay: -4s; }
.ambient-grid path:nth-child(3) { animation-duration: 20s; animation-delay: -7s; }
.ambient-grid path:nth-child(4) { animation-duration: 18s; animation-delay: -2s; }
.ambient-grid path:nth-child(5) { animation-duration: 22s; animation-delay: -9s; }

.ambient-nodes circle {
    fill: rgba(245, 245, 245, 0.42);
    animation: ambient-pulse 6s ease-in-out infinite;
}

.ambient-nodes circle:nth-child(2) { animation-delay: -1.4s; }
.ambient-nodes circle:nth-child(3) { animation-delay: -2.8s; }
.ambient-nodes circle:nth-child(4) { animation-delay: -4.2s; }
.ambient-nodes circle:nth-child(5) { animation-delay: -5.1s; }

.ambient-glow {
    animation: ambient-drift 18s ease-in-out infinite alternate;
}

.ambient-glow.two {
    animation-duration: 23s;
    animation-delay: -8s;
}

.login-copy h1, .intro h1, .page-title h1 {
    margin: 0 0 10px;
    font-size: clamp(42px, 6vw, 74px);
    line-height: 1;
    letter-spacing: -0.055em;
}

.login-copy p, .intro p, .page-title p, .bullet-section p {
    max-width: 620px;
    color: var(--muted);
    font-size: 18px;
}

.login-panel, .section-block, .doc-card, .project-row, .note-row, .flash {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
}

.login-panel {
    display: grid;
    gap: 14px;
    padding: 24px;
    background: rgba(17, 17, 17, 0.86);
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 80px rgba(0,0,0,0.34);
}

.login-alert-stack {
    display: grid;
    gap: 8px;
}

.login-alert {
    border: 1px solid rgba(255, 112, 112, 0.28);
    border-radius: 8px;
    padding: 11px 12px;
    background: linear-gradient(180deg, rgba(68, 24, 24, 0.82), rgba(35, 14, 14, 0.88));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.login-alert strong {
    display: block;
    margin-bottom: 2px;
    color: #ffe5e5;
    font-size: 13px;
}

.login-alert span {
    color: #ffb9b9;
    font-size: 14px;
}

.intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 46%);
    gap: 48px;
    align-items: center;
    margin-bottom: 44px;
}

.hero-media {
    min-height: 280px;
    border-radius: 10px;
    padding: 28px;
    background:
        radial-gradient(circle at 12% 20%, rgba(37, 99, 235, 0.95), transparent 34%),
        radial-gradient(circle at 88% 22%, rgba(127, 86, 217, 0.85), transparent 42%),
        linear-gradient(145deg, #111, #1a1a1a);
}

.mock-window {
    height: 100%;
    min-height: 220px;
    border-radius: 8px;
    padding: 22px;
    background: #090909;
    box-shadow: 0 24px 80px rgba(0,0,0,0.48);
}

.mock-window span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 99px;
    background: #525252;
}

.mock-window strong {
    display: grid;
    place-items: center;
    height: calc(100% - 20px);
    color: #eee;
}

.eyebrow {
    display: block;
    margin-bottom: 10px;
    color: var(--soft);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.bullet-section {
    max-width: 690px;
    margin-bottom: 42px;
}

.bullet-section ul {
    display: grid;
    gap: 18px;
    margin: 24px 0 30px;
    padding-left: 24px;
}

.bullet-section li::marker { color: #6b7280; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card-grid.compact .doc-card { min-height: 150px; }

.doc-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

a.doc-card:hover {
    border-color: #4a4a4a;
    background: #151515;
    box-shadow: 0 18px 52px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.04);
    transform: translateY(-2px);
}

.card-icon {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 8px;
    color: #f8f8f8;
    background: linear-gradient(145deg, rgba(255,255,255,0.11), rgba(255,255,255,0.03));
}

.doc-card h3, .section-block h2, .note-row h3 {
    margin: 0;
    font-size: 19px;
    letter-spacing: -0.02em;
}

.doc-card p, .note-row p, .project-row p {
    margin: 0;
    color: var(--muted);
}

.metric-card {
    gap: 10px;
    border-color: #2b2b2b;
    background:
        linear-gradient(155deg, #151515, #111),
        linear-gradient(155deg, #2f2f2f, #535353 32%, #7c3aed 78%, #3b82f6);
}

.metric-label {
    color: var(--soft);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    margin: 0;
    font-size: 27px;
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.doc-card .card-link { margin-top: auto; color: #fff; font-weight: 700; justify-content: flex-start; }
.doc-card strong { font-size: 25px; letter-spacing: -0.04em; }

.muted-note {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.section-block {
    padding: 24px;
    margin-bottom: 24px;
}

.section-block.narrow { max-width: 560px; margin: 0 auto; }

.section-head, .composer-actions, .meta-line, .project-row, .row-actions, .form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-head { margin-bottom: 18px; }
.section-head h2 { margin-top: 0; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tag {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px 10px;
    color: var(--muted);
    background: #171717;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tag:hover {
    color: #fff;
    border-color: #4a4a4a;
    background: #222;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.tag.active, .tag.mini { color: #fff; border-color: #3a3a3a; background: #2a2a2a; }
.tag.active { box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 1px rgba(255,255,255,0.04); }
.tag.income { border-color: rgba(74, 222, 128, 0.42); background: rgba(22, 46, 28, 0.64); color: #bdf5c4; }
.tag.expense { border-color: rgba(248, 113, 113, 0.48); background: rgba(67, 20, 20, 0.56); color: #ffbab9; }
.tag.mini { font-size: 12px; padding: 3px 8px; }

.project-list { display: grid; gap: 10px; }

.project-row {
    align-items: center;
    padding: 18px;
    min-width: 0;
    overflow: hidden;
}

.project-row > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.project-row > form,
.project-row > .row-actions {
    flex: 0 0 auto;
    align-self: center;
}

.project-title {
    display: inline-block;
    max-width: 100%;
    margin-bottom: 7px;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.meta-line {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--soft);
    font-size: 13px;
    min-width: 0;
}

.row-actions {
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.button, .icon-button, .link-button {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    min-height: 40px;
    padding: 0 16px;
    color: #f2f2f2;
    background: #1a1a1a;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    backface-visibility: hidden;
    transform: translateZ(0);
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
    will-change: background-color, border-color, color, box-shadow;
}

.button > *,
.icon-button > *,
.link-button > * {
    pointer-events: none;
}

.button {
    min-width: 112px;
}

.button:hover,
.icon-button:hover {
    border-color: #565656;
    background: #242424;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 0 1px rgba(255,255,255,0.035);
}

.button.white:hover,
.pill.white:hover {
    color: #050505;
    border-color: #ffffff;
    background-color: #ffffff;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 6px 18px rgba(255,255,255,0.08);
}

.button.quiet:hover {
    color: #ffffff;
    border-color: #4a4a4a;
    background: rgba(255,255,255,0.055);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.button:active,
.icon-button:active,
.pill.white:active {
    border-color: #3e3e3e;
    background: #161616;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.24);
}
.button.white:active,
.pill.white:active {
    color: #050505;
    border-color: #dedede;
    background: #e8e8e8;
}
.button.full { width: 100%; margin-top: 8px; }
.button.quiet { color: #d6d6d6; background: transparent; }
.button.danger { color: #ffc8c8; border-color: rgba(248, 113, 113, 0.34); background: rgba(75, 24, 24, 0.52); }
.button.danger:hover { color: #fff; border-color: rgba(248, 113, 113, 0.7); background: rgba(110, 31, 31, 0.72); }
.icon-button { width: 40px; min-width: 40px; padding: 0; }
.link-button { min-height: 0; padding: 0; border: 0; color: var(--muted); background: transparent; }
.link-button:hover { color: #fff; }

form { display: grid; gap: 12px; }
label { color: #e6e6e6; font-weight: 700; }
input, textarea, select {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px 13px;
    color: var(--text);
    background:
        linear-gradient(#0b0b0b, #0b0b0b) padding-box,
        linear-gradient(135deg, #2f2f2f, #535353 34%, #7c3aed 68%, #3b82f6) border-box;
    background-size: 100% 100%, 180% 180%;
    background-position: 0 0, 0% 50%;
    outline: none;
    scrollbar-color: #4a4a4a #101010;
    scrollbar-width: thin;
    transition: color 0.18s ease, box-shadow 0.18s ease, background-position 0.32s ease, filter 0.18s ease;
}

textarea { resize: vertical; }
input:hover, textarea:hover, select:hover {
    background-position: 0 0, 58% 50%;
}
input:focus, textarea:focus, select:focus,
input.field-focus, textarea.field-focus, select.field-focus {
    background-position: 0 0, 100% 50%;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.07), 0 0 30px rgba(124, 58, 237, 0.12);
    filter: saturate(1.08);
}
.note-modal-form textarea::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    width: 11px;
}

.note-modal-form textarea::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
    border-radius: 0 7px 7px 0;
    background: #101010;
}

.note-modal-form textarea::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
    border: 3px solid #101010;
    border-radius: 999px;
    background: #484848;
}

.note-modal-form textarea::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
    background: #5f5f5f;
}

.login-panel input:focus {
    box-shadow: 0 0 0 4px rgba(255,255,255,0.08), 0 0 38px rgba(122,167,255,0.14);
}
.composer textarea { min-height: 190px; }
.composer-actions { margin-top: 12px; color: var(--muted); }

.text-writer-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.text-writer-form {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.text-writer-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.text-writer-form textarea {
    min-height: 54vh;
    max-height: 70vh;
}

.text-writer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}

.text-writer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.text-writer-explorer {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 12px;
    min-width: 0;
}

.text-writer-explorer .section-head {
    margin-bottom: 0;
}

.text-writer-explorer .section-head h2 {
    margin-bottom: 4px;
}

.text-explorer-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px auto;
    gap: 8px;
    align-items: center;
}

.text-explorer-search input {
    height: 38px;
    min-height: 0;
    padding: 0 11px;
}

.text-explorer-search .icon-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
}

.text-document-list {
    display: grid;
    gap: 8px;
    max-height: 52vh;
    overflow: auto;
    padding-right: 4px;
}

.text-document-link {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #f4f4f4;
    background: #151515;
    text-decoration: none;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.text-document-link:hover,
.text-document-link.active {
    border-color: #555;
    background: #202020;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.text-document-link strong,
.text-document-link span,
.text-document-link p {
    min-width: 0;
    overflow-wrap: anywhere;
}

.text-document-link strong {
    font-size: 14px;
    line-height: 1.25;
}

.text-document-link span {
    color: var(--muted);
    font-size: 12px;
}

.text-document-link p {
    margin: 0;
    display: -webkit-box;
    color: var(--soft);
    font-size: 12px;
    line-height: 1.35;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-explorer-pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
}

.text-explorer-pagination .button {
    min-width: 0;
    width: 100%;
    padding: 0 12px;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.notes-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 24px;
    align-items: start;
}

.notes-list-panel {
    min-width: 0;
}

.notes-list {
    display: grid;
    gap: 12px;
}

.notes-compose {
    position: sticky;
    top: 88px;
}

.stack { display: grid; gap: 16px; }
.stack .section-block { margin-bottom: 0; }

.page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 30px;
}

.page-title > h1,
.page-title > div {
    min-width: 0;
    overflow-wrap: anywhere;
}

.back-link { justify-content: flex-start; color: var(--muted); font-weight: 700; }
.back-link:hover { color: #fff; }

.note-row {
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: 20px;
    overflow: hidden;
}

.note-row h3 {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    color: #f4f4f4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.note-head {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.note-head small {
    color: var(--soft);
    overflow-wrap: anywhere;
}

.note-content {
    max-height: 260px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 12px;
    color: var(--muted);
    background: rgba(255,255,255,0.025);
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    scrollbar-color: #4a4a4a #101010;
}

.note-row .meta-line {
    gap: 18px;
}

.note-content::-webkit-scrollbar {
    width: 11px;
}

.note-content::-webkit-scrollbar-track {
    background: #101010;
}

.note-content::-webkit-scrollbar-thumb {
    border: 3px solid #101010;
    border-radius: 999px;
    background: #484848;
}

.note-content::-webkit-scrollbar-thumb:hover {
    background: #5f5f5f;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 28px;
    max-height: 100dvh;
    overflow: hidden;
    background: rgba(0,0,0,0);
    opacity: 0;
    transition: opacity 0.22s ease, background 0.22s ease;
}

.job-status, .job-inline {
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #bfdbfe;
    background: rgba(30, 58, 138, 0.18);
}
.job-status { display: grid; gap: 6px; padding: 12px 14px; border-radius: 10px; }
.job-inline { padding: 3px 8px; border-radius: 999px; font-size: 12px; }
.job-status.failed, .job-inline.failed { border-color: rgba(248,113,113,.4); color: #fecaca; background: rgba(127,29,29,.2); }
.button:disabled, .icon-button:disabled { opacity: .48; cursor: not-allowed; pointer-events: none; }

.modal-backdrop.is-open {
    background: rgba(0,0,0,0.72);
    opacity: 1;
}

.note-modal {
    width: min(980px, 100%);
    max-height: min(860px, calc(100vh - 56px));
    max-height: min(860px, calc(100dvh - 56px));
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 18px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 22px;
    background: rgba(14,14,14,0.98);
    box-shadow: 0 36px 120px rgba(0,0,0,0.58), inset 0 1px 0 rgba(255,255,255,0.05);
    transform: translateY(24px) scale(0.97);
    transition: transform 0.24s cubic-bezier(.2,.8,.2,1), opacity 0.22s ease;
}

.modal-backdrop.is-open .note-modal {
    transform: translateY(0) scale(1);
}

.modal-backdrop.is-submitting {
    pointer-events: none;
}

.modal-backdrop.is-saving .note-modal,
.modal-backdrop.is-open.is-saving .note-modal,
.note-modal.is-saving {
    opacity: 0 !important;
    transform: translateY(18px) scale(0.98) !important;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.modal-head h2 {
    margin: 0;
    font-size: 28px;
    line-height: 1.12;
    overflow-wrap: anywhere;
    letter-spacing: -0.02em;
}

.note-modal-form {
    min-height: 0;
    min-width: 0;
    grid-template-rows: auto auto auto minmax(280px, 1fr) auto;
}

.note-modal-form textarea {
    min-height: min(52vh, 520px);
    max-height: 58vh;
}

.button.is-loading,
form.is-loading button[type="submit"] {
    position: relative;
    pointer-events: none;
    color: transparent;
}

.button.is-loading .icon,
form.is-loading button[type="submit"] .icon,
.button.is-loading span,
form.is-loading button[type="submit"] span {
    opacity: 0;
}

.button.is-loading::after,
form.is-loading button[type="submit"]::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 18px;
    height: 18px;
    margin: auto;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    color: #111;
    animation: loading-spin 0.75s linear infinite;
}

.button:not(.white).is-loading::after,
form.is-loading button[type="submit"]:not(.white)::after {
    color: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.table-shell {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--line);
    margin: 0 -2px;
}

.table-shell table { min-width: 640px; }

th, td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

td.table-action {
    width: 1%;
    white-space: nowrap;
}

th { color: var(--soft); font-size: 13px; }
td { color: #dedede; }

.section-note {
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.13);
    color: var(--muted);
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.section-note p { color: var(--muted); }

.flash-stack {
    display: grid;
    gap: 12px;
    position: fixed;
    top: 82px;
    right: 24px;
    z-index: 40;
    width: min(420px, calc(100vw - 48px));
    pointer-events: none;
}

.flash {
    --flash-accent: #4ade80;
    --flash-accent-rgb: 74, 222, 128;
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    min-height: 76px;
    padding: 15px 14px 15px 15px;
    overflow: hidden;
    color: #ecfdf3;
    border: 1px solid rgba(var(--flash-accent-rgb), 0.24);
    border-radius: 13px;
    background:
        linear-gradient(110deg, rgba(var(--flash-accent-rgb), 0.12), transparent 58%),
        rgba(15, 20, 17, 0.96);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.045);
    backdrop-filter: blur(18px);
    pointer-events: auto;
    animation: flash-enter 0.32s cubic-bezier(.2, .8, .2, 1) both;
}

.flash.error {
    --flash-accent: #fb7185;
    --flash-accent-rgb: 251, 113, 133;
    color: #fff1f2;
    background:
        linear-gradient(110deg, rgba(var(--flash-accent-rgb), 0.12), transparent 58%),
        rgba(24, 15, 17, 0.97);
}

.flash-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(var(--flash-accent-rgb), 0.27);
    border-radius: 10px;
    color: var(--flash-accent);
    background: rgba(var(--flash-accent-rgb), 0.11);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.flash-icon .icon {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

.flash-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
    padding-top: 1px;
}

.flash-copy strong {
    color: #f7fff9;
    font-size: 13px;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

.flash-copy > span {
    color: #b9c7bd;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.flash.error .flash-copy > span {
    color: #d8bdc1;
}

.flash-close {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: -3px -3px 0 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: #819087;
    background: transparent;
    cursor: pointer;
    transition: color 0.16s ease, background-color 0.16s ease;
}

.flash-close:hover {
    color: #f4fff7;
    background: rgba(255, 255, 255, 0.07);
}

.flash-close:focus-visible {
    outline: 2px solid rgba(var(--flash-accent-rgb), 0.75);
    outline-offset: 2px;
}

.flash-close .icon {
    width: 15px;
    height: 15px;
}

.flash-timer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: rgba(var(--flash-accent-rgb), 0.7);
    transform-origin: left center;
    animation: flash-timer 5.2s linear forwards;
}

.flash:hover .flash-timer,
.flash:focus-within .flash-timer {
    animation-play-state: paused;
}

.flash.is-leaving {
    animation: flash-leave 0.24s ease forwards;
    pointer-events: none;
}

@keyframes flash-enter {
    from { opacity: 0; transform: translate3d(18px, -8px, 0) scale(0.98); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes flash-leave {
    to { opacity: 0; transform: translate3d(18px, -6px, 0) scale(0.98); }
}

@keyframes flash-timer {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@keyframes ambient-flow {
    from { stroke-dashoffset: 0; opacity: 0.24; }
    to { stroke-dashoffset: -420; opacity: 0.52; }
}

@keyframes ambient-pulse {
    0%, 100% { opacity: 0.18; transform: scale(0.86); }
    50% { opacity: 0.58; transform: scale(1.18); }
}

@keyframes ambient-drift {
    from { transform: translate3d(-18px, 12px, 0) scale(0.96); opacity: 0.7; }
    to { transform: translate3d(22px, -18px, 0) scale(1.06); opacity: 1; }
}

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

@media (prefers-reduced-motion: reduce) {
    .ambient-grid path,
    .ambient-nodes circle,
    .ambient-glow,
    .button.is-loading::after,
    form.is-loading button[type="submit"]::after {
        animation: none;
    }

    .modal-backdrop,
    .note-modal {
        transition: none;
    }

    .flash,
    .flash-timer {
        animation: none;
    }

    .flash-timer {
        display: none;
    }
}

.empty {
    border: 1px dashed var(--line-strong);
    border-radius: 9px;
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 1100px) {
    .topbar {
        grid-template-columns: 1fr auto;
        align-items: center;
        padding: 0 14px;
    }
    .topnav { display: none; }
    .nav-toggle {
        display: inline-flex !important;
    }
    body.is-authenticated .nav-toggle {
        display: inline-flex !important;
    }
    .top-actions {
        width: auto;
        min-width: 0;
        align-items: center;
        justify-content: flex-start;
        flex: 1 1 auto;
    }
    .search-form {
        width: min(100%, 420px);
        min-width: 0;
        flex: 1 1 auto;
        max-width: none;
    }
    .search-form .search-input { width: 100%; }
    .dashboard-pill { display: none; }
    body.sidebar-open { overflow: hidden; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 64px;
        left: 0;
        width: min(80vw, 320px);
    }
    body.sidebar-open .sidebar {
        left: 0;
    }
    .sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 14px; }
    .sidebar-close { display: inline-flex !important; }
    .content { grid-column: 1; width: calc(100% - 32px); max-width: 960px; padding-top: 104px; }
    .intro, .two-column, .notes-layout, .login-layout, .text-writer-layout { grid-template-columns: 1fr; }
    .notes-compose { position: static; }
    .text-writer-explorer { position: static; }
    .text-document-list { max-height: none; }
}

@media (max-width: 760px) {
    body.is-authenticated [id] { scroll-margin-top: 94px; }
    .topbar { height: auto; min-height: 58px; padding: 12px; }
    .brand { font-size: 18px; }
    .topbar { grid-template-columns: minmax(0, 1fr) auto; }
    .top-actions .pill { display: none; }
    .session-status {
        min-height: 34px;
        padding: 0 9px;
        gap: 5px;
    }
    .session-status span { display: none; }
    .top-actions {
        gap: 8px;
        width: auto;
        min-width: 0;
        justify-content: flex-start;
        flex: 1 1 auto;
    }
    .search-form {
        width: min(100%, 320px);
        max-width: none;
        flex: 1 1 auto;
    }
    .content { width: calc(100% - 24px); max-width: 960px; padding-top: 90px; }
    .flash-stack {
        top: 70px;
        right: 12px;
        width: calc(100vw - 24px);
    }
    .flash {
        min-height: 70px;
        padding: 13px 12px;
    }
    .card-grid { grid-template-columns: 1fr; }
    .project-row, .composer-actions, .section-head, .page-title, .form-actions { display: grid; align-items: stretch; }
    .row-actions { justify-content: stretch; }
    .row-actions .button { width: 100%; }
    .login-copy h1, .intro h1, .page-title h1 { font-size: 42px; }
    .hero-media { min-height: 220px; }
    .guest-content {
        place-items: end center;
        padding: 24px 14px 36px;
    }
    body.is-authenticated .sidebar-backdrop { inset: 58px 0 0 0; }
    .login-ambient {
        inset: -18vh -42vw;
        width: 184vw;
        height: 136vh;
        opacity: 0.9;
    }
    .login-layout {
        gap: 28px;
    }
    .login-panel {
        padding: 18px;
    }
    .modal-backdrop {
        padding: 10px;
        align-items: end;
    }
    .note-modal {
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: 12px 12px 0 0;
        padding: 16px;
    }
    .modal-head h2 {
        font-size: 24px;
    }
    .note-modal-form textarea {
        min-height: 50vh;
        max-height: 58vh;
    }
    .guest-content .ambient-grid path,
    .guest-content .ambient-nodes circle,
    .guest-content .ambient-glow {
        animation: none;
    }
}

input.field-focus,
textarea.field-focus,
select.field-focus {
    background-position: 0 0, 100% 50% !important;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.07), 0 0 30px rgba(124, 58, 237, 0.12) !important;
    filter: saturate(1.08) !important;
}
