:root {
  --bg: #000;
  --surface: #0b0b0c;
  --raised: #141416;
  --raised-2: #1c1c1f;
  --glass: rgba(10, 10, 11, 0.68);
  --pop: rgba(14, 14, 16, 0.94);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f2f2f3;
  --text-2: #a0a0a8;
  --text-3: #8a8a93;
  --btn: #f2f2f3;
  --btn-ink: #0a0a0b;
  --bad: #ff7a7a;
  --ok: #9fe0bd;
  --accent: var(--text);
  --muted: var(--text-3);
  --sans: 'Hanken Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --streak: rgba(255, 255, 255, 0.07);
  color-scheme: dark;
}

html.light {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --raised: #f0f0f2;
  --raised-2: #e6e6e9;
  --glass: rgba(255, 255, 255, 0.78);
  --pop: rgba(255, 255, 255, 0.96);
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.14);
  --text: #111113;
  --text-2: #55555c;
  --text-3: #6b6b73;
  --btn: #111113;
  --btn-ink: #ffffff;
  --bad: #c43b3b;
  --ok: #23855a;
  --streak: rgba(0, 0, 0, 0.05);
  color-scheme: light;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

.streak {
  position: fixed;
  inset: -20vh -20vw;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(168deg, transparent 52%, color-mix(in srgb, var(--streak) 50%, transparent) 57%, var(--streak) 59%, color-mix(in srgb, var(--streak) 40%, transparent) 61.5%, transparent 67%);
  filter: blur(24px);
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- shared controls ---------- */

.btn,
.icon-btn,
.logout,
.refresh,
.mv-back,
.mv-actions button,
.mbtn,
.sa-remove,
.pagination button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}

.icon-btn:hover,
.logout:hover,
.refresh:hover,
.mv-back:hover,
.mv-actions button:hover,
.mbtn-outline:hover,
.sa-remove:hover,
.pagination button:hover:not(:disabled) {
  background: var(--raised);
  border-color: var(--line-2);
}

.icon-btn:active,
.logout:active,
.refresh:active,
.mv-back:active,
.mv-actions button:active,
.mbtn:active,
.btn:active {
  transform: scale(0.97);
}

.icon-btn svg,
.refresh svg,
.mv-back svg {
  flex-shrink: 0;
  color: var(--text-2);
}

/* primary: the single white pill */
.btn,
.mbtn-accent {
  background: var(--btn);
  border-color: transparent;
  color: var(--btn-ink);
}

.btn:hover,
.mbtn-accent:hover {
  background: color-mix(in srgb, var(--btn) 88%, var(--bg));
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.mbtn-danger,
.mv-actions .btn-del:hover,
.sa-remove:hover {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 8%, var(--surface));
}

.mbtn-danger:hover {
  background: color-mix(in srgb, var(--bad) 14%, var(--surface));
}

/* switches (login + settings share the look) */

.lc-box,
.cc-box {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--raised);
  transition: background-color 200ms var(--ease), border-color 200ms var(--ease);
}

.lc-box::after,
.cc-box::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--text-3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 420ms var(--spring), width 220ms var(--ease), background-color 200ms var(--ease);
}

/* the check rides inside the knob */
.lc-box svg,
.cc-box svg {
  position: absolute;
  z-index: 1;
  top: 6px;
  left: 22px;
  width: 10px;
  height: 10px;
  color: var(--btn);
  opacity: 0;
  transform: scale(0.3) rotate(-30deg);
  transition: opacity 160ms var(--ease), transform 380ms var(--spring);
  pointer-events: none;
}

.login-check input:checked + .lc-box svg,
.custom-check input:checked + .cc-box svg {
  opacity: 1;
  transform: none;
  transition-delay: 90ms;
}

/* press-and-hold stretches the knob toward where it's going */
.login-check:active .lc-box::after,
.custom-check:active .cc-box::after {
  width: 23px;
}

.login-check:active input:checked + .lc-box::after,
.custom-check:active input:checked + .cc-box::after {
  transform: translateX(11px);
}

