:root {
  --blue: #087BFF;
  --deep-blue: #0057D9;
  --midnight: #071426;
  --sky: #69B5FF;
  --ice: #F2F8FF;
  --white: #FFFFFF;
  --ink: #111827;
  --muted: #64748b;
  --line: #e7ebf1;
  --panel: #f8fafc;
  --hover: #f3f6fa;
  --shadow: 0 18px 55px rgba(7, 20, 38, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--white);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    Inter, system-ui, sans-serif;
}

button, input, textarea, select {
  font: inherit;
}

button, a { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }

.universal-bar {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(22px);
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: var(--midnight);
  text-decoration: none;
  font-weight: 780;
  letter-spacing: -.03em;
  white-space: nowrap;
}

.brand-star {
  color: var(--blue);
  font-size: 18px;
  line-height: 1;
}

.universal-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.universal-nav::-webkit-scrollbar { display: none; }

.universal-nav a {
  color: #596579;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.universal-nav a:hover,
.universal-nav a.active {
  color: var(--midnight);
}

.app-shell {
  height: 100dvh;
  padding-top: 46px;
}

.center-state {
  height: calc(100dvh - 46px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
}

.center-state h1 {
  margin: 16px 0 8px;
  font-size: clamp(30px, 6vw, 54px);
  letter-spacing: -.055em;
}

.center-state p {
  color: var(--muted);
  max-width: 520px;
  line-height: 1.55;
  margin: 0 0 22px;
}

.berry-mark,
.reader-star {
  color: var(--blue);
  font-weight: 800;
  line-height: 1;
}

.berry-mark { font-size: 58px; }
.reader-star { font-size: 42px; }

.primary-button,
.secondary-button,
.compose-button,
.icon-button,
.folder {
  border: 0;
  cursor: pointer;
}

.primary-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--blue);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.primary-button:hover { background: var(--deep-blue); }

.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--hover);
  color: var(--ink);
}

