:root {
  --bg: #eef3f8;
  --card: #ffffff;
  --line: #e5ebf2;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #e8f0ff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --success: #16a34a;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top center, rgba(37, 99, 235, 0.08), transparent 30%),
    var(--bg);
}

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

.viewer-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.topbar,
.hero-card,
.config-panel,
.tab-card,
.mail-list-panel,
.mail-detail-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}

.title-cn {
  font-size: 24px;
  font-weight: 700;
}

.title-en {
  color: var(--muted);
  margin-top: 4px;
}

.hero-card,
.config-panel,
.tab-card {
  margin-top: 18px;
  padding: 22px;
}

.email-row {
  display: grid;
  gap: 10px;
}

.email-label {
  color: var(--muted);
  font-size: 14px;
}

.email-value-wrap {
  display: flex;
  gap: 12px;
}

.email-input {
  flex: 1;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 16px;
  font-size: 18px;
  background: #f8fafc;
}

.toolbar-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.compact-row {
  margin-top: 12px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.tab-btn,
.link-btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.tab-btn:hover,
.link-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn,
.link-btn {
  background: #f8fafc;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.small-btn {
  padding: 10px 12px;
}

.status-row {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
}

.hidden {
  display: none;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 14px;
}

label input {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 2px;
}

.checkbox-label input {
  min-height: auto;
}

.tab-row {
  display: flex;
  gap: 10px;
}

.tab-btn {
  background: #f3f4f6;
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.meta-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.meta-item {
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.meta-item strong {
  font-size: 20px;
}

.content-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.mail-list-panel,
.mail-detail-panel {
  padding: 20px;
  min-height: 420px;
  overflow: hidden;
}

.mail-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.mail-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.mail-item.active {
  border-color: #93c5fd;
  background: #f8fbff;
}

.mail-subject {
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mail-from,
.mail-snippet,
.mail-meta,
.empty-subtitle {
  color: var(--muted);
}

.mail-from,
.mail-meta {
  font-size: 13px;
  margin-top: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mail-snippet {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mail-detail {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: #fafcff;
  min-height: 320px;
}

.detail-subject {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
}

.detail-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.detail-text {
  margin-top: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

.links-output {
  width: 100%;
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  resize: vertical;
  background: #fafcff;
}

.admin-grid {
  grid-template-columns: 420px 1fr;
}

.mail-list.empty,
.mail-detail.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  color: var(--muted);
  padding-top: 56px;
}

.mail-detail.empty {
  padding-top: 72px;
}

.empty {
  text-align: center;
  color: var(--muted);
}

.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.16), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(96, 165, 250, 0.14), transparent 24%),
    linear-gradient(180deg, #eef4fb 0%, #f8fbff 100%);
}

.login-shell {
  width: 100%;
  max-width: 1120px;
  padding: 24px;
}

.login-card-premium {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 80px rgba(37, 99, 235, 0.12);
  backdrop-filter: blur(14px);
}

.login-side {
  padding: 40px;
}

.login-side-brand {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 45%, #60a5fa 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-badge {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 24px;
  font-weight: 800;
}

.login-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 13px;
  margin-bottom: 18px;
}

.login-brand-block h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
}

.login-brand-block p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.75;
  max-width: 420px;
}

.login-feature-list {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.login-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.92);
}

.feature-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.login-side-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,255,0.96));
}

.login-form-head h2 {
  margin: 12px 0 8px;
  font-size: 32px;
}

.login-form-head p {
  margin: 0;
  color: var(--muted);
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.login-form {
  margin-top: 30px;
  display: grid;
  gap: 18px;
}

.full-btn {
  width: 100%;
}

.big-btn {
  min-height: 52px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 14px;
}

.login-status-box {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.center-wrap,
.center-status {
  justify-content: center;
}

@media (max-width: 980px) {
  .config-grid,
  .meta-grid,
  .content-grid,
  .admin-grid,
  .login-card-premium {
    grid-template-columns: 1fr;
  }

  .email-value-wrap,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .login-side {
    padding: 28px;
  }
}
