:root {
  --bg: #f3ecdf;
  --bg-strong: #eadcc5;
  --surface: rgba(255, 250, 242, 0.92);
  --surface-strong: #fffdf8;
  --surface-border: rgba(27, 55, 49, 0.12);
  --text: #183932;
  --text-soft: #5c7169;
  --text-faint: #8a9792;
  --primary: #176b60;
  --primary-strong: #124b45;
  --accent: #dc7b58;
  --danger: #b0493b;
  --shadow: 0 26px 70px rgba(25, 54, 47, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --max-width: 1240px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(235, 123, 86, 0.18), transparent 28rem),
    radial-gradient(circle at top right, rgba(19, 111, 99, 0.2), transparent 24rem),
    linear-gradient(180deg, #f9f4ea 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.background-orb,
.background-grid {
  position: fixed;
  pointer-events: none;
}

.background-orb {
  z-index: 0;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.42;
}

.background-orb--left {
  top: -10rem;
  left: -8rem;
  background: rgba(235, 123, 86, 0.22);
}

.background-orb--right {
  top: 12rem;
  right: -10rem;
  background: rgba(19, 111, 99, 0.18);
}

.background-grid {
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(23, 55, 48, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 55, 48, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 85%);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.hero-copy,
.control-panel,
.workspace,
.inbox-list,
.detail-panel {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
}

.brand,
.topbar-status,
.workspace-bar,
.inbox-address-info,
.workspace-actions,
.button-row,
.detail-toolbar,
.preview-card {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
  text-decoration: none;
}

.brand-mark,
.feature-icon,
.empty-icon,
.inbox-avatar {
  display: grid;
  place-items: center;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0f574e 0%, #1c8b7b 100%);
  color: white;
  box-shadow: 0 16px 32px rgba(15, 87, 78, 0.25);
}

.brand-mark svg,
.feature-icon svg,
.empty-icon svg {
  width: 24px;
  height: 24px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong,
.hero h1,
.panel-head h2,
.panel-top h2,
.detail-subject,
.detail-empty h2 {
  font-family: "Sora", sans-serif;
}

.brand-copy strong {
  font-size: 1.05rem;
}

.brand-copy span:last-child,
.mail-meta,
.detail-row,
.preview-label,
.meta-card span {
  color: var(--text-soft);
}

.topbar-status {
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill,
.domain-chip,
.count-badge,
.mail-badge,
.attachment-link,
.toast {
  display: inline-flex;
  align-items: center;
}

.status-pill {
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(19, 111, 99, 0.16);
  background: rgba(19, 111, 99, 0.08);
  color: var(--primary-strong);
  font-weight: 700;
}

.status-pill--soft {
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-soft);
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b9c7c2;
}

.status-dot.is-live {
  background: #2f9d73;
  box-shadow: 0 0 0 5px rgba(47, 157, 115, 0.16);
}

.content {
  display: grid;
  gap: 26px;
  margin-top: 26px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 26px;
}

.hero-copy,
.control-panel,
.workspace,
.inbox-list,
.detail-panel {
  border-radius: var(--radius-xl);
}

.hero-copy {
  padding: 42px;
}

.eyebrow,
.panel-kicker,
.workspace-label {
  display: inline-block;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 800;
}

.hero h1 {
  margin: 16px 0;
  max-width: 12ch;
  font-size: clamp(2.6rem, 4vw, 4.5rem);
  line-height: 1.02;
}

.hero-lead,
.feature-card p,
.input-hint,
.mail-preview,
.detail-empty p {
  line-height: 1.65;
}

.hero-lead {
  max-width: 58ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 1.05rem;
}

.feature-grid,
.meta-grid,
.email-list-items {
  display: grid;
  gap: 16px;
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 34px;
}

.feature-card,
.meta-card,
.mail-item {
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 55, 48, 0.08);
}

.feature-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
}

.feature-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(19, 111, 99, 0.12), rgba(235, 123, 86, 0.18));
  color: var(--primary-strong);
}

.feature-card h2,
.detail-empty h2,
.empty-state h3 {
  margin: 0 0 6px;
}

.feature-card p,
.input-hint,
.mail-preview,
.empty-state p,
.detail-empty p {
  margin: 0;
  color: var(--text-soft);
}

.control-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.panel-head h2,
.panel-top h2 {
  margin: 8px 0 0;
  font-size: 1.6rem;
}

.email-form,
.input-stack,
.detail-meta {
  display: grid;
  gap: 12px;
}

.field-label,
.preview-address,
.mail-sender,
.mail-subject,
.inbox-address,
.detail-subject,
.meta-card strong {
  font-weight: 800;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 8px 8px 18px;
  border-radius: 18px;
  border: 1px solid rgba(23, 55, 48, 0.12);
  background: rgba(255, 255, 255, 0.78);
}

.email-input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.email-input::placeholder {
  color: var(--text-faint);
}

.domain-chip {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(19, 111, 99, 0.08);
  color: var(--primary-strong);
  font-weight: 800;
  white-space: nowrap;
}

