.compose-root {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    background: rgba(30, 22, 14, 0.55);
    padding: 2rem 1rem;
    overflow-y: auto;
}
.compose-root[aria-hidden="false"] { display: block; }

.compose {
    max-width: 42rem;
    margin: 0 auto;
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-serif);
    color: var(--ink);
}
.compose h2 {
    margin: 0 0 1rem;
    font-size: 1.6rem;
    font-style: italic;
    font-weight: 400;
}
.compose .scaffold-top,
.compose .scaffold-bottom {
    font-size: 1.35rem;
    font-style: italic;
    color: var(--ink);
    margin: 0;
    padding: .25rem 0;
}
.compose .scaffold-bottom { text-align: right; }

.compose textarea {
    width: 100%;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
    border: 1px dashed rgba(107, 81, 55, 0.25);
    border-radius: var(--radius);
    padding: .75rem;
    min-height: 10rem;
    resize: vertical;
    margin-top: .25rem;
}
.compose .char-count {
    font-family: var(--font-sans);
    font-size: .8rem;
    color: var(--ink-soft);
    text-align: right;
    margin-top: .25rem;
}
.compose .char-count.over-soft { color: var(--accent-dark); }

.compose .date-row {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin: 1.25rem 0 0;
    font-family: var(--font-sans);
    font-size: .9rem;
    color: var(--ink-soft);
    flex-wrap: wrap;
}
.compose .date-row input {
    font: inherit;
    padding: .3rem .5rem;
    border: 1px solid rgba(107, 81, 55, 0.25);
    background: var(--bg);
    color: var(--ink);
    border-radius: var(--radius);
    width: auto;
    margin: 0;
}

.compose .dropzone {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 2px dashed rgba(107, 81, 55, 0.22);
    border-radius: var(--radius);
    text-align: center;
    font-family: var(--font-sans);
    color: var(--ink-soft);
    font-size: .9rem;
    cursor: pointer;
}
.compose .dropzone.over {
    border-color: var(--accent-dark);
    background: rgba(201, 168, 160, 0.1);
}
.compose .pick-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: .6rem;
    font-family: var(--font-sans);
    font-size: .9rem;
    justify-content: center;
}
.compose .anon-name-row { margin-top: .25rem; }
.compose .anon-name-row input {
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid rgba(107, 81, 55, 0.25);
    border-radius: var(--radius);
    padding: .4rem .55rem;
    width: 100%;
    margin-top: .25rem;
}
.compose .turnstile-slot {
    margin-top: 1rem;
    min-height: 1px;
}
.compose .buttons-wrap {
    margin-top: 1.25rem;
}
.compose .buttons-wrap .submit-hint {
    font-family: var(--font-sans);
    font-size: .85rem;
    text-align: right;
    min-height: 1.2em;
    margin-bottom: .35rem;
}
.compose .buttons-wrap .buttons { margin-top: 0; }

.compose .attachments {
    margin-top: .75rem;
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.compose .att-chip-block {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.compose .chip-caption {
    font: inherit;
    font-size: .85rem;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid rgba(107, 81, 55, 0.25);
    border-radius: var(--radius);
    padding: .35rem .5rem;
    width: 100%;
    margin: 0;
}
.compose .att-chip {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--envelope);
    border-radius: var(--radius);
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: .75rem;
}
.compose .att-chip img,
.compose .att-chip video { width: 100%; height: 100%; object-fit: cover; }
.compose .att-chip.pdf {
    display: grid; place-items: center;
    padding: .5rem; text-align: center; color: var(--ink);
}
.compose .att-chip.uploading {
    display: grid; place-items: center; color: var(--ink-soft);
}
.compose .att-chip .remove {
    position: absolute; top: .25rem; right: .25rem;
    background: rgba(40, 30, 20, .6); color: white; border: 0;
    width: 1.4rem; height: 1.4rem; border-radius: 50%;
    font: inherit; line-height: 1; cursor: pointer;
    font-size: 1rem;
}

/* Gallery picker modal (invoked from the composer's "Pick from gallery"). */
.gallery-picker-root {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    background: rgba(30, 22, 14, .6);
    padding: 2rem 1rem;
    overflow-y: auto;
}
.gallery-picker-root[aria-hidden="false"] { display: block; }

.picker-panel {
    max-width: 48rem;
    margin: 0 auto;
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-sans);
    color: var(--ink);
}
.picker-panel h3 {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 1.3rem;
    margin: 0 0 .25rem;
    color: var(--ink);
}
.picker-panel .hint { margin: 0 0 .5rem; }

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .5rem;
    margin: 1rem 0;
    max-height: 60vh;
    overflow-y: auto;
    padding: 3px; /* room for focus ring / selection border */
}
.picker-tile {
    position: relative;
    padding: 0;
    border: 0;
    margin: 0;
    aspect-ratio: 1 / 1;
    background: var(--envelope);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform .1s ease;
}
.picker-tile:hover:not(:disabled) { transform: scale(1.02); }
.picker-tile img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.picker-tile .badge {
    position: absolute; right: .25rem; bottom: .25rem;
    background: rgba(30, 22, 14, .55); color: white;
    font-size: .7rem; padding: .1rem .35rem; border-radius: 3px;
    font-family: var(--font-sans);
    pointer-events: none;
}
.picker-tile.selected {
    box-shadow: 0 0 0 3px var(--accent-dark);
}
.picker-tile .picker-check {
    position: absolute; top: .3rem; right: .3rem;
    width: 1.5rem; height: 1.5rem;
    display: grid; place-items: center;
    background: var(--accent-dark);
    color: white;
    border-radius: 50%;
    font-size: .9rem; font-weight: 700;
    pointer-events: none;
}
.picker-tile.attached,
.picker-tile.disabled {
    opacity: .45;
    cursor: not-allowed;
}
.picker-tile .picker-attached-tag {
    position: absolute; inset: auto 0 0 0;
    background: rgba(30, 22, 14, .78);
    color: white;
    font-size: .7rem;
    padding: .15rem .35rem;
    text-align: center;
    letter-spacing: .04em;
    pointer-events: none;
}

.picker-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: .75rem;
    border-top: 1px dashed rgba(107, 81, 55, 0.2);
}

.compose .buttons {
    display: flex; gap: .5rem; justify-content: flex-end;
    margin-top: 1.5rem;
}
.compose .error { margin-top: 1rem; }
