:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: #111318;
  --surface-2: #191c22;
  --surface-3: #222630;
  --line: rgba(255, 255, 255, 0.11);
  --text: #fffaf1;
  --muted: #afaeb4;
  --accent: #ed2f79;
  --accent-2: #ff5aa0;
  --gold: #e9b84c;
  --gold-bright: #ffd978;
  --danger: #ff6675;
  --success: #62d99b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --radius: 14px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-brand: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; font-size: 16px; }

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  transform: translateY(-200%);
  background: var(--text);
  color: var(--bg);
  padding: 0.7rem 1rem;
  border-radius: 0.4rem;
  font-weight: 800;
}

.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}

/* Three entrances */
.entrance-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
  min-height: 100vh;
  background: var(--bg);
}

.brand-stage {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  flex-direction: column;
  padding: clamp(1.25rem, 3vw, 3rem);
  background:
    linear-gradient(135deg, rgba(7, 8, 11, 0.98), rgba(18, 19, 24, 0.88)),
    url("/assets/hootsotraa-studio-reference.png") center / cover;
}

.brand-stage::before,
.brand-stage::after {
  position: absolute;
  z-index: -1;
  content: "";
  pointer-events: none;
}

.brand-stage::before {
  width: min(62vw, 820px);
  aspect-ratio: 1;
  right: -25%;
  top: -30%;
  border: 1px solid rgba(238, 47, 122, 0.3);
  border-radius: 50%;
  box-shadow:
    0 0 0 70px rgba(238, 47, 122, 0.045),
    0 0 0 145px rgba(233, 184, 76, 0.035);
}

.brand-stage::after {
  inset: auto 8% 8% auto;
  width: 34%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--gold));
  box-shadow: 0 -10px 34px rgba(238, 47, 122, 0.45);
}

.brand-stage__shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  background: rgba(0, 0, 0, 0.72);
}

.brand-stage__header,
.brand-stage__footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.domain-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid rgba(233, 184, 76, 0.5);
  background: rgba(0, 0, 0, 0.48);
  color: var(--gold-bright);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand-stage__content {
  position: relative;
  z-index: 2;
  width: min(780px, 100%);
  margin: auto 0;
}

.brand-mark {
  display: grid;
  width: 4.25rem;
  height: 4.25rem;
  place-items: center;
  margin-bottom: 2rem;
  border: 2px solid var(--gold);
  background: var(--accent);
  color: white;
  font-size: 2.1rem;
  transform: rotate(-3deg);
  box-shadow: 10px 10px 0 rgba(233, 184, 76, 0.15);
}

.brand-mark span { transform: rotate(3deg); }

.brand-kicker,
.section-label {
  margin: 0 0 0.75rem;
  color: var(--gold-bright);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-stage h1 {
  max-width: 12ch;
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(4.2rem, 10vw, 9.5rem);
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 0.82;
  text-transform: uppercase;
  text-shadow: 0 10px 44px rgba(0, 0, 0, 0.55);
}

.brand-stage h1 em {
  color: var(--accent);
  font-style: normal;
}

.brand-statement {
  max-width: 34rem;
  margin: 2rem 0 0;
  color: rgba(255, 250, 241, 0.88);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2.5vw, 2rem);
}

.brand-stage__footer {
  max-width: 50rem;
  color: rgba(255, 250, 241, 0.65);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.signin-side {
  display: grid;
  overflow-y: auto;
  place-items: center;
  min-height: 100vh;
  padding: clamp(1.25rem, 4vw, 4rem);
  background:
    radial-gradient(circle at 80% 10%, rgba(238, 47, 122, 0.12), transparent 32%),
    var(--bg);
}

.signin-panel,
.chooser {
  width: min(31rem, 100%);
}

.signin-heading h2,
.chooser h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.05;
}

