@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/fonts/plus-jakarta-sans-latin-wght.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --navy: #102039;
  --ink: #2d3a4f;
  --muted: #5b6577;
  --teal: #0b6557;
  --teal-hover: #08584b;
  --sage: #a9ccbf;
  --mint: #e2f3ec;
  --blush-soft: #fbe7e2;
  --coral: #b74241;
  --blue: #2563a5;
  --blue-soft: #e5effe;
  --purple: #6251b5;
  --lavender: #ece6fc;
  --cream: #fcf8f4;
  --white: #ffffff;
  --line: #ece5de;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(16, 32, 57, 0.07);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--navy);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

h1,
h2,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: var(--teal);
}

button,
input {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.small {
  font-size: 0.875rem;
}

/* ───────── Buttons ───────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 20px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: none;
  font-size: 0.9375rem;
  font-weight: 650;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--teal);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(11, 101, 87, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--teal-hover);
}

.btn-outline {
  border-color: var(--navy);
  background: var(--white);
}

.btn-outline:hover {
  background: var(--navy);
  color: var(--white);
}

.btn-quiet {
  padding: 8px 14px;
  border-color: var(--line);
  background: var(--white);
  color: var(--ink);
  font-weight: 600;
}

.btn-quiet:hover:not(:disabled) {
  border-color: var(--sage);
  background: var(--mint);
}

.btn-danger {
  color: var(--coral);
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--coral);
  background: var(--blush-soft);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--mint);
  color: var(--teal);
}

.link-btn {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--teal);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ───────── Brand, avatars, badges ───────── */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  flex: none;
}

.brand-name {
  font-size: 1.0625rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-weight: 700;
}

.avatar-teal {
  background: var(--mint);
  color: var(--teal);
}

.avatar-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.avatar-purple {
  background: var(--lavender);
  color: var(--purple);
}

.avatar-coral {
  background: var(--blush-soft);
  color: var(--coral);
}

.avatar-sage {
  background: #dcebe5;
  color: #1f5a4b;
}

.badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-teal {
  background: var(--mint);
  color: var(--teal);
}

.badge-coral {
  background: var(--blush-soft);
  color: var(--coral);
}

/* ───────── Forms ───────── */

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 0.875rem;
  font-weight: 650;
}

.field-hint {
  color: var(--muted);
  font-size: 0.8125rem;
}

input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

input:not([type="checkbox"]):focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(11, 101, 87, 0.15);
}

.address-input,
.password-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.address-input input,
.password-input input {
  flex: 1 1 9rem;
}

.address-domain {
  color: var(--muted);
  font-weight: 600;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
}

.check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.form-error {
  color: var(--coral);
  font-size: 0.9375rem;
  font-weight: 600;
}

.form-error:empty {
  display: none;
}

/* ───────── Sign-in and setup ───────── */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}

.auth-card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  padding: clamp(22px, 6vw, 36px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-top: 8px;
  font-size: 1.625rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.auth-card .form {
  margin-top: 6px;
}

/* ───────── Signed-in frame ───────── */

.shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
  background: var(--white);
}

.side .brand {
  padding: 0 8px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--cream);
}

.nav-link.active {
  background: var(--mint);
  color: var(--teal);
  font-weight: 700;
}

.nav-count {
  margin-left: auto;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--teal);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
}

.side-user {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding: 12px 4px 0 10px;
  border-top: 1px solid var(--line);
}

.side-user-text {
  display: grid;
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
}

.side-user-text span {
  color: var(--muted);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.main {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

/* ───────── Message list ───────── */

.list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--white);
}

.list-head {
  display: grid;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.list-title h1 {
  font-size: 1.375rem;
  letter-spacing: -0.02em;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--cream);
  color: var(--muted);
}

.search:focus-within {
  border-color: var(--teal);
}

.search .search-input {
  min-height: 42px;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--navy);
}

.search .search-input:focus {
  box-shadow: none;
}

.trash-note,
.image-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 0.875rem;
}

.list-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.row {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  color: var(--ink);
  text-decoration: none;
}

.row:hover {
  background: var(--cream);
}

.row.selected {
  border-left-color: var(--teal);
  background: var(--mint);
}

