:root {
  color-scheme: light;
  --bg: #f5f6f1;
  --panel: #ffffff;
  --panel-soft: #f9faf6;
  --ink: #20231f;
  --muted: #6a7169;
  --line: #dde2d8;
  --green: #126b5a;
  --green-dark: #0b4d41;
  --amber: #b16a00;
  --red: #b42318;
  --blue: #2f5f98;
  --shadow: 0 18px 40px rgba(29, 33, 27, 0.08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  min-height: 40px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

button.secondary {
  background: #fff;
  color: var(--green);
}

button.secondary:hover {
  background: #eef6f2;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--green);
  padding: 0 8px;
}

button.ghost:hover {
  background: #eef6f2;
  border-color: #cddfd7;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(18, 107, 90, 0.14);
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.hidden {
  display: none !important;
}

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

.sidebar {
  background: #1f2822;
  color: #f4f2e9;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e0b45c;
  color: #1f2822;
  font-weight: 800;
}

.brand-title {
  font-size: 18px;
  font-weight: 750;
}

.brand-subtitle {
  color: #c4cabc;
  font-size: 12px;
  margin-top: 3px;
}

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

.nav-button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: #dfe5da;
}

.nav-button:hover,
.nav-button.active {
  background: #344037;
  border-color: #4a5b50;
}

.sidebar-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c4cabc;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--amber);
}

.status-dot.ok {
  background: #4daa57;
}

.status-dot.error {
  background: var(--red);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

h3 {
  font-size: 15px;
  margin-bottom: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.active-account {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.auth-panel,
.settings-panel,
.docs-panel,
.random-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  max-width: 760px;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  padding: 28px;
}

.auth-copy p,
.settings-panel p,
.docs-panel p,
.helper {
  color: var(--muted);
  line-height: 1.6;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  color: var(--ink);
}

.check-row input {
  width: 16px;
  height: 16px;
  min-height: 16px;
}

.form-error {
  min-height: 20px;
  margin-top: 10px;
  color: var(--red);
  font-size: 13px;
}

.toolbar,
.metrics,
.mail-layout {
  margin-bottom: 16px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 88px;
  gap: 10px;
}

.toolbar-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

.metric strong {
  font-size: 22px;
}

.mail-layout {
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 16px;
}

.message-list-panel,
.message-detail-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.panel-head span,
.panel-head p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 0;
}

.message-list {
  height: 500px;
  overflow: auto;
}

.message-item {
  width: 100%;
  min-height: 96px;
  display: block;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 14px 16px;
}

.message-item:hover,
.message-item.active {
  background: #f2f8f5;
}

.message-item .subject {
  font-weight: 700;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.message-item .from,
.message-item .preview,
.message-item .time {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-item .time {
  margin-top: 8px;
  color: var(--blue);
}

.empty-state,
.empty-detail {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 360px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-detail h2 {
  color: var(--ink);
}

.message-detail {
  padding: 18px;
}

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

.detail-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.detail-head h2 {
  overflow-wrap: anywhere;
}

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

.meta-grid div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

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

.body-section,
.attachments-section,
.raw-html-box {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mail-body,
.raw-html-box pre,
.code-block pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #20231f;
  color: #f7f3e8;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.55;
  max-height: 380px;
  overflow: auto;
}

.attachments {
  display: grid;
  gap: 8px;
}

.attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-soft);
}

.attachment-row span {
  overflow-wrap: anywhere;
}

.settings-panel,
.docs-panel,
.random-panel {
  padding: 18px;
}

.settings-panel .panel-head,
.random-panel .panel-head {
  padding: 0 0 16px;
  margin-bottom: 16px;
}

.random-card {
  max-width: 760px;
  display: grid;
  gap: 14px;
}

.random-card select {
  max-width: 260px;
}

.random-address {
  min-height: 78px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--green-dark);
  padding: 14px 16px;
  font-size: 28px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.random-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.random-tips {
  max-width: 760px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.random-tips p {
  color: var(--muted);
  line-height: 1.6;
}

.webhook-form {
  max-width: 860px;
}

.webhook-form > label,
.webhook-form .two-col {
  margin-top: 14px;
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

#webhookStatus {
  color: var(--muted);
  font-size: 13px;
}

.code-block {
  position: relative;
  margin: 16px 0;
}

.copy-snippet {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f7f3e8;
}

.endpoint-list {
  display: grid;
  gap: 10px;
}

.endpoint-list div {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.endpoint-list strong {
  color: var(--green);
  overflow-wrap: anywhere;
}

.endpoint-list span {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #20231f;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 14px;
    gap: 14px;
  }

  .nav {
    display: flex;
    flex: 1;
    overflow-x: auto;
  }

  .nav-button {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-note {
    display: none;
  }

  .mail-layout {
    grid-template-columns: 1fr;
  }

  .message-list {
    height: 360px;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .address-row,
  .metrics,
  .meta-grid,
  .two-col,
  .endpoint-list div {
    grid-template-columns: 1fr;
  }

  .detail-head,
  .section-title,
  .panel-head {
    display: grid;
  }

  .toolbar-buttons {
    width: 100%;
  }

  .toolbar-buttons button,
  .address-row button {
    width: 100%;
  }
}
