:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c1f24;
  --muted: #69707c;
  --line: #e3e6eb;
  --accent: #2f5d8a;
  --accent-soft: #e6eef6;
  --unread: #0f1115;
  --ok-bg: #e7f4ea; --ok: #1d6b33;
  --warn-bg: #fff4e0; --warn: #8a5200;
  --err-bg: #fdecec; --err: #a12626;
  --info-bg: #eef3fa;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b; --panel: #1d2026; --text: #e3e6ea; --muted: #9aa1ab; --line: #2d3139;
    --accent: #7fb0e0; --accent-soft: #23303e; --unread: #ffffff;
    --ok-bg: #173022; --ok: #8fd6a2; --warn-bg: #33280f; --warn: #f0c070;
    --err-bg: #3a1a1a; --err: #f19b9b; --info-bg: #1f2833;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 14px; font-weight: 600; }
h1 small { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: 8px; }
h2 { font-size: 1.05rem; margin: 26px 0 10px; }
small, .hint { color: var(--muted); }
.warn { color: var(--warn); }

/* horní lišta */
.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.search { flex: 1; max-width: 640px; }
.search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.usermenu { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.usermenu form { margin: 0; }
.who { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font: inherit; }

.shell { display: flex; min-height: calc(100vh - 53px); }
.side { width: 200px; flex: none; padding: 14px 8px; display: flex; flex-direction: column; gap: 2px; }
.side a { padding: 7px 12px; border-radius: 7px; text-decoration: none; color: var(--text); }
.side a:hover { background: var(--accent-soft); }
.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .sep { margin: 16px 12px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
main { flex: 1; min-width: 0; padding: 18px 24px 40px; }
main.solo { max-width: 420px; margin: 10vh auto; }

/* seznam zpráv */
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: grid; grid-template-columns: 220px 1fr auto; gap: 14px; padding: 9px 14px; text-decoration: none; color: var(--muted); align-items: baseline; }
.list a:hover { background: var(--accent-soft); }
.list .from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.list .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.list .snip { color: var(--muted); }
.list .meta { white-space: nowrap; font-size: .85rem; display: flex; gap: 6px; }
.list li.unread .from, .list li.unread .subj { font-weight: 650; color: var(--unread); }
.list li.unread { box-shadow: inset 3px 0 0 var(--accent); }
.star { color: #d49b00; margin-right: 4px; }
.empty { color: var(--muted); padding: 30px 0; }
.more { margin-top: 14px; }

/* zpráva */
.msg { max-width: 1000px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.actions form { margin: 0; }
.back { margin-right: 8px; }
.hdr { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0 0 14px; font-size: .92rem; }
.hdr dt { color: var(--muted); }
.hdr dd { margin: 0; overflow-wrap: anywhere; }
.atts { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.atts li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.atts a { text-decoration: none; }
.atts .removed { color: var(--muted); text-decoration: line-through; }
.body { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.body .loading { padding: 16px; color: var(--muted); }
.body pre.text { margin: 0; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.mailframe { display: block; width: 100%; min-height: 120px; border: 0; background: #fff; }
.alert.remote { margin: 0; border-radius: 0; border: 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.thread ol { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.thread li + li { border-top: 1px solid var(--line); }
.thread a { display: flex; justify-content: space-between; padding: 8px 14px; text-decoration: none; color: var(--text); }
.thread li.current a { background: var(--accent-soft); font-weight: 600; }
.thread li.unread a { font-weight: 650; }

/* hlášky */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.info { background: var(--info-bg); }
input.copy { width: 100%; margin-top: 6px; font-family: ui-monospace, monospace; }

/* formuláře a tlačítka */
button, .btn { font: inherit; padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary, .btn.primary { color: #0d1620; } }
button:disabled { opacity: .6; cursor: progress; }
.form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--panel); }
.form legend { font-weight: 600; padding: 0 6px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; }
.form input:not([type=checkbox]), .form select, .form textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); }
.form details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.form details[open] > label { margin-top: 10px; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; max-width: none; }
.form.login { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* tabulky správy */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: .92rem; }
.grid th, .grid td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.grid th { background: var(--bg); font-weight: 600; border-top: 0; }
.grid.small { font-size: .85rem; }
.grid tr.off td { opacity: .55; }
.grid td form { margin: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.st-ok { color: var(--ok); }
.st-error, .st-reauth_required { color: var(--err); }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: auto; flex-direction: row; overflow-x: auto; padding: 8px; }
  .side .sep { display: none; }
  .side a { white-space: nowrap; }
  main { padding: 14px 12px 30px; }
  .top { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .list a { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .list .from { grid-column: 1; }
  .list .meta { grid-column: 2; grid-row: 1; }
  .list .subj { grid-column: 1 / -1; }
  .grid { display: block; overflow-x: auto; }
}
