:root {
    color-scheme: dark;
    --bg: #111318;
    --panel: #181b22;
    --panel-soft: #20242d;
    --text: #f3f5f7;
    --muted: #9aa3af;
    --line: #303641;
    --accent: #47c2a3;
    --accent-strong: #7ee0c8;
    --danger: #ff7373;
    --shadow: 0 20px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, rgba(71, 194, 163, .14), transparent 34rem), var(--bg);
    color: var(--text);
}
body.modal-open {
    overflow: hidden;
}
body.fullscreen-note-open {
    overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, textarea {
    font: inherit;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-panel {
    width: min(430px, 100%);
    background: rgba(24, 27, 34, .94);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.brand {
    display: inline-flex;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--accent-strong);
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: 0; }
h2 { color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: .92rem; }
input, textarea {
    width: 100%;
    color: var(--text);
    background: #11141a;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    padding: 12px 13px;
}
input:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(71, 194, 163, .16);
}
select {
    width: 100%;
    min-height: 38px;
    color: var(--text);
    background: #11141a;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    padding: 0 10px;
}
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(71, 194, 163, .16);
}
.primary, .ghost, .danger, .icon-btn, .mobile-nav button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    min-height: 40px;
}
.primary {
    background: var(--accent);
    color: #071311;
    font-weight: 800;
    padding: 0 16px;
}
button:disabled {
    cursor: not-allowed;
    opacity: .6;
}
.ghost {
    background: var(--panel-soft);
    color: var(--text);
    border: 1px solid var(--line);
    padding: 0 14px;
}
.danger {
    background: transparent;
    color: var(--danger);
    padding: 0;
}
.icon-btn {
    width: 34px;
    height: 34px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 1.25rem;
}
.alert {
    background: rgba(255, 115, 115, .14);
    border: 1px solid rgba(255, 115, 115, .45);
    border-radius: 8px;
    padding: 12px;
}
.muted, .empty { color: var(--muted); }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px 1fr;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    padding: 22px;
    border-right: 1px solid var(--line);
    background: rgba(17, 19, 24, .86);
    backdrop-filter: blur(16px);
}
.side-head, .groups-head, .topbar, .actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.tiny-link {
    color: var(--muted);
    font-size: .86rem;
}
.search-form {
    flex: 1;
    max-width: 520px;
    margin: 0 auto;
}
.nav-list, .group-list {
    display: grid;
    gap: 7px;
}
.nav-list a, .group-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 42px;
    padding: 0 12px;
    color: var(--muted);
    border-radius: 8px;
}
.nav-list a:hover, .group-list a:hover {
    background: rgba(32, 36, 45, .55);
    color: var(--text);
}
.nav-list a.active, .group-list a.active {
    background: var(--panel-soft);
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--accent);
}
.groups-head {
    margin: 24px 0 10px;
    color: var(--muted);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.overflow-wrap {
    position: relative;
    flex: 0 0 auto;
}
.group-picker {
    min-width: 0;
    flex: 1;
}
.group-picker-button {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    background: #11141a;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}
.group-picker-button span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chevron {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    color: var(--muted);
    font-size: 0;
}
.group-picker-menu {
    left: 0;
    right: 0;
    min-width: 100%;
}
.menu-divider {
    height: 1px;
    margin: 4px 2px;
    background: var(--line);
}
.compact-menu-btn {
    display: inline-grid;
    place-items: center;
}
.overflow-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    display: grid;
    min-width: 190px;
    gap: 6px;
    padding: 8px;
    background: #11141a;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.overflow-menu[hidden] {
    display: none;
}
.overflow-menu a,
.overflow-menu button {
    width: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border: 0;
    border-radius: 8px;
    padding: 0 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.overflow-menu a:hover,
.overflow-menu button:hover {
    background: var(--panel-soft);
}
.overflow-menu a.active {
    background: rgba(71, 194, 163, .14);
    color: var(--accent-strong);
}
.overflow-menu .danger {
    color: var(--danger);
}
.main-pane {
    padding: 34px;
    padding-bottom: 100px;
}
.topbar {
    margin-bottom: 26px;
}
.topbar-search {
    width: min(360px, 34vw);
}
.topbar-search input {
    min-height: 40px;
    background: rgba(17, 20, 26, .86);
    border-color: rgba(148, 163, 184, .18);
}
.eyebrow {
    color: var(--accent-strong);
    margin-bottom: 6px;
    font-weight: 700;
}
.save-status {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 10;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(32, 36, 45, .92);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: .85rem;
}
.note-section { margin-bottom: 32px; }
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    align-items: start;
}
.note-card {
    position: relative;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
    min-height: 260px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, .16);
    cursor: grab;
    transition: transform .16s ease, border-color .16s ease, opacity .16s ease;
}
.note-card:hover {
    border-color: rgba(126, 224, 200, .38);
}
.note-card.dragging {
    opacity: .55;
    transform: scale(.98);
    cursor: grabbing;
}
.note-card.done {
    opacity: .72;
}
.note-card-head {
    display: grid;
    grid-template-columns: 1fr 34px 34px;
    align-items: start;
    gap: 8px;
}
.note-title {
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 1.08rem;
    font-weight: 800;
    cursor: text;
}
.note-content {
    min-height: 160px;
    height: 100%;
    padding: 0;
    resize: none;
    line-height: 1.5;
    background: transparent;
    border: 0;
    box-shadow: none;
    cursor: text;
}
.note-content:focus,
.note-title:focus {
    border-color: transparent;
    box-shadow: none;
}
.file-note-card {
    min-height: 210px;
}
.file-note-body {
    min-height: 140px;
    display: grid;
    align-content: start;
    gap: 10px;
}
.file-note-list {
    display: grid;
    gap: 8px;
}
.file-note-empty {
    margin: 0;
    padding: 12px 2px;
    color: var(--muted);
}
.file-note-link,
.file-upload-button {
    width: 100%;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-height: 74px;
    padding: 14px;
    background: rgba(32, 36, 45, .58);
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 8px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease;
}
.file-note-link:hover,
.file-note-link:focus,
.file-upload-button:hover,
.file-upload-button:focus {
    background: rgba(32, 36, 45, .88);
    border-color: rgba(126, 224, 200, .36);
}
.file-upload-button {
    background: rgba(71, 194, 163, .1);
    border-style: dashed;
}
.file-note-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(71, 194, 163, .14);
    color: var(--accent-strong);
}
.file-note-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.file-note-meta {
    min-width: 0;
    display: grid;
    gap: 4px;
}
.file-note-meta strong,
.file-note-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-note-meta strong {
    font-size: .95rem;
}
.file-note-meta small {
    color: var(--muted);
    font-size: .8rem;
}
.menu-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 900;
    line-height: 1;
}
.menu-btn:hover,
.menu-btn:focus {
    background: var(--panel-soft);
    color: var(--text);
}
.line-icon-btn svg,
.minimize-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.line-icon-btn {
    display: grid;
    place-items: center;
}
[data-action="toggle-note-menu"] {
    margin-top: -4px;
}
.note-menu {
    position: absolute;
    top: 48px;
    right: 12px;
    z-index: 5;
    display: grid;
    min-width: 214px;
    gap: 8px;
    padding: 12px;
    background: #11141a;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.note-menu[hidden] {
    display: none;
}
.note-menu label {
    color: var(--muted);
}
.note-menu input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.note-menu small {
    color: var(--muted);
    line-height: 1.35;
    padding: 4px 2px 2px;
}
.note-move {
    gap: 7px;
    padding-top: 2px;
}
.note-move span {
    font-size: .78rem;
}
.note-menu .danger {
    width: 100%;
    min-height: 38px;
    justify-content: flex-start;
    border-radius: 10px;
    padding: 0 10px;
    text-align: left;
}
.note-menu .danger:hover {
    background: rgba(255, 115, 115, .1);
}
.note-toggle {
    position: relative;
    min-height: 38px;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 10px;
    background: rgba(32, 36, 45, .46);
    cursor: pointer;
    font-weight: 800;
    transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.note-toggle:hover {
    background: rgba(32, 36, 45, .82);
    color: var(--text);
}
.note-toggle::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(154, 163, 175, .56);
}
.toggle-text-active {
    display: none;
}
.note-toggle:has(input:checked) .toggle-text {
    display: none;
}
.note-toggle:has(input:checked) .toggle-text-active {
    display: inline;
}
.note-toggle-pin:has(input:checked) {
    background: rgba(71, 194, 163, .16);
    border-color: rgba(71, 194, 163, .42);
    color: var(--accent-strong);
}
.note-toggle-pin:has(input:checked)::after {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(71, 194, 163, .12);
}
.note-toggle-done:has(input:checked) {
    background: rgba(96, 165, 250, .16);
    border-color: rgba(96, 165, 250, .38);
    color: #bfdbfe;
}
.note-toggle-done:has(input:checked)::after {
    background: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, .12);
}
.note-toggle-archive:has(input:checked) {
    background: rgba(245, 158, 11, .14);
    border-color: rgba(245, 158, 11, .36);
    color: #fcd34d;
}
.note-toggle-archive:has(input:checked)::after {
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, .12);
}
.mobile-nav {
    display: none;
}
.mobile-nav-menu {
    display: none;
}
.mobile-only {
    display: none;
}
.desktop-only {
    display: inline-flex;
    align-items: center;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(4, 6, 10, .68);
    backdrop-filter: blur(10px);
}
.modal-backdrop[hidden] {
    display: none;
}
.modal-panel {
    width: min(430px, 100%);
    display: grid;
    gap: 16px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.modal-panel h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.2rem;
    text-transform: none;
    letter-spacing: 0;
}
.modal-panel p {
    margin: 0;
    line-height: 1.45;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}
