:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, .86);
  --surface-solid: #fff;
  --surface-soft: #f9fafb;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-2: #8a8f98;
  --line: #e5e5ea;
  --line-strong: #d2d2d7;
  --accent: #0071e3;
  --accent-soft: #e8f2ff;
  --green: #16845f;
  --green-soft: #eaf7f1;
  --danger: #c93434;
  --danger-soft: #fff1f1;
  --warning: #a05a00;
  --warning-soft: #fff8ed;
  --shadow: 0 18px 44px rgba(0, 0, 0, .07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, .9), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

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

a {
  color: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid rgba(0, 0, 0, .06);
  background: rgba(247, 247, 249, .78);
  color: var(--text);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 18px;
}

.brand span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #1f8fff, #0a69d6);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.connected {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .04);
}

.connected span {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: #34c759;
}

.connected strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.sidebar a,
.nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 10px;
  border-radius: 8px;
  padding: 0 12px;
  color: #34343a;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.nav a span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line-strong);
}

.sidebar a:hover,
.nav a:hover {
  background: rgba(0, 0, 0, .045);
}

.nav a.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .05);
}

.nav a.active span {
  background: var(--accent);
}

.nav a:focus,
.sidebar a:focus,
.button:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(0, 113, 227, .18);
  outline-offset: 2px;
}

.nav-primary {
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface-solid);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .04);
}

.main {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
  padding: clamp(18px, 2.2vw, 34px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 38px;
  line-height: 1.08;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 17px;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 113, 227, .18);
}

.button:hover {
  background: #0067cf;
}

.button.light {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: none;
}

.compact-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.button.danger {
  background: var(--danger);
  box-shadow: 0 10px 22px rgba(201, 52, 52, .14);
}

.grid {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(420px, 520px);
  gap: 18px;
  align-items: start;
}

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

.single-grid .panel {
  width: 100%;
}

.groups-page .panel {
  width: 100%;
}

.mail-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-height: 0;
}

.mail-workspace.has-detail {
  grid-template-columns: minmax(420px, .86fr) minmax(520px, 1.14fr);
}

.mail-list-panel,
.mail-detail-panel {
  min-width: 0;
}

.mail-detail-panel {
  position: sticky;
  top: clamp(18px, 2.2vw, 34px);
  animation: drawerIn .22s ease-out both;
}

.panel {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  scroll-margin-top: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-actions {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: center;
}

.panel-head span,
.muted,
.list-row span,
.list-row time {
  color: var(--muted);
  font-size: 13px;
}

.welcome {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.scroll-list {
  max-height: calc(100vh - 260px);
  min-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.group-list {
  display: grid;
  max-height: calc(100vh - 260px);
  gap: 8px;
  margin-bottom: 14px;
}

.group-workspace .group-list {
  margin-bottom: 0;
}

.group-create-box {
  margin-top: 12px;
}

.create-popover {
  position: relative;
}

.create-popover summary {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  box-shadow: 0 8px 18px rgba(0, 113, 227, .14);
}

.create-popover summary::-webkit-details-marker {
  display: none;
}

.create-popover-form {
  position: absolute;
  z-index: 5;
  top: 44px;
  right: 0;
  width: min(520px, calc(100vw - 320px));
  min-width: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 24px 54px rgba(0, 0, 0, .16);
  backdrop-filter: blur(22px);
  animation: popoverIn .18s ease-out both;
}

.group-workspace {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.group-detail-page {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, .8fr);
  gap: 16px;
  align-items: start;
}

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

.group-list-pane,
.group-tools-pane {
  min-width: 0;
}

.group-tools-pane {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 238px);
  overflow: auto;
  padding-right: 4px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .74);
  color: inherit;
  text-decoration: none;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.list-row:hover {
  border-color: var(--line-strong);
  background: #fff;
  transform: translateY(-1px);
}

.list-row + .list-row {
  margin-top: 8px;
}

.group-list .list-row + .list-row {
  margin-top: 0;
}

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

.list-row strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
  text-decoration: none;
}

.list-row:hover strong,
.list-row:hover span {
  text-decoration: none;
}

.group-card.active {
  border-color: rgba(0, 113, 227, .38);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.group-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .74);
}

.group-row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.group-row-main strong,
.group-row-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-row-main span,
.group-row-id {
  color: var(--muted);
  font-size: 13px;
}

.danger-link {
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
}

.danger-link:hover {
  background: #ffe4e4;
}

.mail-row.active {
  border-color: rgba(0, 113, 227, .38);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.mail-row.read {
  border-color: rgba(229, 229, 234, .72);
  background: rgba(249, 250, 251, .58);
  opacity: .68;
}

.mail-row.read strong {
  color: #55565a;
  font-weight: 650;
}

.mail-row.read span,
.mail-row.read time {
  color: var(--muted-2);
}

.mail-row.unread {
  background: rgba(255, 255, 255, .88);
}

.mail-row.unread strong::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--accent);
  vertical-align: 2px;
}

