:root {
  color-scheme: dark;
  --bg: #07101d;
  --surface: rgba(17, 29, 47, 0.78);
  --surface-solid: #111d2f;
  --surface-soft: #16253a;
  --line: rgba(148, 174, 209, 0.16);
  --text: #f4f7fb;
  --muted: #91a2b8;
  --accent: #67e8c5;
  --accent-strong: #37c8a5;
  --accent-ink: #06221c;
  --danger: #ff8a8a;
  --warning: #ffd479;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(50, 151, 157, 0.16), transparent 35%),
    linear-gradient(160deg, #07101d 0%, #0a1525 55%, #07101d 100%);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.ambient {
  position: fixed;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.22;
}
.ambient-one { top: -80px; right: -60px; background: #4bd2ba; }
.ambient-two { bottom: 5%; left: -120px; background: #2e6faf; }

.shell {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.login-view {
  width: min(100%, 520px);
  margin: 12vh auto 0;
  padding: 34px 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(13, 25, 41, 0.83);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.brand-lock {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 16px;
  color: var(--accent);
  background: rgba(103, 232, 197, 0.11);
  border: 1px solid rgba(103, 232, 197, 0.22);
  font-size: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 7vw, 40px); line-height: 1.08; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -0.02em; }
h3 { margin-bottom: 0; font-size: 14px; }
.subtle, .hint { color: var(--muted); line-height: 1.65; }
.subtle { font-size: 14px; }
.hint { margin: 14px 0; font-size: 12px; }
.hint code { color: #bad2ec; overflow-wrap: anywhere; }

.login-form { margin-top: 26px; }
label { display: block; color: #c7d3e0; font-size: 12px; font-weight: 650; }
.field-row { display: flex; gap: 10px; margin-top: 9px; }

input, textarea {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: rgba(6, 14, 25, 0.62);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input { height: 48px; padding: 0 14px; }
textarea { min-height: 126px; resize: vertical; padding: 14px; line-height: 1.5; }
input:focus, textarea:focus { border-color: rgba(103, 232, 197, 0.55); box-shadow: 0 0 0 3px rgba(103, 232, 197, 0.09); }

.primary, .secondary, .icon-button, .back-button {
  border: 0;
  border-radius: 14px;
  font-weight: 750;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}
.primary:active, .secondary:active, .icon-button:active, .back-button:active { transform: translateY(1px); }
.primary { padding: 0 20px; color: var(--accent-ink); background: var(--accent); }
.primary:hover { background: #80efd2; }
.secondary, .icon-button, .back-button { color: #dbe5ef; background: var(--surface-soft); border: 1px solid var(--line); }
.secondary { min-height: 46px; padding: 0 16px; }
.primary:disabled, .secondary:disabled { cursor: wait; opacity: 0.5; }
.wide { min-height: 48px; flex: 1; }
.small { min-height: 40px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 8px 4px 24px;
}
.topbar h1 { margin: 0; }
.icon-button { height: 40px; padding: 0 14px; }

.card {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
}

.card-heading, .message-header, .section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-heading > div { display: flex; align-items: center; gap: 10px; }
.compact { margin-bottom: 14px; }
.step { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.privacy-pill, .count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
}
.privacy-pill { padding: 0 10px; color: var(--accent); background: rgba(103, 232, 197, 0.09); }
.count-badge { min-width: 25px; padding: 0 8px; color: #d9e9f9; background: #243750; }
.action-row { display: flex; gap: 10px; margin-top: 12px; }

.inline-errors { margin-top: 12px; padding: 11px 13px; border-radius: 12px; color: #ffd1d1; background: rgba(142, 48, 48, 0.22); font-size: 12px; line-height: 1.5; }

.account-list { display: grid; gap: 9px; }
.account-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  color: #dce8f5;
  text-align: left;
  background: rgba(7, 17, 30, 0.52);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.account-button.active { border-color: rgba(103, 232, 197, 0.5); background: rgba(40, 104, 93, 0.22); }
.account-button span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button span:last-child { color: var(--muted); }

.current-email { margin-bottom: 4px; color: var(--accent); font-size: 11px; overflow-wrap: anywhere; }
.search-field { position: relative; margin: 15px 0 12px; }
.search-field span { position: absolute; left: 14px; top: 13px; color: var(--muted); font-size: 18px; }
.search-field input { padding-left: 40px; }

.message-list { display: grid; }
.message-item {
  width: 100%;
  padding: 15px 2px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}
.message-item:last-child { border-bottom: 0; }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.message-from { max-width: 65%; overflow: hidden; color: #d8e5f1; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.message-date { color: var(--muted); font-size: 10px; white-space: nowrap; }
.message-subject { margin: 0 0 8px; color: #f4f7fb; font-size: 14px; font-weight: 650; line-height: 1.4; }
.folder-tag { display: inline-flex; padding: 3px 7px; border-radius: 999px; color: var(--warning); background: rgba(255, 212, 121, 0.1); font-size: 9px; font-weight: 750; }
.empty-state { padding: 34px 0; color: var(--muted); text-align: center; }
.empty-state span { color: var(--accent); font-size: 30px; }
.empty-state p { margin: 8px 0 0; }
.footer-note { padding: 8px 16px 18px; color: #687b92; font-size: 10px; line-height: 1.6; text-align: center; }

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  overflow: auto;
  background: #07101d;
}
.modal-panel { width: min(100%, 760px); min-height: 100%; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
.modal-header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.back-button { flex: 0 0 auto; width: 42px; height: 42px; font-size: 20px; }
.modal-title-wrap { min-width: 0; }
.modal-title-wrap h2 { margin: 4px 0 7px; font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.detail-from { margin-bottom: 0; color: var(--accent); font-size: 11px; font-weight: 700; overflow-wrap: anywhere; }
.detail-date { margin: 0; color: var(--muted); font-size: 10px; }
.link-section, .email-body-section { margin-top: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.link-list { display: grid; gap: 9px; margin-top: 13px; }
.mail-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  color: inherit;
  text-decoration: none;
  border-radius: 13px;
  background: rgba(7, 17, 30, 0.62);
  border: 1px solid var(--line);
}
.mail-link:hover { border-color: rgba(103, 232, 197, 0.45); }
.mail-link-text { min-width: 0; }
.mail-link-label { display: block; overflow: hidden; color: #e7eef6; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.mail-link-host { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.mail-link-open { color: var(--accent); font-size: 12px; font-weight: 800; }
.email-body-section h3 { margin-bottom: 13px; }
#emailFrame { width: 100%; min-height: 430px; border: 0; border-radius: 12px; background: #fff; }
.email-text { margin: 0; padding: 14px; color: #162237; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 12px; background: #fff; font: 13px/1.65 ui-sans-serif, -apple-system, sans-serif; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 11px 15px;
  color: #eaf7f3;
  background: #19382f;
  border: 1px solid rgba(103, 232, 197, 0.28);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
}

@media (max-width: 520px) {
  .login-view { margin-top: 7vh; padding: 28px 20px; }
  .field-row { flex-direction: column; }
  .field-row .primary { min-height: 48px; }
  .card { padding: 17px; border-radius: 19px; }
  .card-heading { align-items: flex-start; }
  .privacy-pill { max-width: 115px; text-align: center; }
  .action-row { flex-direction: column; }
  .secondary { width: 100%; }
  .message-header .secondary { width: auto; }
  .link-section, .email-body-section { padding: 14px; }
}

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

