/* Primemailz Inbox — familiar mail-client layout (dark default, light toggle). Original emails render in a
   sandboxed iframe on a white "paper" so they look exactly as the sender designed them. */
:root {
  --font: "Google Sans Flex", "Google Sans", Roboto, "Segoe UI", Arial, sans-serif;
  --bg: #f6f8fc; --surface: #fff; --read: #f2f6fc; --text: #1f1f1f; --text2: #444746; --text3: #5e5e5e;
  --line: #e1e5ea; --hover: rgba(68, 71, 70, .08); --search: #e9eef6; --search-on: #fff;
  --compose: #c2e7ff; --on-compose: #001d35; --nav-on: #d3e3fd; --on-nav: #041e49;
  --accent: #0b57d0; --on-accent: #fff; --notice: #e8f0fe; --on-notice: #1f3760;
  --code-bg: #e8f0fe; --digit: #fff; --digit-line: #c4d3ec; --ok: #146c2e; --warn-bg: #fef7e0; --warn: #7a4f01;
  --shadow: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --row-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
}
[data-theme="dark"] {
  --bg: #131314; --surface: #1e1f20; --read: #1e1f20; --text: #e3e3e3; --text2: #c4c7c5; --text3: #a2a6ab;
  --line: #333537; --hover: rgba(227, 227, 227, .08); --search: #282a2c; --search-on: #333537;
  --compose: #004a77; --on-compose: #c2e7ff; --nav-on: #004a77; --on-nav: #c2e7ff;
  --accent: #a8c7fa; --on-accent: #062e6f; --notice: #1f2a3a; --on-notice: #c9d8f1;
  --code-bg: #1d2b3e; --digit: #131314; --digit-line: #3b4d66; --ok: #6dd58c; --warn-bg: #3a2e12; --warn: #f6d58a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .25);
  --row-shadow: inset 0 -1px 0 #3c4043, 0 1px 3px rgba(0, 0, 0, .6);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.center { text-align: center; }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.top { height: 64px; display: flex; align-items: center; gap: 4px; padding: 8px 12px 8px 8px; position: sticky; top: 0; z-index: 20; background: var(--bg); }
.ib { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text2); cursor: pointer; text-decoration: none; }
.ib:hover { background: var(--hover); }
.ib:disabled { opacity: .45; cursor: default; background: none; }
.ib-sm { width: 32px; height: 32px; }
.ib-sm svg { width: 20px; height: 20px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text2); width: 200px; padding-left: 6px; }
.brand span { font-size: 22px; letter-spacing: -.2px; color: var(--text2); }
.search { flex: 1; max-width: 720px; height: 48px; border-radius: 24px; background: var(--search); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 16px; }
.search:focus-within { background: var(--search-on); box-shadow: var(--shadow); }
.search-ico { color: var(--text2); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font: 16px var(--font); }
.search input::-webkit-search-cancel-button { display: none; }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-left: 8px; }
[data-theme="dark"] .ico-moon, [data-theme="light"] .ico-sun { display: none; }
.avatar-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; margin-left: 4px; cursor: pointer; background: #0b8043; color: #fff;
  font-size: 18px; font-weight: 500; box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--line); }
.pop { position: absolute; right: 12px; top: 62px; width: min(360px, calc(100vw - 24px)); background: var(--surface); border-radius: 28px; padding: 18px 20px 20px;
  box-shadow: var(--shadow); text-align: center; z-index: 40; }