.login-check:hover input:not(:checked) + .lc-box,
.custom-check:hover input:not(:checked) + .cc-box {
  background: var(--raised-2);
}

.login-check input,
.custom-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.login-check input:checked + .lc-box,
.custom-check input:checked + .cc-box {
  background: var(--btn);
  border-color: transparent;
}

.login-check input:checked + .lc-box::after,
.custom-check input:checked + .cc-box::after {
  background: var(--btn-ink);
  transform: translateX(16px);
}

.login-check input:focus-visible + .lc-box,
.custom-check input:focus-visible + .cc-box {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.custom-check {
  display: inline-flex;
  cursor: pointer;
}

/* ---------- sign in ---------- */

.login-box {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  overflow-x: hidden;
  overflow-y: auto;
}

.login-top {
  display: flex;
  align-items: center;
  width: min(1120px, 100%);
  height: 64px;
  margin: 0 auto;
  padding: 0 32px;
}

.login-hero {
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  align-items: center;
  gap: 48px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 48px 32px;
}

/* 3D cube */
.cube-stage {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: 620px;
  justify-self: end;
}

.cube-stage canvas {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 1400ms var(--ease), transform 1800ms var(--ease);
}

.cube-stage.ready canvas {
  opacity: 1;
  transform: none;
}

/* floor glow under the cube */
.cube-stage::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 2%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--text) 9%, transparent), transparent);
  filter: blur(10px);
  pointer-events: none;
}

.wordmark {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.wordmark em {
  font-style: normal;
  color: var(--text-3);
}

.login-card {
  width: 100%;
  padding: 24px 0;
}

/* staggered entrance */
.login-card > * {
  animation: arrive 700ms var(--ease) backwards;
}

.login-card > :nth-child(2) { animation-delay: 50ms; }
.login-card > :nth-child(3),
.login-card > :nth-child(4) { animation-delay: 110ms; }
.login-card > :nth-child(5),
.login-card > :nth-child(6) { animation-delay: 160ms; }
.login-card > :nth-child(7) { animation-delay: 210ms; }
.login-card > :nth-child(8) { animation-delay: 250ms; }

.login-top {
  animation: fade 900ms 300ms var(--ease) both;
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes sheen {
  from { background-position: -160px 0; }
  to { background-position: calc(100% + 160px) 0; }
}

.login-card h1 {
  font-size: clamp(52px, 7.4vw, 84px);
  line-height: 0.98;
  font-weight: 400;
  letter-spacing: -0.04em;
  margin-bottom: 40px;
}

.login-card .lede {
  margin: 20px 0 36px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-2);
}

.login-card .lede span {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.login-card label.field-label {
  display: block;
  margin: 0 0 8px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: color 300ms var(--ease), transform 400ms var(--spring);
  transform-origin: left center;
}

.login-card label.field-label:has(+ input:focus) {
  color: var(--text);
  transform: translateX(2px);
}

.login-card input[type='email'],
.login-card input[type='password'],
.modal-input {
  display: block;
  width: 100%;
  height: 50px;
  margin-bottom: 16px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  box-shadow: 0 0 0 0 transparent, 0 0 0 transparent;
  caret-color: var(--text);
  transition:
    background-color 450ms var(--ease),
    border-color 450ms var(--ease),
    box-shadow 600ms var(--ease),
    transform 550ms var(--spring);
}

.login-card input::placeholder,
.modal-input::placeholder {
  color: var(--text-3);
  transition: opacity 400ms var(--ease), transform 500ms var(--ease);
}

.login-card input:focus::placeholder,
.modal-input:focus::placeholder {
  opacity: 0.45;
  transform: translateX(6px);
}

.login-card input:active,
.modal-input:active {
  transform: scale(0.985);
  transition-duration: 120ms;
}

.modal-input {
  height: 46px;
  margin-bottom: 0;
  border-radius: 23px;
}

.login-card input[type='email']:hover,
.login-card input[type='password']:hover,
.modal-input:hover {
  background: var(--raised);
}

.login-card input[type='email']:focus,
.login-card input[type='password']:focus,
.modal-input:focus {
  background: var(--raised);
  border-color: var(--line-2);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--text) 7%, transparent),
    0 16px 32px -20px color-mix(in srgb, var(--text) 28%, transparent);
  transform: translateY(-2px);
}

