/* Вебпочта: раскладка в три колонки — папки, список, чтение. */
.mail-shell { display: grid; grid-template-rows: 48px 1fr; height: 100%; }
.mtop {
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--accent); color: var(--on-accent);
}
.mtop .icon-btn { color: var(--on-accent); opacity: .9; }
.mtop .icon-btn:hover { background: rgba(255,255,255,.15); color: var(--on-accent); }
.mtop-brand { font-weight: 600; font-size: 15px; white-space: nowrap; min-width: 180px; display: flex; align-items: center; gap: 8px; }
.msearch { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.msearch input {
  min-height: 32px; padding-left: 34px; border: 0; border-radius: var(--radius);
  background: rgba(255,255,255,.92); color: #1f2328;
}
.msearch input::placeholder { color: #6a7280; }
.msearch svg { position: absolute; left: 9px; fill: #6a7280; width: 18px; height: 18px; pointer-events: none; }
.mtop-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.me-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.2); color: var(--on-accent); font-weight: 600; font-size: 13px;
}
.nav-toggle { display: none !important; }

.mail-body { display: grid; grid-template-columns: 236px minmax(300px, 400px) 1fr; min-height: 0; }
svg.ico { width: 18px; height: 18px; fill: currentColor; flex: none; }

/* --- папки --- */
.side { background: var(--panel-2); border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; }
.new-btn { width: 100%; min-height: 36px; margin-bottom: 10px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.side-head .icon-btn { width: 24px; height: 24px; font-size: 14px; }
.folder {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; margin-bottom: 1px;
  background: none; border: 0; border-radius: var(--radius); cursor: pointer; text-align: left; color: var(--text);
}
.folder:hover { background: var(--hover); }
.folder.active { background: var(--selected); font-weight: 600; }
.folder.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { font-size: 12px; font-weight: 600; color: var(--accent); }
.folder-more { opacity: 0; width: 22px; height: 22px; font-size: 14px; }
.folder:hover .folder-more, .folder.active .folder-more { opacity: .7; }
.side-sep { height: 1px; background: var(--border); margin: 10px 6px; }
.quota { margin-top: auto; padding: 12px 10px 4px; font-size: 12px; color: var(--muted); }
.quota .bar { margin-top: 5px; }

/* --- список писем --- */
.list { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--border); }
.list-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 8px; border-bottom: 1px solid var(--border); }
.list-title { font-weight: 600; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; }
.list-search-note { padding: 6px 12px; font-size: 12.5px; background: var(--accent-soft); display: flex; align-items: center; gap: 8px; }
.list-items { flex: 1; overflow-y: auto; }
.list-foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 6px 10px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.msg {
  position: relative; display: flex; gap: 10px; padding: 9px 12px 9px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.msg:hover { background: var(--hover); }
.msg.selected { background: var(--selected); }
.msg.unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.msg-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 6px; }
.msg-from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .msg-from, .msg.unread .msg-subject { font-weight: 600; }
.msg.unread .msg-subject { color: var(--accent); }
.msg-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.msg-icons { display: inline-flex; gap: 3px; color: var(--muted); }
.msg-icons svg { width: 14px; height: 14px; }
.msg-icons .flagged { color: var(--danger); }
.msg-quick { position: absolute; right: 8px; bottom: 6px; display: none; gap: 2px; background: inherit; }
.msg:hover .msg-quick { display: flex; }
.msg-quick .icon-btn { width: 26px; height: 26px; }
.msg-quick svg { width: 16px; height: 16px; }