.pop-addr { font-size: 14px; color: var(--text2); word-break: break-all; }
.pop-av { width: 72px; height: 72px; border-radius: 50%; margin: 14px auto 8px; background: #0b8043; color: #fff; font-size: 34px; display: flex; align-items: center; justify-content: center; }
.pop-hi { font-size: 20px; margin-bottom: 14px; }
.pop-note { font-size: 12.5px; color: var(--text2); margin: 14px 4px 0; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: calc(100vh - 64px); }
.side { width: 256px; flex: none; padding: 8px 12px 16px 0; display: flex; flex-direction: column; position: sticky; top: 64px; height: calc(100vh - 64px); }
.compose { margin: 0 0 16px 8px; height: 56px; min-width: 150px; align-self: flex-start; border: 0; border-radius: 16px; padding: 0 24px 0 18px;
  background: var(--compose); color: var(--on-compose); display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.compose:hover { box-shadow: var(--shadow); }
.nav-i { display: flex; align-items: center; gap: 18px; height: 32px; padding: 0 12px 0 26px; border-radius: 0 16px 16px 0; color: var(--text);
  text-decoration: none; font-size: 14px; }
.nav-i svg { width: 20px; height: 20px; color: var(--text2); }
.nav-i:hover { background: var(--hover); }
.nav-i.on { background: var(--nav-on); color: var(--on-nav); font-weight: 700; }
.nav-i.on svg { color: var(--on-nav); }
.nav-i b { margin-left: auto; font-size: 12px; font-weight: 700; }
.side-brand { display: none; align-items: center; gap: 10px; padding: 4px 0 16px 26px; font-size: 20px; color: var(--text2);
  border-bottom: 1px solid var(--line); margin-bottom: 8px; }
@media (max-width: 1023px) { .side-brand { display: flex; } }
.side-foot { margin-top: auto; padding: 0 12px 0 26px; font-size: 12px; color: var(--text3); }
.live { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text2); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #1e8e3e; box-shadow: 0 0 0 0 rgba(30, 142, 62, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(30, 142, 62, 0); } 100% { box-shadow: 0 0 0 0 rgba(30, 142, 62, 0); } }
.main { flex: 1; min-width: 0; padding: 0 16px 16px 0; }
.card { background: var(--surface); border-radius: 16px; min-height: calc(100vh - 80px); overflow: hidden; }
.card-narrow { max-width: 640px; min-height: 0; margin: 24px auto; }

/* ---------- list ---------- */
.bar { height: 48px; display: flex; align-items: center; gap: 4px; padding: 0 8px 0 12px; }
.bar-note { font-size: 13px; color: var(--text2); margin-left: 4px; }
.bar-r { margin-left: auto; display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text2); }
#refresh.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding-left: 4px; }
.tab { height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px; min-width: 220px; font-size: 14px; font-weight: 500; color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent); }
.tab svg { width: 20px; height: 20px; }
.notice { display: flex; gap: 12px; align-items: flex-start; margin: 12px 16px 4px; padding: 10px 14px; border-radius: 12px; background: var(--notice); color: var(--on-notice); font-size: 13px; }
.notice svg { width: 20px; height: 20px; margin-top: 1px; }
.row { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--line); background: var(--read);
  color: var(--text); text-decoration: none; cursor: pointer; }
.row:hover { box-shadow: var(--row-shadow); position: relative; z-index: 1; }
.row.unread { background: var(--surface); font-weight: 700; }
.row .av { display: none; }
.r-from { width: 200px; flex: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.r-mid { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); }
.r-snip { color: var(--text2); font-weight: 400; }
.r-code { flex: none; font-size: 12px; font-weight: 700; color: var(--accent); border: 1px solid var(--digit-line); border-radius: 8px; padding: 1px 7px; letter-spacing: .5px; }
.r-time { flex: none; width: 64px; text-align: right; font-size: 12px; color: var(--text2); }
.row.unread .r-time { color: var(--text); }
.row.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: var(--code-bg); } }
.empty { text-align: center; padding: 56px 20px; color: var(--text2); }
.empty svg { width: 56px; height: 56px; opacity: .5; }
.empty-t { font-size: 18px; color: var(--text); margin: 10px 0 4px; }