.signin-heading > p:last-child {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.runtime-banner {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin: 1.7rem 0;
  padding: 0.8rem 0;
  border-block: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.status-light {
  width: 0.65rem;
  height: 0.65rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(233, 184, 76, 0.12);
}

.runtime-banner.online .status-light {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(98, 217, 155, 0.12);
}

.runtime-banner.preview .status-light {
  background: var(--accent-2);
  box-shadow: 0 0 0 5px rgba(255, 90, 160, 0.12);
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-form > label,
.compose-line {
  display: grid;
  gap: 0.45rem;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 760;
}

input,
textarea {
  width: 100%;
  min-height: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  padding: 0.8rem 0.9rem;
}

input::placeholder,
textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.password-field { position: relative; display: block; }
.password-field input { padding-right: 4.5rem; }

.address-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 0.65);
  background: var(--surface-2);
}

.address-field:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent);
}

.address-field input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.address-field > span {
  padding: 0 0.9rem;
  color: var(--gold-bright);
  font-size: 0.9rem;
  font-weight: 850;
  white-space: nowrap;
}

.reveal-button {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--gold-bright);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.auth-options,
.signin-footer,
.compose-dialog footer {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.check-label {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  gap: 0.55rem !important;
  align-items: center;
  color: var(--muted) !important;
  font-weight: 500 !important;
}

.check-label input { width: 1.05rem; min-height: auto; accent-color: var(--accent); }

.primary-button,
.preview-button,
.secondary-button,
.emma-button,
.compose-button {
  min-height: 3.25rem;
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
  padding: 0.8rem 1.15rem;
  font-weight: 900;
}

.primary-button,
.compose-button {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 75%, #8e1349));
  color: white;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 22%, transparent);
}

.primary-button:hover,
.compose-button:hover { filter: brightness(1.08); }

.preview-button,
.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.full-button { width: 100%; }
.terms-check { align-items: start; }
.terms-check span { line-height: 1.45; }
.public-plan-note { border-left-color: var(--accent); }

.text-button,
.quiet-button,
.signout-button {
  border: 0;
  background: transparent;
  color: var(--gold-bright);
  cursor: pointer;
  padding: 0.3rem;
  font-size: 0.87rem;
  font-weight: 760;
}

.quiet-button {
  min-height: 2.25rem;
  padding-inline: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: white;
}

