:root {
  color-scheme: dark;
  --bg: #0f0a17;
  --surface: #171020;
  --surface-2: #21182c;
  --surface-3: #2a2035;
  --text: #f8f5fb;
  --muted: #b7adbf;
  --soft: #84778e;
  --border: #352a42;
  --accent: #c85ca2;
  --accent-2: #8e68d8;
  --accent-soft: rgba(200, 92, 162, 0.14);
  --success: #56c7ad;
  --danger: #e3647c;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
  --radius: 14px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fff8fc;
  --surface: #ffffff;
  --surface-2: #fff1f7;
  --surface-3: #f5e1ec;
  --text: #251d27;
  --muted: #756574;
  --soft: #9d899a;
  --border: #ead7e2;
  --accent: #c9478c;
  --accent-2: #8d62c7;
  --accent-soft: rgba(201, 71, 140, 0.12);
  --success: #168b75;
  --danger: #c94562;
  --shadow: 0 14px 34px rgba(112, 56, 88, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.aurora {
  display: none;
}

.topbar,
main,
footer {
  position: relative;
}

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 19px;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand small,
.muted {
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  letter-spacing: -0.04em;
  line-height: 1.04;
}

h2 {
  margin-bottom: 18px;
  letter-spacing: -0.025em;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lead {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.lead strong {
  color: var(--text);
}

.welcome,
.auth-layout {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 56px;
}

.welcome {
  min-height: calc(100vh - 150px);
  padding: 48px 0 76px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
}

.auth-layout {
  margin: auto;
  padding: 42px 0;
}

.auth-hero .brand {
  margin-bottom: 50px;
}

.auth-hero h1,
.hero h1 {
  max-width: 620px;
  font-size: clamp(42px, 5.4vw, 64px);
}

.features {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.features span {
  padding: 8px 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.login-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  padding: 30px;
}

.auth-card {
  overflow: hidden;
}

.auth-card::before {
  content: "";
  display: block;
  height: 3px;
  margin: -30px -30px 26px;
  background: var(--accent);
}

.auth-card .notice {
  margin: 0 0 20px;
}

.stack {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

label small {
  color: var(--soft);
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

input::placeholder,
textarea::placeholder {
  color: var(--soft);
}

.button,
button {
  font: inherit;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 150ms, border-color 150ms;
}

.button:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.ghost {
  background: transparent;
}

.button.subtle {
  color: var(--muted);
}

.button.full {
  width: 100%;
}

.button.small {
  min-height: 34px;
  padding: 8px 12px;
  white-space: nowrap;
}

.button.google {
  min-height: 46px;
  margin-bottom: 5px;
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.button.loading {
  opacity: 0.72;
  pointer-events: none;
}

.google-g {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #4285f4;
  font-size: 14px;
  font-weight: 900;
}

.theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-weight: 700;
}

.auth-help {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.auth-switch {
  margin-top: 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

.auth-switch a,
.small-link,
.manage summary {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.5;
}

.check-row input {
  width: auto;
  margin-top: 3px;
}

.check-row a,
.policy-card a {
  color: var(--accent);
}

.owner-access {
  margin-top: 24px;
}

.owner-access summary {
  display: flex;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}

.owner-access .stack {
  margin-top: 20px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.setup-warning,
.notice {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.setup-warning {
  margin-bottom: 20px;
  color: var(--danger);
  background: rgba(227, 100, 124, 0.12);
}

.notice {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto 24px;
  color: var(--success);
  background: rgba(86, 199, 173, 0.12);
  border: 1px solid rgba(86, 199, 173, 0.28);
}

.notice p {
  margin: 0;
}

.notice.error {
  color: var(--danger);
  background: rgba(227, 100, 124, 0.12);
  border-color: rgba(227, 100, 124, 0.28);
}

.notice.inline {
  width: auto;
  margin: 0;
}

.secret {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.secret code {
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.copy,
.text-danger {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.copy {
  color: var(--accent);
}

.text-danger {
  color: var(--danger);
  font-size: 13px;
}

.dashboard,
.webmail-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 76px;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 22px;
  margin-bottom: 28px;
}

.dashboard-head h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 4.4vw, 48px);
}

.count {
  min-width: 120px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: right;
}

.count strong {
  display: block;
  color: var(--accent);
  font-size: 30px;
}

.count span {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.dashboard-grid.staff-grid {
  grid-template-columns: minmax(0, 1fr);
}

.review-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: -8px 0 24px;
}

.review-summary article {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.review-summary strong {
  display: block;
  color: var(--accent);
  font-size: 28px;
}

.review-summary span {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  padding: 22px;
}

.list-panel,
.requests-panel,
.caught-panel,
.staff-panel {
  grid-column: 2;
}

.staff-grid .list-panel,
.staff-grid .requests-panel,
.staff-grid .caught-panel,
.staff-grid .staff-panel {
  grid-column: 1;
}

.joined-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}

.joined-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.joined-input input {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.joined-input span {
  padding-right: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.mailbox-list {
  display: grid;
  gap: 10px;
}

.mailbox {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.mailbox-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mailbox-open {
  margin: 14px 0 0 22px;
}

.mail-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
}

.mail-dot.paused {
  background: var(--danger);
}

.mailbox-main strong {
  display: block;
}

.mailbox-main small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.manage {
  margin: 12px 0 0 22px;
}

.manage summary {
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}

.mini-form {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.mini-form input {
  padding: 10px 12px;
}

.empty {
  min-height: 250px;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.empty h2 {
  margin-bottom: 7px;
  color: var(--text);
}

.request-list {
  display: grid;
  gap: 12px;
}

.access-request {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.access-request strong,
.access-request small {
  display: block;
}

.access-request small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.access-request p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.caught-head {
  display: grid;
  gap: 4px;
}

.pill {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.caught-preview summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.caught-preview pre {
  max-height: 260px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  white-space: pre-wrap;
  font: 13px/1.55 Consolas, "SFMono-Regular", monospace;
}

.staff-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.staff-list article {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.staff-list small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.request-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.reject-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

.reject-form input {
  padding: 9px 11px;
}

.policy-page {
  width: min(900px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 76px;
}

.policy-card {
  padding: clamp(24px, 4vw, 42px);
}

.policy-card h1 {
  max-width: 760px;
  font-size: clamp(34px, 5vw, 56px);
}

.policy-card p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.waiting-shell {
  width: min(760px, calc(100% - 40px));
  margin: auto;
  padding: 48px 0;
}

.waiting-card {
  padding: clamp(28px, 5vw, 46px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.waiting-card .brand {
  margin-bottom: 34px;
}

.waiting-card .lead {
  margin-inline: auto;
}

.waiting-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface-2);
}

.waiting-icon span {
  width: 34px;
  height: 34px;
  border: 4px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.verification-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 30px 0 18px;
  text-align: left;
}

.verification-steps article {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.verification-steps strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 13px;
}

.verification-steps .done strong,
.verification-steps .active strong {
  background: var(--accent);
  color: #fff;
}

.verification-steps span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.small-center {
  font-size: 13px;
  text-align: center;
}

.waiting-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.mail-app {
  display: grid;
  grid-template-columns: 220px minmax(320px, 410px) minmax(0, 1fr);
  min-height: 680px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mail-sidebar {
  padding: 20px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.mail-sidebar .button {
  width: 100%;
  margin-bottom: 20px;
}

.mail-nav {
  display: grid;
  gap: 6px;
}

.mail-nav a,
.mail-nav span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.mail-nav .active {
  color: var(--text);
  background: var(--accent-soft);
}

.mail-list {
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.mail-list-head {
  position: sticky;
  top: 0;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  z-index: 1;
}

.mail-list-head h2 {
  margin: 0 0 4px;
}

.inbox-list {
  display: grid;
}

.inbox-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.inbox-item:hover,
.inbox-item.active {
  background: var(--surface-2);
}

.inbox-item.unread strong::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.inbox-item strong,
.inbox-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-item span,
.inbox-item small {
  color: var(--muted);
  font-size: 13px;
}

.inbox-item small {
  grid-row: 1 / span 2;
  grid-column: 2;
  max-width: 90px;
}

.message-panel {
  min-width: 0;
  background: var(--surface);
}

.message-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.message-view {
  padding: 28px;
}

.message-view h2 {
  font-size: clamp(26px, 4vw, 38px);
}

.message-meta {
  display: grid;
  gap: 8px;
  margin: 0 0 24px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-2);
}

.message-meta div {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 12px;
}

.message-meta dt {
  color: var(--muted);
  font-size: 13px;
}

.message-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
  line-height: 1.72;
}

.message-body.plain {
  margin: 0;
  font: 16px/1.72 Inter, "Segoe UI", Arial, sans-serif;
}

.html-email {
  white-space: normal;
}

.html-email table {
  max-width: 100%;
  border-collapse: collapse;
}

.html-email img {
  max-width: 100%;
  height: auto;
}

.html-email a,
.html-email button {
  color: var(--accent);
}

.html-email button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 12px;
}

.compose {
  margin: 0 28px 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.compose .eyebrow {
  margin-bottom: 0;
}

.small-empty {
  min-height: 220px;
}

.message-empty {
  min-height: 520px;
}

footer {
  padding: 0 20px 28px;
  color: var(--soft);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1050px) {
  .mail-app {
    grid-template-columns: 190px minmax(280px, 380px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .welcome,
  .auth-layout,
  .dashboard-grid,
  .review-summary,
  .verification-steps {
    display: block;
  }

  .verification-steps article {
    margin-top: 10px;
  }

  .list-panel,
  .requests-panel,
  .caught-panel,
  .staff-panel {
    grid-column: auto;
  }

  .review-summary article {
    margin-top: 10px;
  }

  .login-card,
  .auth-card,
  .create-panel,
  .inbox-panel {
    margin-top: 28px;
  }

  .mail-app {
    display: block;
  }

  .mail-sidebar,
  .mail-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .mail-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .topbar,
  .dashboard,
  .webmail-shell,
  .welcome,
  .auth-layout {
    width: min(100% - 28px, 1180px);
  }

  .topbar,
  .dashboard-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-hero h1,
  .hero h1 {
    font-size: 40px;
  }

  .panel,
  .login-card {
    padding: 22px;
  }

  .mini-form,
  .auth-switch,
  .request-actions,
  .reject-form {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }

  .message-view {
    padding: 22px;
  }

  .compose {
    margin: 0 22px 22px;
  }
}
