/* ==========================
   MyMails – styles.css (FINAL)
   Light + Dark mode (default light)
   Keeps New Email panel + fixes inbox shrink + overlay viewer
   ========================== */

/* ---- Reset ---- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---- Theme tokens ---- */
/* Default = LIGHT */
:root {
  --bg: #ffffff;
  --text: #0b0b0f;
  --text-2: rgba(11,11,15,0.72);
  --text-3: rgba(11,11,15,0.56);

  --panel: rgba(255,255,255,0.92);
  --border: rgba(11,11,15,0.12);

  --purple: #6a3cff;
  --orange: #ff5a1f;
  --green: #0f9d67;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(11,11,15,0.10);

  --topbar-bg: rgba(255,255,255,0.78);
  --topbar-border: rgba(11,11,15,0.10);

  --hover: rgba(11,11,15,0.04);
  --ghost-bg: rgba(11,11,15,0.04);
  --field-bg: rgba(11,11,15,0.03);
  --skel-bg: rgba(11,11,15,0.06);
  --skel-shine: rgba(11,11,15,0.12);

  --overlay: rgba(11,11,15,0.12);
}
/* ==========================
   Light mode polish
   ========================== */
    html:not([data-theme="dark"]) body {
      background:
        radial-gradient(900px 420px at 15% 10%, rgba(106, 60, 255, 0.12), transparent 55%),
        radial-gradient(900px 420px at 85% 30%, rgba(255, 90, 31, 0.10), transparent 55%),
        linear-gradient(#ffffff, #ffffff);
    }
    
    /* Softer, richer panels in light mode */
    html:not([data-theme="dark"]) {
      --panel: rgba(255,255,255,0.92);
      --border: rgba(11,11,15,0.10);
      --shadow: 0 14px 44px rgba(11,11,15,0.10);
      --hover: rgba(11,11,15,0.035);
      --ghost-bg: rgba(11,11,15,0.035);
      --field-bg: rgba(11,11,15,0.025);
      --overlay: rgba(11,11,15,0.10);
    }
    
    /* Give cards + main blocks a subtle highlight edge */
    html:not([data-theme="dark"]) .emailbar,
    html:not([data-theme="dark"]) .mailbox,
    html:not([data-theme="dark"]) .card,
    html:not([data-theme="dark"]) .faq,
    html:not([data-theme="dark"]) .contact,
    html:not([data-theme="dark"]) .seo-block {
      background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.90));
      border: 1px solid rgba(11,11,15,0.10);
      box-shadow: 0 18px 55px rgba(11,11,15,0.10);
    }
    
    /* Make hero pop more in light mode */
    html:not([data-theme="dark"]) .hero__badge {
      box-shadow: 0 14px 40px rgba(255, 90, 31, 0.22);
    }
    html:not([data-theme="dark"]) .hero h1 {
      text-shadow: 0 10px 35px rgba(106, 60, 255, 0.12);
    }
    /* Light mode polish */
    html:not([data-theme="dark"]) .card,
    html:not([data-theme="dark"]) .faq,
    html:not([data-theme="dark"]) .mailbox,
    html:not([data-theme="dark"]) .emailbar {
      box-shadow: 0 8px 22px rgba(10,10,15,0.06);
    }


/* DARK */
html[data-theme="dark"] {
  --bg: #000000;
  --text: #ffffff;
  --text-2: rgba(255,255,255,0.72);
  --text-3: rgba(255,255,255,0.56);

  --panel: rgba(15, 15, 15, 0.92);
  --border: rgba(255, 255, 255, 0.08);

  --purple: #7b4dff;
  --orange: #ff5a1f;
  --green: #19c37d;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

  --topbar-bg: rgba(0,0,0,0.78);
  --topbar-border: rgba(255,255,255,0.06);

  --hover: rgba(255,255,255,0.04);
  --ghost-bg: rgba(255,255,255,0.04);
  --field-bg: rgba(0,0,0,0.35);
  --skel-bg: rgba(255,255,255,0.06);
  --skel-shine: rgba(255,255,255,0.12);

  --overlay: rgba(0,0,0,0.65);
}

