:root {
    color-scheme: light dark;
    --bg: #ffffff;
    --fg: #111111;
    --subtle: #6b6b6b;
    --accent: #1d1d1d;
    --muted: #f2f2f2;
    --border: #d8d8d8;
    --sidebar-bg: #f5f5f5;
    --sidebar-border: #d0d0d0;
    --surface: #ffffff;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    --toolbar-bg: rgba(0, 0, 0, 0.04);
    --toolbar-border: rgba(0, 0, 0, 0.08);
    --selection: rgba(0, 0, 0, 0.08);
}

body[data-theme="dark"] {
    --bg: #000000;
    --fg: #e0e0e0;
    --subtle: #7a7a7a;
    --accent: #ffffff;
    --muted: #000000;
    --border: #292929;
    --sidebar-bg: #000000;
    --sidebar-border: #1a1a1a;
    --surface: #000000;
    --toolbar-bg: #000000;
    --toolbar-border: #1a1a1a;
    --selection: rgba(255, 255, 255, 0.12);
}


* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "IBM Plex Mono", monospace, monospace;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
}

body[data-nav="open"] {
    overflow: hidden;
}

.shell {
    display: grid;
    grid-template-columns: minmax(240px, 300px) 1fr;
    grid-template-rows: 100vh;
    overflow: hidden;
    user-select: none;
}

aside {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    gap: 1rem;
}

.brow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.brow h1 {
    margin: 0;
    font-size: 1.4rem;
    letter-spacing: 0.04em;
}

.brow button {
    font-size: 0.85rem;
}

.mbtn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border-radius: 0.65rem;
}

.mbtn i {
    pointer-events: none;
    font-size: 1.1rem;
}

.nact {
    display: flex;
    gap: 0.5rem;
}

button,
select,
input {
    font: inherit;
    color: inherit;
}

button {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
    transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
}

button:hover:not(:disabled) {
    background: var(--muted);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sfield {
    position: relative;
}

.sfield input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem 0.55rem 2.4rem;
}

.sfield .sicon {
    position: absolute;
    top: 50%;
    left: 0.8rem;
    transform: translateY(-50%);
    color: var(--subtle);
    pointer-events: none;
    display: flex;
    align-items: center;
    font-size: 0.92rem;
}

.nlist {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nlist li {
    margin: 0;
    padding: 0;
}

.nbtn {
    width: 100%;
    text-align: left;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border: 1px solid transparent;
    padding: 0.75rem 0.8rem;
    background: transparent;
}

.nbtn:hover,
.nbtn:focus-visible {
    border-color: var(--border);
    background: var(--muted);
    outline: none;
}

.nbtn.is-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.ntitle {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nmeta {
    font-size: 0.75rem;
    color: var(--subtle);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.estate {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--subtle);
    text-align: center;
}

main {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    min-width: 0;
}

.tbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.1rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--toolbar-border);
    background: var(--toolbar-bg);
    backdrop-filter: blur(12px);
}

.trow {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.trow .mbtn {
    margin-right: 0.25rem;
}

#title_in {
    flex: 1;
    min-width: 12rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
}

.fbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.fgroup {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.35rem;
    border-radius: 0.65rem;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .fgroup {
    background: rgba(255, 255, 255, 0.055);
    border-color: rgba(255, 255, 255, 0.06);
}

.fas::before,
.far::before,
.fab::before,
.fa-solid::before,
.fa-regular::before,
.fa-brands::before,
.fa-classic::before,
.fa::before {
    content: var(--fa);
}

.fbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.65rem;
    min-width: 2.25rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.55rem;
    transition: background 0.2s ease, border 0.2s ease;
}

.fbtn i {
    pointer-events: none;
    font-size: 0.95rem;
    line-height: 1;
}

.fbtn[aria-pressed="true"] {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.nav-layer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 900;
}

body[data-nav="open"] .nav-layer {
    opacity: 1;
    pointer-events: auto;
}

select {
    border: 1px solid var(--border);
    border-radius: 0.55rem;
    background: var(--surface);
    padding: 0.45rem 1.6rem 0.45rem 0.65rem;
    position: relative;
    appearance: none;
}

.swrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.swrap::after {
    content: "\f0d7";
    font-family: "Font Awesome 7 Free";
    font-weight: 900;
    position: absolute;
    right: 0.65rem;
    pointer-events: none;
    font-size: 0.75rem;
    color: var(--subtle);
}

#edit_area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    line-height: 1.6;
    outline: none;
}

#edit_area:focus {
    background: color-mix(in srgb, var(--accent) 4%, transparent);
}

#edit_area p {
    margin: 0 0 1rem;
}

#edit_area ul,
#edit_area ol {
    padding-left: 1.5rem;
    margin: 0 0 1rem;
}

::selection {
    background: var(--selection);
}

.sbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--toolbar-border);
    font-size: 0.85rem;
    color: var(--subtle);
}

.sgroup {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.meta-link {
    color: var(--subtle);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.meta-link:hover,
.meta-link:focus {
    color: var(--accent);
    text-decoration: underline;
}

.tag {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tag.off {
    background: #eb445a;
    border-color: #650707;
    color: #fff;
}

.tag.on {
    background: #37aa42;
    border-color: #076507;
    color: #fff;
}

.sbar button {
    padding: 0.4rem 0.9rem;
}

@media (max-width: 960px) {
    .shell {
        grid-template-columns: minmax(200px, 240px) 1fr;
    }
}

@media (max-width: 780px) {
    .shell {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    .mbtn {
        display: inline-flex;
    }

    .brow {
        gap: 0.5rem;
    }

    aside {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: min(78vh, 520px);
        padding: 1.1rem 1.25rem 1.25rem;
        transform: translateY(-110%);
        transition: transform 0.25s ease;
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
        border-top: none;
        border-radius: 0 0 1.2rem 1.2rem;
        overflow-y: auto;
        box-shadow: var(--shadow);
        z-index: 1000;
    }

    body[data-nav="open"] aside {
        transform: translateY(0);
    }

    .nact {
        flex-wrap: wrap;
    }

    .nlist {
        flex-direction: column;
        gap: 0.4rem;
    }

    .nlist li {
        width: 100%;
    }

    main {
        grid-column: 1;
        grid-row: 1;
    }

    .tbar {
        position: sticky;
        top: 0;
        z-index: 200;
        padding: 0.85rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--toolbar-border);
    }

    #edit_area {
        padding: 1.1rem;
    }

    .sbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
        padding: 0.85rem 1rem;
    }
}

@media (max-width: 520px) {
    .nact button {
        flex: 1 1 48%;
    }

    .swrap select {
        padding-right: 2.2rem;
    }

    .trow {
        gap: 0.6rem;
    }

    #title_in {
        min-width: 0;
    }

    .tbar {
        padding: 0.75rem 0.85rem;
    }

    #edit_area {
        padding: 0.9rem;
    }

    aside {
        max-height: min(82vh, 460px);
        padding: 1rem 1.1rem 1.15rem;
    }
}