/* failed sign-in: the empty fields go soft red, then settle */
.login-card input.invalid {
  border-color: color-mix(in srgb, var(--bad) 55%, transparent);
  animation: invalid-pulse 900ms var(--ease);
}

@keyframes invalid-pulse {
  0% { background-color: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
  100% { background-color: var(--surface); }
}

input:focus,
input:focus-visible {
  outline: none;
}

.search-box {
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease), box-shadow 300ms var(--ease), width 300ms var(--ease);
}

.search-box:focus {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 6%, transparent);
}

label.login-check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 24px 4px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.login-card .btn {
  width: 100%;
  height: 50px;
  border-radius: 25px;
  font-size: 15px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  gap: 0;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--btn) 0%, transparent);
  transition: background-color 160ms var(--ease), transform 450ms var(--spring), box-shadow 450ms var(--ease);
}

/* hover: a shine passes over once and an arrow slides in beside the label */
.login-card .btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 30%, color-mix(in srgb, var(--btn-ink) 12%, transparent) 50%, transparent 70%);
  transform: translateX(-110%);
  pointer-events: none;
}

.login-card .btn::after {
  content: '→';
  display: inline-block;
  width: 0;
  margin-left: 0;
  opacity: 0;
  transform: translateX(-8px);
  transition: width 450ms var(--ease), margin-left 450ms var(--ease), opacity 300ms var(--ease), transform 450ms var(--spring);
}

.login-card .btn:hover:not(:disabled) {
  background: var(--btn);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--btn) 50%, transparent);
}

.login-card .btn:hover:not(:disabled)::before {
  transform: translateX(110%);
  transition: transform 900ms var(--ease);
}

.login-card .btn:hover:not(:disabled)::after {
  width: 1em;
  margin-left: 6px;
  opacity: 1;
  transform: translateX(0);
}

.login-card .btn:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: none;
  transition-duration: 100ms;
}

/* while signing in: keep it readable, run a light sweep across */
.login-card .btn:disabled {
  opacity: 0.85;
  background-image: linear-gradient(100deg, transparent 0, color-mix(in srgb, var(--btn-ink) 14%, transparent) 50%, transparent 100%);
  background-size: 160px 100%;
  background-repeat: no-repeat;
  animation: sheen 1.1s var(--ease) infinite;
}

.login-error {
  min-height: 20px;
  margin-top: 14px;
  font-size: 13px;
  text-align: center;
  color: var(--bad);
}

.login-error.show {
  animation: error-in 550ms var(--ease) both;
}

@keyframes error-in {
  from {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(-6px) scale(0.97);
  }
}

/* ---------- app shell ---------- */

.app {
  position: relative;
  z-index: 1;
  display: none;
  width: 100%;
  min-height: 100vh;
}

.app.active {
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(980px, calc(100% - 24px));
  height: 56px;
  margin: 12px auto 0;
  padding: 0 10px 0 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.app.active .topbar {
  animation: drop 600ms var(--ease) both;
}

@keyframes drop {
  from { opacity: 0; transform: translateY(-12px); }
}

.topbar .logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.topbar .logo em {
  font-style: normal;
  color: var(--text-3);
}

.topbar .spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle.icon-btn {
  position: relative;
  width: 36px;
  padding: 0;
  overflow: hidden;
}

.theme-toggle .t-icon {
  position: absolute;
  display: flex;
  transition: transform 400ms var(--ease), opacity 250ms ease;
}

.theme-toggle .t-sun { opacity: 0; transform: rotate(90deg) scale(0.4); }
.theme-toggle .t-moon { opacity: 1; transform: none; }
html.light .theme-toggle .t-sun { opacity: 1; transform: none; }
html.light .theme-toggle .t-moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }

