/* ═══════════════════════════════════════════════
   TMail — Dark Neo-Brutalist (Merah + Carbon)
   ═══════════════════════════════════════════════ */

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

:root {
  --bg:             #0E0E0E;
  --bg-carbon:      #141414;
  --surface:        #1A1A1A;
  --surface-raised: #222222;
  --surface-hover:  #2A2A2A;
  --ink:            #FFFFFF;
  --text:           #E8E8E8;
  --text-muted:     #999999;
  --text-dim:       #666666;
  --border:         #333333;
  --border-strong:  #444444;

  --red:            #FF2D2D;
  --red-hover:      #FF4D4D;
  --red-dark:       #CC0000;
  --red-glow:       rgba(255, 45, 45, 0.25);
  --red-soft:       rgba(255, 45, 45, 0.1);

  --green:          #22C55E;
  --green-soft:     rgba(34, 197, 94, 0.12);
  --yellow:         #FACC15;
  --yellow-soft:    rgba(250, 204, 21, 0.12);

  /* brutalist tokens */
  --radius:         4px;
  --border-w:       2px;
  --shadow-hard:    4px 4px 0px 0px rgba(255, 45, 45, 0.35);
  --shadow-hard-sm: 3px 3px 0px 0px rgba(255, 45, 45, 0.25);
  --shadow-hard-lg: 6px 6px 0px 0px rgba(255, 45, 45, 0.4);

  --font-display:   'Space Grotesk', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;
  --transition:     0.15s ease;
}

html { background: var(--bg); }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.5;
}

/* ── Scanline Background ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 45, 45, 0.015) 2px,
      rgba(255, 45, 45, 0.015) 4px
    );
  pointer-events: none;
  z-index: 0;
}

main {
  width: 100%;
  max-width: 860px;
  padding: 32px 20px;
  position: relative;
  z-index: 1;
}

/* ── Animations ── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.animate-spin { animation: spin 0.8s linear infinite; }

/* ── Top Bar ── */
.topbar {
  width: 100%;
  background: var(--surface);
  border-bottom: var(--border-w) solid var(--border);
  box-shadow: 0 4px 0 0 rgba(0,0,0,0.4);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  width: 100%;
  max-width: 860px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: var(--transition);
}

.logo:hover {
  transform: translateY(-1px);
}

.logo-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
  filter: drop-shadow(0 2px 8px rgba(255, 30, 45, 0.35));
}

.logo:hover .logo-icon {
  filter: drop-shadow(0 4px 14px rgba(255, 45, 60, 0.65));
}

.logo-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 1px;
}

.logo-text span { color: var(--red); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Status Badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  box-shadow: var(--shadow-hard-sm);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.off {
  background: var(--red);
  animation: none;
}

.status-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ── Lang Switcher ── */
.lang-group {
  display: inline-flex;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lang-btn {
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-dim);
  transition: var(--transition);
}

.lang-btn.active {
  background: var(--red);
  color: var(--ink);
}

.lang-btn:not(.active):hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ── Hero Section ── */
.hero {
  text-align: center;
  margin: 40px 0 32px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 8px;
}

.hero-title em {
  font-style: normal;
  color: var(--red);
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

/* ── Email Card ── */
.email-card {
  background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-hard);
  position: relative;
}

.email-card::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 24px;
  right: 24px;
  height: 3px;
  background: var(--red);
  border-radius: 0 0 2px 2px;
}

.email-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  display: block;
}

.email-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  transition: var(--transition);
}

.email-input-row:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow), var(--shadow-hard-sm);
}

.email-icon {
  width: 20px;
  height: 20px;
  color: var(--red);
  flex-shrink: 0;
}

.email-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
}

.email-input::placeholder { color: var(--text-dim); }

.btn-copy {
  background: var(--red);
  color: var(--ink);
  border: var(--border-w) solid var(--ink);
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 2px 2px 0 0 rgba(0,0,0,0.5);
}

.btn-copy:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 0 rgba(0,0,0,0.5);
}

.btn-copy:active {
  transform: translate(1px, 1px);
  box-shadow: 0 0 0 0 transparent;
}

.btn-copy svg { width: 16px; height: 16px; }

/* ── Domain Selector ── */
.domain-selector {
  margin-bottom: 14px;
  display: none;
}

.domain-selector.visible { display: block; }

.domain-selector-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.domain-selector-label svg {
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}

.domain-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.domain-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-raised);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 2px 2px 0 0 rgba(0,0,0,0.2);
}

.domain-chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
  background: var(--surface-hover);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 0 rgba(0,0,0,0.3);
}

.domain-chip:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.domain-chip.active {
  border-color: var(--red);
  color: var(--ink);
  background: var(--red-soft);
  box-shadow: 2px 2px 0 0 rgba(255,45,45,0.2);
}

.domain-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ── Domain Status ── */
.domain-status { margin-bottom: 16px; display: none; }
.domain-status.visible { display: block; }

.domain-badge {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  border: var(--border-w) solid transparent;
}

.domain-badge.visible { display: flex; }
.domain-badge svg { width: 16px; height: 16px; flex-shrink: 0; }

