/* Tempx inbox application styles. Loaded after site.css on every page;
   only the homepage contains the live widget. Mobile-first. */

/* ---------- Address panel (sits in the hero) ---------- */
.address-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  padding: clamp(18px, 3.5vw, 28px);
}
.address-panel .panel-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}

.address-field { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.address-box {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
@media (min-width: 480px) {
  .address-box { flex-direction: row; align-items: center; padding: 6px 8px 6px 16px; }
}
.address-box .addr {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: clamp(0.95rem, 2.7vw, 1.08rem);
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-all;
  color: var(--text);
  padding: 6px 0;
  text-align: center;
}
@media (min-width: 480px) { .address-box .addr { text-align: left; } }
.address-box .addr.is-loading { color: var(--text-faint); }
.address-box .copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--brand);
  color: var(--on-brand);
  border: 0;
  border-radius: 9px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.14s ease, transform 0.06s ease;
}
.address-box .copy:hover { background: var(--brand-hover); }
.address-box .copy:active { transform: translateY(1px); }
.address-box .copy.done { background: var(--ok); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn-sec {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  flex: 1 1 auto;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}
@media (min-width: 480px) { .btn-sec { flex: 0 0 auto; } }
.btn-sec:hover { background: var(--bg-subtle); border-color: var(--brand); color: var(--brand); }
.btn-sec:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sec svg { flex: 0 0 auto; }
.btn-sec.spinning svg { animation: spin 0.9s linear infinite; }
.btn-sec.btn-sm { flex: 0 0 auto; padding: 8px 14px; min-height: 38px; font-size: 0.9rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.meta-line {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-line .live {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ok); font-weight: 600;
}
.meta-line .live::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.turnstile-holder { margin-top: 12px; }
.turnstile-holder:empty { margin-top: 0; }
.turnstile-holder iframe { max-width: 100%; }

/* ---------- Inbox list (full width, below the hero) ---------- */
.inbox {
  margin-top: clamp(14px, 2vw, 20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 13px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 720px) { .inbox-head { padding: 14px 20px; } }

/* Live address shown inside the inbox header; refresh + delete all sit right */
.inbox-addr {
  flex: 1 1 180px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-addr:empty::before { content: "—"; color: var(--text-faint); }
.inbox-head-actions { display: inline-flex; gap: 8px; flex: 0 0 auto; }

/* ---------- Mail split: list + reading pane (desktop, email-app style) ---------- */
.mail-pane { display: none; }
.pane-empty {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-faint);
  font-size: 0.95rem;
  text-align: center;
  padding: 20px;
}
.pane-empty .ic {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--brand-subtle); color: var(--brand);
  display: grid; place-items: center;
}
.pane-viewer { display: flex; flex-direction: column; min-height: 100%; }

@media (min-width: 900px) {
  .mail-split {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: stretch;
  }
  .mail-list-col { border-right: 1px solid var(--border); }
  .mail-pane {
    display: block;
    min-height: 380px;
    max-height: min(72vh, 680px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
  }
  /* The pane itself scrolls; the embedded body must not double-scroll. */
  .mail-pane .viewer-body { max-height: none; overflow: visible; }
}

.msg-item.active {
  background: var(--brand-subtle);
  box-shadow: inset 3px 0 0 var(--brand);
}
.msg-item.active:hover { background: var(--brand-subtle); }
.viewer-head .to-line {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 2px 0 0;
}
.inbox-head h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.inbox-head .count {
  font-size: 0.8rem;
  background: var(--brand);
  color: var(--on-brand);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}
.inbox-head .count[data-empty="true"] { background: var(--text-faint); }

.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list > li { border-bottom: 1px solid var(--border); }
.msg-list > li:last-child { border-bottom: 0; }

.msg-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 13px;
  row-gap: 3px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 14px 18px;
  font: inherit;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease;
}
@media (min-width: 720px) { .msg-item { padding: 15px 20px; } }
.msg-item:hover { background: var(--bg-subtle); }
.msg-item.unseen { background: color-mix(in srgb, var(--brand-subtle) 60%, var(--bg-elevated)); }

.msg-av {
  grid-row: 1 / 3;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--brand-subtle);
  color: var(--brand);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
  align-self: start;
}
.msg-item.unseen .msg-av { background: var(--brand); color: var(--on-brand); }

.msg-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.msg-item.unseen .msg-from { font-weight: 700; }
.msg-time { color: var(--text-faint); font-size: 0.78rem; white-space: nowrap; flex: 0 0 auto; }
.msg-subject { grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.msg-preview { grid-column: 2 / 4; color: var(--text-faint); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-badges { grid-column: 2 / 4; display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-inset);
  border-radius: 5px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.exp { color: var(--warn-bd); background: var(--warn-bg); }

/* Skeleton */
.skeleton-row { display: flex; gap: 13px; padding: 14px 18px; align-items: center; }
.skeleton-row .sk-av { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; }
.skeleton-row .sk-lines { flex: 1; }
.sk { background: var(--bg-inset); border-radius: 6px; position: relative; overflow: hidden; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-lines .sk { height: 11px; margin: 5px 0; }
.sk-lines .sk:first-child { width: 40%; }
.sk-lines .sk:last-child { width: 75%; }

/* Empty state */
.empty-state { padding: 44px 20px; text-align: center; color: var(--text-muted); }
.empty-state .ic {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
  display: grid; place-items: center;
  background: var(--brand-subtle); color: var(--brand);
}
.empty-state p { margin: 4px 0; }
.empty-state .hint { font-size: 0.9rem; color: var(--text-faint); }

/* Status bar */
.status {
  padding: 11px 18px;
  font-size: 0.87rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-subtle);
}
.status[data-kind="error"] { color: var(--danger); }

/* ---------- Message viewer (dialog) ---------- */
dialog.viewer {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
/* Flex column layout must apply ONLY while open — an always-on display:flex
 * would override the UA's dialog:not([open]) { display: none } and leave a
 * ghost box on screen after close. */
dialog.viewer[open] {
  display: flex;
  flex-direction: column;
}
dialog.viewer::backdrop { background: rgba(9, 12, 20, 0.55); backdrop-filter: blur(2px); }

@media (max-width: 560px) {
  dialog.viewer {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px);
    margin: auto 8px;
  }
}

.viewer-head {
  flex: 0 0 auto;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.viewer-head h2 { margin: 0 0 5px; font-size: 1.12rem; overflow-wrap: anywhere; }
.viewer-head .from { color: var(--text-muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.viewer-close {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 9px;
  width: 40px; height: 40px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.viewer-close:hover { background: var(--bg-inset); color: var(--text); }

.viewer-toolbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.86rem;
  align-items: center;
}
.viewer-toolbar button {
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  min-height: 36px;
}
.viewer-toolbar button:hover { background: var(--bg-inset); }
.viewer-toolbar button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border-strong)); }
.viewer-toolbar .note { color: var(--text-faint); }

.viewer-body {
  flex: 1 1 auto;
  min-height: 200px;
  /* Hard cap that does not rely on flex shrinking (some engines do not shrink
   * items inside a fit-content dialog) — head+toolbar need ~240px. */
  max-height: calc(100dvh - 240px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
}
.viewer-body iframe { width: 100%; min-height: 320px; border: 0; display: block; background: #fff; }
.viewer-loading { padding: 40px 20px; color: var(--text-faint); font-family: var(--mono); font-size: 0.9rem; }

.viewer-attach {
  flex: 0 0 auto;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
}
.viewer-attach strong { color: var(--text); }

.att-list { list-style: none; margin: 0; padding: 0; }

/* File-type icon chip */
.att-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--bg-inset);
  color: var(--text-muted);
}
.att-ic.k-image { background: color-mix(in srgb, #2456e6 14%, transparent); color: #2456e6; }
.att-ic.k-pdf { background: color-mix(in srgb, #d2373a 14%, transparent); color: #d2373a; }
.att-ic.k-archive { background: color-mix(in srgb, #d97706 16%, transparent); color: #c26a05; }
.att-ic.k-audio { background: color-mix(in srgb, #7c3aed 14%, transparent); color: #7c3aed; }
.att-ic.k-video { background: color-mix(in srgb, #0d9488 14%, transparent); color: #0d9488; }
.att-ic.k-text { background: color-mix(in srgb, #475569 14%, transparent); color: #475569; }
:root[data-theme="dark"] .att-ic.k-image { color: #8fb0ff; }
:root[data-theme="dark"] .att-ic.k-pdf { color: #ff9b9d; }
:root[data-theme="dark"] .att-ic.k-archive { color: #f5b960; }
:root[data-theme="dark"] .att-ic.k-audio { color: #b794ff; }
:root[data-theme="dark"] .att-ic.k-video { color: #5fd6c8; }
:root[data-theme="dark"] .att-ic.k-text { color: #a8b4c6; }

.att-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.att-row:last-child { border-bottom: 0; }
.att-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.att-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  overflow-wrap: anywhere;
}
.att-meta { font-size: 0.75rem; color: var(--text-faint); }
.att-note { font-size: 0.75rem; color: var(--text-faint); font-style: italic; }
.att-note.blocked { color: var(--danger); font-style: normal; font-weight: 600; }
.att-actions { display: inline-flex; gap: 7px; flex: 0 0 auto; }
.att-actions button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  min-height: 32px;
}
.att-actions button:hover { background: var(--bg-inset); }
.att-actions button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.att-actions button.primary:hover { background: var(--brand-hover); }
.att-actions button:disabled { opacity: 0.5; cursor: wait; }

.tx-plain {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 20px;
  margin: 0;
  color: #10131a;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 300;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