/* account switcher */

.account-switch {
  position: relative;
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  max-width: 300px;
  padding: 0 12px 0 4px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: background-color 160ms var(--ease);
}

.account-btn:hover {
  background: var(--raised);
}

.ab-avatar,
.ai-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--raised-2), var(--surface));
  box-shadow: inset 0 0 0 1px var(--line-2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.ab-email {
  overflow: hidden;
  max-width: 200px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ab-chevron {
  display: flex;
  color: var(--text-3);
  transition: transform 200ms var(--ease);
}

.account-switch.open .ab-chevron {
  transform: rotate(180deg);
}

.account-menu,
.cd-menu {
  position: absolute;
  z-index: 70;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--pop);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 220ms var(--ease);
}

.account-menu {
  top: calc(100% + 8px);
  right: 0;
  min-width: 300px;
}

.account-switch.open .account-menu,
.custom-dropdown.open .cd-menu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.am-label {
  padding: 8px 12px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.account-item,
.am-action,
.cd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 6px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  transition: background-color 120ms var(--ease);
}

.account-item:hover,
.am-action:hover,
.cd-option:hover,
.account-item.active,
.cd-option.active {
  background: var(--raised-2);
}

.ai-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-check {
  display: flex;
  opacity: 0;
}

.account-item.active .ai-check {
  opacity: 1;
}

.ai-check svg {
  width: 14px;
  height: 14px;
}

.account-switch.open .account-menu > * {
  animation: arrive 360ms var(--ease) both;
}

.account-switch.open .account-menu > :nth-child(2) { animation-delay: 30ms; }
.account-switch.open .account-menu > :nth-child(3) { animation-delay: 60ms; }
.account-switch.open .account-menu > :nth-child(n + 4) { animation-delay: 90ms; }

.am-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}

.am-action {
  color: var(--text-2);
}

.am-action:hover {
  color: var(--text);
}

.am-action svg {
  flex: none;
}

/* ---------- inbox ---------- */

.content {
  flex: 1;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 44px 24px 56px;
}

.inbox-header {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  animation: arrive 600ms var(--ease) both;
}

.inbox-header h2 {
  font-size: 44px;
  line-height: 1;
  font-weight: 300;
  letter-spacing: -0.03em;
}

.inbox-header .count {
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}