/* --- чтение --- */
.reader { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.reader-empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.reader-empty svg { width: 64px; height: 64px; fill: var(--border-strong); margin-bottom: 10px; }
.actionbar { display: flex; align-items: center; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.actionbar .btn { border-color: transparent; background: transparent; min-height: 30px; padding: 3px 9px; font-weight: 400; }
.actionbar .btn:hover { background: var(--hover); }
.actionbar .btn svg { width: 17px; height: 17px; fill: var(--accent); }
.actionbar .btn.danger svg { fill: var(--danger); }
.actionbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.reader-scroll { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.reader-head { padding: 14px 20px 10px; }
.reader-subject { font-size: 19px; font-weight: 600; margin-bottom: 12px; word-break: break-word; }
.reader-from { display: flex; gap: 12px; align-items: flex-start; }
.reader-from .msg-avatar { width: 40px; height: 40px; font-size: 15px; }
.reader-meta { flex: 1; min-width: 0; }
.reader-sender { font-weight: 600; }
.reader-sender .addr { font-weight: 400; color: var(--muted); }
.reader-rcpt { font-size: 12.5px; color: var(--muted); word-break: break-word; }
.reader-date { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.notice { display: flex; align-items: center; gap: 10px; margin: 0 20px 10px; padding: 7px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.att {
  display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2);
  color: var(--text); text-decoration: none; font-size: 13px;
}
.att:hover { border-color: var(--accent); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.att svg { fill: var(--muted); }
.att button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; font-size: 15px; }
iframe.body-frame { flex: 1; width: 100%; min-height: 400px; border: 0; background: #fff; border-top: 1px solid var(--border); }
.multi { margin: auto; text-align: center; padding: 20px; }
.multi .row-wrap { justify-content: center; margin-top: 14px; }

/* --- написание --- */
.compose { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.compose-fields { padding: 8px 16px 0; }
.cf-row { display: flex; align-items: flex-start; gap: 8px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.cf-label { width: 64px; flex: none; padding-top: 7px; color: var(--muted); font-size: 13px; }
.cf-row > input { border: 0; box-shadow: none !important; padding-left: 0; }
.cf-toggle { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 7px 4px; font-size: 13px; }
.rcpt-wrap { flex: 1; position: relative; min-width: 0; }
.rcpt { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 34px; padding: 3px 0; cursor: text; }
.rcpt-input { flex: 1; min-width: 90px; border: 0 !important; box-shadow: none !important; padding: 4px 2px !important; min-height: 26px !important; background: transparent !important; }
.rchip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 4px 2px 10px;
  background: var(--accent-soft); color: var(--text); border-radius: 12px; font-size: 13px;
}
.rchip.bad { background: var(--danger-soft); color: var(--danger); }
.rchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rchip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 4px; }
.rcpt-suggest {
  position: absolute; top: 100%; left: 0; z-index: 20; width: min(420px, 100%); max-height: 260px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.rcpt-suggest button { display: block; width: 100%; padding: 7px 12px; text-align: left; border: 0; background: none; cursor: pointer; }
.rcpt-suggest button.hl, .rcpt-suggest button:hover { background: var(--hover); }
.rcpt-suggest .s-addr { color: var(--muted); font-size: 12.5px; }
.toolbar-ed { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.toolbar-ed button { min-width: 30px; height: 28px; border: 0; background: none; border-radius: 4px; cursor: pointer; color: var(--text); }
.toolbar-ed button:hover { background: var(--hover); }
.toolbar-ed .sep { width: 1px; background: var(--border); margin: 4px 4px; }
.editor { flex: 1; min-height: 220px; padding: 14px 18px; overflow-y: auto; outline: none; word-wrap: break-word; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor blockquote { margin: 0 0 0 4px; padding-left: 10px; border-left: 2px solid var(--border-strong); }
.editor img { max-width: 100%; }
.compose-atts { padding: 6px 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.compose-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.compose.drag .editor { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* --- контакты --- */
.contacts { grid-column: 2 / -1; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.contacts-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.contacts-head input { max-width: 320px; }
.contacts-list { flex: 1; overflow-y: auto; }
.contacts table td { border-bottom: 1px solid var(--border); }

/* --- настройки --- */
.settings-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 4px; overflow-x: auto; }
.settings-tabs button { padding: 8px 12px; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; color: var(--muted); white-space: nowrap; }
.settings-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.sig-editor { min-height: 140px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); outline: none; background: var(--panel); }
.sig-editor:focus { border-color: var(--accent); }
.conn-table td { padding: 6px 10px; font-size: 13px; }

/* --- телефоны и узкие окна --- */
@media (max-width: 1100px) {
  .mail-body { grid-template-columns: 210px minmax(260px, 340px) 1fr; }
  .mtop-brand { min-width: 0; }
}
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex !important; }
  .mtop-brand span { display: none; }
  .mail-body { grid-template-columns: 1fr; position: relative; }
  .side { position: fixed; top: 48px; bottom: 0; left: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .mail-shell.nav-open .side { transform: none; }
  .reader { display: none; }
  .mail-shell.reading .list { display: none; }
  .mail-shell.reading .reader { display: flex; }
  .contacts { grid-column: 1; }
  .msg-quick { display: none !important; }
}
.back-btn { display: none !important; }
@media (max-width: 860px) { .back-btn { display: inline-flex !important; } }