.modal-actions .primary,
.modal-actions .ghost {
    min-width: 96px;
}
.fullscreen-note-shell {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 16px;
    padding: 18px 6px;
    background:
        radial-gradient(circle at 20% -10%, rgba(71, 194, 163, .16), transparent 22rem),
        rgba(10, 13, 18, .98);
    backdrop-filter: blur(18px);
}
.fullscreen-note-shell[hidden] {
    display: none !important;
}
.fullscreen-note-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .1em;
}
.minimize-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 12px;
}
.fullscreen-note-stage {
    min-height: 0;
    display: grid;
}
.fullscreen-note-card {
    width: 100%;
    min-height: 0;
    height: 100%;
    justify-self: center;
    cursor: default;
    border-radius: 18px;
    padding: 22px;
    background: rgba(24, 27, 34, .92);
    border-color: rgba(126, 224, 200, .28);
    box-shadow: 0 28px 80px rgba(0, 0, 0, .38);
}
.fullscreen-note-card .note-title {
    font-size: clamp(1.35rem, 3vw, 2rem);
}
.fullscreen-note-card .note-content {
    min-height: 0;
    font-size: 1.05rem;
}
.fullscreen-note-card .note-menu {
    top: 62px;
}
.fullscreen-note-card [data-action="open-fullscreen"] {
    display: none;
}
.fullscreen-note-card .note-card-head {
    grid-template-columns: 1fr 34px;
}