.inbox-header .spacer {
  flex: 1;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap svg {
  position: absolute;
  left: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.search-box {
  width: 240px;
  height: 36px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: width 300ms var(--ease), border-color 160ms var(--ease);
}

.search-box:focus {
  width: 300px;
  border-color: color-mix(in srgb, var(--text) 45%, transparent);
}

.search-box::placeholder {
  color: var(--text-3);
}

.refresh.spinning svg {
  animation: spin 600ms var(--ease);
}

.inbox-panel {
  transition: opacity 120ms ease, transform 120ms ease;
}

.inbox-panel.page-out {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.inbox-panel.page-in {
  opacity: 0;
  transform: translateY(-4px);
}

.mail-list,
.message-view {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  overflow: hidden;
}

.mail-list {
  animation: arrive 600ms 60ms var(--ease) both;
}

.mail-item {
  position: relative;
  padding: 16px 22px 16px 24px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 140ms var(--ease);
}

.mail-item:last-child {
  border-bottom: 0;
}

.mail-item.enter {
  animation: rise 520ms var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

.mail-item:hover {
  background: color-mix(in srgb, var(--raised) 70%, transparent);
}

.mi-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 3px;
}

.mi-from {
  overflow: hidden;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mi-date {
  flex: none;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}

.mi-subject {
  overflow: hidden;
  margin-bottom: 3px;
  font-size: 15px;
  color: var(--text-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mail-item.unread .mi-from,
.mail-item.unread .mi-subject {
  color: var(--text);
  font-weight: 600;
}

.mi-preview {
  overflow: hidden;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mi-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  margin-top: 6px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--raised);
}

.mic-icon {
  display: flex;
  color: var(--text-2);
}

.mic-val {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.mic-copy {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  color: var(--text-3);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.mic-copy:hover {
  background: var(--raised-2);
  color: var(--text);
}

.mic-copy:active,
.mv-copy:active {
  transform: scale(0.88);
}

.mic-copy,
.mv-copy {
  transition: background-color 120ms var(--ease), color 120ms var(--ease), opacity 200ms var(--ease), transform 160ms var(--spring);
}

.no-results,
.loading {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-3);
}

.no-results a {
  color: var(--text) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty-inbox {
  padding: 88px 24px;
  text-align: center;
  color: var(--text-3);
}

.empty-inbox svg {
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  color: var(--text-2);
  stroke-width: 1.25;
}

.empty-inbox p {
  font-size: 20px;
  font-weight: 300;
  color: var(--text);
}

.empty-inbox small {
  display: block;
  margin-top: 6px;
  font-size: 13px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 20px 0 0;
}

.pagination:empty {
  display: none;
}

.pagination button {
  min-width: 36px;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 12.5px;
}

.pagination button.active {
  background: var(--btn);
  border-color: transparent;
  color: var(--btn-ink);
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* skeletons */

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skel-shine {
  background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--text) 4%, transparent) 40%, color-mix(in srgb, var(--text) 7%, transparent) 50%, color-mix(in srgb, var(--text) 4%, transparent) 60%, transparent 100%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skel-item {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.skel-item:last-child {
  border-bottom: 0;
}

.skel-line {
  height: 10px;
  margin-bottom: 8px;
  border-radius: 5px;
  background: var(--raised-2);
}

.skel-line.w70 { width: 70%; }
.skel-line.w50 { width: 50%; }
.skel-line.w90 { width: 90%; }
.skel-line.w40 { width: 40%; }
.skel-line.w60 { width: 60%; }
.skel-line.w30 { width: 30%; }
.skel-line.h14 { height: 14px; }
.skel-line.h12 { height: 12px; }
.skel-line.h8 { height: 8px; }

.skel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.skel-top .skel-line {
  margin-bottom: 0;
}

.skel-msg-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.skel-msg-body {
  padding: 28px;
}

.skel-msg-body .skel-line {
  margin-bottom: 14px;
}

/* ---------- message ---------- */

.message-view {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 300ms var(--ease);
}

.message-view.active {
  display: block;
}

.message-view.visible {
  opacity: 1;
  transform: none;
}

.mv-header {
  padding: 20px 28px 24px;
  border-bottom: 1px solid var(--line);
}

.mv-back {
  height: 32px;
  margin-bottom: 22px;
  padding: 0 12px 0 10px;
  font-size: 12.5px;
}

.mv-subject {
  margin-bottom: 14px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.mv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 13px;
  color: var(--text-3);
}

.mv-meta strong {
  font-weight: 500;
  color: var(--text);
}

.code-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 28px 0;
  padding: 14px 16px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--raised), var(--surface));
  cursor: pointer;
  transition: border-color 160ms var(--ease), transform 120ms var(--ease);
}

.code-banner:hover {
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}

.code-banner:active {
  transform: scale(0.99);
}

.code-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--raised-2);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--text);
}

.code-label {
  font-size: 13px;
  color: var(--text-2);
}

.code-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--text);
}

.code-copy-icon {
  display: flex;
  margin-left: auto;
  color: var(--text-3);
  transition: color 160ms var(--ease);
}

.code-banner:hover .code-copy-icon {
  color: var(--text);
}

.remote-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 28px 0;
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
}

.remote-bar svg {
  flex: none;
  color: var(--text-3);
}

.remote-bar span {
  flex: 1;
  min-width: 0;
}

.remote-bar button {
  flex: none;
  padding: 7px 12px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}

.remote-bar button:hover {
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
  background: var(--raised-2);
}

@media (max-width: 640px) {
  .remote-bar { margin: 12px 18px 0; }
}

.mv-body-wrap {
  position: relative;
  padding: 0 28px 28px;
}

