/* =========================================================================
   StarMailer — astronaut / deep-space theme
   ========================================================================= */

:root {
  --bg1: #060a1d;
  --bg2: #0b1130;
  --glass: rgba(20, 28, 62, 0.58);
  --glass2: rgba(28, 38, 80, 0.75);
  --line: rgba(130, 155, 255, 0.16);
  --line2: rgba(130, 155, 255, 0.32);
  --txt: #e9eeff;
  --muted: #9aa8d8;
  --faint: #6b78a8;
  --acc: #7c8cff;
  --acc2: #45d6ff;
  --good: #4ade80;
  --bad: #fb7185;
  --grad: linear-gradient(135deg, #6a7bff 0%, #45d6ff 100%);
  --shadow: 0 18px 50px rgba(3, 6, 20, 0.55);
}

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

html, body { height: 100%; }

body {
  font-family: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 85% -10%, #1a2560 0%, transparent 55%),
              radial-gradient(900px 700px at -10% 100%, #12275c 0%, transparent 55%),
              linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  color: var(--txt);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------------------------------------------------------- space scene -- */

.space { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.stars, .stars2, .stars3 {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: transparent; top: 0; left: 0;
}
.stars  { box-shadow: var(--stars1); animation: twinkle 7s ease-in-out infinite; }
.stars2 { box-shadow: var(--stars2); animation: twinkle 11s ease-in-out infinite 2s; }
.stars3 { box-shadow: var(--stars3); animation: twinkle 16s ease-in-out infinite 5s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.9; } 50% { opacity: 0.35; }
}

.planet {
  position: absolute; right: -140px; top: -160px; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #3a4c9c 0%, #1d2a63 45%, #101838 70%, #0a102c 100%);
  box-shadow: 0 0 90px rgba(90, 110, 255, 0.22), inset -30px -30px 80px rgba(0, 0, 0, 0.45);
  opacity: 0.85;
}
.planet::after {
  content: ''; position: absolute; left: -34%; top: 44%; width: 168%; height: 40%;
  border-radius: 50%; border: 2px solid rgba(140, 160, 255, 0.18);
  transform: rotate(-14deg);
}

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

.page { position: relative; z-index: 1; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* -------------------------------------------------------------- login ---- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; gap: 40px; flex-wrap: wrap;
}

.astronaut { width: 250px; max-width: 70vw; animation: floaty 6s ease-in-out infinite; filter: drop-shadow(0 24px 40px rgba(0,0,0,.5)); }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-16px) rotate(2.5deg); }
}

.login-card { width: 400px; max-width: 94vw; padding: 38px 36px 30px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand svg { flex: 0 0 auto; }
.brand .t1 { font-size: 23px; font-weight: 700; letter-spacing: .5px; }
.brand .t1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 8px 0 26px; }

/* ------------------------------------------------------------ controls --- */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.field label { font-size: 12px; font-weight: 500; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.field input, .field textarea, .field select {
  background: rgba(8, 13, 36, 0.7); border: 1px solid var(--line); border-radius: 11px;
  color: var(--txt); font: inherit; font-size: 14.5px; padding: 11px 14px; outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.field input:focus, .field textarea:focus {
  border-color: var(--acc); box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.18); background: rgba(10, 16, 44, 0.9);
}
.field textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.field .hint { font-size: 11.5px; color: var(--faint); }

.btn {
  font: inherit; font-weight: 600; font-size: 14.5px; border: 0; cursor: pointer;
  border-radius: 12px; padding: 12px 22px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .16s, box-shadow .16s, opacity .16s; color: var(--txt);
}
.btn:active { transform: scale(0.975); }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn-primary { background: var(--grad); box-shadow: 0 8px 26px rgba(80, 110, 255, 0.4); }
.btn-primary:hover:not([disabled]) { box-shadow: 0 10px 34px rgba(80, 150, 255, 0.55); transform: translateY(-1px); }
.btn-ghost { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line2); }
.btn-ghost:hover:not([disabled]) { background: rgba(255, 255, 255, 0.11); }
.btn-block { width: 100%; }

.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: rot .7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- chrome -- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 26px; margin: 14px; border-radius: 16px;
  background: rgba(10, 15, 40, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.topbar .brand .t1 { font-size: 19px; }
.topbar nav { display: flex; gap: 6px; margin-left: auto; }
.tab {
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: 10px; padding: 8px 16px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--txt); background: rgba(255,255,255,.06); }
.tab.on { color: #fff; background: rgba(124, 140, 255, 0.16); border-color: rgba(124, 140, 255, 0.45); }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.user-chip b { color: var(--txt); font-weight: 600; }
.user-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); }

/* ------------------------------------------------------------- compose --- */

