:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #667085;
  --line: #dde3ea;
  --accent: #0891b2;
  --accent-dark: #0e7490;
  --success: #0f766e;
  --danger: #b42318;
  --shadow: 0 20px 55px rgba(23, 32, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #dff7fb 0, rgba(223, 247, 251, 0) 300px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 16px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

button.primary:hover {
  background: var(--accent-dark);
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 13px;
  background: #ffffff;
  color: var(--ink);
}

input[readonly],
select:disabled {
  background: var(--surface-soft);
}

label,
.eyebrow {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(221, 227, 234, 0.85);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(1120px, calc(100% - 32px));
  height: 66px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.82rem;
  letter-spacing: 0;
}

.breadcrumb {
  color: var(--muted);
  font-weight: 800;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 26px auto;
  display: grid;
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer-card,
.history-card {
  padding: 24px;
}

.card-head,
.mail-header,
.history-title,
.refresh-meta,
.current-email,
.current-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-head,
.mail-header,
.history-title,
.current-email {
  justify-content: space-between;
}

.status {
  max-width: 42%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, 0.9fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 24px;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(145px, auto) 96px;
  gap: 8px;
}

.current-email {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.current-email > div:first-child {
  min-width: 0;
  flex: 1;
}

.current-email span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.current-actions {
  flex-wrap: wrap;
}

.muted {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.history-card {
  box-shadow: none;
}

.history-title {
  margin-bottom: 14px;
}

.history-title button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.inbox-history {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.history-item {
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  text-align: left;
}

.history-item.active {
  border-color: var(--accent);
  background: #e8f8fc;
}

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

.history-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.inbox-card {
  overflow: hidden;
}

.mail-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.refresh-meta {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--surface-soft);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 800;
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  min-height: 520px;
}

.message-list {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.message-item {
  width: 100%;
  min-height: 92px;
  padding: 15px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  transform: none;
}

.message-item:hover,
.message-item.active {
  background: #e8f8fc;
}

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

.message-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.message-view {
  min-width: 0;
  overflow: auto;
  padding: 26px;
}

.message-meta {
  display: grid;
  gap: 7px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.message-meta h3 {
  margin-bottom: 4px;
  font-size: 1.35rem;
}

.message-body {
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.message-body iframe {
  width: 100%;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 100%;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--ink);
}

.footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

@media (max-width: 900px) {
  .composer-form {
    grid-template-columns: 1fr;
  }

  .mail-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .message-list {
    max-height: 300px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .topbar-inner,
  .page,
  .footer {
    width: min(100% - 20px, 1120px);
  }

  .composer-card,
  .history-card,
  .mail-header,
  .message-view {
    padding: 18px;
  }

  .card-head,
  .current-email,
  .mail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .status {
    max-width: 100%;
  }

  .form-actions,
  .current-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .breadcrumb {
    display: none;
  }
}
