/* SNBC TempMail – © LYNEX LAB® – Renggli Ventures GmbH, Zug – Schweiz */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f9f9fb;
  --hover: rgba(29, 31, 34, 0.04);
  --line: rgba(29, 31, 34, 0.08);
  --line-2: rgba(29, 31, 34, 0.14);
  --text: #1d1f22;
  --text-2: #565b63;
  --text-3: #8b9099;
  --ink: #1d1f22;
  --logo-ink: #ffffff;
  --accent: #23a35a;
  --accent-ink: #157a41;
  --accent-soft: rgba(35, 163, 90, 0.1);
  --danger: #c93c3c;
  --danger-soft: rgba(201, 60, 60, 0.09);
  --warn: #a8691a;
  --warn-soft: rgba(196, 128, 32, 0.12);
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(16, 18, 20, 0.04), 0 6px 20px rgba(16, 18, 20, 0.05);
  --shadow-lg: 0 24px 60px rgba(16, 18, 20, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --surface: #17181b;
    --surface-2: #1c1d21;
    --hover: rgba(255, 255, 255, 0.05);
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --text: #f1f2f4;
    --text-2: #b2b6bd;
    --text-3: #7d828b;
    --ink: #f1f2f4;
    --logo-ink: #17181b;
    --accent: #3cc977;
    --accent-ink: #5bd98f;
    --accent-soft: rgba(60, 201, 119, 0.13);
    --danger: #f06363;
    --danger-soft: rgba(240, 99, 99, 0.13);
    --warn: #e0a24a;
    --warn-soft: rgba(224, 162, 74, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
.muted { color: var(--text-3); }
.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Shell ---------- */
.app {
  min-height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 2px 0; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { width: 34px; height: 34px; color: var(--ink); flex: none; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.version { margin: 1px 0 0; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.status {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status[data-state="ok"] .status-dot { background: var(--accent); }
.status[data-state="offline"] .status-dot, .status[data-state="error"] .status-dot, .status[data-state="session"] .status-dot { background: var(--danger); }
.status[data-state="offline"], .status[data-state="error"], .status[data-state="session"] { color: var(--danger); border-color: var(--danger-soft); }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

.primary, .secondary, .danger, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 590; font-size: 14px; transition: transform 0.08s, background 0.15s, opacity 0.15s;
}
.primary { background: var(--ink); color: var(--bg); }
.primary:hover { opacity: 0.9; }
.primary:active, .secondary:active, .danger:active { transform: scale(0.985); }
.primary:disabled { opacity: 0.45; cursor: default; }
.primary.big { height: 48px; width: 100%; font-size: 15px; border-radius: 14px; }
.secondary { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.secondary:hover { background: var(--hover); }
.danger { background: var(--danger); color: #fff; }
.ghost { background: transparent; color: var(--text-2); height: 30px; padding: 0 10px; font-size: 12.5px; font-weight: 550; border-radius: 9px; }
.ghost:hover { background: var(--hover); color: var(--text); }
.ghost.is-danger { color: var(--danger); }
.ghost.is-armed { background: var(--danger); color: #fff; }

/* ---------- Panes ---------- */
.panes { flex: 1; display: grid; grid-template-columns: 1fr; gap: 14px; min-height: 0; }
.pane { display: none; flex-direction: column; gap: 12px; min-width: 0; }
.app[data-view="list"] .pane-addresses,
.app[data-view="inbox"] .pane-inbox,
.app[data-view="message"] .pane-message { display: flex; }

.pane-inbox, .pane-message { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 60px; }
.pane-title { flex: 1; min-width: 0; }
.pane-title h2 { margin: 0; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-title p { margin: 1px 0 0; font-size: 12.5px; }
#inbox-title { font-family: var(--mono); font-size: 14px; font-weight: 600; }

@media (min-width: 900px) {
  .app { padding-top: 22px; gap: 18px; }
  .panes { grid-template-columns: 340px minmax(0, 1fr); gap: 18px; }
  .pane-addresses { display: flex !important; }
  .app[data-view="list"] .pane-inbox { display: flex; }
  .pane-addresses .back { display: none; }
  .pane-inbox .back { display: none; }
  .panes { height: calc(100dvh - 120px); }
  .pane-addresses { overflow-y: auto; padding-bottom: 6px; }
}
@media (min-width: 1240px) {
  .panes { grid-template-columns: 340px 380px minmax(0, 1fr); }
  .pane { display: flex !important; }
  .back { display: none !important; }
}

/* ---------- Create ---------- */
.create { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { height: 32px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 560; transition: background 0.15s, color 0.15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line); }
.custom { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
.custom input, .custom select, .field input {
  height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); min-width: 0;
}
.custom input:focus, .custom select:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { margin: -2px 0 0; text-align: center; font-size: 12px; color: var(--text-3); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 4px 0; }
.section-head h2 { margin: 0; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- Address list ---------- */
.addr-list, .msg-list { list-style: none; margin: 0; padding: 0; }
.addr-list { display: flex; flex-direction: column; gap: 8px; }
.addr {
  position: relative; padding: 12px 12px 10px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 15px; box-shadow: var(--shadow); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.addr:hover { border-color: var(--line-2); }
.addr[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.addr-row { display: flex; align-items: center; gap: 8px; }
.addr-mail { flex: 1; min-width: 0; font: 600 14px/1.3 var(--mono); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.copy-btn { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); font-size: 12px; font-weight: 600; color: var(--text-2); }
.copy-btn:hover { color: var(--text); background: var(--hover); }
.copy-btn .ic { width: 15px; height: 15px; }
.copy-btn.is-done { color: var(--accent-ink); border-color: var(--accent); }
.timer { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.timer .ic { width: 14px; height: 14px; color: var(--text-3); }
.bar { flex: 1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 1s linear; }
.timer.is-low { color: var(--warn); }
.timer.is-low .bar > i { background: var(--warn); }
.addr-actions { display: flex; justify-content: flex-end; gap: 2px; margin-top: 6px; margin-right: -4px; }

/* ---------- Messages ---------- */
.msg-list { overflow-y: auto; flex: 1; }
.msg { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.msg:hover { background: var(--hover); }
.msg[aria-current="true"] { background: var(--accent-soft); }
.msg.unread::before { content: ""; position: absolute; left: 6px; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msg-from { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .msg-from, .msg.unread .msg-subject { font-weight: 700; }
.msg-time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.msg-subject { grid-column: 1 / -1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-codes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); font: 700 13px var(--mono); letter-spacing: 0.06em; }
.chip .ic { width: 14px; height: 14px; }
.chip:hover { background: var(--accent); color: #fff; }

/* ---------- Message view ---------- */
.message { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.message-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.message-head h3 { margin: 0 0 10px; font-size: 18px; line-height: 1.3; font-weight: 680; letter-spacing: -0.01em; word-break: break-word; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.meta dt { color: var(--text-3); }
.meta dd { margin: 0; min-width: 0; word-break: break-all; color: var(--text-2); }
.codes { margin: 14px 20px 0; padding: 14px; border-radius: 15px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.codes-label { display: flex; align-items: center; gap: 6px; margin: 0 0 9px; font-size: 12px; font-weight: 650; color: var(--accent-ink); text-transform: uppercase; letter-spacing: 0.04em; }
.codes-label .ic { width: 15px; height: 15px; }
.codes-list { display: flex; flex-wrap: wrap; gap: 8px; }
.code-big { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); font: 700 22px var(--mono); letter-spacing: 0.12em; box-shadow: var(--shadow); }
.code-big .ic { width: 17px; height: 17px; color: var(--text-3); }
.code-big:hover .ic { color: var(--accent-ink); }
.notices { display: flex; flex-direction: column; gap: 6px; margin: 12px 20px 0; }
.notice { display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.notice .ic { width: 16px; height: 16px; margin-top: 1px; color: var(--text-3); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.notice.warn .ic { color: var(--warn); }
.notice-title { margin: 0 0 4px; font-weight: 600; }
.susp-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 2px; }
.link-btn { padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; text-align: left; word-break: break-all; font-size: 12.5px; }
.body-switch { display: flex; gap: 4px; margin: 12px 20px 0; }
.body-switch .ghost[aria-pressed="true"] { background: var(--hover); color: var(--text); }
.mail-frame { display: block; width: 100%; min-height: 240px; border: 0; margin-top: 8px; background: #fff; color-scheme: light; }
.mail-text { margin: 14px 20px 24px; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.55; }
.mail-text a { word-break: break-all; }

/* ---------- Empty ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; padding: 36px 20px; color: var(--text-2); flex: 1; }
.empty p { margin: 0; font-size: 14px; }
.empty .muted { font-size: 13px; }
.empty-ic { width: 34px; height: 34px; color: var(--text-3); margin-bottom: 8px; opacity: 0.8; }

/* ---------- Pairing ---------- */
.pair { display: grid; place-items: start center; padding-top: 6px; }
.pair-card { width: 100%; max-width: 420px; padding: 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.pair-icon { width: 36px; height: 36px; color: var(--accent); }
.pair-card h2 { margin: 0; font-size: 19px; font-weight: 680; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 13.5px; display: flex; flex-direction: column; gap: 5px; }
.pair-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
#pair-code { font: 700 20px var(--mono); letter-spacing: 0.15em; text-transform: uppercase; height: 48px; text-align: center; }
.form-error { margin: 0; padding: 9px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }

/* ---------- Dialogs ---------- */
.dialog { width: min(440px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog.wide { width: min(560px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(10, 11, 13, 0.4); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; }
.dialog-head h3 { margin: 0; font-size: 17px; font-weight: 680; }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.dialog-body h3 { margin: 0; font-size: 17px; }
.dialog-body p { margin: 0; }
.dialog-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.dialog-icon.warn { background: var(--warn-soft); color: var(--warn); }
.dialog-icon .ic { width: 22px; height: 22px; }
.reasons { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.url-box { display: block; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font: 12.5px/1.45 var(--mono); word-break: break-all; max-height: 120px; overflow: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-section + .settings-section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 6px; }
.settings-section h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }
.device { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; }
.device .ic { color: var(--text-3); }
.device-info { flex: 1; min-width: 0; }
.device-info strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-info span { font-size: 12px; color: var(--text-3); }
.pair-code-box { padding: 16px; border-radius: 15px; background: var(--accent-soft); text-align: center; }
.pair-code-box code { display: block; font: 700 30px var(--mono); letter-spacing: 0.18em; color: var(--text); }
.pair-code-box span { font-size: 12.5px; color: var(--accent-ink); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 13px; background: var(--ink); color: var(--bg);
  font-size: 13.5px; font-weight: 560; box-shadow: var(--shadow-lg); z-index: 10; animation: toast-in 0.2s ease-out;
}
.toast.is-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

.foot { text-align: center; font-size: 11.5px; color: var(--text-3); padding: 4px 0 2px; }
.foot a { color: inherit; }

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