/* דואר אחוותא — בסיס, מעטפת, רכיבים. פלטה: דיו-טורקיז עמוק + חול חם. */
:root {
  --font: "Heebo", "Assistant", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --bg: #f3eee4; --surface: #fffdf8; --surface-2: #f8f3ea; --sunken: #ebe4d6;
  --ink: #1b2a2a; --ink-2: #485856; --ink-3: #7a8582; --line: #e4dccd; --line-2: #d3c8b4;
  --brand: #134543; --brand-2: #1d6560; --brand-ink: #f7f2e8; --sand: #ecdcc0; --accent: #b4693a; --accent-soft: #f4e4d4;
  --sel: #e3eee8; --hover: #f1ebe0; --read-bg: #f8f4ec; --focus: #2f8f86;
  --star: #c68a1d; --danger: #b23b2e; --ok: #2f7a4f;
  --cat-primary: #1d6560; --cat-promotions: #b4693a; --cat-social: #7a5a8a; --cat-updates: #6b7a35; --cat-forums: #47688a;
  --radius: 16px; --radius-s: 10px;
  --shadow: 0 1px 2px rgba(20, 40, 38, .06), 0 10px 30px rgba(20, 40, 38, .10);
  --shadow-l: 0 4px 10px rgba(20, 40, 38, .10), 0 24px 60px rgba(20, 40, 38, .18);
  --hdr: 60px; --side: 260px;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1716; --surface: #142120; --surface-2: #192927; --sunken: #0a1211;
  --ink: #ebe5d8; --ink-2: #b6bdb6; --ink-3: #87918c; --line: #233331; --line-2: #2f4441;
  --brand: #1d5c58; --brand-2: #6cc2b5; --brand-ink: #f2ecdf; --sand: #ecdcc0; --accent: #df9a68; --accent-soft: #3a2a1f;
  --sel: #1d3532; --hover: #1a2b29; --read-bg: #111c1b; --focus: #6cc2b5;
  --star: #e4b24a; --danger: #ef7d6d; --ok: #7cc79a;
  --cat-primary: #6cc2b5; --cat-promotions: #df9a68; --cat-social: #b996c9; --cat-updates: #b3c27a; --cat-forums: #8fb0d3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-l: 0 4px 10px rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior-x: none; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow: hidden;
  text-rendering: optimizeLegibility;
}
body.login-mode { overflow: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.spacer { flex: 1; }
code, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
kbd { background: var(--sunken); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
.ic { flex: none; }

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, white); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line-2)); }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.big { min-height: 50px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer; flex: none; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { background: var(--sel); color: var(--brand-2); }
.link-btn { background: none; border: 0; color: var(--brand-2); cursor: pointer; padding: 6px 4px; min-height: 40px; font-size: 14px; }

/* ---------- שדות ---------- */
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-s); border: 1px solid var(--line-2);
  background: var(--surface); font-size: 16px;
}
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237a8582' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: 14px 50%; background-repeat: no-repeat; padding-left: 36px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.field-err { color: var(--danger); margin: 0; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-2); }
.switch { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--brand-2); }
.switch:checked::after { transform: translateX(-18px); }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 44px; }

/* ---------- טעינה ---------- */
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; }
.boot h2 { margin: 8px 0 0; }
.sk { display: block; height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--sunken), var(--hover), var(--sunken)); background-size: 300% 100%; animation: sk 1.3s ease-in-out infinite; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } * { transition-duration: 0s !important; } }

/* ---------- סימן ומותג ---------- */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.wordmark { font-weight: 800; font-size: 20px; letter-spacing: -.01em; color: var(--ink); }
.brand-mark { flex: none; display: block; }

/* ---------- מעטפת ---------- */
.topbar {
  position: fixed; top: 0; inset-inline: 0; height: calc(var(--hdr) + var(--st)); padding: var(--st) calc(8px + var(--sr)) 0 calc(8px + var(--sl));
  display: flex; align-items: center; gap: 6px; background: var(--bg); z-index: 30;
}
.topbar .brand { display: none; }
.top-acts { display: flex; align-items: center; gap: 2px; }
.desk-only { display: none !important; }
.av-btn { border: 0; background: none; padding: 3px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; width: 44px; height: 44px; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; letter-spacing: -.02em; user-select: none; }
.avatar.sel { background: var(--brand-2) !important; width: 40px; height: 40px; color: var(--surface); }

