
:root {
  color-scheme: dark;
  --bg-body: #020617;
  --bg-elevated: #020617;
  --border-subtle: #1f2937;
  --border-strong: #374151;
  --fg: #e5e7eb;
  --fg-muted: #9ca3af;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --danger: #f97373;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: radial-gradient(circle at top, #020617 0, #020617 35%, #000 100%);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(to bottom,
              rgba(2, 6, 23, 0.96),
              rgba(2, 6, 23, 0.92),
              rgba(2, 6, 23, 0.86));
}

.layout-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 0.95rem;
}

.brand-icon {
  width: 24px;
  height: 24px;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(circle at 30% 0%, #22d3ee, #1d4ed8 40%, #020617 100%);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9),
              0 18px 35px rgba(15, 23, 42, 0.9);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.layout-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  margin-top: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top left,
              rgba(15, 23, 42, 1) 0,
              rgba(15, 23, 42, 1) 40%,
              rgba(15, 23, 42, 0.95) 100%);
  box-shadow:
      0 24px 60px rgba(0, 0, 0, 0.85),
      0 0 0 1px rgba(15, 23, 42, 1);
  padding: 1.25rem 1.25rem 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.actions {
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn,
.btn:link,
.btn:visited {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: radial-gradient(circle at top left,
               #111827 0,
               #020617 55%,
               #020617 100%);
  color: var(--fg);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition:
      background 120ms ease-out,
      border-color 120ms ease-out,
      box-shadow 120ms ease-out,
      transform 80ms ease-out;
}

.btn:hover {
  border-color: rgba(148, 163, 184, 0.9);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.95);
  transform: translateY(-0.5px);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0.5px) scale(0.99);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.9);
}

.btn-secondary {
  border-color: rgba(148, 163, 184, 0.35);
  background: radial-gradient(circle at top left,
               #020617 0,
               #020617 40%,
               #020617 100%);
  color: var(--fg-muted);
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.85);
  background: radial-gradient(circle at top left,
               rgba(127, 29, 29, 1) 0,
               rgba(127, 29, 29, 0.9) 40%,
               rgba(15, 23, 42, 1) 100%);
  color: #fecaca;
}

.btn-danger:hover {
  border-color: rgba(252, 165, 165, 1);
  box-shadow: 0 10px 30px rgba(127, 29, 29, 0.9);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(circle at top left,
              rgba(15, 23, 42, 1) 0,
              rgba(15, 23, 42, 0.9) 100%);
  font-size: 0.7rem;
  color: var(--fg-muted);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 1);
}

.table-wrapper {
  margin-top: 0.75rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  overflow: hidden;
  background: radial-gradient(circle at top left,
              rgba(15, 23, 42, 1) 0,
              rgba(15, 23, 42, 0.96) 100%);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table thead {
  background: linear-gradient(to bottom,
              rgba(15, 23, 42, 1),
              rgba(15, 23, 42, 0.95));
}

.table th,
.table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}

.table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.table td:nth-child(3),
.table th:nth-child(3) {
  width: 100%;
  white-space: normal;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: rgba(15, 23, 42, 0.9);
}

.table a {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.table-checkbox-cell {
  width: 1%;
}

tr.row-unread {
  background-color: rgba(30, 64, 175, 0.08); /* azul bem sutil */
}

tr.row-unread td {
  font-weight: 600;
}

tr.row-unread:hover {
  background-color: rgba(30, 64, 175, 0.4);
}

.subject-line {
  display: block;
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin-top: 0.15rem;
}

.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.meta {
  margin-top: 1.5rem;
}

/* container do RAW */
.raw-body {
  margin-top: 0.35rem;
  background: #ffffff;
  color: #111111;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  max-height: 420px;      /* ajusta como preferir */
  overflow: auto;         /* scroll se passar do tamanho */
  box-sizing: border-box;
}

/* conteúdo dentro do <pre> */
.raw-body pre {
  margin: 0;
  white-space: pre-wrap;  /* mantém formatação mas quebra linha */
  word-wrap: break-word;  /* quebra URLs enormes */
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
               Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
}

.message-layout {
  display: flex;
  flex-direction: column;  /* uma coluna só */
  gap: 1rem;
}

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

.message-header {
  font-size: 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  padding: 0.75rem 0.9rem;
  background: radial-gradient(circle at top left,
              rgba(15, 23, 42, 1) 0,
              rgba(15, 23, 42, 0.96) 100%);
}

.message-header-row {
  margin-bottom: 0.25rem;
}

.message-header-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-muted);
}

.message-header-value {
  font-size: 0.85rem;
}

/* container do HTML do email */
.message-body {
  margin-top: 0.75rem;
  background: #ffffff;
  color: #111111;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto; /* <<< scroll horizontal se precisar */
  box-sizing: border-box;
}