/* ---- Containers / Typography ---- */
.container {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--purple); }

.section-title {
  font-size: clamp(1.35rem, 1rem + 1vw, 2rem);
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}

.section-desc { margin: 0 0 20px; color: var(--text-2); }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--topbar-border);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
}

.brand__logo {
  height: 36px;
  width: auto;
  display: block;
}

.topnav { display: flex; gap: 18px; flex-wrap: wrap; }
.topnav a { font-size: 0.95rem; color: var(--text-2); }
.topnav a:hover { color: var(--purple); }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================
   iPhone-style theme switch
   ========================== */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.theme-switch__label {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-2);
}

/* Switch button */
.switch {
  position: relative;
  width: 52px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(127,127,127,0.16);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(11,11,15,0.10);
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
}

.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 20px rgba(11,11,15,0.18);
  transition: transform 180ms ease;
}

/* On (dark) */
.switch.is-dark {
  background: rgba(123, 77, 255, 0.35);
  border-color: rgba(123, 77, 255, 0.45);
}
.switch.is-dark .switch__thumb {
  transform: translateX(22px);
}

/* Respect dark mode contrast */
html[data-theme="dark"] .switch {
  box-shadow: 0 10px 26px rgba(0,0,0,0.55);
}
html[data-theme="dark"] .switch__thumb {
  background: rgba(255,255,255,0.92);
}


.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(127,127,127,0.08);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}
.theme-toggle:hover { border-color: rgba(106,60,255,0.45); }
.theme-toggle__icon { width: 18px; display: inline-flex; justify-content: center; }
.theme-toggle__text { font-size: 0.92rem; }

/* ---- Hero ---- */
.hero {
  padding: 54px 0 34px;
  background:
    radial-gradient(700px 320px at 50% 20%, rgba(123, 77, 255, 0.18), transparent 60%),
    radial-gradient(700px 320px at 30% 75%, rgba(255, 90, 31, 0.12), transparent 55%),
    linear-gradient(rgba(127,127,127,0.02), rgba(127,127,127,0.02));
}
html[data-theme="dark"] .hero {
  background:
    radial-gradient(700px 320px at 50% 20%, rgba(123, 77, 255, 0.22), transparent 60%),
    radial-gradient(700px 320px at 30% 75%, rgba(255, 90, 31, 0.16), transparent 55%),
    linear-gradient(rgba(0,0,0,0.92), rgba(0,0,0,0.92));
}

.hero__inner { display: grid; gap: 22px; }

.hero__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff; /* intentional */
  font-weight: 800;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.65rem, 1.2rem + 2vw, 2.6rem);
  line-height: 1.15;
  color: var(--purple);
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--text-2);
  max-width: 820px;
}

/* ---- Email bar ---- */
.emailbar {
  margin-top: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.emailbar__row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.emailbar__addrwrap { min-width: 240px; flex: 1; }

.emailbar__label { display: block; font-size: 0.85rem; color: var(--text-2); }

.emailbar__addr {
  margin-top: 6px;
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--green);
  word-break: break-word;
}

.emailbar__hint { margin-top: 5px; font-size: 0.9rem; color: var(--text-3); }