@media (max-width: 760px) {
    body {
        background:
            radial-gradient(circle at 20% -10%, rgba(71, 194, 163, .18), transparent 18rem),
            linear-gradient(180deg, #11141a 0, #0d1015 44%, #0b0e13 100%);
    }
    .app-shell {
        display: block;
    }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 25;
        height: auto;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .07);
        padding: 14px 14px 12px;
        background: rgba(13, 16, 21, .88);
        box-shadow: 0 18px 34px rgba(0, 0, 0, .22);
        backdrop-filter: blur(18px);
        transform: translateY(0);
        opacity: 1;
        transition: transform .28s cubic-bezier(.22, 1, .36, 1), opacity .22s ease, box-shadow .28s ease;
        will-change: transform, opacity;
    }
    body.mobile-sidebar-hidden .sidebar {
        transform: translateY(calc(-100% - 14px));
        opacity: 0;
        pointer-events: none;
        box-shadow: none;
    }
    .side-head {
        display: grid;
        grid-template-columns: 74px minmax(0, 1fr) 38px;
        gap: 12px;
        align-items: center;
    }
    .brand {
        width: auto;
        height: auto;
        overflow: hidden;
        color: var(--accent-strong);
        background: transparent;
        border-radius: 0;
        font-size: .95rem;
        line-height: 1.05;
        letter-spacing: 0;
    }
    .search-form {
        width: 100%;
        max-width: none;
        margin: 0;
    }
    .search-form input {
        text-align: center;
        min-height: 44px;
        padding: 9px 14px;
        border-radius: 12px;
        background: rgba(17, 20, 26, .86);
        border-color: rgba(148, 163, 184, .22);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
    }
    .compact-menu-btn {
        width: 38px;
        height: 38px;
        border-radius: 12px;
        background: rgba(32, 36, 45, .82);
        border: 1px solid rgba(148, 163, 184, .16);
        color: #cbd5e1;
        font-size: 1.15rem;
    }
    .nav-menu-btn {
        font-size: 1rem;
        font-weight: 900;
    }
    .overflow-menu {
        top: calc(100% + 10px);
        right: 0;
        min-width: 184px;
        padding: 8px;
        border-radius: 14px;
        background: rgba(17, 20, 26, .98);
        border-color: rgba(148, 163, 184, .18);
        box-shadow: 0 24px 48px rgba(0, 0, 0, .42);
    }
    .overflow-menu a,
    .overflow-menu button {
        min-height: 42px;
        border-radius: 10px;
        font-weight: 700;
    }
    .group-list {
        display: none !important;
    }
    .groups-head {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        margin: 14px 0 0;
    }
    .groups-head span {
        font-size: .7rem;
        letter-spacing: .12em;
        color: #aeb8c6;
    }
    .group-picker-button {
        min-height: 40px;
        padding: 8px 12px;
        border-radius: 12px;
        background: rgba(17, 20, 26, .86);
        border-color: rgba(148, 163, 184, .22);
        font-weight: 700;
    }
    .group-picker-menu {
        top: calc(100% + 8px);
        min-width: 100%;
    }
    .nav-list:not([hidden]) {
        display: grid;
    }
    .main-pane {
        padding: 20px 15px 112px;
    }
    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 14px;
        margin-bottom: 18px;
    }
    .topbar > div:first-child {
        min-width: 0;
    }
    .eyebrow {
        margin-bottom: 5px;
        font-size: .82rem;
    }
    h1 {
        margin-bottom: 0;
        font-size: 1.8rem;
        line-height: 1.1;
    }
    h2 {
        margin-bottom: 12px;
        font-size: .78rem;
        letter-spacing: .1em;
    }
    .actions {
        width: auto;
        justify-content: flex-end;
    }
    .group-manage-btn {
        min-height: 34px;
        padding: 0 12px;
        border-radius: 999px;
        font-size: .78rem;
        font-weight: 800;
        background: rgba(32, 36, 45, .82);
    }
    .actions .overflow-menu {
        right: 0;
    }
    .note-section {
        margin-bottom: 22px;
    }
    .notes-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .note-card {
        min-height: 220px;
        border-radius: 14px;
        padding: 15px;
        background: rgba(24, 27, 34, .82);
        border-color: rgba(148, 163, 184, .15);
        box-shadow: 0 16px 36px rgba(0, 0, 0, .2);
    }
    .note-title {
        font-size: 1rem;
    }
    .note-content {
        min-height: 132px;
    }
    .save-status {
        top: auto;
        right: 18px;
        bottom: 82px;
        border-radius: 999px;
    }
    .mobile-nav {
        position: fixed;
        left: auto;
        right: 18px;
        transform: none;
        bottom: calc(18px + env(safe-area-inset-bottom));
        z-index: 20;
        display: block;
        padding: 0;
        background: transparent;
        border: 0;
        border-radius: 999px;
        box-shadow: none;
    }
    .mobile-add {
        width: 48px;
        height: 48px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        background: var(--accent);
        color: #071311;
        font-size: 1.35rem;
        font-weight: 900;
        box-shadow: 0 18px 40px rgba(71, 194, 163, .28), 0 10px 28px rgba(0, 0, 0, .36);
        border: 1px solid rgba(255, 255, 255, .16);
        touch-action: manipulation;
    }
    .mobile-nav-menu {
        position: absolute;
        left: auto;
        right: 0;
        bottom: calc(100% + 12px);
        transform: none;
        display: grid;
        grid-template-columns: repeat(3, 72px);
        gap: 7px;
        padding: 7px;
        background: rgba(17, 20, 26, .98);
        border: 1px solid rgba(148, 163, 184, .18);
        border-radius: 16px;
        box-shadow: 0 22px 48px rgba(0, 0, 0, .42);
        backdrop-filter: blur(16px);
    }
    .mobile-nav-menu[hidden] {
        display: none !important;
    }
    .mobile-nav-menu a, .mobile-nav-menu button {
        display: grid;
        place-items: center;
        min-height: 40px;
        border-radius: 12px;
        background: var(--panel-soft);
        color: var(--text);
        font-weight: 700;
        border: 0;
        font-size: .84rem;
    }
    .empty {
        min-height: 180px;
        display: grid;
        place-items: center;
        text-align: center;
        padding: 24px;
        border: 1px dashed rgba(148, 163, 184, .2);
        border-radius: 16px;
        background: rgba(24, 27, 34, .34);
        line-height: 1.45;
    }
    .modal-actions {
        grid-template-columns: 1fr 1fr;
        display: grid;
    }
    .desktop-only {
        display: none !important;
    }
    .mobile-only {
        display: block;
    }
}
