/* ============================================================ tokens */
:root {
  --bg: #f5f4f0;
  --sidebar: #eeece6;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --text: #1c1b18;
  --muted: #6b675f;
  --faint: #9a958b;
  --line: #e6e3db;
  --hover: #f1efe9;
  --active: #e5f2ef;
  --accent: #0f766e;
  --accent-2: #e8a33a;
  --accent-ink: #ffffff;
  --danger: #c2410c;
  --shadow: 0 1px 2px rgba(28, 27, 24, .04), 0 8px 24px rgba(28, 27, 24, .06);
  --shadow-lg: 0 24px 60px rgba(28, 27, 24, .14);
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --av-s: 60%; --av-l: 90%; --av-ink: 30%;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013; --sidebar: #0b0c0f; --panel: #15181d; --panel-2: #1a1e24;
    --text: #ebe8e2; --muted: #9aa0a9; --faint: #646a73; --line: #242930;
    --hover: #1c2027; --active: #12302c; --accent: #2dd4bf; --accent-2: #f5b84f;
    --accent-ink: #04201c; --danger: #fb923c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    --av-s: 32%; --av-l: 22%; --av-ink: 78%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --sidebar: #0b0c0f; --panel: #15181d; --panel-2: #1a1e24;
  --text: #ebe8e2; --muted: #9aa0a9; --faint: #646a73; --line: #242930;
  --hover: #1c2027; --active: #12302c; --accent: #2dd4bf; --accent-2: #f5b84f;
  --accent-ink: #04201c; --danger: #fb923c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --av-s: 32%; --av-l: 22%; --av-ink: 78%;
  color-scheme: dark;
}

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
kbd {
  font: 500 11px/1 var(--font);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--muted);
  background: var(--panel);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================ brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand.big { font-size: 20px; }
.logo {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: inline-block;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 46%, #000 48%);
          mask: radial-gradient(circle, transparent 46%, #000 48%);
}
.logo-xl { width: 64px; height: 64px; opacity: .9; }

/* ============================================================ landing */
.landing { min-height: 100dvh; display: grid; place-items: center; padding: 40px 16px; position: relative; overflow: hidden; }
.landing-glow {
  position: absolute; inset: -20%; pointer-events: none; filter: blur(30px);
  background:
    radial-gradient(38% 32% at 28% 22%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%),
    radial-gradient(32% 28% at 78% 78%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 70%);
}
.landing-card { position: relative; width: 100%; max-width: 520px; animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.landing-title { font: 400 clamp(46px, 9vw, 72px)/1 var(--serif); letter-spacing: -.02em; margin: 26px 0 18px; }
.landing-title em { color: var(--accent); }
.landing-sub { font-size: 16px; line-height: 1.6; color: var(--muted); margin: 0 0 30px; max-width: 450px; }
.gsi-btn {
  display: inline-flex; align-items: center; gap: 12px; height: 50px; padding: 0 24px 0 18px;
  border-radius: 999px; background: #fff; color: #1f1f1f; border: 1px solid #dadce0;
  font-weight: 600; font-size: 15px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .08);
  transition: transform .15s ease, box-shadow .15s ease;
}
.gsi-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 12px 30px rgba(0, 0, 0, .12); }
.gsi-btn:disabled { opacity: .6; cursor: progress; transform: none; }
.landing-error {
  margin: 16px 0 0; font-size: 13.5px; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-radius: 10px; padding: 10px 12px;
}
.trust { list-style: none; padding: 0; margin: 44px 0 0; display: grid; gap: 16px; }
.trust li { display: flex; gap: 14px; align-items: flex-start; }
.trust-icon {
  width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--accent); box-shadow: var(--shadow);
}
.trust strong { display: block; font-weight: 600; margin-bottom: 1px; }
.trust span { color: var(--muted); font-size: 13.5px; }
.fine { margin-top: 32px; font-size: 12.5px; color: var(--faint); }
.fine a { color: inherit; }

/* ============================================================ layout */
.app { display: grid; grid-template-columns: 252px minmax(320px, 410px) 1fr; height: 100dvh; }

