/* ToMail na webu – vzhled podle desktopového ToMailu, upravený pro telefon */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: rgba(0, 0, 0, 0.08);
  --pane: #ffffff;
  --bg: #f2f2f7;
  --side: #f6f6f8;
  --hover: rgba(0, 0, 0, 0.04);
  --selected: #e9f0fd;
  --accent: #2b6cf0;
  --accent-soft: rgba(43, 108, 240, 0.12);
  --flag: #e8473b;
  --danger: #c93a2f;
  --ok: #2f9e55;
  --archive: #2f9e55;
  --skeleton: rgba(0, 0, 0, 0.06);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-h: 52px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f2f2f7;
    --muted: #a1a1a8;
    --faint: #6c6c72;
    --line: rgba(255, 255, 255, 0.09);
    --pane: #1c1c1e;
    --bg: #000000;
    --side: #161618;
    --hover: rgba(255, 255, 255, 0.05);
    --selected: #1f3357;
    --accent: #4d8dff;
    --accent-soft: rgba(77, 141, 255, 0.18);
    --skeleton: rgba(255, 255, 255, 0.07);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--pane);
  color: var(--text);
  font: 16px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.ico { width: 22px; height: 22px; flex: none; }

#app, #main { position: fixed; inset: 0; overflow: hidden; }

/* ---------- Lišta ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: calc(var(--bar-h) + var(--safe-top));
  padding: var(--safe-top) 6px 0;
  background: color-mix(in srgb, var(--pane) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
  position: relative;
  z-index: 5;
  flex: none;
}

.bar-title { flex: 1; min-width: 0; text-align: center; font-weight: 600; font-size: 17px; line-height: 1.15; }
.bar-title span, .bar-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title small { font-weight: 400; font-size: 12px; color: var(--muted); }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 10px; }
.icon-btn:active { background: var(--hover); }
.icon-btn:disabled { opacity: 0.3; }
.text-btn { color: var(--accent); padding: 8px 10px; font-size: 16px; }
.text-btn.strong { font-weight: 600; }
.text-btn:disabled { opacity: 0.35; }

/* ---------- Panely ---------- */

.pane { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--pane); }
.read-pane { transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 10; box-shadow: var(--shadow); }
body.reading .read-pane { transform: none; }
body.reading .list-pane { transform: translateX(-25%); }
.list-pane { transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }

@media (min-width: 820px) {
  .list-pane { right: auto; width: 380px; border-right: 0.5px solid var(--line); transform: none !important; }
  .read-pane { left: 380px; transform: none; box-shadow: none; }
  .read-pane .back { visibility: hidden; }
  .drawer { box-shadow: var(--shadow); }
}

@media (min-width: 1180px) {
  .list-pane { left: 260px; }
  .read-pane { left: 640px; }
  .drawer { transform: none !important; width: 260px !important; box-shadow: none !important; border-right: 0.5px solid var(--line); }
  .scrim { display: none !important; }
  .list-pane [data-act="drawer"] { visibility: hidden; }
}

/* ---------- Složky ---------- */

.drawer {
  position: absolute;
  z-index: 30;
  top: 0; bottom: 0; left: 0;
  width: min(84vw, 320px);
  background: var(--side);
  transform: translateX(-102%);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
body.drawer-open .drawer { transform: none; }
.scrim { position: absolute; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.3); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
body.drawer-open .scrim { opacity: 1; pointer-events: auto; }

.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 10px; font-weight: 700; font-size: 20px; }
.drawer-logo { width: 30px; height: 30px; border-radius: 7px; }
.folders { flex: 1; overflow-y: auto; padding: 4px 8px 12px; -webkit-overflow-scrolling: touch; }
.folders h3 { margin: 18px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folders .err { margin: 0 10px; color: var(--danger); font-size: 13px; }
.folder { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 10px; border-radius: 10px; text-align: left; font-size: 16px; }
.folder .ico { color: var(--accent); }
.folder .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .count { color: var(--muted); font-size: 14px; }
.folder.active { background: var(--accent-soft); }
.folder:active { background: var(--hover); }
.drawer-settings { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 0.5px solid var(--line); color: var(--muted); }

/* ---------- Hledání ---------- */

.search-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 0.5px solid var(--line); background: var(--pane); }
.search-bar form { flex: 1; }
.search-bar input[type=search] { width: 100%; height: 36px; border-radius: 10px; border: 0; background: var(--skeleton); padding: 0 12px; font-size: 16px; outline: none; -webkit-appearance: none; }
.search-all { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }

/* ---------- Seznam ---------- */

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding-bottom: calc(90px + var(--safe-bottom)); outline: none; }
.pull { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 13px; transition: height 0.2s; flex: none; }
.pull.on { height: 44px; }

