:root {
  color-scheme: light;
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef0f2;
  --ink: #202326;
  --muted: #6c7278;
  --line: #dfe3e6;
  --line-strong: #c9ced3;
  --accent: #2f3337;
  --danger: #b42318;
  --danger-bg: #fff5f5;
  --shadow: 0 10px 28px rgba(20, 24, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand,
.section-title,
.panel-toolbar,
.detail-header,
.reply-head,
.toolbar-actions,
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand h1,
.panel-toolbar h2,
.detail-header h2,
.reply-head h3 {
  margin: 2px 0 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 22px;
}

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

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #4b5563;
  box-shadow: 0 0 0 5px rgba(75, 85, 99, 0.12);
  flex: 0 0 auto;
}

.search-box,
.reply-box label {
  display: grid;
  gap: 8px;
}

.search-box span,
.reply-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.search-box input,
.reply-box input,
.reply-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-box input:focus,
.reply-box input:focus,
.reply-box textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 51, 55, 0.08);
}

.sidebar-section {
  min-height: 0;
}

.section-title {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.filter-list,
.email-list {
  display: grid;
  gap: 8px;
}

.filter-list {
  max-height: 30vh;
  overflow: auto;
  padding-right: 4px;
}

.filter-item,
.email-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.filter-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  background: var(--surface-2);
  color: var(--ink);
}

.filter-item.active {
  border-color: var(--accent);
  background: var(--surface-3);
}

.filter-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.filter-count {
  color: var(--muted);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  min-width: 0;
}

.list-panel,
.detail-panel {
  min-width: 0;
  padding: 22px;
}

.list-panel {
  border-right: 1px solid var(--line);
  background: #fafafa;
}

.panel-toolbar {
  margin-bottom: 16px;
}

.panel-toolbar h2,
.detail-header h2 {
  font-size: 23px;
}

.soft-btn,
.primary-btn,
.danger-btn,
.icon-btn {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.danger-btn {
  border-color: #f0c4c0;
  background: var(--danger-bg);
  color: var(--danger);
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.email-list {
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding-right: 4px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.email-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(20, 24, 28, 0.04);
}

.email-item.active {
  border-color: var(--accent);
}

.email-item.unread .email-subject::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.email-topline,
.email-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.email-subject,
.email-sender {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-subject {
  font-weight: 850;
}

.email-sender,
.email-meta {
  color: var(--muted);
  font-size: 13px;
}

.detail-panel {
  background: var(--bg);
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: calc(100vh - 44px);
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.empty-state.compact {
  min-height: 190px;
}

.empty-state h2 {
  margin: 8px 0;
  font-size: 28px;
  letter-spacing: 0;
}

.empty-state p:last-child {
  color: var(--muted);
  line-height: 1.7;
}

.email-detail {
  display: grid;
  gap: 16px;
}

.hidden {
  display: none !important;
}

.detail-header,
.meta-grid,
.mail-body,
.reply-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-header {
  align-items: flex-start;
  padding: 18px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  padding: 0;
}

.meta-grid div {
  min-width: 0;
  padding: 14px;
  background: #fff;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meta-grid dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.mail-body {
  min-height: 260px;
  padding: 20px;
  line-height: 1.75;
}

.reply-box {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.reply-box span {
  color: var(--muted);
}

.reply-box textarea {
  resize: vertical;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 13px 15px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(244, 245, 246, 0.88);
  backdrop-filter: blur(8px);
}

.auth-card {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
  font-size: 22px;
}

.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline: none;
}

.auth-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 51, 55, 0.08);
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .empty-state {
    min-height: 240px;
  }
}

@media (max-width: 680px) {
  .sidebar,
  .list-panel,
  .detail-panel {
    padding: 14px;
  }

  .brand h1,
  .panel-toolbar h2,
  .detail-header h2 {
    font-size: 20px;
  }

  .panel-toolbar,
  .detail-header,
  .reply-head,
  .email-topline,
  .email-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions,
  .detail-actions,
  .pager {
    width: 100%;
  }

  .toolbar-actions button,
  .detail-actions button,
  .reply-head button {
    flex: 1;
    width: 100%;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .mail-body {
    min-height: 180px;
  }
}