.emailbar__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.emailbar__new {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---- New email panel ---- */
.newemail {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  align-items: end;
}
.newemail__col { min-width: 0; }
.newemail__actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Fields ---- */
.fieldlabel {
  display: block;
  font-size: 0.88rem;
  color: var(--text-2);
  margin-bottom: 6px;
}
.fieldhelp {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-3);
}
.field {
  width: 100%;
  border-radius: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--text);
  outline: none;
}
.field:focus {
  border-color: rgba(123, 77, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(123, 77, 255, 0.18);
}

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.04s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--purple); color: #fff; }
.btn--primary:hover { background: #5c2fff; }

.btn--ghost {
  background: var(--ghost-bg);
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover {
  border-color: rgba(123, 77, 255, 0.55);
  color: var(--purple);
}
.btn--full { width: 100%; }

/* ---- Mailbox ---- */
.mailbox {
  position: relative;
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mailbox__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.mailbox__title { margin: 0; font-size: 1.05rem; letter-spacing: -0.01em; }

.mailbox__meta {
  font-size: 0.9rem;
  color: var(--text-2);
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.dot { opacity: 0.55; }

/* Stable height always */
.mailbox__list { min-height: 320px; display: block; }

/* IMPORTANT FIX: keep space even when JS sets hidden=true */
#mailList[hidden]{
  display: block !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Empty state */
.mail-empty { padding: 26px 16px; text-align: center; color: var(--text-2); }
.mail-empty__title { font-weight: 900; font-size: 1.05rem; margin-bottom: 8px; color: var(--text); }
.mail-empty__text { max-width: 520px; margin: 0 auto; color: var(--text-3); font-size: 0.95rem; }

/* Loading skeleton */
.mail-loading { padding: 16px; }
.skel {
  height: 14px;
  border-radius: 10px;
  margin: 10px 0;
  background: var(--skel-bg);
  overflow: hidden;
  position: relative;
}
.skel::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  height: 100%;
  width: 40%;
  background: var(--skel-shine);
  filter: blur(10px);
  animation: skel 1.2s infinite;
}
@keyframes skel {
  0% { left: -40%; }
  100% { left: 120%; }
}

/* Mail items */
.mail-item {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.mail-item:hover { background: var(--hover); }

.mail-from {
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mail-subject {
  margin-top: 3px;
  font-size: 0.92rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mail-date {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--text-3);
}

/* ---- Viewer Overlay ---- */
.mailbox__viewer[hidden] { display: none !important; }

.mailbox__viewer {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.viewer__head {
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.viewer__subject { font-weight: 900; font-size: 1.02rem; color: var(--text); }
.viewer__meta { margin-top: 4px; color: var(--text-2); font-size: 0.9rem; }

.viewer__body {
  padding: 16px;
  color: var(--text);
  overflow: auto;
  overflow-wrap: anywhere;
}
.viewer__body a { color: var(--orange); text-decoration: underline; }
.viewer__body pre { white-space: pre-wrap; word-wrap: break-word; margin: 0; }

/* ---- Sections ---- */
section { padding: 46px 0; }

.section-alt {
  background: linear-gradient(rgba(127,127,127,0.02), rgba(127,127,127,0.02));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Cards */
.cards {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 1.02rem; color: var(--text); }
.card p { margin: 0; color: var(--text-2); font-size: 0.95rem; }

/* SEO block */
.seo-block {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.seo-block h3 { margin: 0 0 8px; color: var(--orange); }
.seo-block p { margin: 0; color: var(--text-2); }

/* FAQ */
.faq {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.faq__item + .faq__item { border-top: 1px solid var(--border); }
.faq__q {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.faq__q:hover { background: var(--hover); }
.faq__icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--purple);
}
.faq__a { padding: 0 16px 14px; }
.faq__a p { margin: 0; color: var(--text-2); }

/* ==========================
   FAQ – Visual Refinement
   ========================== */

.faq__q {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
  letter-spacing: -0.01em;
}

.faq__q:hover {
  background: rgba(127,127,127,0.06);
}

/* Icon refinement */
.faq__icon {
  border-radius: 50%;
  font-weight: 700;
  background: rgba(127,127,127,0.10);
  border: none;
}

/* Answer text */
.faq__a p {
  font-weight: 400;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--muted);
}


/* Contact */
.contact {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.formnote { margin-top: 10px; min-height: 20px; font-size: 0.95rem; color: var(--text-2); }

/* Footer */
.footer { padding: 28px 0; border-top: 1px solid var(--border); }
.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-3);
  font-size: 0.92rem;
}
.footer__links a { color: var(--text-2); }
.footer__links a:hover { color: var(--orange); }

/* Responsive */
@media (max-width: 980px) {
  .cards { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topnav { display: none; }
  .row { grid-template-columns: 1fr; }
  .newemail { grid-template-columns: 1fr; }
  .emailbar__actions { width: 100%; }
  .emailbar__actions .btn { flex: 1; }
}

/* --- Fix theme toggle alignment (put at end of CSS) --- */
.topbar__actions {
  display: flex;
  align-items: center;
}

.theme-switch {
  display: inline-flex;
  align-items: center;     /* key */
  gap: 10px;
  height: 36px;            /* match logo height */
}

.theme-switch__label {
  display: inline-flex;
  align-items: center;     /* key */
  line-height: 1;          /* prevents baseline drift */
  margin: 0;
  padding: 0;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-2);
}

/* Make the switch behave like an inline-flex control */
.switch {
  display: inline-flex;    /* key */
  align-items: center;     /* key */
  justify-content: flex-start;
  vertical-align: middle;
  margin: 0;               /* prevents any default offset */
  padding: 0;
  width: 52px;
  height: 30px;
  border-radius: 999px;
}

/* Ensure thumb is perfectly centered vertically */
.switch__thumb {
  top: 50%;
  transform: translateY(-50%);
  left: 3px;
}

/* Dark state: move thumb right while keeping vertical centering */
.switch.is-dark .switch__thumb {
  transform: translate(22px, -50%);
}

/* Inline message beside Use Custom */
.inline-msg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
}

.inline-msg:empty {
  display: none;
}

/* Variants */
.inline-msg--error {
  border-color: rgba(255, 90, 31, 0.35);
}

.inline-msg--ok {
  border-color: rgba(15, 157, 103, 0.35);
}

/* On small screens let it go to next line */
@media (max-width: 720px) {
  .inline-msg {
    width: 100%;
    white-space: normal;
  }
}

/* ==========================
   Typography Refinement
   ========================== */


/* Section titles: confident but not aggressive */
.section-title {
  font-weight: 700;
}

/* Reduce heavy bold usage in body/UI */
.emailbar__addr,
.mail-from,
.viewer__subject {
  font-weight: 650;
}

/* Meta / secondary text */
.mail-subject,
.mail-date,
.mailbox__meta,
.fieldhelp,
.section-desc {
  font-weight: 400;
}

/* Buttons: readable, not bulky */
.btn {
  font-weight: 600;
}

/* ==========================
   Back to Top Button
   ========================== */

.backtotop {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--orange);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;

  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    background 0.2s ease;
  z-index: 90;
}

/* Visible state */
.backtotop.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.backtotop:hover {
  background: var(--green);
}

/* Light mode subtle shadow */
html:not([data-theme="dark"]) .backtotop {
  box-shadow: 0 8px 18px rgba(10,10,15,0.18);
}

/* Mobile comfort */
@media (max-width: 720px) {
  .backtotop {
    right: 14px;
    bottom: 14px;
    width: 42px;
    height: 42px;
  }
}
/* ==========================
   Ads (centered + responsive)
   ========================== */

.ad-slot {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.ad-slot__inner {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* Make ad iframe fit smaller screens without breaking layout */
.ad-slot iframe {
  max-width: 100%;
}

/* ==========================
   Light Mode – Viewer Fix
   ========================== */

html:not([data-theme="dark"]) .mailbox__viewer {
  background: #ffffff;      /* full white */
  backdrop-filter: none;    /* remove blur */
}

html:not([data-theme="dark"]) .viewer__head {
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

html:not([data-theme="dark"]) .viewer__subject {
  color: #111111;
}

html:not([data-theme="dark"]) .viewer__meta {
  color: rgba(0,0,0,0.65);
}

html:not([data-theme="dark"]) .viewer__body {
  color: #222222;
}