/* TOMLI Auto: веб-почта владельца. Разработчик: TOMLI. */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1d2129; --muted: #6b7280; --line: #e3e5e9;
  --accent: #1f5fbf; --accent-text: #ffffff; --active: #e8effb; --unread: #0f172a;
  --danger: #b42318; --ok: #16794a; --notice: #fff7e0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --panel: #1c1f24; --text: #e6e8eb; --muted: #9aa1ab; --line: #2c3036;
    --accent: #5b8def; --accent-text: #0b0d10; --active: #24324a; --unread: #ffffff;
    --danger: #f2766b; --ok: #4cc38a; --notice: #3a3320;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.notice { background: var(--notice); padding: 8px 10px; border-radius: 6px; margin: 8px 0; }
label { display: block; margin: 10px 0; font-weight: 600; }
input, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
textarea { resize: vertical; font-family: inherit; }
button, .button { display: inline-block; padding: 8px 14px; font: inherit; font-weight: 600; border: 0; border-radius: 6px;
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none; }
.button:hover { text-decoration: none; }
button.secondary, .button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger, .button.danger { background: var(--danger); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 400; }
form.inline { display: inline; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

/* вход */
body.auth { display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; width: 100%; max-width: 380px; }
.card.wide { max-width: 560px; }
.card button[type=submit] { width: 100%; margin-top: 6px; }
.card form.inline button { width: auto; margin-top: 12px; }
.steps { padding-left: 18px; }
.steps li { margin: 6px 0; }
.key { font-family: Consolas, monospace; font-size: 15px; letter-spacing: 1px; padding: 8px; margin-top: 6px;
  background: var(--bg); border-radius: 6px; word-break: break-all; }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg { width: 220px; height: 220px; background: #fff; border-radius: 6px; }
.codes { columns: 2; list-style: none; padding: 0; font-family: Consolas, monospace; font-size: 16px; }
.codes li { padding: 4px 0; }

/* верхняя полоса */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 16px; align-items: center; }

/* страницы настроек и письма */
.page { max-width: 820px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.status.on { color: var(--ok); font-weight: 600; }
.status.off { color: var(--danger); font-weight: 600; }
.log { border-collapse: collapse; width: 100%; }
.log td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); }
.from { margin: 6px 0 4px; }

/* почта: ящики | папки | список | письмо */
body.mailapp { display: flex; flex-direction: column; }
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 170px minmax(260px, 360px) 1fr; }
.boxes, .folders, .list, .reader { min-height: 0; overflow: auto; border-right: 1px solid var(--line); background: var(--panel); }
.boxes { padding: 10px; }
.box { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px; border-radius: 8px; color: var(--text); }
.box .name { display: flex; flex-direction: column; font-weight: 600; }
.box small { font-weight: 400; color: var(--muted); }
.box.active, .folder.active, .item.active { background: var(--active); }
.box:hover, .folder:hover, .item:hover { text-decoration: none; background: var(--active); }
.compose { display: block; text-align: center; margin-top: 12px; }
.folders { padding: 10px 6px; }
.folder { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.list-head { display: flex; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list .notice { margin: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.item .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .when { color: var(--muted); font-size: 12px; }
.item .subj { grid-column: 1 / -1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .who, .item.unread .subj { color: var(--unread); font-weight: 700; }
.empty { padding: 16px; }
.pager { display: flex; justify-content: space-between; padding: 10px 12px; }
.reader { display: flex; flex-direction: column; border-right: 0; }
.reader-head { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.reader-head dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0; }
.reader-head dt { color: var(--muted); }
.reader-head dd { margin: 0; overflow-wrap: anywhere; }
.reader .back { display: none; }
.atts { list-style: none; padding: 0; margin: 10px 0 0; }
.atts li { margin: 3px 0; }
iframe.body { flex: 1; min-height: 400px; width: 100%; border: 0; background: #fff; }
.text { padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .panes { grid-template-columns: 200px 1fr 1.4fr; }
  .folders { grid-column: 1; grid-row: 2; border-top: 1px solid var(--line); }
  .boxes { grid-row: 1; }
  .list { grid-column: 2; grid-row: 1 / span 2; }
  .reader { grid-column: 3; grid-row: 1 / span 2; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .panes { display: block; overflow: auto; }
  .boxes, .folders { display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .box { flex: 0 0 auto; }
  .compose { margin-top: 0; flex: 0 0 auto; align-self: center; }
  .folder { flex: 0 0 auto; gap: 6px; }
  .list, .reader { border-right: 0; }
  .panes.has-open .list { display: none; }
  .panes:not(.has-open) .reader { display: none; }
  .reader .back { display: inline-block; margin-bottom: 8px; }
  iframe.body { min-height: 70vh; }
}