.main { padding: 0 14px 14px; }
.view { display: none; animation: fadeUp .32s ease both; }
.view.on { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.compose-grid { display: grid; grid-template-columns: minmax(430px, 540px) minmax(420px, 1fr); gap: 16px; align-items: start; padding: 0 0 24px; }
@media (max-width: 1080px) { .compose-grid { grid-template-columns: 1fr; } }

.card { padding: 20px 22px; margin-bottom: 16px; }
.card h2 { font-size: 12px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h2 .n { width: 18px; height: 18px; border-radius: 6px; background: var(--grad); color: #04102a; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

.bank-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bank-chip {
  border: 1.5px solid var(--line); background: rgba(9, 14, 38, 0.55); border-radius: 13px;
  padding: 11px 8px 9px; cursor: pointer; text-align: center; transition: border-color .15s, transform .15s, background .15s;
}
.bank-chip:hover { transform: translateY(-2px); background: rgba(14, 20, 52, 0.8); }
.bank-chip.on { border-color: var(--chip, var(--acc)); box-shadow: 0 0 0 3px rgba(124,140,255,.14), 0 8px 24px rgba(3,6,20,.4); background: rgba(16, 23, 60, 0.85); }
.bank-chip img { height: 26px; max-width: 110px; object-fit: contain; display: block; margin: 0 auto 7px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.bank-chip span { font-size: 12px; color: var(--muted); font-weight: 500; }
.bank-chip.on span { color: var(--txt); }

.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-card {
  border: 1.5px solid var(--line); background: rgba(9, 14, 38, 0.55); border-radius: 13px;
  padding: 14px 12px; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; text-align: left;
}
.type-card:hover { transform: translateY(-2px); background: rgba(14, 20, 52, 0.8); }
.type-card.on { border-color: var(--acc2); box-shadow: 0 0 0 3px rgba(69, 214, 255, .12), 0 8px 24px rgba(3,6,20,.4); background: rgba(16, 23, 60, 0.85); }
.type-card .ico { font-size: 19px; margin-bottom: 8px; display: block; }
.type-card b { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.type-card small { font-size: 11px; color: var(--faint); line-height: 1.45; display: block; }

.var-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.var-grid .field { margin: 0; }
.var-grid .field.full { grid-column: 1 / -1; }
@media (max-width: 640px) { .var-grid { grid-template-columns: 1fr; } }

.rcpt-row { display: flex; gap: 10px; align-items: flex-start; }
.rcpt-row .field { flex: 1; margin: 0; }
.send-row { display: flex; gap: 12px; margin-top: 4px; flex-wrap: wrap; }
.send-row .btn { flex: 1; }

/* ------------------------------------------------------------- preview --- */

.preview-card { position: sticky; top: 92px; padding: 0; overflow: hidden; }
.preview-head { padding: 15px 18px 13px; border-bottom: 1px solid var(--line); }
.preview-head .subj { font-size: 14px; font-weight: 600; line-height: 1.45; word-break: break-word; }
.preview-head .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.preview-head .from { font-size: 12px; color: var(--muted); }
.vp { display: flex; gap: 5px; }
.vp button {
  font: inherit; font-size: 11px; color: var(--muted); background: rgba(255,255,255,.05);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; cursor: pointer; transition: all .15s;
}
.vp button.on { color: #fff; border-color: var(--acc2); background: rgba(69, 214, 255, 0.12); }
.preview-frame-wrap { background: #f4f5f7; }
#previewFrame { width: 100%; height: 760px; border: 0; background: #f4f5f7; display: block; margin: 0 auto; transition: width .25s ease; }
#previewFrame.mobile { width: 400px; }

/* ------------------------------------------------------------- history --- */

table.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hist th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.hist td { padding: 11px 12px; border-bottom: 1px solid rgba(130,155,255,.07); vertical-align: top; }
table.hist tr { transition: background .12s; }
table.hist tr:hover { background: rgba(255,255,255,.03); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 20px; padding: 3px 10px; }
.pill.ok { color: #04250f; background: var(--good); }
.pill.bad { color: #33060d; background: var(--bad); }
.pill.mid { color: #231a04; background: #fbbf24; }
.td-sub { color: var(--txt); font-weight: 500; }
.td-mut { color: var(--muted); }
.td-err { color: var(--bad); font-size: 11.5px; margin-top: 4px; }

/* --------------------------------------------------------------- toast --- */

.toast-zone { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 280px; max-width: 380px; padding: 14px 18px; border-radius: 14px;
  background: var(--glass2); border: 1px solid var(--line2); box-shadow: var(--shadow);
  backdrop-filter: blur(16px); font-size: 13.5px; line-height: 1.5;
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.2) both;
}
.toast.ok { border-color: rgba(74, 222, 128, .5); }
.toast.bad { border-color: rgba(251, 113, 133, .5); }
.toast b { display: block; margin-bottom: 2px; }
.toast.out { animation: toastOut .25s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

.empty { color: var(--faint); text-align: center; padding: 34px 0; font-size: 13.5px; }

/* ------------------------------------------------------------- misc ----- */

.smtp-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 0; border-bottom: 1px solid rgba(130,155,255,.09);
}
.smtp-row:last-child { border-bottom: 0; }
.smtp-info { display: flex; flex-direction: column; gap: 3px; }
.smtp-info b { font-size: 14px; font-weight: 600; }
.smtp-info span { font-size: 12px; }
.smtp-info .muted { color: var(--faint); }
.smtp-actions { display: flex; gap: 8px; align-items: center; }
.btn-sm { font-size: 12px; padding: 7px 13px; border-radius: 9px; }

a { color: var(--acc2); }
.mono { font-family: 'Space Grotesk', ui-monospace, monospace; letter-spacing: .3px; }
.fade-in { animation: fadeUp .4s ease both; }
