:root {
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: #080c12;
    color: #f4f7fb;

    --bg: #080c12;
    --panel: #101720;
    --inner: #0b1118;
    --border: #273342;
    --border-strong: #334253;
    --text: #f4f7fb;
    --soft: #dce6f1;
    --muted: #8e9baa;
    --muted-2: #8391a0;
    --success: #9ef0bd;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.letters-shell {
    display: grid;
    grid-template-columns:
        230px
        360px
        minmax(0, 1fr);

    height: 100dvh;

    background: var(--bg);
}


/* ============================================================
   SIDEBAR
   ============================================================ */

.letters-sidebar {
    display: flex;
    flex-direction: column;

    min-width: 0;

    padding: 28px 16px 18px;

    border-right: 1px solid var(--border);

    background: var(--panel);
}

.letters-brand {
    color: var(--text);

    text-decoration: none;

    font-size: 14px;
    font-weight: 800;

    letter-spacing: .24em;
}

.letters-product-name {
    margin-top: 8px;

    color: var(--muted);

    font-size: 11px;
}

.compose-button {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    width: 100%;
    height: 44px;

    margin-top: 26px;

    border: 0;
    border-radius: 12px;

    background: #f4f7fb;
    color: #080c12;

    font-size: 13px;
    font-weight: 750;
}

.folder-list {
    display: flex;
    flex-direction: column;

    gap: 4px;

    margin-top: 22px;
}

.folder-button {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;
    height: 40px;

    padding: 0 12px;

    border: 1px solid transparent;
    border-radius: 10px;

    background: transparent;
    color: var(--muted);

    font-size: 12px;
    text-align: left;
}

.folder-button:hover {
    background: var(--inner);
    color: var(--soft);
}

.folder-button.active {
    border-color: var(--border);

    background: var(--inner);
    color: var(--text);
}

.folder-count {
    min-width: 20px;

    color: var(--muted-2);

    text-align: right;

    font-size: 10px;
}

.letters-status-panel {
    margin-top: auto;

    padding: 13px;

    border: 1px solid var(--border);
    border-radius: 13px;

    background: var(--inner);
}

.letters-security {
    display: flex;
    align-items: center;

    gap: 9px;
}

.security-dot {
    width: 7px;
    height: 7px;

    flex: 0 0 7px;

    border-radius: 50%;

    background: var(--success);
}

.letters-security > div {
    display: flex;
    flex-direction: column;
}

.letters-security strong {
    color: var(--soft);

    font-size: 10px;
}

.letters-security span {
    margin-top: 2px;

    color: var(--muted);

    font-size: 8px;
}

.letters-status {
    min-height: 30px;

    margin-top: 10px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.5;
}

.letters-sound-button {
    width: 100%;
    height: 32px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--panel);
    color: var(--soft);

    font-size: 9px;
}

.letters-sound-button.enabled {
    border-color: #2c8f57;

    color: var(--success);
}

.product-links {
    display: flex;
    justify-content: space-between;

    gap: 6px;

    margin-top: 12px;
}

.product-links a {
    color: var(--muted);

    text-decoration: none;

    font-size: 9px;
}

.product-links a:hover {
    color: var(--text);
}


/* ============================================================
   LETTER LIST
   ============================================================ */

.letter-list-panel {
    display: grid;
    grid-template-rows: 82px minmax(0, 1fr);

    min-width: 0;

    border-right: 1px solid var(--border);

    background: #0b1118;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 18px;

    border-bottom: 1px solid var(--border);
}

.list-eyebrow,
.compose-eyebrow {
    color: var(--muted-2);

    font-size: 8px;
    font-weight: 800;

    letter-spacing: .16em;
}

.list-header h1 {
    margin: 4px 0 0;

    font-size: 20px;
}

.icon-button {
    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;

    padding: 0;
    margin: 0;

    border: 1px solid var(--border);
    border-radius: 9px;

    background: var(--panel);
    color: var(--soft);

    font-size: 16px;
}

.letter-list {
    min-height: 0;

    overflow-y: auto;

    padding: 7px;
}

.letter-list-empty {
    margin: 24px 8px;

    padding: 24px 15px;

    border: 1px dashed var(--border);
    border-radius: 13px;

    color: var(--muted);

    font-size: 11px;
    line-height: 1.6;

    text-align: center;
}

.letter-row {
    position: relative;

    width: 100%;

    padding: 14px;

    margin-bottom: 4px;

    border: 1px solid transparent;
    border-radius: 12px;

    background: transparent;
    color: var(--text);

    text-align: left;
}

.letter-row:hover {
    background: var(--panel);
}

.letter-row.active {
    border-color: var(--border);

    background: var(--panel);
}

.letter-row.unread::before {
    content: "";

    position: absolute;

    top: 18px;
    right: 12px;

    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: var(--success);
}

.letter-row-top {
    display: flex;
    justify-content: space-between;

    gap: 12px;
}

.letter-peer {
    max-width: 220px;

    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: var(--soft);

    font-size: 11px;
    font-weight: 650;
}

.letter-time {
    color: var(--muted-2);

    font-size: 8px;
}

.letter-subject {
    margin-top: 7px;

    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 12px;
    font-weight: 650;
}

.letter-preview {
    margin-top: 5px;

    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: var(--muted);

    font-size: 9px;
}

.draft-label {
    color: #f0c987;
}


/* ============================================================
   READER
   ============================================================ */

.letter-reader {
    position: relative;

    min-width: 0;

    overflow: hidden;

    background: var(--bg);
}

.reader-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    padding: 40px;

    text-align: center;
}

.reader-empty-mark {
    display: grid;
    place-items: center;

    width: 70px;
    height: 70px;

    margin-bottom: 22px;

    border: 1px solid var(--border-strong);
    border-radius: 20px;

    background: var(--panel);

    font-size: 24px;
    font-weight: 800;
}