.mv-body {
  padding: 28px 0 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.mv-html-frame {
  display: none;
  width: 100%;
  min-height: 420px;
  margin-top: 24px;
  border: 0;
  border-radius: 14px;
  background: #fff;
}

.mv-body-wrap.html-mode .mv-body {
  display: none;
}

.mv-body-wrap.html-mode .mv-html-frame {
  display: block;
}

.mv-copy {
  position: absolute;
  top: 16px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 15px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 200ms var(--ease), color 160ms var(--ease);
}

.mv-body-wrap:hover .mv-copy,
.mv-copy:focus-visible {
  opacity: 1;
}

.mv-copy:hover {
  color: var(--text);
}

.mv-copy.copied {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.mv-actions {
  display: flex;
  gap: 8px;
  padding: 14px 28px;
  border-top: 1px solid var(--line);
}

.mv-actions .btn-del {
  margin-left: auto;
}

/* ---------- modals ---------- */

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

html.light .modal-bg {
  background: rgba(0, 0, 0, 0.25);
}

.modal-bg.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 420px;
  max-width: 100%;
  padding: 28px;
  border: 1px solid var(--line-2);
  border-radius: 24px;
  background: var(--pop);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition: transform 320ms var(--ease), opacity 220ms ease;
}

.modal.wide {
  width: 480px;
}

.modal-bg.open .modal {
  opacity: 1;
  transform: none;
}

.modal h3 {
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.modal p {
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.mbtn {
  height: 40px;
  padding: 0 18px;
  border-radius: 20px;
  font-size: 14px;
}

.modal-label {
  display: block;
  margin: 0 0 8px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.modal-error {
  min-height: 18px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--bad);
}

/* settings */

.settings-panel {
  margin-top: 8px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.setting-info {
  flex: 1;
  min-width: 0;
}

.setting-info h4 {
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
}

.setting-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}

.settings-section {
  margin-top: 20px;
}

.settings-section h4 {
  margin: 0 0 10px 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.saved-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

#settings-accounts {
  max-height: 236px;
  margin-right: -6px;
  padding-right: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--raised-2) transparent;
}

#settings-accounts:has(.saved-account:nth-child(5)) {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  padding-bottom: 20px;
}

.setting-row {
  position: relative;
}

.setting-row:has(.custom-dropdown.open) {
  z-index: 5;
}

.sa-who {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 10px;
  min-width: 0;
}

.sa-email {
  overflow: hidden;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sa-remove {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-2);
}

/* dropdown */

.custom-dropdown {
  position: relative;
  min-width: 150px;
}

.cd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 19px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 160ms var(--ease);
}

.cd-trigger:hover,
.custom-dropdown.open .cd-trigger {
  background: var(--raised);
}

.cd-chevron {
  display: flex;
  color: var(--text-3);
  transition: transform 200ms var(--ease);
}

.custom-dropdown.open .cd-chevron {
  transform: rotate(180deg);
}

.cd-menu {
  top: calc(100% + 6px);
  left: 0;
  right: 0;
}