/* latest-code strip (top of the list) */
.strip { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 16px; padding: 14px 16px; border-radius: 16px; background: var(--code-bg); }
.strip.old { background: none; border: 1px solid var(--line); }
.strip-t { flex: 1; min-width: 200px; }
.strip-l { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.strip-l svg { width: 16px; height: 16px; }
.strip-s { font-size: 13px; color: var(--text2); margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.strip-s a { color: inherit; }
.new-badge { font-size: 11px; font-weight: 700; color: var(--ok); }
.strip.wait { background: none; border: 1px dashed var(--line); color: var(--text2); font-size: 13px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.strip.arrived { animation: pop .6s ease-out; }
@keyframes pop { 0% { transform: scale(.98); box-shadow: 0 0 0 0 var(--accent); } 60% { box-shadow: 0 0 0 6px transparent; } 100% { transform: none; } }

/* code digits (strip + reading view) */
.digits { display: flex; gap: 6px; flex-wrap: wrap; }
.digits span { min-width: 34px; height: 44px; padding: 0 6px; border-radius: 8px; background: var(--digit); border: 1px solid var(--digit-line); display: flex;
  align-items: center; justify-content: center; font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pill { height: 40px; border-radius: 20px; padding: 0 20px; border: 1px solid var(--line); background: var(--surface); color: var(--accent); display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; }
.pill svg { width: 18px; height: 18px; }
.pill:hover { background: var(--hover); }
.pill-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pill-primary:hover { background: var(--accent); box-shadow: var(--shadow); }
.pill.done { color: var(--ok); }
.pill-primary.done { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }

/* ---------- reading view ---------- */
.read { padding: 4px 24px 32px 72px; }
.subject { font-size: 22px; font-weight: 400; line-height: 1.35; margin: 4px 0 16px; word-break: break-word; }
.lbl { font-size: 12px; vertical-align: middle; background: var(--search); color: var(--text2); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.codecard { background: var(--code-bg); border-radius: 16px; padding: 16px 20px; margin: 0 0 18px; max-width: 760px; }
.codecard h3 { margin: 0 0 12px; font-size: 16px; font-weight: 500; }
.codecard .row-b { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.codecard .src { font-size: 12px; color: var(--text2); margin-top: 12px; }
.sender { display: flex; align-items: flex-start; gap: 12px; margin-left: -52px; }
.sender-t { flex: 1; min-width: 0; }
.sender-t b { font-weight: 700; }
.addr { font-size: 12px; color: var(--text2); }
.tome { font-size: 12px; color: var(--text2); display: flex; align-items: center; }
.tome svg { width: 18px; height: 18px; }
.mtime { font-size: 12px; color: var(--text2); white-space: nowrap; padding-top: 2px; }
.paper { margin-top: 16px; background: #fff; border-radius: 12px; overflow: hidden; }
[data-theme="dark"] .paper { box-shadow: 0 0 0 1px #2c2d2f; }
.paper iframe { display: block; width: 100%; height: 360px; border: 0; background: #fff; }

/* avatars */
.av { width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
  font-weight: 500; position: relative; overflow: hidden; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; padding: 8px; background: #fff; display: none; }
.av.img img { display: block; }
.av i { font-style: normal; }
body.home .main { padding: 0 16px; }

/* ---------- help ---------- */
.doc { padding: 8px 32px 32px; max-width: 760px; }
.doc h1 { font-size: 24px; font-weight: 400; margin: 12px 0 16px; }
.doc h2 { font-size: 18px; font-weight: 500; margin: 28px 0 10px; display: flex; align-items: center; gap: 8px; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 12px; }
.steps li b { display: block; }
.steps li span { color: var(--text2); }
.important { scroll-margin-top: 76px; background: var(--warn-bg); color: var(--warn); border-radius: 16px; padding: 4px 18px 6px; margin-top: 20px; }
.important h2 { margin-top: 14px; }
.important .muted { color: inherit; opacity: .85; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { cursor: pointer; font-weight: 500; }
details p { color: var(--text2); margin: 8px 0 0; }
.private { display: flex; gap: 8px; align-items: center; color: var(--text2); font-size: 13px; margin-top: 24px; }
.private svg { width: 18px; height: 18px; }
.find { display: flex; gap: 10px; margin: 18px 0 8px; flex-wrap: wrap; }
.find input { flex: 1; min-width: 220px; height: 48px; border-radius: 24px; border: 1px solid var(--line); background: var(--search); color: var(--text);
  padding: 0 20px; font: 16px var(--font); outline: 0; }
.find input:focus { border-color: var(--accent); }
.find .pill { height: 48px; border-radius: 24px; }
.err { color: #d93025; font-size: 13px; }
#lastLink { margin: 8px 0; }

/* ---------- mobile FAB, drawer, toast ---------- */
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 56px; border: 0; border-radius: 16px; padding: 0 20px 0 16px;
  background: var(--compose); color: var(--on-compose); display: none; align-items: center; gap: 12px; font-weight: 500; box-shadow: var(--shadow); z-index: 25; cursor: pointer; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 29; }
.toast { position: fixed; left: 24px; bottom: 24px; background: #303030; color: #f2f2f2; padding: 14px 20px; border-radius: 8px; font-size: 14px;
  transform: translateY(calc(100% + 48px)); visibility: hidden; transition: transform .25s, visibility .25s; z-index: 50; max-width: calc(100vw - 48px); }
[data-theme="dark"] .toast { background: #e3e3e3; color: #1f1f1f; }
.toast.show { transform: none; visibility: visible; }
.toast-act { margin-left: 20px; border: 0; background: none; color: #a8c7fa; font-weight: 600; cursor: pointer; padding: 4px 6px; font-size: 14px; }
[data-theme="dark"] .toast-act { color: #0b57d0; }
.acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.acts .digits, .row-b .digits { margin-right: 6px; }
.r-code svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }

@media (max-width: 1023px) {
  .side { position: fixed; left: 0; top: 0; height: 100%; z-index: 30; background: var(--surface); padding-top: 16px; transform: translateX(-100%);
    transition: transform .2s; width: 280px; border-radius: 0 16px 16px 0; }
  .side.open { transform: none; }
  .main { padding: 0 8px 88px; }
  .brand { width: auto; }
  .fab.show { display: flex; }
  .compose { display: none; }
}
@media (max-width: 720px) {
  /* phone: Gmail-app style — one rounded search bar holds the menu and the account button */
  .top { height: 64px; padding: 8px 12px; }
  .top > #menuBtn { position: absolute; left: 18px; z-index: 2; }
  .brand, .hide-sm { display: none; }
  body.home .brand { display: flex; }
  .search { max-width: none; padding-left: 52px; }
  .search-ico { display: none; }
  .top-r { position: absolute; right: 18px; padding: 0; }
  .top-r .ib { width: 36px; height: 36px; }
  .avatar-btn { width: 32px; height: 32px; font-size: 15px; box-shadow: none; }
  .search { padding-right: 84px; }
  .main { padding: 0 0 88px; }
  .card { border-radius: 0; min-height: calc(100vh - 64px); background: var(--bg); }
  [data-theme="light"] .card { background: #fff; }
  .tabs, .bar-note { display: none; }
  .notice { margin: 4px 12px 8px; }
  .row { height: auto; align-items: flex-start; padding: 10px 16px; gap: 14px; border-bottom: 0; background: none; flex-wrap: wrap; position: relative; }
  .row.unread { background: none; }
  .row:hover { box-shadow: none; background: var(--hover); }
  .row .av { display: flex; }
  .r-body { flex: 1; min-width: 0; }
  .r-top { display: flex; gap: 8px; align-items: baseline; }
  .r-from { width: auto; flex: 1; font-size: 16px; }
  .r-time { width: auto; }
  .r-mid { display: block; white-space: nowrap; font-size: 14px; }
  .r-snip { display: block; overflow: hidden; text-overflow: ellipsis; }
  .r-code { position: absolute; right: 16px; bottom: 12px; background: var(--surface); }
  .r-dash { display: none; }
  .row.has-code .r-snip { padding-right: 84px; }
  .strip { margin: 8px 12px; }
  .digits span { min-width: 30px; height: 40px; font-size: 22px; }
  .read { padding: 0 12px 24px; }
  .subject { font-size: 20px; }
  .sender { margin-left: 0; }
  .sender .addr, .mtime .ago { display: none; }
  body.reading .fab { display: none; }
  .sender .av { width: 36px; height: 36px; }
  .paper { margin: 14px -12px 0; border-radius: 0; }
  .doc { padding: 4px 16px 24px; }
  .toast { left: 12px; right: 12px; bottom: 84px; max-width: none; }
}
@media (min-width: 721px) {
  .r-body { display: contents; }
  .r-top { display: contents; }
  .r-top .r-time { order: 9; }
}