.reader-eyebrow {
    color: var(--muted-2);

    font-size: 8px;
    font-weight: 800;

    letter-spacing: .16em;
}

.reader-empty h2 {
    margin: 10px 0 8px;

    font-size: 28px;
}

.reader-empty p {
    margin: 0;

    color: var(--muted);

    font-size: 12px;
}

.reader-panel {
    width: 100%;
    height: 100%;

    overflow-y: auto;
}

.reader-header {
    display: flex;
    justify-content: space-between;

    gap: 25px;

    padding: 32px 38px 26px;

    border-bottom: 1px solid var(--border);
}

.reader-direction {
    color: var(--muted-2);

    font-size: 9px;
    font-weight: 750;

    letter-spacing: .08em;

    text-transform: uppercase;
}

.reader-header h2 {
    margin: 9px 0;

    font-size: 25px;
    line-height: 1.25;
}

.reader-meta {
    color: var(--muted);

    font-size: 10px;
}

.reader-actions {
    display: flex;
    align-items: flex-start;

    gap: 7px;
}

.reader-actions button,
.secondary-button {
    width: auto;

    margin: 0;

    padding: 9px 12px;

    border: 1px solid var(--border);
    border-radius: 9px;

    background: var(--inner);
    color: var(--soft);

    font-size: 10px;
}

.reader-actions .danger-action {
    border-color: #623943;

    color: #ffb1b1;
}

.reader-body {
    max-width: 850px;

    padding: 38px;

    color: var(--text);

    font-size: 14px;
    line-height: 1.75;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.reader-footer {
    display: flex;
    align-items: center;

    gap: 7px;

    margin: 0 38px 30px;
    padding-top: 20px;

    border-top: 1px solid var(--border);

    color: var(--muted-2);

    font-size: 9px;
}

.reader-footer span {
    color: var(--success);
}


/* ============================================================
   COMPOSE
   ============================================================ */

.compose-overlay {
    position: fixed;

    z-index: 100;

    inset: 0;

    display: grid;
    place-items: center;

    padding: 24px;

    background: rgba(3, 5, 8, .78);

    backdrop-filter: blur(9px);
}

.compose-window {
    width: min(700px, 100%);
    max-height: calc(100dvh - 48px);

    overflow-y: auto;

    padding: 28px;

    border: 1px solid var(--border-strong);
    border-radius: 20px;

    background: var(--panel);

    box-shadow:
        0 25px 90px rgba(0,0,0,.5);
}

.compose-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    margin-bottom: 24px;
}

.compose-header h2 {
    margin: 5px 0 0;

    font-size: 25px;
}

.compose-window label {
    display: block;

    margin: 18px 0 7px;

    font-size: 11px;
    font-weight: 650;
}

.letter-address {
    display: flex;
    align-items: center;

    border: 1px solid var(--border-strong);
    border-radius: 11px;

    background: var(--inner);

    padding: 0 12px;
}

.letter-address span {
    color: var(--muted-2);
}

.letter-address input,
.subject-input {
    width: 100%;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--text);

    padding: 13px 8px;

    font-size: 13px;
}

.subject-input {
    border: 1px solid var(--border-strong);
    border-radius: 11px;

    background: var(--inner);

    padding: 13px;
}

.compose-window textarea {
    width: 100%;
    min-height: 280px;

    resize: vertical;

    border: 1px solid var(--border-strong);
    border-radius: 12px;
    outline: 0;

    background: var(--inner);
    color: var(--text);

    padding: 15px;

    font-size: 13px;
    line-height: 1.6;
}

.letter-address:focus-within,
.subject-input:focus,
.compose-window textarea:focus {
    border-color: #52657a;
}

.compose-privacy {
    display: flex;
    gap: 7px;

    margin-top: 14px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.5;
}

.compose-privacy span {
    color: var(--success);
}

.compose-footer {
    display: flex;
    justify-content: flex-end;

    gap: 9px;

    margin-top: 20px;
}

.compose-footer button {
    width: auto;

    margin: 0;

    padding: 11px 17px;

    font-size: 12px;
}

.compose-footer #send-letter-button {
    border: 0;

    background: #f4f7fb;
    color: #080c12;
}

.compose-status {
    min-height: 22px;

    margin-top: 12px;

    color: var(--muted);

    font-size: 10px;

    text-align: right;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1000px) {

    .letters-shell {
        grid-template-columns:
            190px
            310px
            minmax(0, 1fr);
    }

}

@media (max-width: 760px) {

    html,
    body {
        overflow: auto;
    }

    .letters-shell {
        grid-template-columns: 1fr;

        height: auto;
        min-height: 100dvh;
    }

    .letters-sidebar {
        min-height: auto;

        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .folder-list {
        display: grid;
        grid-template-columns:
            repeat(5, minmax(0, 1fr));
    }

    .folder-button {
        justify-content: center;

        padding: 0 5px;

        font-size: 9px;
    }

    .folder-count {
        display: none;
    }

    .letters-status-panel {
        margin-top: 18px;
    }

    .letter-list-panel {
        min-height: 420px;

        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .letter-reader {
        min-height: 500px;
    }

    .reader-header {
        flex-direction: column;

        padding: 24px 20px;
    }

    .reader-body {
        padding: 25px 20px;
    }

    .reader-footer {
        margin: 0 20px 25px;
    }

}



/* ============================================================
   PRIVYN LETTERS — HIDDEN STATE FIX
   ============================================================ */

[hidden] {
    display: none !important;
}

.compose-overlay[hidden] {
    display: none !important;
}

.reader-panel[hidden] {
    display: none !important;
}

.reader-empty[hidden] {
    display: none !important;
}