.domain-badge.approved {
  background: var(--green-soft);
  border-color: rgba(34,197,94,0.3);
  color: var(--green);
}

.domain-badge-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-wrap: wrap;
  gap: 8px;
}

.domain-alive-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.45);
  color: var(--green);
  padding: 3px 8px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.18);
}

.chip-alive-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--green);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 5px;
}

.alive-dot-sm {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 4px var(--green);
}

.alive-pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--green);
  border-radius: 50%;
  position: relative;
  display: inline-block;
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

.alive-pulse-dot::after {
  content: '';
  position: absolute;
  top: -2.5px;
  left: -2.5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--green);
  animation: alivePulse 1.8s infinite cubic-bezier(0.25, 1, 0.5, 1);
  opacity: 0.8;
}

@keyframes alivePulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.domain-badge.not-connected {
  background: var(--red-soft);
  border-color: rgba(255,45,45,0.3);
  color: var(--red);
}

.domain-badge.checking {
  background: var(--yellow-soft);
  border-color: rgba(250,204,21,0.3);
  color: var(--yellow);
}

/* ── Action Buttons ── */
.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: var(--border-w) solid var(--ink);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-hard-sm);
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hard);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  flex: 1;
  background: var(--red);
  color: var(--ink);
}

.btn-secondary {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover { border-color: var(--ink); }

.btn-accent {
  background: var(--surface);
  color: var(--red);
  border-color: var(--red);
}

/* ── Inbox ── */
.inbox-section {
  margin-top: 8px;
}

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
}

.inbox-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.inbox-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-raised);
  padding: 2px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.btn-clear {
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: var(--transition);
}

.btn-clear:hover { color: var(--red-hover); text-decoration: underline; }

.inbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Email Item ── */
.email-item {
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-left: 4px solid transparent;
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: var(--transition);
  animation: fadeInUp 0.25s ease forwards;
}

.email-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hard-sm);
}

.email-item:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.email-item.new-email {
  border-left-color: var(--red);
}

.email-item.expanded {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-glow);
  transform: none;
}

.email-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.email-item-sender {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sender-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--red-soft);
  border: var(--border-w) solid var(--border);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.sender-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.sender-address-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
}

.sender-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.new-badge {
  font-family: var(--font-mono);
  background: var(--red);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--ink);
  box-shadow: 1px 1px 0 0 rgba(0,0,0,0.3);
}

.email-subject {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

.email-body-content {
  display: none;
  margin-top: 12px;
  padding-top: 14px;
  margin-left: 0;
  border-top: 1px solid var(--border);
}

.email-body-content.visible { display: block; }

.email-meta-details {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: text;
  cursor: pointer;
  transition: all 0.2s ease;
}

.email-meta-details:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.15);
}

.email-meta-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text);
  font-size: 12.5px;
}

.email-meta-line .meta-label {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12.5px;
  min-width: 65px;
}

.email-meta-line code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  background: transparent;
  padding: 0;
  border: none;
}

.email-meta-line code.highlight-addr {
  color: var(--yellow) !important;
  font-weight: 600;
  text-shadow: 0 0 10px rgba(255, 214, 0, 0.25);
}

.email-meta-line .meta-subject-val {
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  word-break: break-word;
}

.email-meta-line .meta-date {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.email-body-html {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  word-break: break-word;
  user-select: text;
}

.email-body-html a { color: var(--red-hover); text-decoration: underline; }
.email-body-html img { max-width: 100%; border-radius: var(--radius); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  border: var(--border-w) dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.empty-state p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Loading ── */
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.visible { display: flex; }

.modal-box {
  background: var(--surface);
  border: var(--border-w) solid var(--border-strong);
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-hard-lg);
  animation: slideDown 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: var(--transition);
}

.modal-close:hover { color: var(--red); }

.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  margin-bottom: 8px;
}

.modal-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.modal-input::placeholder { color: var(--text-dim); }

.modal-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.btn-modal-submit {
  width: 100%;
  padding: 12px;
  background: var(--red);
  color: var(--ink);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-hard-sm);
}

.btn-modal-submit:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-hard);
}

.btn-modal-submit:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* ── Toast ── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  background: var(--surface-raised);
  border: var(--border-w) solid var(--border-strong);
  color: var(--ink);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-hard-sm);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Footer ── */
.site-footer {
  margin-top: 48px;
  text-align: center;
  padding: 24px 16px;
  border-top: var(--border-w) solid var(--border);
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: var(--transition);
}

.footer-links a:hover { color: var(--red); }

.footer-links .dot {
  color: var(--text-dim);
  font-size: 8px;
}

.footer-copy {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero-title { font-size: 28px; }
  .email-card { padding: 18px; }
  .email-input { font-size: 13px; }
  .action-row { flex-direction: column; }
  .btn { justify-content: center; }
  .email-subject, .email-body-content, .email-from-detail { margin-left: 0; }
  .email-item { padding: 14px; }
  .topbar-inner { gap: 8px; }
  .status-badge { display: none; }
}