:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5f6b7a;
  --line: #d9e1e8;
  --soft: #f4f8fb;
  --blue: #2f78b7;
  --green: #2e8b57;
  --red: #d94a45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f7fbff;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
}

.mail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand,
.mail-header nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  color: inherit;
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  border-radius: 8px;
}

.mail-header nav a {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.mail-header nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 800;
}

.mail-shell {
  width: min(1080px, calc(100vw - 36px));
  margin: 0 auto;
  padding: clamp(34px, 7vw, 72px) 0 48px;
}

.mail-hero {
  max-width: 760px;
  margin-bottom: 26px;
}

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

h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 72px);
  line-height: 0.98;
  letter-spacing: 0;
}

.intro {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.query-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: clamp(18px, 4vw, 30px);
  box-shadow: 0 18px 50px rgba(22, 34, 48, 0.1);
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 15px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(47, 120, 183, 0.22);
  border-color: var(--blue);
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

button {
  min-height: 44px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 10px 18px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.62;
  cursor: progress;
}

button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.status-box {
  min-height: 42px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--soft);
  font-size: 14px;
}

.status-box.ok {
  color: var(--green);
  background: #f1faf5;
}

.status-box.error {
  color: var(--red);
  background: #fff5f4;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr);
  gap: 16px;
}

.otp-card,
.meta-card {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: #fff;
}

.otp-card {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 14px;
}

.otp-card span,
.meta-card > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.otp-card strong {
  font-size: clamp(38px, 8vw, 62px);
  line-height: 1;
  letter-spacing: 0;
}

.otp-age-hint {
  margin: -4px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 800;
}

.otp-age-hint--ok {
  color: var(--green);
  background: #f1faf5;
}

.otp-age-hint--warn,
.status-box.warn {
  color: #a15c00;
  background: #fff8e8;
  border-color: #f2cf8f;
}

dl {
  margin: 14px 0 0;
  display: grid;
  gap: 12px;
}

dl div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

dd {
  min-width: 0;
  margin: 0;
  word-break: break-all;
}

.message-section {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.message-head strong {
  color: var(--ink);
}

.message-list {
  display: grid;
}

.message-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 18px 16px;
  color: var(--muted);
  font-weight: 800;
}

.loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--blue);
  animation: loadingPulse 1s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 400;
}

.message-row:hover,
.message-row:focus {
  background: var(--soft);
  outline: none;
}

.message-row:last-child {
  border-bottom: 0;
}

.message-subject {
  min-width: 0;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-line {
  min-width: 0;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-otp {
  align-self: center;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 5px 9px;
  color: var(--green);
  font-weight: 800;
}

.message-empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.message-modal {
  width: min(900px, 100%);
  max-height: min(82vh, 760px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  position: relative;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 34px;
  width: 34px;
  border-color: var(--line);
  padding: 0;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.modal-meta {
  display: grid;
  gap: 6px;
  padding: 20px 58px 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-meta strong {
  font-size: 18px;
}

.modal-meta span {
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.modal-otp {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--green);
  font-weight: 800;
}

.modal-body {
  margin: 0;
  padding: 18px 20px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  font: 14px/1.7 "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
}

@media (max-width: 760px) {
  .mail-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .query-form,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .message-row {
    grid-template-columns: 1fr;
  }

  dl div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
