:root {
  --ink: #12201f; --muted: #5d6b6a; --line: #e3e8e7; --bg: #f6f8f7; --panel: #fff;
  --brand: #0f3d3e; --accent: #1f8a70; --accent-soft: #e4f4ee; --danger: #b42318; --warn-bg: #fff6e5; --warn-ink: #7a4b00;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
button { font: inherit; }
.boot { padding: 40px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.pad { padding: 16px; }
.mobile-only { display: none; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: #f1f4f3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #145354; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f1c7c3; }
.icon-btn { border: 0; background: transparent; font-size: 18px; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: #eef2f1; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }
.input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; background: #fff; margin-bottom: 8px; }
.input:focus, .search:focus { outline: 2px solid #9fd9c7; border-color: var(--accent); }
.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 6px 0 4px; }

/* sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0f3d3e 0%, #16595a 55%, #1f8a70 100%); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card .btn.wide { margin-top: 10px; padding: 11px; }
.auth-msg { color: var(--danger); min-height: 1em; margin: 8px 0; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand.big { font-size: 20px; margin-bottom: 6px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 6px 5px; border: 2px solid #7fe0c4; border-top-width: 2px; border-radius: 2px; }

/* app grid */
.app { display: grid; grid-template-columns: 240px 380px 1fr; height: 100vh; height: 100dvh; }
.side { background: var(--brand); color: #dfeeed; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.side .brand { color: #fff; margin: 2px 6px 14px; }
.side .btn.primary { background: #7fe0c4; color: var(--brand); border-color: #7fe0c4; margin-bottom: 10px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; opacity: .6; margin: 12px 8px 4px; }
.side-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; color: #dfeeed; text-decoration: none; padding: 7px 9px; border-radius: 7px; }
.side-item:hover { background: rgba(255,255,255,.07); }
.side-item.on { background: rgba(127,224,196,.18); color: #fff; font-weight: 600; }
.side-addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.badge { background: #7fe0c4; color: var(--brand); font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.badge.soft { background: rgba(255,255,255,.18); color: #fff; }
.side-foot { margin-top: auto; padding: 14px 8px 0; font-size: 13px; }
.side-user { font-weight: 600; color: #fff; margin-top: 10px; }
.side-links { display: flex; gap: 14px; margin-top: 4px; }
.side-links a { color: #a9d6cb; }
.note { font-size: 12px; background: rgba(255,255,255,.08); border-radius: 8px; padding: 8px 10px; }
.modal .note, .compose .note { background: var(--accent-soft); color: var(--ink); margin-bottom: 8px; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* list */
.list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px; }
.list-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list-title b { font-size: 17px; }
.list-title .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-search { display: flex; gap: 8px; align-items: center; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.search { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; background: var(--bg); }
.hint { font-size: 12px; color: var(--muted); padding: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.list-scroll { overflow-y: auto; flex: 1; }
.row { display: block; padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.row:hover { background: #f8faf9; }
.row.on { background: var(--accent-soft); }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.row-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.row-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-snip { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.2em; }
.row.unread .row-who, .row.unread .row-subj { font-weight: 700; }
.row.unread { box-shadow: inset 3px 0 0 var(--accent); }
.cnt { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; }
.list .btn.wide { margin: 12px 14px; width: calc(100% - 28px); }

/* reader */
.reader { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.empty-reader { justify-content: center; }
.reader-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 20px; }
.reader-head h1 { font-size: 19px; margin: 10px 0 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reader-scroll { overflow-y: auto; flex: 1; padding: 16px 20px 40px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.msg-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.msg-foot { padding: 8px 16px 12px; }
.mail-frame { width: 100%; height: 65vh; border: 0; display: block; background: #fff; }
.mail-text { white-space: pre-wrap; word-wrap: break-word; font: inherit; margin: 0; padding: 16px; }
.img-note { font-size: 12.5px; color: var(--muted); padding: 8px 16px; background: #fafbfb; border-bottom: 1px solid var(--line); }
.warn-box { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 16px; font-size: 13px; border-bottom: 1px solid #f3dfb5; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.att { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; text-decoration: none; color: var(--ink); font-size: 13px; }
.reply-bar { display: flex; gap: 8px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,25,25,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 18px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.compose { max-width: 680px; }
.modal h3 { font-size: 14px; margin: 18px 0 6px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.input.body { min-height: 260px; resize: vertical; font-family: inherit; }
.pk { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* tablet */
@media (max-width: 1100px) { .app { grid-template-columns: 210px 320px 1fr; } }

/* phone: one pane at a time */
@media (max-width: 820px) {
  .mobile-only { display: inline-block; }
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 25% 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 30px rgba(0,0,0,.3); }
  .side.open { transform: none; }
  .app.has-thread .list { display: none; }
  .app:not(.has-thread) .reader { display: none; }
  .reader-head { padding: 10px 12px; }
  .reader-scroll { padding: 12px 10px 40px; }
  .mail-frame { height: 70vh; }
  .msg-head { flex-direction: column; gap: 4px; }
}