.row { position: relative; overflow: hidden; border-bottom: 0.5px solid var(--line); }
.row-under { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; color: #fff; font-weight: 600; font-size: 14px; }
.row-under .l, .row-under .r { display: flex; align-items: center; gap: 6px; }
.row-in { position: relative; display: flex; gap: 11px; padding: 11px 14px 11px 10px; background: var(--pane); touch-action: pan-y; transition: transform 0.2s; }
.row-in.dragging { transition: none; }
.row.active .row-in { background: var(--selected); }
.row-in:active { background: var(--hover); }
.dot { width: 9px; flex: none; padding-top: 6px; }
.dot i { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.who { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.unseen .who, .unseen .subj { font-weight: 650; }
.when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.unseen .when { color: var(--accent); }
.subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; margin-top: 1px; display: flex; gap: 5px; align-items: center; }
.subj .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.subj .ico { width: 15px; height: 15px; color: var(--muted); }
.subj .flag { color: var(--flag); }
.prev { color: var(--muted); font-size: 14px; line-height: 1.32; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.acc-tag { font-size: 11px; color: var(--faint); margin-top: 3px; }
.list-msg { padding: 40px 24px; text-align: center; color: var(--muted); }
.list-err { margin: 10px 14px 0; padding: 10px 12px; border-radius: 10px; background: rgba(201, 58, 47, 0.1); color: var(--danger); font-size: 14px; }
.more { display: block; margin: 16px auto; color: var(--accent); padding: 10px 18px; }
.skel { padding: 14px 16px; border-bottom: 0.5px solid var(--line); }
.skel i { display: block; height: 11px; border-radius: 6px; background: var(--skeleton); margin: 7px 0; }

.fab {
  position: absolute;
  right: 18px;
  bottom: calc(22px + var(--safe-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(43, 108, 240, 0.4);
  z-index: 4;
}
.fab .ico { width: 26px; height: 26px; }
.fab:active { transform: scale(0.95); }

/* ---------- Čtení ---------- */

.reader { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
.empty-read { color: var(--faint); text-align: center; margin-top: 30vh; }
.msg-head { padding: 14px 16px 10px; border-bottom: 0.5px solid var(--line); }
.msg-subj { font-size: 21px; font-weight: 700; line-height: 1.25; margin: 0 0 12px; word-break: break-word; }
.msg-from { display: flex; gap: 11px; align-items: center; }
.msg-from .avatar { width: 42px; height: 42px; }
.msg-from .who2 { flex: 1; min-width: 0; }
.msg-from .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-from .addr, .msg-to { color: var(--muted); font-size: 13px; word-break: break-all; }
.msg-to { margin-top: 8px; line-height: 1.45; }
.msg-to b { font-weight: 500; color: var(--text); }
.msg-date { color: var(--muted); font-size: 13px; white-space: nowrap; align-self: flex-start; }
.msg-flag { color: var(--flag); }
.atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.att { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 10px; background: var(--skeleton); font-size: 14px; max-width: 100%; text-decoration: none; color: var(--text); }
.att .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.att small { color: var(--muted); }
.att .ico { width: 18px; height: 18px; color: var(--muted); }
.unsub { margin: 10px 16px 0; font-size: 13px; color: var(--muted); }
.body-frame { display: block; width: 100%; border: 0; min-height: 80px; margin-top: 8px; background: transparent; }

.toolbar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(50px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  border-top: 0.5px solid var(--line);
  background: color-mix(in srgb, var(--pane) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  flex: none;
}
.toolbar button { width: 48px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 10px; }
.toolbar button:active { background: var(--hover); }
.toolbar .on { color: var(--flag); }

/* ---------- Okna zespodu (psaní, nastavení) ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--pane);
  display: flex;
  flex-direction: column;
  animation: up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 820px) {
  .sheet { inset: 6vh auto 6vh 50%; width: 720px; margin-left: -360px; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); overflow: hidden; }
}
.sheet .bar { background: var(--pane); }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.field { display: flex; align-items: center; gap: 8px; border-bottom: 0.5px solid var(--line); padding: 0 16px; min-height: 46px; position: relative; }
.field label { color: var(--muted); width: 62px; flex: none; font-size: 15px; }
.field input, .field select { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; padding: 12px 0; -webkit-appearance: none; }
.field .text-btn { font-size: 14px; }
.compose textarea { display: block; width: 100%; min-height: 40vh; border: 0; outline: none; resize: none; background: transparent; padding: 14px 16px; font-size: 16px; line-height: 1.45; }
.sig { padding: 0 16px 10px; color: var(--muted); font-size: 14px; }
.sig-box { border-left: 2px solid var(--line); padding-left: 10px; margin-top: 4px; max-height: 160px; overflow: hidden; }
.sig-box img { max-width: 100%; height: auto; }
.quote-box { margin: 6px 16px 16px; border-left: 2px solid var(--line); padding-left: 10px; color: var(--muted); font-size: 14px; }
.quote-box summary { cursor: pointer; padding: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-bottom: 0.5px solid var(--line); }
.chips:empty { display: none; }
.chip { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 11px; border-radius: 16px; background: var(--skeleton); font-size: 14px; max-width: 100%; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip button { width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); }
.chip .ico { width: 16px; height: 16px; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--pane); box-shadow: var(--shadow); border-radius: 0 0 12px 12px; overflow: hidden; }
.suggest button { display: block; width: 100%; text-align: left; padding: 10px 16px; border-bottom: 0.5px solid var(--line); }
.suggest small { display: block; color: var(--muted); font-size: 13px; }

.settings .sheet-body { background: var(--bg); padding: 10px 0 40px; }
.group { background: var(--pane); margin: 18px 14px 0; border-radius: 12px; overflow: hidden; }
.group-title { margin: 22px 30px 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.group .item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 0.5px solid var(--line); min-height: 46px; }
.group .item:last-child { border-bottom: 0; }
.group .item .grow { flex: 1; min-width: 0; }
.group .item small { display: block; color: var(--muted); font-size: 13px; }
.group button.item { width: 100%; text-align: left; color: var(--accent); }
.group button.item.danger { color: var(--danger); }
.group textarea { width: 100%; min-height: 110px; border: 0; outline: none; background: transparent; padding: 12px 16px; font: 14px/1.4 ui-monospace, Menlo, monospace; resize: vertical; }
.group input[type=text], .group input[type=email], .group input[type=password] { width: 100%; border: 0; outline: none; background: transparent; padding: 12px 16px; border-bottom: 0.5px solid var(--line); font-size: 16px; }
.note { margin: 6px 30px 0; color: var(--muted); font-size: 13px; }

/* ---------- Přihlášení ---------- */

.gate { position: fixed; inset: 0; overflow-y: auto; background: var(--bg); display: flex; justify-content: center; padding: calc(40px + var(--safe-top)) 20px 40px; }
.gate-box { width: 100%; max-width: 380px; text-align: center; }
.gate-logo { width: 84px; height: 84px; border-radius: 19px; box-shadow: 0 6px 20px rgba(240, 104, 42, 0.35); }
.gate h1 { font-size: 26px; margin: 16px 0 4px; }
.gate p { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.gate form { text-align: left; }
.gate .inp { display: block; width: 100%; height: 50px; border-radius: 12px; border: 0.5px solid var(--line); background: var(--pane); padding: 0 14px; font-size: 17px; margin-bottom: 10px; outline: none; }
.gate .inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gate .code { letter-spacing: 6px; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.btn { display: block; width: 100%; height: 50px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; margin-top: 6px; }
.btn:disabled { opacity: 0.5; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.gate .err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 10px 2px 0; text-align: center; }
.gate details { margin: 6px 0 12px; color: var(--muted); font-size: 14px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; margin: 6px 0 12px; }
.qr img, .qr svg { display: block; width: 200px; height: 200px; }
.secret { font: 14px ui-monospace, Menlo, monospace; word-break: break-all; color: var(--muted); margin-bottom: 14px; }

/* ---------- Nabídka a oznámení ---------- */

.menu { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.3); display: flex; align-items: flex-end; justify-content: center; padding: 10px 10px calc(10px + var(--safe-bottom)); }
.menu-box { width: 100%; max-width: 440px; animation: up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.menu-list { background: var(--pane); border-radius: 14px; overflow: hidden; max-height: 66vh; overflow-y: auto; }
.menu-list .menu-title { padding: 12px 16px; text-align: center; color: var(--muted); font-size: 13px; border-bottom: 0.5px solid var(--line); }
.menu-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 18px; border-bottom: 0.5px solid var(--line); font-size: 17px; color: var(--accent); text-align: left; }
.menu-list button:last-child { border-bottom: 0; }
.menu-list button.danger { color: var(--danger); }
.menu-list button .sub { color: var(--muted); font-size: 13px; margin-left: auto; }
.menu-cancel { display: block; width: 100%; margin-top: 8px; padding: 15px; border-radius: 14px; background: var(--pane); color: var(--accent); font-weight: 600; font-size: 17px; }

.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(76px + var(--safe-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: #2c2c2e;
  color: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  font-size: 15px;
}
.toast button { color: #8ab4ff; font-weight: 600; }
.toast.err { background: var(--danger); }
.toast.err button { color: #fff; }

.spin { width: 18px; height: 18px; border: 2px solid var(--skeleton); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
