/* =========================================================================
   TempBox — disposable inbox generator
   Dark by default; [data-theme="light"] flips the token set.
   ========================================================================= */

:root {
  --bg: #0d0f13;
  --bg-elev: #14171d;
  --bg-elev-2: #1a1e26;
  --bg-hover: #202632;
  --border: #262c38;
  --border-strong: #333b4a;

  --fg: #e8eaf0;
  --fg-muted: #949cad;
  --fg-faint: #6a7285;

  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, .14);
  --accent-fg: #ffffff;

  --good: #35c48c;
  --warn: #f0a93b;
  --danger: #ef4d5a;
  --danger-soft: rgba(239, 77, 90, .13);

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .42);

  --sidebar-w: 310px;
  --topbar-h: 58px;
  --footer-h: 36px;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f8fafc;
  --bg-hover: #eef1f7;
  --border: #dfe4ed;
  --border-strong: #c7cedb;

  --fg: #161a22;
  --fg-muted: #5c6577;
  --fg-faint: #8a93a6;

  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .1);

  --shadow: 0 10px 30px rgba(20, 30, 60, .12);

  color-scheme: light;
}

* { box-sizing: border-box; }

/* Several panes below are laid out with display:flex/grid, which would otherwise
   win over the browser's default [hidden] rule and leave them on screen. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand__mark { width: 28px; height: 28px; color: var(--accent); flex: 0 0 auto; }

.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__text strong {
  font-size: 15px; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand__text span {
  font-size: 11px; color: var(--fg-faint); text-transform: lowercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar__actions { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
.field--inline { min-width: 0; }

/* ------------------------------------------------------------------ layout */

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
  position: relative;
}

.layout.reader-open { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) minmax(0, 1.25fr); }

/* ----------------------------------------------------------------- sidebar */

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel { padding: 14px 14px 16px; border-bottom: 1px solid var(--border); }
.panel--grow { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; border-bottom: 0; }

.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.panel__title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--fg-faint);
  display: flex; align-items: center; gap: 7px;
}
.panel__head .panel__title { margin-bottom: 10px; }

.count {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px; font-size: 10px; color: var(--fg-muted);
  letter-spacing: 0;
}

/* --------------------------------------------------------------- generator */

.generator { display: flex; flex-direction: column; gap: 8px; }
.generator__row { display: flex; gap: 8px; }
.generator__row .input { flex: 1 1 auto; min-width: 0; }
.generator__row .select { flex: 1 1 0; min-width: 0; }

.input, .select {
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: border-color .14s, box-shadow .14s;
}

.select { appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-faint) 50%),
                    linear-gradient(135deg, var(--fg-faint) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.select--sm { padding: 6px 24px 6px 9px; font-size: 12px; width: auto; min-width: 104px; }

.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder { color: var(--fg-faint); }

.field--inline { display: flex; align-items: center; gap: 6px; }
.field__label { font-size: 11px; color: var(--fg-faint); }

.hint { margin: 2px 0 0; font-size: 11px; color: var(--fg-faint); line-height: 1.45; }
.hint--error { color: var(--danger); }
.hint a {
  color: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font: 600 13px/1 inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .14s, border-color .14s, transform .06s, opacity .14s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--bg-hover); }

.btn--danger-ghost { background: transparent; border-color: var(--border); color: var(--fg-muted); }
.btn--danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn--block { width: 100%; }
.btn--square { padding: 9px 11px; flex: 0 0 auto; }

.btn.is-busy { pointer-events: none; opacity: .75; }
.btn.is-busy .btn__label::after {
  content: "";
  display: inline-block;
  width: 11px; height: 11px;
  margin-left: 8px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  appearance: none;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg-faint);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 14px;
  transition: color .14s, background .14s, border-color .14s;
}
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.link-btn {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--fg-faint); font: inherit; font-size: 11px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
  margin-bottom: 10px;
}
.link-btn:hover { color: var(--accent); }

.back-btn {
  appearance: none; background: none; border: 0;
  color: var(--fg-muted); font-size: 26px; line-height: 1;
  padding: 0 4px; cursor: pointer; display: none; flex: 0 0 auto;
}
.back-btn:hover { color: var(--fg); }

/* ------------------------------------------------------------ account list */

.account-list { list-style: none; margin: 0; padding: 0 0 12px; overflow-y: auto; flex: 1 1 auto; }

.account {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
  transition: background .12s, border-color .12s;
}
.account:hover { background: var(--bg-hover); }
.account.is-active { background: var(--accent-soft); border-color: var(--accent); }

.account__main { min-width: 0; flex: 1 1 auto; }

.account__address {
  font: 500 12.5px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}

.account__meta { font-size: 10.5px; color: var(--fg-faint); }

.account__badge {
  flex: 0 0 auto;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px;
  background: var(--accent); color: var(--accent-fg);
  font: 700 10.5px/19px inherit; text-align: center;
}

.empty { color: var(--fg-faint); font-size: 12px; padding: 4px 2px 12px; margin: 0; }

/* ------------------------------------------------------------------- inbox */

.inbox { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.address-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.address-bar__main { min-width: 0; flex: 1 1 auto; }

.address {
  display: block;
  font: 600 14.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: all;
}

.address-bar__meta { display: flex; align-items: center; gap: 9px; margin-top: 3px; }

.tag {
  font-size: 10.5px; color: var(--fg-faint);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px;
}

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--fg-faint); }