.search { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; height: 48px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.search-input { flex: 1; min-width: 0; border: 0; background: transparent; height: 100%; font-size: 16px; padding: 0 4px; }
.search-input::-webkit-search-cancel-button { display: none; }
.search .s-ic { color: var(--ink-3); }
.search .s-clear { width: 36px; height: 36px; }
.search-input:placeholder-shown ~ .s-clear { visibility: hidden; }
.search-help {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-l); padding: 8px; z-index: 40; max-height: 60vh; overflow: auto;
}
.sh-title { padding: 4px 8px 6px; }
.sh-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%; text-align: start; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.sh-item:hover { background: var(--hover); }
.sh-item code { color: var(--brand-2); font-weight: 600; }

.body { position: fixed; top: calc(var(--hdr) + var(--st)); bottom: 0; inset-inline: 0; display: flex; z-index: 31; }
.topbar:focus-within { z-index: 32; }
.main { flex: 1; min-width: 0; display: flex; padding: 0 var(--sr) 0 var(--sl); }
.pane { min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.list-pane { flex: 1; }
.thread-pane { display: none; }

/* ---------- סרגל צד (מגירה בטלפון) ---------- */
.sidebar {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(86vw, 320px); z-index: 50; background: var(--surface);
  transform: translateX(105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); overflow-y: auto; overscroll-behavior: contain;
  padding: calc(12px + var(--st)) 10px calc(16px + var(--sb)); box-shadow: var(--shadow-l); display: flex; flex-direction: column;
}
.drawer-open .sidebar { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 17, .42); z-index: 45; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.side-top { padding: 4px 4px 12px; }
.compose-btn { min-height: 52px; padding: 0 22px; border-radius: 18px; background: var(--accent-soft); border-color: transparent; color: var(--ink); font-weight: 600; font-size: 15px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.compose-btn:hover { background: color-mix(in srgb, var(--accent-soft) 80%, var(--accent)); }
.compose-btn .ic { color: var(--accent); }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-row { display: flex; align-items: center; position: relative; }
.nav-row .nav-item { flex: 1; min-width: 0; padding-inline-end: 40px; }
.nav-more { position: absolute; inset-inline-end: 2px; width: 36px; height: 36px; opacity: .0; }
.nav-row:hover .nav-more, .nav-more:focus-visible, .nav-row .nav-item.active + .nav-more { opacity: 1; }
@media (hover: none) { .nav-more { opacity: .7; } }
.nav-item {
  display: flex; align-items: center; gap: 14px; min-height: 42px; padding: 0 14px; border-radius: 999px; text-decoration: none;
  color: var(--ink); font-size: 15px;
}
.nav-item .ic { color: var(--ink-2); }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--sel); font-weight: 700; color: var(--brand-2); }
.nav-item.active .ic { color: var(--brand-2); }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nav-count.strong { font-weight: 700; color: var(--ink); }
.nav-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; margin: 0 4px; }
.nav-dot.big { width: 16px; height: 16px; border-radius: 5px; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 2px; font-size: 13px; font-weight: 700; color: var(--ink-3); letter-spacing: .02em; }
.nav-empty { font-size: 13px; color: var(--ink-3); padding: 4px 14px; margin: 0; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.side-note { font-size: 12px; color: var(--ink-3); padding: 8px 14px 0; margin: 0; }

/* ---------- כפתור כתיבה צף (טלפון) ---------- */
.fab {
  position: fixed; inset-inline-end: calc(16px + var(--sl)); bottom: calc(18px + var(--sb)); z-index: 25; height: 56px; padding: 0 20px 0 22px;
  display: flex; align-items: center; gap: 10px; border: 0; border-radius: 18px; background: var(--accent-soft); color: var(--ink);
  font-weight: 600; font-size: 15px; box-shadow: var(--shadow); cursor: pointer;
}
.fab .ic { color: var(--accent); }
.has-thread .fab, .composing .fab, .settings-mode .fab, .drawer-open .fab { display: none; }

/* ---------- הודעות קופצות ---------- */
#toasts { position: fixed; bottom: calc(86px + var(--sb)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; padding: 0 12px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 4px; max-width: min(560px, 100%); min-height: 48px; padding: 6px 6px 6px 6px; padding-inline-start: 16px;
  background: #1d2b2a; color: #f3eee4; border-radius: 14px; box-shadow: var(--shadow-l); animation: tin .2s ease-out; font-size: 14.5px;
}
[data-theme="dark"] .toast { background: #e9e3d6; color: #1b2a2a; }
.toast.error { background: #6b231b; color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .2s; }
.toast-msg { flex: 1; min-width: 0; padding: 4px 0; }
.toast-act { border: 0; background: none; color: #f0b98d; font-weight: 700; padding: 0 12px; min-height: 40px; cursor: pointer; border-radius: 8px; }
[data-theme="dark"] .toast-act { color: #9a4f22; }
.toast-x { border: 0; background: none; color: inherit; opacity: .7; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }

/* ---------- חלונות ותפריטים ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 18, 17, .5); z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--surface); width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow-l);
  padding-bottom: var(--sb); animation: sheet .22s ease-out;
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 4px 8px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.modal-body { padding: 8px 18px 12px; overflow-y: auto; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px 18px 16px; border-top: 1px solid var(--line); }
.menu-back { position: fixed; inset: 0; z-index: 85; }
.menu {
  position: fixed; min-width: 220px; max-width: min(320px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-l); padding: 6px;
}
.menu-back.sheet { background: rgba(8, 18, 17, .42); display: flex; align-items: flex-end; }
.menu-back.sheet .menu { position: static; width: 100%; max-width: none; border-radius: 22px 22px 0 0; padding: 8px 8px calc(12px + var(--sb)); max-height: 80dvh; animation: sheet .2s ease-out; }
.menu-title { font-weight: 700; padding: 8px 12px 6px; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head { font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 8px 12px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: start; font-size: 15px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item .ic { color: var(--ink-2); }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger); }
.menu-item:disabled { opacity: .55; cursor: default; }
.menu-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item kbd { font-size: 11px; }
.menu-pad { width: 18px; flex: none !important; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dot { width: 14px; height: 14px; border-radius: 5px; flex: none; }

/* ---------- כניסה ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--st)) 16px calc(24px + var(--sb)); position: relative; overflow: hidden; }
.login-art { position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(60% 50% at 85% 10%, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent 70%),
  radial-gradient(50% 45% at 10% 90%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 28px 22px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-brand .wordmark { font-size: 24px; }
.login-intro { margin: -4px 0 2px; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.user-wrap { display: flex; direction: ltr; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--surface); overflow: hidden; }
.user-wrap:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.user-wrap .input, .user-wrap .input:focus { border: 0; border-radius: 0; flex: 1; min-width: 0; outline: none; box-shadow: none; background: transparent; }
.user-domain { display: flex; align-items: center; padding: 0 12px; font-size: 16px; color: var(--ink-2); background: color-mix(in srgb, var(--line) 45%, transparent); border-inline-start: 1px solid var(--line); white-space: nowrap; }
.login-help { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--brand-2) 8%, transparent); color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.login-help svg { flex: none; margin-top: 2px; }
.login-help p { margin: 0; }
.login-help a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.login-new { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: transparent; border: 1.5px solid var(--brand); color: var(--brand); }
.login-forgot { margin: 0; text-align: center; }
.login-forgot a, .login-help a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.su-avail { margin: -8px 0 0; color: var(--ink-2); min-height: 1.4em; }
.su-avail.ok { color: var(--ok, #1f7a4d); font-weight: 600; }
.su-avail.bad { color: var(--danger); }
.su-trap { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; inset-inline-start: -9999px; }
.login-card { position: relative; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-inline-start: 46px; }
.pw-eye { position: absolute; inset-inline-start: 2px; top: 2px; }
.login-err { margin: 0; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.login-foot { display: flex; align-items: center; gap: 6px; justify-content: center; margin: 4px 0 0; }

/* ---------- מחשב ---------- */
@media (min-width: 900px) {
  .topbar { gap: 10px; padding-inline: calc(12px + var(--sr)) calc(16px + var(--sl)); }
  .topbar .brand { display: flex; width: calc(var(--side) - 64px); }
  .search { max-width: 720px; }
  .desk-only { display: inline-grid !important; }
  .top-acts { margin-inline-start: auto; }
  .sidebar { position: static; transform: none; box-shadow: none; width: var(--side); flex: none; background: transparent; padding: 4px 8px 16px; z-index: auto; transition: none; }
  .side-collapsed .sidebar { width: 76px; }
  .side-collapsed .sidebar .nav-name, .side-collapsed .sidebar .nav-count, .side-collapsed .sidebar .nav-head span, .side-collapsed .compose-btn span,
  .side-collapsed .sidebar .nav-empty, .side-collapsed .sidebar .side-note, .side-collapsed .nav-more { display: none; }
  .side-collapsed .compose-btn { padding: 0; width: 56px; }
  .side-collapsed .nav-item { padding: 0; justify-content: center; }
  .scrim, .fab { display: none !important; }
  .main { padding: 0 0 12px 12px; gap: 12px; }
  .pane { border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.04); border: 1px solid var(--line); overflow: hidden; }
  #toasts { bottom: 24px; align-items: flex-start; padding-inline-start: 24px; }
  .modal-back { align-items: center; padding: 24px; }
  .modal { width: min(460px, 100%); border-radius: 20px; padding-bottom: 0; }
  .modal.wide { width: min(640px, 100%); }
}
