:root {
    color-scheme: light;
    --ink: #152d26;
    --muted: #496457;
    --paper: #fbfaf4;
    --green: #153a30;
    --accent: #d6ea86;
    --line: #d7dfcf;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #e7eddf; min-height: 100vh; }
a { color: #214c3e; text-underline-offset: .2em; }
.masthead {
    min-height: 76px;
    padding: max(16px, env(safe-area-inset-top)) max(24px, calc((100vw - 784px) / 2)) 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--green);
    color: #f8f8ed;
}
.brand { display: inline-flex; align-items: center; gap: 7px; color: inherit; text-decoration: none; font-size: 17px; font-weight: 650; }
.brand-name { font-weight: 400; opacity: .74; }
.brand-mark { width: 24px; height: 18px; border: 2px solid var(--accent); border-radius: 5px; margin-right: 6px; position: relative; }
.brand-mark::after { content: ''; position: absolute; width: 10px; height: 10px; left: 5px; top: -3px; border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
main { margin: 58px auto; max-width: 784px; padding: 0 24px max(24px, env(safe-area-inset-bottom)); }
.sheet { background: var(--paper); border: 1px solid #d9e1cf; border-radius: 24px; padding: clamp(24px, 5vw, 52px); box-shadow: 0 16px 44px #153a3016, 0 2px 6px #153a3009; }
.access { max-width: 510px; margin: 0 auto; }
h1 { font: 400 clamp(2rem, 6vw, 3.4rem)/1.08 Georgia, serif; letter-spacing: -.035em; margin: 0 0 18px; overflow-wrap: anywhere; }
.access > p { line-height: 1.55; margin: 0 0 28px; color: var(--muted); }
label { display: block; margin-bottom: 8px; font-weight: 650; }
input { display: block; width: 100%; min-height: 50px; border: 1px solid #a5b8aa; border-radius: 10px; background: #fff; color: var(--ink); padding: 10px 14px; font: inherit; }
.button, .leave { font: inherit; cursor: pointer; }
.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: space-between; gap: 26px; margin-top: 16px; background: var(--accent); color: #192b15; border: 1px solid #bfd474; border-radius: 10px; text-decoration: none; font-weight: 650; padding: 10px 16px; }
.button:active { background: #c6de76; }
.leave { min-height: 44px; border: 0; background: transparent; color: #ecf4d9; padding: 0 2px; font-size: .85rem; }
.error { color: #8b2e20; }
:focus-visible { outline: 3px solid #2d7251; outline-offset: 3px; }
.masthead :focus-visible { outline-color: var(--accent); }
.message-header { border-bottom: 1px solid var(--line); padding-bottom: 21px; }
.sender { margin: 0 0 5px; font-weight: 650; overflow-wrap: anywhere; }
.date { margin: 0; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.body-text { margin: 24px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.67; }
.attachments { padding: 16px 18px; border-radius: 13px; background: #eef2e5; overflow-wrap: anywhere; }
h2 { font-size: 1rem; margin: 0; }
ul { margin-bottom: 0; padding-left: 20px; }
.actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.actions a, .home-link { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.home-link { margin-top: 12px; display: flex; }

@media (max-width: 560px) {
    .masthead { min-height: 62px; padding-inline: 18px; }
    main { margin: 24px auto; padding-inline: 14px; }
    .sheet { border-radius: 17px; padding: 22px; }
    .access .button { width: 100%; }
}

[hidden] {display:none!important}
.sheet.access {border-top:5px solid var(--accent)}
.access h1 {max-width:12ch}
#status {margin:16px auto;max-width:510px;line-height:1.55;color:var(--muted)}
#status:empty {display:none}
#pairing {margin-top:24px;padding-top:20px;border-top:1px solid var(--line)}
#pairing p {line-height:1.5}
#fingerprint {display:block;user-select:all;overflow-wrap:anywhere;line-height:1.7}
button.home-link {font:inherit;color:#214c3e;text-decoration:underline;text-underline-offset:.2em;border:0;background:none;padding:0;cursor:pointer}
.toolbar {display:flex;align-items:baseline;justify-content:space-between;gap:12px}
.text-action {min-height:44px;display:inline-flex;align-items:center}
.messages {list-style:none;padding:0}
.messages li {border-bottom:1px solid var(--line);padding:4px 0}
.messages button {text-align:left;background:none;border:0;color:inherit;width:100%;font:inherit;padding:12px 0;cursor:pointer}
.messages strong,.messages span {display:block;overflow-wrap:anywhere}
.messages span {margin-top:5px;color:var(--muted);font-size:.875rem}
.actions button.home-link {margin:0}
.button:disabled {opacity:.65}
