/* =========================================================
   Webmail — sötét, minimál téma
   ========================================================= */
:root {
  color-scheme: dark;
  --bg: #08080a;
  --surface: #101013;
  --surface-2: #16161a;
  --surface-3: #1d1d23;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --text: #ededf1;
  --muted: #8d8d98;
  --faint: #5e5e69;
  --accent: #5cb9ff;
  --accent-strong: #8accff;
  --accent-ink: #051019;
  --accent-soft: rgba(92, 185, 255, .12);
  --danger: #ff6b72;
  --danger-soft: rgba(255, 107, 114, .1);
  --ok: #4fe0a0;
  --ok-soft: rgba(79, 224, 160, .1);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(900px 480px at 78% -8%, rgba(92, 185, 255, .07), transparent 62%),
    radial-gradient(700px 400px at -5% 105%, rgba(140, 120, 255, .045), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 1.7rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; }
pre { margin: 0; }
.ic { flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.accent { color: var(--accent); }
[hidden] { display: none !important; }
::selection { background: rgba(92, 185, 255, .3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* scrollbar */
* { scrollbar-width: thin; scrollbar-color: #2a2a31 transparent; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; }
.page { max-width: 1000px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 44px) 64px; }
.page-wide { max-width: 1060px; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px 16px;
  background: rgba(10, 10, 12, .85);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 4px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-name { font-weight: 650; letter-spacing: -.02em; font-size: .94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent-strong), var(--accent));
  box-shadow: 0 6px 22px rgba(92, 185, 255, .28), inset 0 1px 0 rgba(255, 255, 255, .4);
}
.brand-mark-lg { width: 52px; height: 52px; border-radius: 15px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--muted); font-weight: 500; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.nav-link.is-active .ic { color: var(--accent); }

.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 6px;
  padding: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
}
.me { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; color: var(--text); }
.me:hover { color: var(--text); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-mail { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar { display: none; }
.scrim { display: none; }

/* ---------- Gombok / űrlap ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); border-color: rgba(255, 255, 255, .2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(92, 185, 255, .22), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn-primary:hover { background: linear-gradient(180deg, #a3d8ff, var(--accent-strong)); color: var(--accent-ink); border-color: transparent; box-shadow: 0 10px 30px rgba(92, 185, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(255, 107, 114, .25); }
.btn-danger:hover { background: rgba(255, 107, 114, .18); color: #ff9499; border-color: rgba(255, 107, 114, .4); }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
.btn-lg { padding: 13px 22px; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: rgba(255, 255, 255, .2); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: #121216; }
.input:disabled { color: var(--muted); background: var(--surface); cursor: not-allowed; opacity: .8; }
.textarea { resize: vertical; min-height: 220px; line-height: 1.6; }
.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-right: 46px; }
.input-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 9px; cursor: pointer; }
.input-btn:hover { color: var(--text); background: var(--surface-3); }
.form-actions { display: flex; gap: 10px; }

/* ---------- Kártyák, értesítések ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.form-card { padding: clamp(18px, 3vw, 30px); }
.notice {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 18px;
  border-radius: 13px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: .92rem;
}
.notice > span { flex: 1; min-width: 0; }
.notice-ok { background: var(--ok-soft); border-color: rgba(79, 224, 160, .28); color: var(--ok); }
.notice-error { background: var(--danger-soft); border-color: rgba(255, 107, 114, .3); color: #ffb3b7; }
.notice-error .ic { color: var(--danger); }
.notice-info { background: var(--accent-soft); border-color: rgba(92, 185, 255, .25); color: #cfe9ff; }
.notice-info .ic { color: var(--accent); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.sub { color: var(--muted); margin-top: 6px; font-size: .92rem; }

.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 13px; color: var(--faint); pointer-events: none; }
.search input {
  width: 300px; max-width: 100%; padding: 10px 14px 10px 38px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s, width .2s;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::placeholder { color: var(--faint); }

/* ---------- Avatar ---------- */
.avatar {
  --size: 42px;
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden;
  background: linear-gradient(145deg, hsl(var(--h) 62% 46%), hsl(calc(var(--h) + 38) 58% 30%));
  color: #fff; font-weight: 650; font-size: calc(var(--size) * .38); letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  user-select: none;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-3); }
.avatar-sm { --size: 30px; }
.avatar-md { --size: 42px; }
.avatar-lg { --size: 56px; }
.avatar-xl { --size: 132px; }

/* ---------- Inbox ---------- */
.mail-list { overflow: hidden; }
.mail-row {
  display: grid; grid-template-columns: auto minmax(120px, 210px) minmax(0, 1fr) auto;
  align-items: center; gap: 0 16px; padding: 12px 18px;
  color: var(--muted); border-bottom: 1px solid var(--line);
  transition: background .12s;
}
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: var(--surface-2); color: var(--muted); }
.mail-from, .mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-from { color: var(--text); font-weight: 500; }
.mail-meta { display: flex; align-items: center; gap: 10px; justify-content: flex-end; font-size: .82rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.clip { display: inline-flex; color: var(--muted); }
.mail-row.is-unread { color: var(--text); }
.mail-row.is-unread .mail-from, .mail-row.is-unread .mail-subject { font-weight: 650; color: #fff; }
.mail-row.is-unread .mail-meta { color: var(--accent); }
.mail-row.is-unread .avatar::after {
  content: ""; position: absolute; right: 1px; top: 1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 10px var(--accent);
}
.mail-row.is-unread .avatar { overflow: visible; }
.mail-row.is-unread .avatar img { border-radius: 50%; }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.pager-info { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 64px 24px; }
.empty p { color: var(--muted); }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty-icon-error { background: var(--danger-soft); color: var(--danger); }
.error-pre { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; color: #ffb3b7; font: .85rem/1.5 var(--mono); text-align: left; }

/* ---------- Levél ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar .btn-ghost { margin-left: -10px; }
.toolbar-actions { display: flex; gap: 8px; }

.msg { overflow: hidden; }
.msg-head { padding: clamp(18px, 3vw, 30px); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 20px; }
.msg-subject { font-size: clamp(1.35rem, 2.6vw, 1.85rem); font-weight: 650; overflow-wrap: anywhere; }
.msg-from { display: flex; align-items: center; gap: 14px; }
.msg-from-text { min-width: 0; flex: 1; }
.msg-from-name { font-weight: 600; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-from-addr { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { color: var(--muted); font-size: .84rem; text-align: right; }
.msg-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: .86rem; }
.msg-meta:empty { display: none; }
.msg-meta dt { color: var(--faint); }
.msg-meta dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }

.msg > .notice { margin: 18px clamp(18px, 3vw, 30px) 0; }
.tabs { display: flex; gap: 4px; padding: 14px clamp(18px, 3vw, 30px) 0; }
.tab { padding: 6px 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .86rem; font-weight: 550; cursor: pointer; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { background: var(--surface-3); color: var(--text); }

.msg-panel { padding: 18px clamp(12px, 2.4vw, 24px) clamp(14px, 2.4vw, 24px); }
.mail-frame { display: block; width: 100%; min-height: 160px; border: 0; border-radius: 12px; background: #fff; color-scheme: light; }
.text-body { padding: 24px clamp(18px, 3vw, 30px) 30px; font-size: 1rem; line-height: 1.75; overflow-wrap: anywhere; }
.msg-panel.text-body { padding: 18px clamp(18px, 3vw, 30px) 30px; }
.text-body p { margin: 0 0 1em; }
.text-body p:last-child { margin-bottom: 0; }

/* Mellékletek */
.attachments { margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 9px; font-size: .92rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.count { background: var(--surface-3); color: var(--text); border-radius: 99px; padding: 1px 9px; font-size: .78rem; letter-spacing: 0; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.att { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, background .15s; }
.att:hover { border-color: var(--line-2); background: var(--surface-2); }
.att-thumb, .att-badge { width: 56px; height: 56px; border-radius: 12px; flex: none; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-badge span { font: 700 .72rem/1 var(--mono); letter-spacing: .04em; color: var(--accent); background: var(--accent-soft); padding: 6px 7px; border-radius: 7px; }
.att-info { min-width: 0; flex: 1; }
.att-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { color: var(--faint); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-actions { display: flex; gap: 2px; }

/* ---------- Compose ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 26px 16px; border: 1.5px dashed var(--line-2); border-radius: 14px; background: var(--surface-2);
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.dropzone strong { color: var(--accent); font-weight: 600; }
.dropzone small { color: var(--faint); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.chips { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chip { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.chip-size { color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }

/* ---------- Profil ---------- */
.profile-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 36px; align-items: start; }
.profile-avatar { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.avatar-drop { position: relative; display: block; border-radius: 50%; cursor: pointer; }
.avatar-drop .avatar { box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line-2); transition: box-shadow .2s; }
.avatar-drop-hint {
  position: absolute; inset: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: rgba(0, 0, 0, .6); color: #fff; font-weight: 600; font-size: .9rem;
  opacity: 0; transition: opacity .18s; backdrop-filter: blur(2px);
}
.avatar-drop:hover .avatar-drop-hint, .avatar-drop.is-over .avatar-drop-hint { opacity: 1; }
.avatar-drop:hover .avatar, .avatar-drop.is-over .avatar { box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--accent); }
.danger-zone { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.page .muted.small { margin-top: 14px; }

/* ---------- Bejelentkezés ---------- */
body.auth { display: grid; place-items: center; padding: 24px; }
.auth-glow { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(520px 340px at 50% 28%, rgba(92, 185, 255, .13), transparent 70%); }
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 34px 30px 26px;
  background: rgba(16, 16, 19, .82); backdrop-filter: blur(20px);
  border: 1px solid var(--line-2); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 26px; }
.auth-brand h1 { font-size: 1.45rem; }
.auth-brand p { color: var(--muted); font-size: .92rem; }
.auth-foot { margin-top: 20px; text-align: center; color: var(--faint); font-size: .78rem; }
.auth-card .empty { padding: 10px 0; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Reszponzív ---------- */
@media (max-width: 900px) {
  .app { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
    background: rgba(8, 8, 10, .82); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
  }
  .topbar-title { font-weight: 650; letter-spacing: -.01em; }
  .sidebar {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
    background: rgba(12, 12, 15, .98);
  }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .page { padding: 20px 14px 48px; }
  h1 { font-size: 1.45rem; }
  .search, .search input { width: 100%; }
  .page-head { align-items: stretch; }
  .profile-grid { grid-template-columns: 1fr; gap: 24px; }
  .msg-from { flex-wrap: wrap; }
  .msg-date { text-align: left; width: 100%; padding-left: 70px; margin-top: -8px; }
}

@media (max-width: 640px) {
  .mail-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "av from meta" "av subj subj";
    gap: 1px 12px; padding: 12px 14px;
  }
  .mail-row .avatar { grid-area: av; align-self: start; margin-top: 2px; }
  .mail-from { grid-area: from; }
  .mail-subject { grid-area: subj; font-size: .92rem; }
  .mail-meta { grid-area: meta; }
  .att-grid { grid-template-columns: 1fr; }
  .toolbar-actions .btn { padding: 9px 14px; }
  .btn-lg { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