.status__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg-faint); flex: 0 0 auto;
}
.status.is-live .status__dot { background: var(--good); animation: pulse 2s ease-in-out infinite; }
.status.is-error .status__dot { background: var(--danger); animation: none; }
.status.is-live { color: var(--good); }
.status.is-error { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(53, 196, 140, .45); }
  50% { opacity: .65; box-shadow: 0 0 0 5px rgba(53, 196, 140, 0); }
}

.address-bar__actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }

.inbox__body { flex: 1 1 auto; overflow-y: auto; min-height: 0; position: relative; }

/* ------------------------------------------------------------ message list */

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

.message {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.message:hover { background: var(--bg-elev); }
.message.is-selected { background: var(--accent-soft); }
.message.is-new { animation: slide-in .35s ease-out; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-7px); background: var(--accent-soft); }
  to { opacity: 1; transform: none; }
}

.message__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-top: 7px; flex: 0 0 auto;
}
.message__dot.is-read { background: transparent; }

.message__main { min-width: 0; flex: 1 1 auto; }

.message__top { display: flex; align-items: baseline; gap: 10px; }

.message__from {
  font-weight: 600; font-size: 13.5px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto;
}
.message.is-unread .message__from { color: var(--fg); }
.message:not(.is-unread) .message__from { color: var(--fg-muted); font-weight: 500; }

.message__time { font-size: 11px; color: var(--fg-faint); flex: 0 0 auto; }

.message__subject {
  font-size: 13px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.message.is-unread .message__subject { font-weight: 600; }

.message__intro {
  font-size: 12px; color: var(--fg-faint); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.message__clip { font-size: 11px; color: var(--fg-faint); flex: 0 0 auto; margin-top: 4px; }

.message__archived {
  flex: 0 0 auto;
  font-size: 10px; letter-spacing: .02em;
  color: var(--fg-faint);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 7px;
}

/* ------------------------------------------------------------- placeholder */

.placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; gap: 4px;
  color: var(--fg-faint);
  pointer-events: none;
}
.placeholder__art { width: 52px; height: 52px; opacity: .3; margin-bottom: 8px; }
.placeholder__title { margin: 0; font-size: 14px; font-weight: 600; color: var(--fg-muted); }
.placeholder__body { margin: 0; font-size: 12.5px; max-width: 330px; line-height: 1.55; }

/* ------------------------------------------------------------------ reader */

.reader {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
}

.reader__head {
  flex: 0 0 auto;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.reader__headings { flex: 1 1 auto; min-width: 0; }

.reader__subject {
  margin: 0; font-size: 15px; font-weight: 650; line-height: 1.35;
  overflow-wrap: anywhere;
}

.reader__from {
  margin: 3px 0 0; font-size: 12px; color: var(--fg-faint);
  overflow-wrap: anywhere;
}

.reader__actions { display: flex; gap: 7px; flex: 0 0 auto; }

.reader__frame-wrap { flex: 1 1 auto; overflow-y: auto; min-height: 0; }

.reader__frame { display: block; width: 100%; border: 0; min-height: 100%; background: transparent; }

.attachments {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}

.attachment {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--fg);
  padding: 6px 10px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}
.attachment:hover { border-color: var(--accent); color: var(--accent); }
.attachment__size { color: var(--fg-faint); font-size: 11px; }

/* ------------------------------------------------------------------ toasts */

.toast-host {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 9px;
  max-width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 11px 32px 11px 13px;
  opacity: 0; transform: translateY(9px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--clickable { cursor: pointer; }
.toast--clickable:hover { background: var(--bg-hover); }

.toast--good { border-left-color: var(--good); }
.toast--warn { border-left-color: var(--warn); }
.toast--mail { border-left-color: var(--accent); }

.toast__title { font-size: 13px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.toast__body { font-size: 12px; color: var(--fg-muted); margin-top: 2px; overflow-wrap: anywhere; }

.toast__close {
  position: absolute; top: 6px; right: 7px;
  appearance: none; background: none; border: 0;
  color: var(--fg-faint); font-size: 17px; line-height: 1;
  cursor: pointer; padding: 2px 5px; border-radius: 4px;
}
.toast__close:hover { color: var(--fg); background: var(--bg-hover); }

/* ------------------------------------------------------------------ footer */

.footer {
  flex: 0 0 auto;
  height: var(--footer-h);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 11px; color: var(--fg-faint);
  text-align: center;
}
.footer a { color: var(--fg-muted); }
.footer__sep { opacity: .5; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .layout.reader-open { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .layout.reader-open .inbox { display: none; }
  .layout.reader-open .reader { border-left: 0; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout.reader-open { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  /* One pane at a time: sidebar → inbox → reader. */
  .layout.pane-inbox .sidebar,
  .layout.pane-reader .sidebar { display: none; }
  .layout:not(.pane-inbox):not(.pane-reader) .inbox { display: none; }
  .layout.pane-reader .inbox { display: none; }
  .layout:not(.pane-reader) .reader { display: none; }

  .back-btn { display: block; }

  .footer { height: auto; padding: 8px 16px; line-height: 1.45; }
  .brand__text span { display: none; }
  .topbar { padding: 0 11px; gap: 8px; }

  /* The provider picker carries its own meaning ("Auto (mail.tm)"), so the
     separate label is the first thing to go when space runs out. */
  .field__label { display: none; }
  .select--sm { min-width: 0; max-width: 150px; }
}

/* Below this the brand wordmark and the picker cannot both fit. */
@media (max-width: 460px) {
  .brand__text { display: none; }
  .toast-host { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