/* FORÇA qualquer elemento interno a respeitar o card */
.message-body * {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Imagens não podem estourar */
.message-body img {
  max-width: 100% !important;
  height: auto !important;
}

/* tabelas se adaptam e não quebram o layout */
.message-body table {
  width: 100% !important;
  max-width: 100% !important;
  display: block;
  overflow-x: auto; /* scroll interno para tabelas largas */
  border-collapse: collapse;
}

/* evita "indentação gigante" causada por margin/padding de e-mails */
.message-body div,
.message-body p,
.message-body span,
.message-body td,
.message-body th {
  word-wrap: break-word;
  white-space: normal !important; /* força quebrar linhas longas */
}

.code-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 0.35rem;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.1fr);
  gap: 1rem;
  margin-top: 1rem;
}

/* container do RAW */
.raw-body {
  margin-top: 0.35rem;
  background: #ffffff;
  color: #111111;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  max-height: 420px;      /* ajusta como preferir */
  overflow: auto;         /* scroll se passar do tamanho */
  box-sizing: border-box;
}

/* conteúdo dentro do <pre> */
.raw-body pre {
  margin: 0;
  white-space: pre-wrap;  /* mantém formatação mas quebra linha */
  word-wrap: break-word;  /* quebra URLs enormes */
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
               Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
}

@media (max-width: 800px) {
  .home-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.home-highlight {
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

.home-side-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-random-panel {
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: radial-gradient(circle at top left,
              rgba(15, 23, 42, 1) 0,
              rgba(15, 23, 42, 0.96) 100%);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.9);
  font-size: 0.7rem;
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono",
               "Courier New", monospace;
}

.footer {
  margin-top: 1.5rem;
  font-size: 0.73rem;
  color: var(--fg-muted);
  text-align: right;
}

.home-form {
   margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.home-form-help {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.home-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 200px;
}

.home-form-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.home-form-input {
  padding: 0.4rem 0.6rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.95);
  color: var(--fg);
  font-size: 0.85rem;
}

.home-form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.captcha-colors {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.captcha-color-btn {
  width: 32px;
  height: 32px;
  border-radius: 0.5rem;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.captcha-color-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

/* Specific colors */
.captcha-color-red {
  background: #ef4444;
}
.captcha-color-green {
  background: #22c55e;
}
.captcha-color-blue {
  background: #3b82f6;
}
.captcha-color-yellow {
  background: #eab308;
}
.captcha-color-purple {
  background: #a855f7;
}
.captcha-color-orange {
  background: #f97316;
}

.message-tabs {
  margin-top: 1rem;
  border-bottom: 1px solid #ddd;
}

.message-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.35;
}

.message-tab-button {
  border: none;
  background: transparent;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: #555;
}

.message-tab-button.is-active {
  border-bottom: 2px solid #007bff;
  font-weight: 600;
  color: #000;
}

.message-tab-panel {
  display: none;
  margin-top: 0.75rem;
}

.message-tab-panel.is-active {
  display: block;
}

.error-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(248, 113, 113, 0.45); /* usa o mesmo tom do btn-danger */
  background: radial-gradient(circle at top left,
              rgba(127, 29, 29, 0.9) 0%,
              rgba(127, 29, 29, 0.75) 40%,
              rgba(15, 23, 42, 0.95) 100%);
  color: #fecaca; /* readable danger-light */
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow:
      0 6px 20px rgba(0, 0, 0, 0.45),
      0 0 0 1px rgba(127, 29, 29, 0.3);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box input {
  background-color: #1c1f26;
  border: 1px solid #323743;
  color: #d7d7d7;
  border-radius: 12px;        /* arredondado */
  padding: 8px 12px;
  width: 180px;
  font-size: 14px;
  outline: none;
}

.search-box input:focus {
  border-color: #4aa3ff;
  box-shadow: 0 0 0 2px rgba(40,120,255,0.3);
}

.small {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 12px;
}
.attachments {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
}

.attachments-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.attachment-item {
  margin: 4px 0;
}

.attachment-meta {
  color: #666;
  font-size: 0.85em;
  margin-left: 4px;
}

.headers-box{
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden; /* ou auto, depois que estiver ok */
}
.message-frame {
  width: 100%;
  min-height: 400px;
  border: none;
  background: white;
}

.attachments-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.attachments-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attachments-filter input[name="q"] {
  width: 220px;
}

.attachments-filter input[name="mime"] {
  width: 180px;
}

.attachments-filter input[type="text"],
.attachments-filter input[name="q"],
.attachments-filter input[name="mime"] {
  height: 32px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.9em;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9999;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

.copyable {
  cursor: pointer;
  font-family: monospace;
  padding: 6px 8px;
  background: #111;
  border-radius: 6px;
}