/* sidebar */
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px 12px; min-height: 0;
}
.sidebar .brand { padding: 2px 10px 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 10px;
  color: var(--muted); font-weight: 500; text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.nav-item.active svg { color: var(--accent); }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count {
  font-size: 11.5px; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 1px 8px; border-radius: 999px;
}
.nav-section-title { margin: 22px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.nav-labels { flex: 1; min-height: 0; overflow-y: auto; }
.nav-empty { padding: 6px 10px; color: var(--faint); font-size: 13px; }
.label-dot { width: 9px; height: 9px; border-radius: 50%; margin: 0 4.5px; background: var(--faint); flex: none; }
.account { display: flex; align-items: center; gap: 8px; padding: 12px 6px 4px; margin-top: 10px; border-top: 1px solid var(--line); }
.account-info { flex: 1; min-width: 0; }
.me-email { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: 10px;
  color: var(--muted); text-decoration: none; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.menu-btn, .back-btn { display: none; }

/* list pane */
.list-pane { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 16px 14px 6px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 10px 0 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--faint);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font: inherit; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search:focus-within kbd { display: none; }
.list-title { display: flex; align-items: flex-end; justify-content: space-between; padding: 12px 18px 10px; }
.list-title h2 { margin: 0; font: 400 30px/1.1 var(--serif); letter-spacing: -.01em; }
.list-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; min-height: 1em; }
.thread-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 12px; overscroll-behavior: contain; }

.thread {
  position: relative; display: flex; gap: 12px; align-items: flex-start; width: 100%;
  padding: 12px 12px 12px 14px; border-radius: 12px; text-align: left; transition: background .12s;
}
.thread:hover { background: var(--hover); }
.thread.active { background: var(--active); }
.thread.unread::before {
  content: ""; position: absolute; left: 4px; top: 27px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.thread-body { flex: 1; min-width: 0; }
.thread-top { display: flex; align-items: baseline; gap: 6px; }
.thread-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.thread-count { font-size: 11.5px; color: var(--faint); flex: none; }
.thread-date { margin-left: auto; padding-left: 8px; font-size: 12px; color: var(--faint); white-space: nowrap; flex: none; }
.thread-subject { display: flex; align-items: center; gap: 5px; margin-top: 2px; min-width: 0; color: var(--text); }
.subject-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-snippet {
  margin-top: 3px; font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.thread.unread .thread-from, .thread.unread .subject-text { font-weight: 650; }
.thread.unread .thread-date { color: var(--accent); font-weight: 600; }
.star-icon { color: var(--accent-2); fill: var(--accent-2); flex: none; }
.clip-icon { color: var(--faint); flex: none; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 650; font-size: 14px; user-select: none;
  background: hsl(var(--h, 190) var(--av-s) var(--av-l));
  color: hsl(var(--h, 190) 50% var(--av-ink));
}

.list-footer { padding: 12px 0 4px; text-align: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 18px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13.5px;
}
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .6; cursor: progress; }

.empty { text-align: center; padding: 64px 24px; color: var(--muted); max-width: 340px; margin: 0 auto; }
.empty h3 { font: 400 26px/1.2 var(--serif); color: var(--text); margin: 16px 0 6px; }
.empty p { margin: 0 0 18px; font-size: 13.5px; line-height: 1.55; }
.empty-mark {
  width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 46%, #000 48%); mask: radial-gradient(circle, transparent 46%, #000 48%);
  opacity: .7;
}

/* skeletons */
.skel { display: flex; gap: 12px; padding: 12px 12px 12px 14px; animation: fade .4s both; }
.skel-av { width: 36px; height: 36px; border-radius: 50%; background: var(--hover); flex: none; }
.skel-lines { flex: 1; display: grid; gap: 8px; padding-top: 3px; }
.bar {
  height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, var(--hover) 25%, var(--line) 50%, var(--hover) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}

/* reader */
.reader-pane { background: var(--bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.empty-reader { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.empty-reader h3 { font: 400 28px/1.2 var(--serif); color: var(--text); margin: 18px 0 8px; }
.empty-reader p { margin: 0; font-size: 13.5px; }
.reader-loading { margin: auto; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.reader-head { display: flex; align-items: flex-start; gap: 10px; padding: 26px 32px 16px; }
.reader-title { flex: 1; min-width: 0; }
.reader-title h1 { margin: 0; font: 400 34px/1.12 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: var(--active); color: var(--accent); }
.chip-soft { background: var(--hover); color: var(--muted); }
.reader-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 32px 48px; }
.messages { max-width: 880px; display: flex; flex-direction: column; gap: 10px; }

.msg {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; animation: rise .35s cubic-bezier(.2, .7, .2, 1) both;
}
.msg-head { display: flex; gap: 12px; align-items: flex-start; padding: 15px 18px; cursor: pointer; }
.msg-head:focus-visible { outline-offset: -2px; border-radius: var(--radius); }
.msg-meta { flex: 1; min-width: 0; }
.msg-from { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; }
.msg-from strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.msg-email { color: var(--faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.msg-to { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.msg-snippet { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.msg.open .msg-snippet, .msg:not(.open) .msg-to { display: none; }
.msg-date { font-size: 12px; color: var(--faint); white-space: nowrap; padding-top: 2px; }
.msg-content { display: none; padding: 0 18px 18px 68px; }
.msg.open .msg-content { display: block; }
.msg-frame { background: #fff; border-radius: 10px; }
.msg-iframe { display: block; width: 100%; height: 120px; min-height: 40px; border: 0; background: #fff; border-radius: 10px; }
:root[data-theme="dark"] .msg-frame { padding: 16px 18px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-frame { padding: 16px 18px; } }

.privacy-banner {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 9px 12px;
  font-size: 12.5px; color: var(--muted); background: var(--panel-2);
  border: 1px dashed var(--line); border-radius: 10px;
}
.privacy-banner svg { color: var(--accent); flex: none; }
.link-btn { margin-left: auto; color: var(--accent); font-weight: 600; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.attachment {
  display: flex; align-items: center; gap: 10px; max-width: 300px; padding: 8px 12px 8px 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--faint);
  transition: border-color .12s, color .12s;
}
.attachment:hover { border-color: var(--accent); color: var(--accent); }
.att-icon { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--active); color: var(--accent); }
.att-meta { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.att-name { color: var(--text); font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-size { font-size: 11.5px; color: var(--faint); }
.att-dl { flex: none; }
.muted { color: var(--muted); }

/* toasts / banners */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: rise .25s both;
  max-width: calc(100vw - 32px);
}
.reauth {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; max-width: calc(100vw - 32px);
}
.reauth button { background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 8px 14px; border-radius: 10px; white-space: nowrap; }
.scrim { display: none; }

/* ============================================================ responsive */
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(300px, 380px) 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50;
    transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .7, .2, 1); box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .32); }
  .menu-btn { display: inline-grid; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .list-head { padding: 12px 10px 4px; }
  .reader-pane {
    position: fixed; inset: 0; z-index: 30;
    transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .7, .2, 1);
  }
  body.reading .reader-pane { transform: none; }
  .back-btn { display: inline-grid; margin-left: -6px; }
  .reader-head { padding: 12px 12px 12px; padding-top: max(12px, env(safe-area-inset-top)); }
  .reader-title h1 { font-size: 26px; }
  .reader-scroll { padding: 0 10px 32px; }
  .msg-head { padding: 12px; }
  .msg-content { padding: 0 12px 12px; }
  .msg-email { display: none; }
  .landing-title { margin-top: 20px; }
}

/* ============================================================ motion */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { animation-name: toastIn; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

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

/* ============================================================ privacy page */
.policy { max-width: 680px; margin: 0 auto; padding: 56px 20px 80px; line-height: 1.65; }
.policy .brand { text-decoration: none; color: var(--text); margin-bottom: 36px; }
.policy h1 { font: 400 48px/1.05 var(--serif); margin: 0 0 8px; }
.policy h2 { font-size: 16px; margin: 32px 0 6px; }
.policy p { color: var(--muted); margin: 0; }
.policy code { font-size: 13px; background: var(--hover); padding: 1px 6px; border-radius: 5px; }