.button-row,
.workspace-actions,
.detail-toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.toolbar-btn,
.mail-item {
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.toolbar-btn {
  min-height: 46px;
  border-radius: 14px;
  padding: 0 16px;
  border: 1px solid rgba(23, 55, 48, 0.12);
  font-weight: 800;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, var(--primary) 0%, #27a088 100%);
  color: white;
  box-shadow: 0 18px 32px rgba(19, 111, 99, 0.24);
}

.secondary-btn,
.ghost-btn,
.toolbar-btn {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
}

.toolbar-btn--danger {
  color: var(--danger);
  border-color: rgba(179, 77, 57, 0.22);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.toolbar-btn:hover,
.mail-item:hover {
  transform: translateY(-1px);
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.toolbar-btn:focus-visible,
.email-input:focus-visible,
.mail-item:focus-visible {
  outline: 3px solid rgba(19, 111, 99, 0.18);
  outline-offset: 2px;
}

.input-hint.is-error {
  color: var(--danger);
}

.preview-card {
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(19, 111, 99, 0.1), rgba(235, 123, 86, 0.12));
}

.preview-address {
  margin-top: 4px;
  word-break: break-word;
}

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

.meta-card {
  padding: 16px;
}

.meta-card strong {
  display: block;
  margin-top: 8px;
}

.workspace {
  padding: 22px;
}

.workspace-bar {
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(23, 55, 48, 0.08);
}

.inbox-address-info {
  gap: 16px;
}

.inbox-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(19, 111, 99, 0.95), rgba(235, 123, 86, 0.74));
  color: white;
  font-family: "Sora", sans-serif;
  font-size: 1.2rem;
}

.inbox-address {
  margin-top: 6px;
  font-size: clamp(1rem, 2vw, 1.25rem);
  word-break: break-word;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.35fr);
  gap: 18px;
  margin-top: 20px;
  align-items: start;
}

.inbox-list,
.detail-panel {
  padding: 20px;
  min-height: 720px;
}

.panel-top,
.mail-item-header,
.mail-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.mail-item-header {
  align-items: baseline;
}

.count-badge {
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 16px;
  background: rgba(19, 111, 99, 0.08);
  color: var(--primary-strong);
  font-weight: 800;
}

.email-list-items {
  margin-top: 18px;
  align-content: start;
}

.mail-item {
  width: 100%;
  text-align: left;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(244, 249, 247, 0.82));
  box-shadow: 0 12px 28px rgba(23, 55, 48, 0.05);
}

.mail-item.is-active {
  border-color: rgba(23, 107, 96, 0.42);
  background:
    linear-gradient(180deg, rgba(236, 247, 244, 0.98), rgba(226, 241, 236, 0.9));
  box-shadow: 0 18px 40px rgba(23, 107, 96, 0.12);
}

.mail-item.is-unread {
  border-color: rgba(220, 123, 88, 0.4);
}

.mail-subject {
  margin: 10px 0;
  line-height: 1.4;
  font-size: 1.12rem;
}

.mail-badges,
.attachment-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mail-badge,
.attachment-link {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(23, 55, 48, 0.07);
  font-size: 0.84rem;
  font-weight: 700;
}

.empty-state,
.detail-empty {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 420px;
  text-align: center;
  color: var(--text-soft);
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  background: rgba(19, 111, 99, 0.08);
  color: var(--primary);
}

.detail-toolbar {
  justify-content: space-between;
}

.detail-meta {
  margin: 18px 0;
}

.detail-subject {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.2;
}

.detail-summary {
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(238, 247, 244, 0.92), rgba(255, 255, 255, 0.76));
  border: 1px solid rgba(23, 107, 96, 0.1);
  color: var(--text-soft);
  line-height: 1.65;
}

.attachment-list.hidden {
  display: none !important;
}

.attachment-link {
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
  border: 1px solid rgba(23, 55, 48, 0.1);
}

.viewer-switcher {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(23, 55, 48, 0.06);
  border: 1px solid rgba(23, 55, 48, 0.08);
}

.viewer-tab {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 800;
}

.viewer-tab.is-active {
  background: #ffffff;
  color: var(--primary-strong);
  box-shadow: 0 8px 20px rgba(23, 55, 48, 0.08);
}

.text-shell,
.iframe-shell {
  min-height: 580px;
  margin-top: 16px;
  border-radius: 20px;
  border: 1px solid rgba(23, 55, 48, 0.08);
  background: rgba(255, 255, 255, 0.97);
  overflow: hidden;
}

.text-shell {
  padding: 24px;
}

.detail-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-family: "Manrope", sans-serif;
  font-size: 0.98rem;
  line-height: 1.8;
}

.email-iframe {
  width: 100%;
  min-height: 580px;
  border: 0;
  background: white;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 30;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: #173730;
  color: white;
  box-shadow: 0 22px 40px rgba(23, 55, 48, 0.22);
}

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

@media (max-width: 720px) {
  .page-shell {
    width: min(calc(100% - 20px), var(--max-width));
    padding-top: 12px;
  }

  .topbar,
  .hero-copy,
  .control-panel,
  .workspace,
  .inbox-list,
  .detail-panel {
    padding: 18px;
  }

  .topbar,
  .workspace-bar,
  .preview-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-status,
  .workspace-actions,
  .button-row,
  .detail-toolbar {
    width: 100%;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .toolbar-btn {
    flex: 1 1 0;
  }

  .input-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .domain-chip {
    justify-content: center;
  }

  body.detail-open .inbox-list {
    display: none;
  }

  body.detail-open #emailDetail {
    display: block !important;
  }

  body.detail-open #detailPlaceholder {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
