@font-face {
  font-family: Inter;
  src: url(/fonts/inter.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url(/fonts/jetbrains-mono-500.woff2) format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #0b0c10;
  --surface: #12141a;
  --surface-2: #181b23;
  --border: #262a34;
  --text: #e6e7eb;
  --muted: #9399a6;
  --accent: #a78bfa;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --danger: #f87171;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; width: 100%; outline: none; transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--danger); }
.meta, .dim { color: var(--muted); }
.meta { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.error:empty { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 20; }
.skip:focus { top: 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* Forms */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field-error { color: var(--danger); font-size: 12px; margin: 5px 0 0; }
.field-error:empty { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 3px 0 0; flex: none; accent-color: var(--primary); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.logo { width: 1.35em; height: 1.35em; flex: none; border-radius: 8px; background: url(/favicon.svg) center/contain no-repeat; box-shadow: 0 0 24px #8b5cf655; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 9px; padding: 9px 16px; font-size: 14px;
  font-weight: 500; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s, transform .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 16px; font-weight: 600; border-radius: 11px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-lg.btn-primary { box-shadow: 0 8px 30px #7c3aed55; }
.btn-lg.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: #f8717155; color: var(--danger); }
.btn-danger:hover { background: #f871711a; }
.link-btn { background: none; border: 0; text-decoration: none; padding: 8px 4px; color: var(--muted); font-weight: 500; }
.link-btn:hover { color: var(--text); }

/* ---------- Landing ---------- */
#landing { min-height: 100%; display: flex; flex-direction: column;
  background: radial-gradient(700px 420px at 75% 10%, #7c3aed26, transparent 70%), radial-gradient(500px 300px at 10% 40%, #a78bfa12, transparent 70%); }
.site-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; max-width: 1120px; width: 100%; margin: 0 auto; }
#main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; align-items: center; padding: 64px 0 80px; }
.pill { display: inline-block; font-size: 12px; font-weight: 500; color: var(--accent); background: #a78bfa14; border: 1px solid #a78bfa33; padding: 4px 12px; border-radius: 99px; margin: 0 0 20px; }
.hero h1 { font-size: clamp(36px, 5.5vw, 58px); line-height: 1.05; letter-spacing: -.035em; margin: 0 0 20px; font-weight: 700; }
.grad { background: linear-gradient(90deg, #c4b5fd, #8b5cf6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 32px; max-width: 34em; }
.hint { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

.mock { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: 0 30px 80px #0009; transform: rotate(1.5deg); }
.mock-bar { display: flex; gap: 6px; margin-bottom: 16px; }
.mock-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.mock-addr { font: 500 15px "JetBrains Mono", monospace; color: var(--accent); padding: 0 4px 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.mock-mail { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.mock-mail:last-child { border-bottom: 0; }
.mock-mail b { font-weight: 600; }
.mock-mail span { grid-column: 1; color: var(--muted); }
.mock-mail em { grid-row: 1; grid-column: 2; font-style: normal; font-size: 12px; color: var(--muted); }
.mock-mail.is-new { background: #7c3aed1a; border-radius: 10px; padding: 12px; margin: 0 -8px; border-bottom-color: transparent; animation: arrive 3s ease-out infinite; }
.mock-mail.is-new b::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: middle; }
@keyframes arrive { 0% { opacity: 0; transform: translateY(-6px); } 10%, 100% { opacity: 1; transform: none; } }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding-bottom: 72px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.feature-icon { font-size: 22px; width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; margin-bottom: 14px; }
.feature h3 { margin: 0 0 6px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }

.faq { max-width: 720px; margin: 0 auto; padding-bottom: 80px; }
.faq h2 { font-size: 24px; letter-spacing: -.02em; text-align: center; margin: 0 0 24px; }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary { padding: 16px 4px; cursor: pointer; font-weight: 500; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 20px; line-height: 1; transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 4px 16px; color: var(--muted); }

.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 20px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ---------- Legal / simple pages ---------- */
.doc-page { min-height: 100%; display: flex; flex-direction: column; }
.doc { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 24px 64px; }
.doc h1 { font-size: 32px; letter-spacing: -.03em; margin: 16px 0 4px; }
.doc h2 { font-size: 19px; margin: 36px 0 10px; letter-spacing: -.01em; }
.doc p, .doc li { color: #c9ccd3; }
.doc ul { padding-left: 20px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.doc th, .doc td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { color: var(--muted); font-weight: 500; }
.table-wrap { overflow-x: auto; }

.notfound { flex: 1; display: grid; place-items: center; text-align: center; padding: 48px 24px; }
.notfound .code { font-size: clamp(88px, 18vw, 150px); font-weight: 700; letter-spacing: -.06em; line-height: 1; margin: 0;
  background: linear-gradient(180deg, #c4b5fd, #7c3aed); -webkit-background-clip: text; background-clip: text; color: transparent; }
.notfound h1 { font-size: 22px; margin: 12px 0 8px; }
.notfound p { color: var(--muted); margin: 0 0 28px; }

/* ---------- Cookie banner ---------- */
.cookie-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 640px; margin: 0 auto; z-index: 30;
  display: flex; gap: 16px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 20px 50px #000a; font-size: 13px; }
.cookie-banner p { margin: 0; color: #c9ccd3; }

/* ---------- App ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.layout { flex: 1; display: grid; grid-template-columns: 280px 360px 1fr; min-height: 0; font-size: 14px; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--border); }
.pane:last-child { border-right: 0; }
.pane-addresses { background: var(--surface); }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); min-height: 58px; }
.pane-head h2 { font-size: 14px; margin: 0; flex: 1; font-weight: 600; }
.back { display: none; }
.app ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }

.address-list { padding: 8px !important; }
.address-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 9px; cursor: pointer; transition: background .12s; }
.address-item:hover { background: var(--surface-2); }
.address-item.active { background: #7c3aed24; box-shadow: inset 0 0 0 1px #8b5cf655; }
.address-info { flex: 1; min-width: 0; }
.address-email { font: 500 13px "JetBrains Mono", monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; border-radius: 99px; padding: 1px 7px; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 4px 6px; border-radius: 6px; opacity: 0; transition: opacity .12s; }
.address-item:hover .icon-btn, .address-item.active .icon-btn, .icon-btn:focus-visible { opacity: 1; }
.icon-btn:hover { color: var(--danger); background: #f871711a; }

.inbox-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.copy { background: none; border: 0; padding: 0; text-align: left; font: 500 14px "JetBrains Mono", monospace;
  color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy:hover { text-decoration: underline; }
.message-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.message-item:hover { background: var(--surface); }
.message-item.active { background: var(--surface-2); }
.message-item.unread .msg-subject { font-weight: 600; }
.message-item.unread .msg-from::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.msg-row { display: flex; justify-content: space-between; gap: 8px; }
.msg-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.msg-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.msg-preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

.reader-actions { display: flex; gap: 8px; margin-left: auto; }
.reader { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; }
.reader h1 { font-size: 20px; margin: 0 0 8px; letter-spacing: -.01em; word-break: break-word; }
.msg-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; font-size: 13px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.attachments:empty { display: none; }
.attachment { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; font-size: 12px; }
.attachment:hover { border-color: var(--accent); }
#msg-html { flex: 1; width: 100%; min-height: 400px; border: 0; border-radius: 10px; background: #fff; }
#msg-text { white-space: pre-wrap; word-break: break-word; font: 13px/1.6 Inter, sans-serif; margin: 0; }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 4px; color: var(--muted); }
.empty p { margin: 4px 0; }
.empty .btn { margin-top: 10px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-bottom: 12px; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #a78bfa88; } 70% { box-shadow: 0 0 0 16px #a78bfa00; } 100% { box-shadow: 0 0 0 0 #a78bfa00; } }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--primary); min-width: 2px; }

/* Dialog */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px 24px; width: min(420px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; }
dialog::backdrop { background: #000b; backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 18px; font-size: 18px; }
dialog h3 { margin: 0 0 12px; font-size: 15px; }
.dialog-close { position: absolute; top: 12px; right: 12px; background: none; border: 0; color: var(--muted); padding: 6px 9px; border-radius: 8px; }
.dialog-close:hover { background: var(--surface-2); color: var(--text); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin: 4px 0 20px; }
.tab { background: none; border: 0; padding: 8px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--surface-2); color: var(--text); }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-radius: 8px 0 0 8px; min-width: 0; }
.input-suffix > span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); font: 12px "JetBrains Mono", monospace; color: var(--muted); white-space: nowrap; }
.account-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--surface-2); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 13px; z-index: 40; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* Responsive */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px 1fr; }
  .pane-reader { display: none; }
  .layout[data-view="reader"] .pane-inbox { display: none; }
  .layout[data-view="reader"] .pane-reader { display: flex; }
  .layout[data-view="reader"] .back[data-back="inbox"] { display: inline-flex; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 32px 0 56px; }
  .mock { transform: none; }
  .features { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .site-header, .topbar { padding: 12px 16px; }
  #main, .doc { padding-left: 16px; padding-right: 16px; }
  .site-footer { padding: 20px 16px; }
  .lead { font-size: 16px; }
  .btn-lg { width: 100%; }
  #logout, #stats-link { display: none; }
  #account-btn { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .layout { grid-template-columns: 1fr; }
  .layout > .pane { display: none; border-right: 0; }
  .layout[data-view="addresses"] .pane-addresses,
  .layout[data-view="inbox"] .pane-inbox,
  .layout[data-view="reader"] .pane-reader { display: flex; }
  .back { display: inline-flex; }
  .icon-btn { opacity: 1; }
  .reader { padding: 16px; }
  .cookie-banner { padding: 12px 14px; gap: 12px; }
  .stackable thead { display: none; }
  .stackable tr { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; margin-bottom: 10px; }
  .stackable td { display: block; border: 0; padding: 6px 0; }
  .stackable td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
}