.cd-option {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.cd-option.active {
  font-weight: 600;
}

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  padding: 10px 18px;
  border: 1px solid var(--line-2);
  border-radius: 22px;
  background: var(--pop);
  backdrop-filter: blur(20px);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 200ms var(--ease), transform 300ms var(--ease);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- motion ---------- */

body {
  transition: background-color 400ms var(--ease), color 400ms var(--ease);
}

.icon-btn:hover,
.logout:hover,
.refresh:hover,
.mv-back:hover,
.mv-actions button:hover,
.mbtn:hover,
.account-btn:hover,
.cd-trigger:hover,
.pagination button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.mv-back:hover svg {
  transform: translateX(-3px);
}

.mv-back svg,
.icon-btn svg {
  transition: transform 300ms var(--spring);
}

.icon-btn:not(.theme-toggle):hover svg {
  transform: rotate(45deg);
}

/* settings / dialogs: contents follow the panel in */
.modal-bg.open .modal > *,
.modal-bg.open .settings-panel > * {
  animation: arrive 460ms var(--ease) both;
}

.modal-bg.open .modal > :nth-child(2) { animation-delay: 50ms; }
.modal-bg.open .modal > :nth-child(3) { animation-delay: 90ms; }
.modal-bg.open .modal > :nth-child(n + 4) { animation-delay: 130ms; }
.modal-bg.open .settings-panel > :nth-child(1) { animation-delay: 70ms; }
.modal-bg.open .settings-panel > :nth-child(2) { animation-delay: 110ms; }
.modal-bg.open .settings-panel > :nth-child(3) { animation-delay: 150ms; }

.modal-bg.open .saved-account {
  animation: arrive 420ms var(--ease) both;
}

.modal-bg.open .saved-account:nth-child(2) { animation-delay: 200ms; }
.modal-bg.open .saved-account:nth-child(1) { animation-delay: 170ms; }
.modal-bg.open .saved-account:nth-child(n + 3) { animation-delay: 230ms; }

/* dropdown options cascade */
.custom-dropdown.open .cd-option {
  animation: arrive 320ms var(--ease) both;
}

.custom-dropdown.open .cd-option:nth-child(2) { animation-delay: 25ms; }
.custom-dropdown.open .cd-option:nth-child(3) { animation-delay: 50ms; }
.custom-dropdown.open .cd-option:nth-child(4) { animation-delay: 75ms; }

.cd-option {
  transition: background-color 120ms var(--ease), padding-left 200ms var(--ease);
}

.cd-option:hover,
.account-item:hover,
.am-action:hover {
  padding-left: 14px;
}

.account-item,
.am-action {
  transition: background-color 120ms var(--ease), padding-left 200ms var(--ease), color 120ms var(--ease);
}

/* opening a message */
.message-view.visible .mv-header > *,
.message-view.visible .mv-meta,
.message-view.visible .code-banner,
.message-view.visible .mv-body-wrap {
  animation: arrive 520ms var(--ease) both;
}

.message-view.visible .mv-subject { animation-delay: 40ms; }
.message-view.visible .mv-meta { animation-delay: 80ms; }
.message-view.visible .code-banner { animation: pop-in 560ms 120ms var(--spring) both; }
.message-view.visible .mv-body-wrap { animation-delay: 150ms; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
}

.code-banner:hover .code-icon {
  transform: rotate(-8deg) scale(1.06);
}

.code-icon {
  transition: transform 360ms var(--spring);
}

/* empty inbox */
.empty-inbox svg {
  animation: float 3.2s ease-in-out infinite;
}

@keyframes float {
  50% { transform: translateY(-8px); }
}

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .login-hero {
    grid-template-columns: minmax(0, 420px);
    justify-content: center;
    gap: 0;
  }
  .cube-stage {
    grid-row: 1;
    justify-self: center;
    width: min(300px, 70vw);
    margin-bottom: -8px;
  }
}

@media (max-width: 700px) {
  .login-hero { padding: 32px 20px; }
  .topbar { top: 8px; margin-top: 8px; padding: 0 6px 0 16px; height: 52px; gap: 8px; }
  .topbar .logo { display: none; }
  .topbar .spacer { display: none; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .ab-email { max-width: 130px; }
  .topbar .icon-btn span { display: none; }
  .topbar .icon-btn:not(.theme-toggle) { width: 36px; padding: 0; }
  .content { padding: 28px 12px 40px; }
  .inbox-header h2 { font-size: 34px; }
  .search-wrap { order: 10; width: 100%; }
  .search-box, .search-box:focus { width: 100%; }
  .mail-item { padding: 14px 16px 14px 18px; }
  .mv-header { padding: 16px 18px 20px; }
  .mv-subject { font-size: 22px; }
  .code-banner { margin: 16px 18px 0; }
  .mv-body-wrap { padding: 0 18px 20px; }
  .mv-copy { right: 18px; }
  .mv-actions { padding: 12px 18px; }
}