:root {
  color-scheme: light;
  --bg: #f4efe4;
  --bg-deep: #d7e2df;
  --paper: rgba(255, 251, 245, 0.82);
  --paper-strong: rgba(255, 252, 247, 0.94);
  --paper-border: rgba(53, 74, 87, 0.12);
  --ink: #223642;
  --muted: #5e6f78;
  --accent: #9f3f22;
  --accent-soft: rgba(159, 63, 34, 0.12);
  --shadow: 0 24px 60px rgba(28, 44, 53, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(191, 214, 206, 0.7), transparent 34%),
    radial-gradient(circle at top right, rgba(184, 125, 84, 0.18), transparent 26%),
    linear-gradient(180deg, #f7f2e8 0%, #eef2ea 54%, #f4efe4 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(24px);
  z-index: 0;
}

body::before {
  top: -120px;
  right: -140px;
  background: rgba(191, 214, 206, 0.34);
}

body::after {
  left: -140px;
  bottom: -180px;
  background: rgba(208, 171, 143, 0.26);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-view {
  min-height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: center;
}

.hero-copy {
  padding: 22px 10px;
}

.hero-copy h1,
.topbar-title,
.message-subject,
.column-head h3,
.login-panel h2,
.note-card h2,
.empty-state h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  letter-spacing: -0.02em;
}

.hero-copy h1 {
  max-width: 12ch;
  font-size: clamp(2.7rem, 5vw, 4.8rem);
  line-height: 0.96;
}

.lede {
  max-width: 52ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.8;
}

.hero-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.note-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 244, 0.74);
  border: 1px solid rgba(53, 74, 87, 0.09);
}

.note-card h2 {
  font-size: 1.18rem;
}

.note-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-panel {
  padding: 28px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 2rem;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field:last-of-type {
  margin-bottom: 0;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--ink);
}

.field input,
.field textarea,
.search-field input {
  width: 100%;
  border: 1px solid rgba(53, 74, 87, 0.12);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.68);
  padding: 14px 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
}

.field-copy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.field-divider {
  position: relative;
  display: grid;
  place-items: center;
  margin: 18px 0 16px;
}

.field-divider::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  border-top: 1px solid rgba(53, 74, 87, 0.12);
}

.field-divider span {
  position: relative;
  z-index: 1;
  padding: 0 12px;
  background: rgba(255, 251, 245, 0.92);
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.06em;
}

.field input:focus,
.field textarea:focus,
.search-field input:focus {
  border-color: rgba(159, 63, 34, 0.45);
  box-shadow: 0 0 0 4px rgba(159, 63, 34, 0.08);
  transform: translateY(-1px);
}

.primary-button,
.ghost-button,
.mode-button {
  border: 0;
  border-radius: 999px;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.primary-button {
  width: 100%;
  padding: 15px 20px;
  background: linear-gradient(135deg, #b14d29 0%, #8f3418 100%);
  color: #fffaf4;
  font-weight: 700;
  box-shadow: 0 14px 26px rgba(143, 52, 24, 0.22);
}

.primary-button:hover,
.ghost-button:hover,
.mode-button:hover,
.mail-item:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.ghost-button,
.mode-button {
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink);
  border: 1px solid rgba(53, 74, 87, 0.1);
}

.mode-button.active {
  background: rgba(159, 63, 34, 0.12);
  color: var(--accent);
  border-color: rgba(159, 63, 34, 0.18);
}

.form-hint,
.form-error,
.message-note {
  margin: 14px 0 0;
  line-height: 1.7;
}

.form-hint,
.message-note {
  color: var(--muted);
  font-size: 0.93rem;
}

.form-error {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(159, 63, 34, 0.08);
  color: #8a2f14;
}

.app-view {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
}

.topbar-title {
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(33, 54, 66, 0.08);
  color: var(--ink);
  font-weight: 600;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 182px);
}

.mail-column,
.message-column {
  min-height: 0;
}

.mail-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.column-head {
  display: grid;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(53, 74, 87, 0.08);
}

.column-head h3 {
  font-size: 1.6rem;
}

.mail-list {
  flex: 1;
  overflow: auto;
  padding: 12px;
}

.mail-list-footer {
  padding: 0 16px 18px;
}

.mail-list-more {
  width: 100%;
}

.mail-item {
  width: 100%;
  padding: 18px;
  margin-bottom: 10px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.56);
  color: inherit;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.mail-item.active {
  background: rgba(159, 63, 34, 0.11);
  border-color: rgba(159, 63, 34, 0.16);
  box-shadow: inset 0 0 0 1px rgba(159, 63, 34, 0.05);
}

.mail-item-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: baseline;
}

.mail-item-subject {
  display: block;
  font-size: 1rem;
  line-height: 1.4;
}

.mail-item-date,
.mail-item-from {
  color: var(--muted);
  font-size: 0.88rem;
}

.mail-item-from {
  margin-top: 8px;
}

.mail-item-preview {
  margin: 10px 0 0;
  color: var(--ink);
  line-height: 1.6;
}

.mail-list-empty,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 30px;
  text-align: center;
}

.mail-list-empty h4,
.empty-state h3 {
  margin: 0;
  font-size: 1.3rem;
}

.mail-list-empty p,
.empty-state p {
  max-width: 34ch;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.message-column {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 26px;
  overflow: hidden;
}

.message-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.message-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(53, 74, 87, 0.08);
}

.message-heading {
  min-width: 0;
}

.message-subject {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.04;
}

.message-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
}

.view-switcher {
  display: inline-flex;
  gap: 10px;
  padding-top: 28px;
}

.message-frame,
.message-text {
  width: 100%;
  flex: 1;
  min-height: 420px;
  border: 1px solid rgba(53, 74, 87, 0.08);
  border-radius: 22px;
  background: var(--paper-strong);
}

.message-frame {
  padding: 0;
}

.message-text {
  margin: 0;
  padding: 22px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  line-height: 1.8;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(31, 46, 54, 0.92);
  color: #fdf8ef;
  box-shadow: 0 20px 40px rgba(18, 29, 36, 0.22);
  z-index: 10;
}

@media (max-width: 1080px) {
  .login-view,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-copy h1 {
    max-width: 16ch;
  }

  .workspace {
    min-height: auto;
  }

  .mail-column {
    min-height: 360px;
  }

  .message-column {
    min-height: 680px;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1320px);
    padding: 16px 0 26px;
  }

  .hero-notes {
    grid-template-columns: 1fr;
  }

  .login-panel,
  .message-column,
  .column-head,
  .topbar {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .message-header {
    flex-direction: column;
  }

  .view-switcher {
    padding-top: 0;
  }

  .message-frame,
  .message-text {
    min-height: 340px;
  }
}