.row-text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.row-from {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-clip {
  align-self: center;
  color: var(--muted);
  line-height: 0;
}

.row-clip .icon {
  width: 1rem;
  height: 1rem;
}

.row-date {
  flex: none;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.row-subject,
.row-snippet {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.row-subject {
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 0.9375rem;
}

.row-snippet {
  -webkit-line-clamp: 2;
  line-clamp: 2;
  color: var(--muted);
  font-size: 0.875rem;
}

.row.unread .row-from,
.row.unread .row-subject {
  color: var(--navy);
  font-weight: 750;
}

.row.unread .row-date {
  color: var(--teal);
  font-weight: 700;
}

.load-more {
  display: flex;
  margin: 16px auto;
}

.empty,
.reader-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

.empty .icon,
.reader-empty .icon {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 6px;
  color: var(--sage);
}

.empty strong {
  color: var(--navy);
}

.nowrap-address {
  font-weight: 650;
  overflow-wrap: anywhere;
}

/* ───────── Reader ───────── */

.reader-pane {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.reader-empty {
  height: 100%;
  align-content: center;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(252, 248, 244, 0.94);
  backdrop-filter: blur(6px);
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.back-btn {
  display: none;
}

.reader {
  display: grid;
  gap: 20px;
  max-width: 860px;
  padding: 24px clamp(16px, 3vw, 32px) 48px;
}

.reader-subject {
  font-size: clamp(1.25rem, 2.4vw, 1.625rem);
  letter-spacing: -0.02em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.reader-from {
  display: flex;
  gap: 12px;
}

.reader-from-text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.reader-from-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}

.reader-from-line strong {
  font-size: 1rem;
}

.reader-from-line time,
.reader-address,
.reader-detail {
  color: var(--muted);
}

.reader-detail span {
  font-weight: 650;
}

.reader-html,
.reader-text {
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.reader-html {
  display: grid;
  gap: 16px;
  overflow-x: auto;
}

.reader-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mail-frame {
  display: block;
  width: 100%;
  min-height: 80px;
  border: 0;
}

.attachments {
  display: grid;
  gap: 10px;
}

.attachments h2 {
  font-size: 1rem;
}

.attachments ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 10px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy);
  text-decoration: none;
}

.attachment:hover {
  border-color: var(--sage);
  background: var(--mint);
}

.attachment .icon {
  color: var(--teal);
}

.attachment-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.attachment-size {
  flex: none;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* ───────── Mailboxes and Account pages ───────── */

.page {
  display: grid;
  grid-column: 1 / -1;
  align-content: start;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  padding: 28px clamp(16px, 4vw, 40px) 48px;
  overflow-y: auto;
}

.page-narrow {
  max-width: 560px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-head h1 {
  font-size: 1.625rem;
  letter-spacing: -0.02em;
}

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

.card,
.box-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.card {
  display: grid;
  gap: 14px;
}

.card h2 {
  font-size: 1.0625rem;
}

.box-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}

.box-off .avatar,
.box-off .box-text {
  opacity: 0.6;
}

.account-who {
  display: flex;
  align-items: center;
}

.box-text {
  display: grid;
  flex: 1 1 200px;
  gap: 2px;
  min-width: 0;
}

.box-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.box-address {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.box-meta {
  color: var(--muted);
  font-size: 0.8125rem;
}

.box-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page > .btn {
  justify-self: start;
}

/* ───────── Dialogs and toasts ───────── */

.dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: clamp(20px, 5vw, 28px);
  border: 0;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 18px 50px rgba(16, 32, 57, 0.25);
}

.dialog::backdrop {
  background: rgba(16, 32, 57, 0.45);
}

.dialog h2 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: var(--white);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.toast-error {
  background: var(--coral);
}

/* ───────── Phones and small tablets ───────── */

@media (max-width: 899px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .side {
    gap: 10px;
    padding: 12px 12px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side .brand {
    padding: 0 4px;
  }

  .side-user {
    display: none;
  }

  .nav {
    display: flex;
    gap: 2px;
    margin: 0 -4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-link {
    flex: 1 0 auto;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 10px;
    border-bottom: 3px solid transparent;
    border-radius: 10px 10px 0 0;
    font-size: 0.875rem;
  }

  .nav-link.active {
    border-bottom-color: var(--teal);
    background: none;
  }

  .nav-count {
    margin-left: 0;
    padding: 0 7px;
  }

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

  .list-pane {
    border-right: 0;
  }

  .reader-pane {
    display: none;
  }

  .shell.reading .list-pane {
    display: none;
  }

  .shell.reading .reader-pane {
    display: block;
  }

  .back-btn {
    display: inline-flex;
  }

  .box-actions {
    flex-basis: 100%;
  }
}

@media (max-width: 479px) {
  .nav-link .icon {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Grid boxes must be allowed to get narrower than a long word or address inside them. */
.row-text,
.reader,
.reader-from-text,
.reader-html,
.box-text,
.side-user-text,
.page,
.card,
.form,
.field,
.auth-card,
.attachments {
  grid-template-columns: minmax(0, 1fr);
}

/* ───────── Writing a message ───────── */

textarea {
  display: block;
  width: 100%;
  min-height: 11rem;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: inherit;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

textarea:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(11, 101, 87, 0.15);
}

.dialog-wide {
  width: min(680px, calc(100vw - 24px));
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.list-title {
  flex-wrap: wrap;
}

.preview-note {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--blush-soft);
  color: var(--ink);
  font-size: 0.875rem;
}