.mail-app {
  height: calc(100dvh - 46px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mail-header {
  min-height: 76px;
  display: grid;
  grid-template-columns: 220px minmax(260px, 680px) 220px;
  align-items: center;
  gap: 22px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
}

.mail-header h1 {
  margin: 1px 0 0;
  font-size: 25px;
  letter-spacing: -.04em;
}

.search-wrap {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.search-wrap:focus-within {
  border-color: rgba(8,123,255,.38);
  box-shadow: 0 0 0 3px rgba(8,123,255,.08);
  background: white;
}

.search-wrap span {
  color: #738096;
  font-size: 20px;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.account-pill {
  justify-self: end;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.status-banner {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px;
  border-bottom: 1px solid #dceaff;
  background: var(--ice);
  color: #28435f;
  font-size: 12px;
}

.status-banner strong {
  margin-right: 7px;
  color: var(--midnight);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(8,123,255,.12);
}

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 220px minmax(300px, 390px) minmax(420px, 1fr);
}

.sidebar,
.message-list-panel {
  border-right: 1px solid var(--line);
}

.sidebar {
  min-height: 0;
  padding: 15px 12px;
  display: flex;
  flex-direction: column;
  background: #fbfcfe;
  overflow-y: auto;
}

.compose-button {
  width: 100%;
  height: 44px;
  border-radius: 13px;
  background: var(--blue);
  color: white;
  font-weight: 750;
  text-align: left;
  padding: 0 15px;
}

.compose-button:hover { background: var(--deep-blue); }

.compose-button span {
  font-size: 19px;
  margin-right: 4px;
}

.folder-list {
  display: grid;
  gap: 3px;
  margin-top: 15px;
}

.folder {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: transparent;
  color: #445267;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}

.folder:hover { background: var(--hover); }
.folder.active {
  background: #eaf3ff;
  color: var(--deep-blue);
  font-weight: 700;
}
.folder b { font-size: 11px; }

.mailbox-card {
  margin-top: auto;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  display: grid;
  gap: 4px;
  overflow: hidden;
}

.mailbox-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.mailbox-card > span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.mailbox-label {
  color: var(--blue);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
}

.message-list-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: white;
}

.panel-toolbar {
  min-height: 58px;
  padding: 10px 12px 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.panel-toolbar > div {
  display: grid;
  gap: 2px;
}

.panel-toolbar span { font-weight: 750; }
.panel-toolbar small { color: var(--muted); }

.icon-button {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  background: transparent;
  color: #526075;
  font-size: 18px;
}

.icon-button:hover { background: var(--hover); }

.message-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.empty-list {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-list strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

.message-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  padding: 13px 15px;
  text-align: left;
  cursor: pointer;
}

.message-row:hover { background: var(--hover); }
.message-row.unread { background: #fbfdff; }

.message-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.message-row.unread .message-row-from,
.message-row.unread .message-row-subject {
  font-weight: 760;
}

.message-row-time {
  color: var(--muted);
  white-space: nowrap;
}

.message-row-subject {
  margin-top: 6px;
  font-size: 13px;
}

.message-row-snippet {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: white;
}

.empty-reader {
  height: 100%;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 42px;
}

.empty-reader h2 {
  margin: 13px 0 8px;
  letter-spacing: -.035em;
}

.empty-reader p {
  max-width: 580px;
  color: var(--muted);
  line-height: 1.58;
}

.reader-message {
  padding: 28px clamp(20px, 4vw, 54px);
}

.reader-message h2 {
  margin: 8px 0 18px;
  font-size: 27px;
  letter-spacing: -.04em;
}

.reader-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.reader-body {
  margin-top: 28px;
  white-space: pre-wrap;
  line-height: 1.65;
}

.compose-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 74px 24px 24px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  background: rgba(7,20,38,.18);
  backdrop-filter: blur(3px);
}

.composer {
  width: min(650px, 100%);
  height: min(620px, calc(100dvh - 100px));
  border: 1px solid rgba(7,20,38,.12);
  border-radius: 18px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.composer-header {
  min-height: 48px;
  padding: 0 10px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--midnight);
  color: white;
}

.compose-line {
  min-height: 45px;
  display: grid;
  grid-template-columns: 65px 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.compose-line input,
.compose-line select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.compose-body {
  flex: 1;
  width: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 18px;
  line-height: 1.58;
  color: var(--ink);
}

.composer-footer {
  min-height: 62px;
  padding: 9px 12px 9px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.composer-status {
  color: var(--muted);
  font-size: 11px;
}

.composer-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 960px) {
  .mail-header {
    grid-template-columns: 170px minmax(220px, 1fr) auto;
  }

  .workspace {
    grid-template-columns: 190px minmax(300px, 1fr);
  }

  .reader-panel { display: none; }
}

@media (max-width: 680px) {
  .universal-bar { padding: 0 12px; gap: 14px; }
  .universal-nav { gap: 15px; }

  .mail-header {
    min-height: 112px;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto 42px;
    padding: 10px 12px;
    gap: 8px 12px;
  }

  .search-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .status-banner {
    padding: 8px 12px;
  }

  .status-banner span:not(.status-dot) {
    line-height: 1.35;
  }

  .workspace {
    display: block;
    overflow-y: auto;
  }

  .sidebar {
    min-height: auto;
    padding: 10px 10px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .compose-button {
    height: 42px;
  }

  .folder-list {
    display: flex;
    overflow-x: auto;
    gap: 5px;
    margin-top: 8px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .folder-list::-webkit-scrollbar { display: none; }

  .folder {
    flex: 0 0 auto;
    height: 34px;
    gap: 7px;
  }

  .mailbox-card { display: none; }

  .message-list-panel {
    min-height: calc(100dvh - 46px - 112px - 50px - 94px);
    border-right: 0;
  }

  .compose-backdrop {
    padding: 46px 0 0;
    align-items: stretch;
    background: white;
  }

  .composer {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .composer-footer {
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }

  .composer-status {
    max-width: 45%;
  }
}