.form-message {
  min-height: 1.5rem;
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.setup-note {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border-left: 4px solid var(--gold);
  background: var(--surface-2);
}

.setup-note span,
.optional { color: var(--muted); font-weight: 500; }

.optional { font-size: 0.8rem; }

.signin-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.entrance-grid { display: grid; gap: 0.9rem; margin-top: 2rem; }

.entrance-card {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  column-gap: 1rem;
  align-items: center;
  min-height: 6.4rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 1rem;
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease;
}

.entrance-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.entrance-card strong { align-self: end; font-size: 1.08rem; }
.entrance-card small { color: var(--gold-bright); }
.entrance-card > span:last-child { grid-column: 2; color: var(--muted); font-size: 0.84rem; }

.entrance-card__mark {
  grid-row: 1 / 4;
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 900;
  font-size: 1.35rem;
}

.entrance-card--craft { background: #fffaf0; color: #171725; border: 2px solid #d6a32a; box-shadow: 6px 6px 0 #d51f62; }
.entrance-card--craft small { color: #9c1746; }
.entrance-card--craft > span:last-child { color: #5e5360; }
.entrance-card--emma { border-radius: 1.25rem; background: linear-gradient(135deg, #25152e, #12101c); }

/* EmmaCraft entrance */
body[data-brand="craft"] {
  color-scheme: light;
  --bg: #fffaf0;
  --surface: #fffdf8;
  --surface-2: #f8eedf;
  --surface-3: #efe1ca;
  --line: rgba(89, 50, 33, 0.18);
  --text: #171625;
  --muted: #665c67;
  --accent: #d92067;
  --accent-2: #f14d8b;
  --gold: #bc8120;
  --gold-bright: #9b6411;
  --shadow: 8px 8px 0 rgba(110, 64, 36, 0.14);
  --radius: 0;
}

body[data-brand="craft"] .brand-stage {
  background: url("/assets/emmacraft-hootsotraa-voxel-flyer.png") center 54% / cover;
}

body[data-brand="craft"] .brand-stage__shade {
  background:
    linear-gradient(90deg, rgba(28, 8, 17, 0.9), rgba(55, 20, 31, 0.57) 60%, rgba(55, 20, 31, 0.82)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.25), transparent 45%);
}

body[data-brand="craft"] .brand-stage::before {
  width: 11rem;
  height: 11rem;
  aspect-ratio: auto;
  right: 8%;
  top: 12%;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(#f7b4ce 0 0) 0 0 / 25% 25%,
    linear-gradient(#e33174 0 0) 100% 0 / 25% 25%,
    linear-gradient(#ffdc7d 0 0) 25% 25% / 25% 25%,
    linear-gradient(#d92067 0 0) 75% 25% / 25% 25%,
    linear-gradient(#fff2cc 0 0) 50% 50% / 25% 25%,
    linear-gradient(#f070a1 0 0) 0 75% / 25% 25%,
    linear-gradient(#cf8f25 0 0) 100% 100% / 25% 25%;
  background-repeat: no-repeat;
  box-shadow: none;
  opacity: 0.85;
}

body[data-brand="craft"] .brand-stage::after {
  height: 8px;
  box-shadow: 8px 8px 0 rgba(217, 32, 103, 0.22);
}

body[data-brand="craft"] .brand-mark {
  border: 5px solid #ffda74;
  box-shadow: 8px 8px 0 #7a173d;
  image-rendering: pixelated;
}

body[data-brand="craft"] .brand-stage h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.8rem, 9vw, 8.2rem);
  letter-spacing: -0.06em;
  text-transform: none;
}

body[data-brand="craft"] .brand-stage h1 em { text-transform: uppercase; }
body[data-brand="craft"] .signin-side { background: #fffaf0; }
body[data-brand="craft"] input,
body[data-brand="craft"] textarea { background: white; }
body[data-brand="craft"] .primary-button,
body[data-brand="craft"] .compose-button { border: 3px solid #812044; box-shadow: 5px 5px 0 #d5a232; }
body[data-brand="craft"] .entrance-card,
body[data-brand="craft"] .setup-note,
body[data-brand="craft"] .message-card,
body[data-brand="craft"] .emma-panel,
body[data-brand="craft"] .compose-dialog { border-radius: 0; }

.voxel-path { display: none; }
body[data-brand="craft"] .voxel-path {
  display: flex;
  gap: 0.35rem;
  align-items: end;
  margin-top: 2rem;
}

.voxel-path i {
  width: 1.45rem;
  height: 1.45rem;
  background: #f04e8b;
  box-shadow: 4px 4px 0 #efc15e;
}
.voxel-path i:nth-child(2) { transform: translateY(0.5rem); }
.voxel-path i:nth-child(3) { transform: translateY(1rem); }
.voxel-path i:nth-child(4) { transform: translateY(0.5rem); }
.voxel-path i:nth-child(5) { transform: translateY(0); }
.voxel-path i:nth-child(6) { transform: translateY(-0.5rem); }

/* Emma's private entrance */
body[data-brand="emma"] {
  --bg: #0c0711;
  --surface: #17101e;
  --surface-2: #211529;
  --surface-3: #302039;
  --line: rgba(255, 213, 230, 0.14);
  --text: #fff7fb;
  --muted: #c3b3c3;
  --accent: #f02f81;
  --accent-2: #ff79b0;
  --gold: #f1b84b;
  --gold-bright: #ffd77b;
  --radius: 22px;
}

body[data-brand="emma"] .brand-stage {
  background:
    radial-gradient(circle at 18% 20%, rgba(242, 57, 135, 0.32), transparent 28%),
    radial-gradient(circle at 75% 72%, rgba(235, 181, 67, 0.19), transparent 30%),
    linear-gradient(145deg, #2d1538, #0a0710 64%);
}

body[data-brand="emma"] .brand-stage__shade { display: none; }
body[data-brand="emma"] .brand-stage::before {
  border-color: rgba(255, 215, 123, 0.22);
  box-shadow: 0 0 0 70px rgba(240, 47, 129, 0.035), 0 0 0 145px rgba(255, 215, 123, 0.025);
}
body[data-brand="emma"] .brand-stage::after { border-radius: 999px; }
body[data-brand="emma"] .brand-mark { border-radius: 1.2rem; transform: none; box-shadow: 0 15px 45px rgba(240, 47, 129, 0.28); }
body[data-brand="emma"] .brand-mark span { transform: none; }
body[data-brand="emma"] .brand-stage h1 { font-family: Georgia, "Times New Roman", serif; text-transform: none; letter-spacing: -0.055em; }
body[data-brand="emma"] .brand-stage h1 em { font-style: italic; }
body[data-brand="emma"] .signin-side { background: linear-gradient(180deg, #120b18, #09060d); }
body[data-brand="emma"] input,
body[data-brand="emma"] textarea,
body[data-brand="emma"] .preview-button { border-radius: 0.9rem; }
body[data-brand="emma"] .primary-button,
body[data-brand="emma"] .compose-button { border-radius: 999px; }

.photo-wall {
  display: none;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  gap: 0.75rem;
  width: min(34rem, 90%);
  margin-top: 2rem;
}

body[data-brand="emma"] .photo-wall:not(:empty) { display: grid; }

.photo-wall figure {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 0.65rem;
  background: #2d2033;
  transform: rotate(var(--tilt, -2deg));
  box-shadow: 0 15px 36px rgba(0, 0, 0, 0.34);
}

.photo-wall figure:nth-child(even) { --tilt: 2deg; transform: translateY(0.8rem) rotate(var(--tilt)); }
.photo-wall img { width: 100%; height: 100%; object-fit: cover; }

/* Mail application */
.mail-shell { height: 100vh; background: var(--bg); }

.topbar {
  display: grid;
  grid-template-columns: 250px minmax(260px, 680px) 1fr;
  gap: 1.25rem;
  align-items: center;
  height: 74px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  padding: 0 1rem 0 1.25rem;
}

.app-wordmark {
  color: var(--text);
  font-family: var(--font-brand);
  font-size: 1.55rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.app-wordmark em { color: var(--accent); font-style: normal; }

.search-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0 0.75rem;
}

.search-box input {
  min-height: 40px;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.search-box kbd {
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  color: var(--muted);
  padding: 0.05rem 0.4rem;
  font-size: 0.72rem;
}

.topbar-actions,
.column-actions,
.reader-tools,
.reader-footer,
.emma-actions { display: flex; gap: 0.5rem; align-items: center; }
.topbar-actions { justify-content: end; }

.icon-button,
.profile-button {
  display: inline-grid;
  min-width: 2.65rem;
  min-height: 2.65rem;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.icon-button:hover,
.profile-button:hover { border-color: var(--line); background: var(--surface-2); }

.profile-button {
  display: inline-flex;
  gap: 0.6rem;
  padding: 0.2rem 0.65rem 0.2rem 0.25rem;
}
.profile-button > span:first-child {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 900;
}
.profile-button > span:last-child { font-weight: 750; }

.mail-workspace {
  display: grid;
  grid-template-columns: 250px minmax(320px, 390px) minmax(420px, 1fr);
  height: calc(100vh - 74px);
}

.folder-sidebar,
.message-column,
.reader-column,
.emma-panel { min-width: 0; min-height: 0; }

.folder-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem;
}

.compose-button {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.compose-button span { font-size: 1.35rem; font-weight: 400; }

.folder-list { display: grid; gap: 0.15rem; }
.folder-button {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.65rem;
  align-items: center;
  min-height: 2.85rem;
  border: 0;
  border-radius: calc(var(--radius) * 0.72);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  text-align: left;
}
.folder-button:hover { background: var(--surface-2); color: var(--text); }
.folder-button.active { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--text); font-weight: 850; }
.folder-button.active > span:first-child { color: var(--accent-2); }
.folder-count { color: var(--muted); font-size: 0.79rem; }

.storage-card {
  display: grid;
  gap: 0.55rem;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 1rem 0.25rem 0;
}
.storage-card div:first-child { display: flex; justify-content: space-between; font-size: 0.78rem; }
.storage-card span,
.storage-card small { color: var(--muted); }
.storage-meter { height: 5px; overflow: hidden; background: var(--surface-3); }
.storage-meter i { display: block; width: 14%; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.storage-link { justify-self: start; padding: 0; }
.signout-button { margin-top: 0.9rem; text-align: left; color: var(--muted); }

.message-column {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 72%, var(--bg));
}

.column-header {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 1rem;
}
.column-header h2 { margin: 0.1rem 0 0; font-size: 1.55rem; }
.mailbox-address { margin: 0; color: var(--muted); font-size: 0.73rem; }
.message-list { overflow-y: auto; }

.message-card {
  position: relative;
  display: grid;
  grid-template-columns: 2.55rem 1fr auto;
  column-gap: 0.75rem;
  min-height: 106px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0.95rem;
  text-align: left;
}
.message-card:hover { background: var(--surface-2); }
.message-card.active { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.message-card.unread .message-card__sender,
.message-card.unread .message-card__subject { font-weight: 900; }
.message-card__avatar,
.sender-avatar {
  display: grid;
  width: 2.55rem;
  height: 2.55rem;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--gold-bright);
  font-weight: 900;
}
.message-card__content { min-width: 0; }
.message-card__top { display: flex; gap: 0.5rem; align-items: baseline; justify-content: space-between; }
.message-card__sender,
.message-card__subject,
.message-card__preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-card__sender { font-size: 0.91rem; }
.message-card__subject { margin-top: 0.2rem; font-size: 0.88rem; }
.message-card__preview { margin-top: 0.15rem; color: var(--muted); font-size: 0.81rem; }
.message-card time { color: var(--muted); font-size: 0.69rem; white-space: nowrap; }
.message-card__star { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0.2rem; }
.message-card__star.is-starred { color: var(--gold-bright); }

.empty-state,
.reader-placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}
.empty-state > span,
.reader-placeholder__mark { color: var(--accent); font-size: 2.5rem; }
.empty-state strong,
.reader-placeholder h2 { color: var(--text); }
.reader-placeholder h2 { margin: 0.75rem 0 0; }
.reader-placeholder p { margin: 0.35rem 0; }

.reader-column { overflow-y: auto; background: var(--bg); }
.message-reader { width: min(850px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
.reader-header { display: flex; justify-content: space-between; align-items: center; }
.reader-header time { color: var(--muted); font-size: 0.8rem; }
.message-reader > h1 { margin: 2rem 0 1.25rem; font-size: clamp(1.85rem, 4vw, 3rem); line-height: 1.12; }
.sender-row { display: flex; gap: 0.8rem; align-items: center; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.sender-row > div:last-child { display: grid; }
.sender-row span { color: var(--muted); font-size: 0.82rem; }
.reader-body { min-height: 240px; padding: 1.8rem 0; color: color-mix(in srgb, var(--text) 92%, var(--muted)); font-size: 1.02rem; line-height: 1.78; white-space: pre-wrap; }
.reader-footer { border-top: 1px solid var(--line); padding-top: 1rem; }
.secondary-button { min-height: 2.8rem; }
.emma-button { margin-left: auto; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent-2); }

.emma-panel {
  position: fixed;
  z-index: 20;
  top: 74px;
  right: 0;
  bottom: 0;
  width: min(370px, 94vw);
  transform: translateX(105%);
  border-left: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.3);
  padding: 1.25rem;
  transition: transform 180ms ease;
}
.emma-panel.open { transform: translateX(0); }
.emma-panel > header { display: grid; grid-template-columns: auto 1fr auto; gap: 0.8rem; align-items: center; }
.emma-panel > header span { color: var(--accent-2); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.14em; }
.emma-panel h2 { margin: 0; font-size: 1.05rem; }
.emma-orb { display: grid; width: 2.8rem; height: 2.8rem; place-items: center; border-radius: 50%; background: var(--accent); color: white; box-shadow: 0 0 25px color-mix(in srgb, var(--accent) 45%, transparent); }
.emma-content { min-height: 240px; margin: 1.25rem 0; border-block: 1px solid var(--line); padding: 1.25rem 0; color: var(--muted); }
.emma-content strong { color: var(--text); }
.emma-actions { flex-wrap: wrap; }
.emma-actions button { border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); cursor: pointer; padding: 0.55rem 0.75rem; }
.emma-panel > small { display: block; margin-top: 1.2rem; color: var(--muted); }

dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.compose-dialog,
.photo-dialog,
.storage-dialog {
  width: min(720px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 0;
}

.storage-dialog { width: min(980px, calc(100vw - 2rem)); }
.storage-dialog__shell { display: grid; gap: 1.25rem; padding: clamp(1rem, 3vw, 2rem); }
.storage-dialog__shell > header { display: flex; gap: 1rem; align-items: start; justify-content: space-between; }
.storage-dialog__shell h2 { margin: 0.2rem 0 0; font-size: clamp(1.6rem, 4vw, 2.5rem); line-height: 1.08; }
.storage-dialog__shell > footer { border-top: 1px solid var(--line); color: var(--muted); padding-top: 1rem; }

.billing-notice {
  border-left: 4px solid var(--gold);
  background: var(--surface-2);
  color: var(--muted);
  padding: 0.9rem 1rem;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.plan-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 1.1rem;
}

.plan-card.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-card__top { display: flex; gap: 0.75rem; align-items: start; justify-content: space-between; }
.plan-card h3 { margin: 0; font-size: 1.15rem; }
.plan-card strong { color: var(--gold-bright); font-size: 1.35rem; }
.plan-card p { flex: 1; margin: 0; color: var(--muted); }
.plan-card small { color: var(--muted); }
.plan-card button { width: 100%; }
.current-plan-pill { border-radius: 999px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent-2); padding: 0.2rem 0.55rem; font-size: 0.72rem; font-weight: 850; }

.owner-controls { display: grid; gap: 0.8rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.owner-controls h3 { margin: 0; }
.owner-account-list { display: grid; gap: 0.5rem; }
.owner-account-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0.8rem;
}
.owner-account-row > div { min-width: 0; }
.owner-account-row strong,
.owner-account-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-account-row span { color: var(--muted); font-size: 0.82rem; }
.owner-account-row select { min-height: 2.7rem; border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.6); background: var(--surface); color: var(--text); padding: 0.4rem 0.7rem; }
.compose-dialog form,
.photo-dialog form { display: grid; gap: 0; }
.compose-dialog header,
.photo-dialog header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0.8rem 1rem; }
.compose-dialog h2,
.photo-dialog h2 { margin: 0; font-size: 1rem; }
.compose-line { grid-template-columns: 4.5rem 1fr; align-items: center; border-bottom: 1px solid var(--line); padding: 0 1rem; }
.compose-line input { border: 0; background: transparent; box-shadow: none; }
.compose-dialog textarea { min-height: 300px; resize: vertical; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 1.2rem; }
.compose-dialog footer,
.photo-dialog footer { border-top: 1px solid var(--line); padding: 0.8rem 1rem; }
.compose-secondary { display: flex; gap: 0.8rem; align-items: center; }
#draft-status { color: var(--muted); font-size: 0.78rem; }

.photo-dialog form > p { margin: 1rem; color: var(--muted); }
.photo-picker { display: grid; gap: 0.5rem; margin: 0 1rem 1rem; border: 1px dashed var(--gold); padding: 1rem; color: var(--gold-bright); font-weight: 800; }
.photo-picker input { min-height: auto; border: 0; background: transparent; padding: 0; }
.photo-preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 0 1rem 1rem; }
.photo-preview-grid img { width: 100%; aspect-ratio: 4 / 3; border-radius: 0.5rem; object-fit: cover; }

.toast {
  position: fixed;
  z-index: 100;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100vw - 2rem));
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  color: var(--text);
  font-weight: 700;
}

.mobile-only { display: none; }

body[data-brand="craft"] .app-wordmark { font-family: Georgia, "Times New Roman", serif; }
body[data-brand="craft"] .topbar,
body[data-brand="craft"] .folder-sidebar,
body[data-brand="craft"] .message-column { box-shadow: inset -4px 0 0 rgba(188, 129, 32, 0.08); }
body[data-brand="craft"] .message-card__avatar,
body[data-brand="craft"] .sender-avatar { border-radius: 0; box-shadow: 3px 3px 0 rgba(188, 129, 32, 0.24); }
body[data-brand="emma"] .app-wordmark { font-family: Georgia, "Times New Roman", serif; text-transform: none; }
body[data-brand="emma"] .folder-sidebar { background: linear-gradient(180deg, #1d1124, #100a15); }

@media (min-width: 1500px) {
  .mail-workspace:has(.emma-panel.open) { padding-right: 370px; }
  .mail-workspace { transition: padding-right 180ms ease; }
}

@media (max-width: 1100px) {
  .entrance-shell { grid-template-columns: 1fr 1fr; }
  .mail-workspace { grid-template-columns: 220px 340px 1fr; }
  .topbar { grid-template-columns: 220px minmax(220px, 1fr) auto; }
  .profile-button > span:last-child { display: none; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .entrance-shell { display: block; }
  .brand-stage { min-height: 43vh; padding: 1.25rem; }
  .brand-stage__content { margin: auto 0 1rem; }
  .brand-stage h1 { font-size: clamp(3.4rem, 17vw, 6rem); }
  .brand-mark { width: 3rem; height: 3rem; margin-bottom: 1rem; font-size: 1.4rem; }
  .brand-statement { margin-top: 1rem; font-size: 1.1rem; }
  .brand-stage__footer { display: none; }
  .signin-side { min-height: 57vh; padding: 1.5rem 1.1rem 2rem; }
  .mail-shell { height: 100dvh; }
  .topbar { grid-template-columns: auto 1fr auto; height: 64px; gap: 0.45rem; padding: 0 0.6rem; }
  .app-wordmark { font-size: 1.15rem; }
  .search-box { min-width: 0; }
  .search-box kbd { display: none; }
  .topbar-actions { gap: 0; }
  #read-aloud-toggle { display: none; }
  .mobile-only { display: inline-grid; }
  .mail-workspace { display: block; height: calc(100dvh - 64px); }
  .folder-sidebar {
    position: fixed;
    z-index: 40;
    top: 64px;
    bottom: 0;
    left: 0;
    width: min(290px, 88vw);
    transform: translateX(-105%);
    box-shadow: 24px 0 70px rgba(0, 0, 0, 0.42);
    transition: transform 180ms ease;
  }
  .folder-sidebar.open { transform: translateX(0); }
  .message-column { height: 100%; border-right: 0; }
  .reader-column { position: fixed; z-index: 15; inset: 64px 0 0; transform: translateX(105%); background: var(--bg); transition: transform 180ms ease; }
  .reader-column.open { transform: translateX(0); }
  .message-reader { padding: 1rem; }
  .message-reader > h1 { margin-top: 1rem; }
  .emma-panel { top: 64px; }
  .photo-wall { grid-template-columns: repeat(3, minmax(60px, 1fr)); }
  .plan-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .signin-heading h2,
  .chooser h2 { font-size: 2rem; }
  .auth-options { align-items: flex-start; flex-direction: column; }
  .signin-footer { align-items: flex-start; flex-direction: column; }
  .message-card { min-height: 98px; }
  .topbar #settings-button { display: none; }
  .reader-tools { gap: 0.15rem; }
  .reader-header { align-items: flex-start; }
  .reader-footer { flex-wrap: wrap; }
  .emma-button { width: 100%; margin-left: 0; }
  .compose-dialog { width: 100vw; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .compose-dialog textarea { min-height: calc(100dvh - 310px); }
  .compose-line { grid-template-columns: 3.8rem 1fr; }
  .photo-preview-grid { grid-template-columns: repeat(2, 1fr); }
  .address-field { grid-template-columns: minmax(0, 1fr); }
  .address-field > span { padding: 0 0.9rem 0.75rem; }
  .storage-dialog { width: 100vw; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .owner-account-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

@media (forced-colors: active) {
  .status-light,
  .storage-meter i { forced-color-adjust: none; }
}
