:root {
  color-scheme: light;
  --bg: #efeeec;
  --panel: #f8f8f7;
  --panel-border: #d9d7d3;
  --line: #dbd8d4;
  --text: #181818;
  --muted: #8e8a85;
  --accent: #e04b26;
  --accent-deep: #c63f1f;
  --accent-soft: rgba(224, 75, 38, 0.12);
  --shadow: 0 10px 28px rgba(16, 16, 16, 0.06);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Consolas", "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top center, rgba(224, 75, 38, 0.08), transparent 30%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input,
select,
button {
  appearance: none;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.mailbox-panel {
  padding: 28px 30px 22px;
  border-top: 4px solid var(--accent);
}

.section-kicker,
.detail-kicker,
.history-title {
  margin: 0;
  font-size: 0.96rem;
  color: var(--muted);
}

.mailbox-form {
  margin-top: 18px;
}

.address-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 172px 156px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
}

.address-field,
.domain-field {
  display: flex;
  align-items: center;
  min-height: 56px;
}

.address-field input,
.domain-field select {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
}

.address-field input {
  padding: 0 18px;
  font-size: 1.1rem;
  font-weight: 700;
}

.address-field input:focus,
.domain-field select:focus,
.history-select:focus,
.primary-button:focus,
.token-button:focus,
.text-button:focus,
.history-action:focus,
.detail-delete:focus,
.email-card:focus {
  outline: none;
}

.domain-field {
  gap: 10px;
  padding: 0 14px 0 10px;
  border-left: 1px solid var(--line);
  background: #f7f6f3;
}

.domain-prefix {
  color: var(--muted);
  font-size: 1rem;
}

.domain-field select {
  padding-right: 22px;
  font-weight: 700;
  background-image:
    linear-gradient(45deg, transparent 50%, #8e8a85 50%),
    linear-gradient(135deg, #8e8a85 50%, transparent 50%);
  background-position:
    calc(100% - 10px) 24px,
    calc(100% - 4px) 24px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.primary-button {
  min-height: 56px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
}

.primary-button:disabled,
.primary-button.is-disabled {
  background: #d1cbc5;
  color: rgba(24, 24, 24, 0.45);
  cursor: not-allowed;
  transform: none;
}

.mailbox-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.toolbar-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.text-button,
.token-button,
.button-secondary,
.history-action {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: background 160ms ease, color 160ms ease;
}

.text-button:hover,
.token-button:hover,
.button-secondary:hover,
.history-action:hover {
  background: rgba(24, 24, 24, 0.05);
  color: var(--text);
}

.status {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.current-mailbox {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(24, 24, 24, 0.08);
}

.current-mailbox-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#mailbox-title {
  font-size: 1rem;
}

.mailbox-meta {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(24, 24, 24, 0.06);
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--mono);
}

.mailbox-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.history-strip {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(24, 24, 24, 0.08);
}

.history-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.history-count,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
}

.history-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-select {
  min-height: 40px;
  width: min(360px, 100%);
  flex: 0 1 360px;
  padding: 0 40px 0 14px;
  border: 1px solid rgba(24, 24, 24, 0.08);
  border-radius: 999px;
  background-color: #fff;
  color: var(--text);
  background-image:
    linear-gradient(45deg, transparent 50%, #8e8a85 50%),
    linear-gradient(135deg, #8e8a85 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 17px,
    calc(100% - 12px) 17px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.history-action {
  min-height: 40px;
  padding: 0 8px;
  color: var(--accent-deep);
}

.inbox-section {
  margin-top: 28px;
}

.inbox-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.inbox-header h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

.inbox-panel {
  min-height: 320px;
  padding: 20px 20px 18px;
}

.inbox-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1.18fr);
  gap: 18px;
  align-items: start;
}

.email-list-pane,
.email-detail-shell {
  min-height: 420px;
}

.email-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.email-card {
  padding: 14px 16px;
  border: 1px solid rgba(24, 24, 24, 0.08);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.email-card:hover {
  transform: translateY(-1px);
  border-color: rgba(224, 75, 38, 0.25);
}

.email-card.is-active {
  border-color: rgba(224, 75, 38, 0.32);
  background: rgba(224, 75, 38, 0.06);
}

.email-card h3,
.email-card p {
  margin: 0;
}

.email-card h3 {
  font-size: 1rem;
}

.email-card p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.mail-meta {
  display: block;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.mail-facts {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.email-empty {
  display: grid;
  place-items: center;
  min-height: 286px;
  border: 1px dashed rgba(24, 24, 24, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.45);
}

.empty-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  position: relative;
  width: 52px;
  height: 38px;
  border: 4px solid rgba(24, 24, 24, 0.18);
  border-radius: 8px;
}

.empty-icon::before,
.empty-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 22px;
  height: 4px;
  background: rgba(24, 24, 24, 0.18);
}

.empty-icon::before {
  left: 2px;
  transform: rotate(35deg);
  transform-origin: left center;
}

.empty-icon::after {
  right: 2px;
  transform: rotate(-35deg);
  transform-origin: right center;
}

.empty-wrap strong {
  font-size: 1.1rem;
  color: #77736e;
}

.empty-wrap p {
  margin: 0;
  font-size: 0.96rem;
}

.email-detail-shell {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(24, 24, 24, 0.08);
}

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

.detail-header h3 {
  margin: 6px 0 0;
  font-size: 1.15rem;
}

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

.detail-block {
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(24, 24, 24, 0.08);
}

.detail-block h3,
.detail-block p,
.detail-block pre,
.detail-block ul {
  margin: 0;
}

.detail-block h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
  color: var(--accent-deep);
}

.detail-block p,
.detail-block li,
.detail-block pre {
  line-height: 1.6;
}

.detail-block pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
}

.detail-code {
  font-family: var(--mono);
  font-size: 0.84rem;
}

.detail-delete {
  min-height: 36px;
  white-space: nowrap;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal-shell.is-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 24, 0.28);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(520px, calc(100vw - 24px));
  padding: 24px;
  border-radius: var(--radius-lg);
  background: #fbfbfa;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.modal-header {
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 8px 0 0;
}

.stack-form {
  display: grid;
  gap: 16px;
}

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

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.button-secondary {
  background: #f1efec;
}

.actions .primary-button,
.actions .button-secondary {
  min-height: 40px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 840px);
    padding-top: 18px;
  }

  .topbar,
  .current-mailbox,
  .mailbox-toolbar {
    display: grid;
    gap: 10px;
  }

  .status,
  .mailbox-note {
    text-align: left;
  }

  .address-composer {
    grid-template-columns: 1fr;
    border-radius: 18px;
  }

  .domain-field,
  .primary-button {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .primary-button {
    min-height: 52px;
  }

  .history-picker {
    display: grid;
  }

  .history-select {
    width: 100%;
    max-width: none;
  }

  .inbox-header h2 {
    font-size: 1.55rem;
  }

  .inbox-panel {
    padding: 14px;
  }

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

  .email-list-pane,
  .email-detail-shell {
    min-height: 0;
  }
}