.mail-row.active,
.mail-row.active strong,
.mail-row.active span,
.mail-row.active time {
  opacity: 1;
}

.mail-row.active {
  border-color: rgba(0, 113, 227, .38);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.compose,
label {
  display: grid;
  gap: 10px;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.group-detail,
.empty-detail,
.action-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}

.group-detail,
.empty-detail {
  margin: 0;
  padding: 16px;
}

.group-detail {
  max-height: calc(100vh - 238px);
  overflow: auto;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.soft-warning {
  margin: 0 0 12px;
  border: 1px solid #ffd9a7;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
}

.alias-list {
  display: grid;
  gap: 8px;
}

.alias-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.alias-row span {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-row button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.alias-row button:hover {
  background: #ffe4e4;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(29, 29, 31, .28);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(14px);
  transition: opacity .18s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.confirm-modal {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  width: min(440px, 100%);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 14px;
  padding: 18px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .22);
  transform: translateY(10px) scale(.97);
  transition: transform .2s ease;
}

.modal-backdrop.open .confirm-modal {
  transform: translateY(0) scale(1);
}

.confirm-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 22px;
  font-weight: 850;
}

.confirm-copy h3 {
  margin: 2px 0 6px;
  font-size: 20px;
}

.confirm-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.action-box {
  overflow: hidden;
}

.action-box summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  color: var(--text);
  font-weight: 760;
  cursor: pointer;
  list-style: none;
}

.action-box summary::-webkit-details-marker {
  display: none;
}

.action-box summary::after {
  content: "+";
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
}

.action-box[open] summary::after {
  content: "-";
}

.action-box .compose {
  padding: 0 14px 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

.suffix-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.suffix-input input {
  border: 0;
  border-radius: 0;
}

.suffix-input input:focus {
  border-color: transparent;
  outline: 0;
}

.suffix-input span {
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.compact-note {
  margin: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 113, 227, .18);
  outline-offset: 0;
}

.notice,
.error {
  margin: 0;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
}

.notice {
  border: 1px solid #b7e4ca;
  background: #f1fbf6;
  color: #146c43;
}

.error {
  border: 1px solid #f6c8a8;
  background: #fff7ed;
  color: #9a3412;
}

.detail-panel {
  width: 100%;
}

.mail-frame {
  width: 100%;
  height: calc(100vh - 260px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding-top: 14px;
}

.pagination a {
  display: inline-flex;
  min-width: 34px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.pagination a:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.pagination a.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.pagination a.disabled {
  pointer-events: none;
  opacity: .42;
}

.mail-empty {
  display: grid;
  min-height: 220px;
  align-content: center;
}

@keyframes drawerIn {
  from {
    opacity: 0;
    transform: translateX(42px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes popoverIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.callback-panel {
  width: min(720px, 100%);
}

pre {
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #f4f6f8;
}

@media (min-width: 1500px) {
  .group-workspace {
    grid-template-columns: minmax(360px, .82fr) minmax(560px, 1.18fr);
  }

  .mail-workspace {
    grid-template-columns: minmax(520px, .82fr) minmax(680px, 1.18fr);
  }

  .mail-workspace:not(.has-detail) {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1200px) {
  .group-workspace,
  .group-detail-page,
  .mail-workspace {
    grid-template-columns: 1fr;
  }

  .group-list {
    max-height: 420px;
    min-height: 0;
  }

  .group-tools-pane {
    max-height: none;
  }

  .mail-detail-panel {
    position: static;
  }

  .create-popover-form {
    width: min(520px, calc(100vw - 44px));
    min-width: 0;
  }
}

@media (max-width: 1100px) {
  .shell,
  .grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 2;
    flex-direction: row;
    height: auto;
    overflow-x: auto;
    padding: 12px 14px;
  }

  .brand {
    min-width: 178px;
    padding: 0 8px 0 0;
  }

  .connected {
    min-width: 180px;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    align-items: center;
  }

  .nav-primary {
    margin-top: 0;
    min-width: max-content;
  }

  .main {
    padding: 24px 16px;
  }

  .scroll-list {
    max-height: none;
  }

  .mail-frame {
    height: 70vh;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 30px;
  }

  .topbar,
  .welcome,
  .panel-head,
  .detail-title,
  .list-row,
  .alias-row,
  .group-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar,
  .welcome,
  .panel-head,
  .detail-title {
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
    justify-content: space-between;
  }

  .create-popover-form {
    position: fixed;
    inset: auto 12px 18px;
    width: auto;
    max-height: calc(100vh - 72px);
    overflow: auto;
  }

  .two-cols {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .confirm-actions .button {
    width: auto;
    flex: 1;
  }

  .sidebar {
    gap: 8px;
  }

  .brand {
    min-width: 150px;
  }

  .connected {
    display: none;
  }

  .main {
    padding: 18px 12px;
  }

  .panel {
    padding: 14px;
  }

  .group-list {
    max-height: 360px;
  }
}
