:root {
  color-scheme: light;
  font-family: Segoe UI, Arial, sans-serif;
  --bg: #fffbeb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #f3e8b4;
  --accent: #facc15;
  --accent-strong: #eab308;
  --accent-soft: #fef3c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(250, 204, 21, 0.12) 0 20%, transparent 20% 100%),
    linear-gradient(30deg, rgba(250, 204, 21, 0.08) 0 14%, transparent 14% 100%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-strong) #fff8dc;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #fff8dc;
  border: 1px solid var(--border);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border: 1px solid #d39f08;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #facc15, #ca8a04);
}

.inbox-list,
.message-detail,
.modal-content {
  scrollbar-gutter: stable;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px;
}

.header {
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 1.52rem;
  letter-spacing: 0.01em;
}

.header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mailbox-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 12px;
  box-shadow: 8px 8px 0 var(--accent-soft);
}

.mailbox-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.mailbox-row h2 {
  margin: 0;
  font-size: 0.94rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.mailbox-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.mailbox-address {
  margin: 0;
  font-weight: 600;
  font-size: 1.65rem;
  line-height: 1.15;
  word-break: break-all;
}

.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 0;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
}

.primary-btn {
  background: var(--accent);
  color: #111827;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn {
  border: 1px solid var(--accent-strong);
  background: #fff;
  color: #111827;
}

#copyBtn {
  width: 104px;
}

.btn-pop {
  animation: popTap 0.22s ease;
}

@keyframes popTap {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}

.no-mailbox .mailbox-address {
  font-size: 1rem;
  color: var(--muted);
}

.no-mailbox .ghost-btn {
  display: none;
}

.no-mailbox .primary-btn {
  font-size: 1.1rem;
  padding: 14px 22px;
}

.has-mailbox .primary-btn,
.has-mailbox .ghost-btn {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin: 8px 0 0;
  color: #374151;
  min-height: 16px;
  font-size: 0.88rem;
}

.content-grid {
  margin-top: 10px;
  display: block;
}

.content-grid .panel {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: 72vh;
}

.seo-content {
  margin-top: 10px;
  content-visibility: auto;
  contain-intrinsic-size: 1px 1000px;
}

.seo-content h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.3;
}

.seo-content h2:not(:first-child) {
  margin-top: 18px;
}

.seo-content p,
.seo-content li {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: #374151;
  line-height: 1.5;
}

.seo-content li {
  margin-bottom: 6px;
}

.seo-content ol {
  margin: 2px 0 12px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.seo-content details {
  border: 1px solid var(--border);
  padding: 7px;
  background: #fffdf4;
  margin: 0;
}

.seo-content details + details {
  margin-top: 7px;
}

.seo-content summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
}

.seo-content details p {
  margin: 6px 0 0;
}

.link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.link-grid a {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fffdf4;
  color: #1f2937;
  text-decoration: none;
  padding: 5px 8px;
  font-size: 0.78rem;
}

.content-page {
  margin-top: 10px;
}

.content-page h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.3;
}

.content-page h2:not(:first-child) {
  margin-top: 18px;
}

.content-page p,
.content-page li {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: #374151;
  line-height: 1.5;
}

.content-page li {
  margin-bottom: 6px;
}

.content-page ol,
.content-page ul {
  margin: 2px 0 12px;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.panel h2 {
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.25;
}

.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.refresh-meta {
  margin: 4px 0 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.inbox-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.inbox-item {
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px;
  cursor: pointer;
  background: #fff;
}

.inbox-item:hover {
  border-color: var(--accent-strong);
}

.inbox-item.unseen {
  background: #fffbeb;
}

.inbox-item.active {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.item-from,
.item-date,
.item-subject,
.item-preview {
  margin: 0;
}

.item-from {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-date {
  font-size: 0.74rem;
  color: var(--muted);
  flex-shrink: 0;
}

.item-subject {
  margin-top: 4px;
  font-size: 0.94rem;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-preview {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skeleton-item {
  cursor: default;
}

.skeleton-line {
  display: block;
  width: 100%;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(90deg, #fff5cc 25%, #fde68a 50%, #fff5cc 75%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}

.skeleton-line.short {
  width: 44%;
}

.skeleton-line.tiny {
  width: 22%;
}

@keyframes shimmer {
  0% {
    background-position: 220% 0;
  }
  100% {
    background-position: -220% 0;
  }
}

.message-detail {
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px;
  min-height: 120px;
  max-height: 72vh;
  overflow: auto;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.message-detail h3,
.message-detail p {
  margin-top: 0;
}

.message-header {
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  background: #fffdf4;
}

.message-header .item-subject {
  white-space: normal;
}

.message-header .item-preview {
  white-space: normal;
}

.message-detail pre {
  white-space: pre-wrap;
}

.html-preview {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--border);
  background: #fff;
}

.message-html {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 40;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
}

.modal-content {
  position: relative;
  width: min(1100px, calc(100vw - 28px));
  height: min(88vh, 860px);
  margin: 14px auto;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 10px 10px 0 var(--accent-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.modal-head h3 {
  margin: 0;
}

.modal-content .message-detail {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.modal-content .message-detail pre {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.modal-content .message-detail .html-preview {
  flex: 1;
  min-height: 0;
}

@media (max-width: 860px) {
  .content-grid .panel {
    min-height: 320px;
    max-height: 66vh;
  }

  .app {
    padding: 8px;
  }

  .header {
    margin-bottom: 10px;
  }

  .brand {
    gap: 10px;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
  }

  .header h1 {
    font-size: 1.18rem;
    line-height: 1.2;
  }

  .mailbox-card,
  .panel {
    padding: 9px;
    box-shadow: 5px 5px 0 var(--accent-soft);
  }

  .mailbox-row {
    gap: 6px;
  }

  .mailbox-row h2 {
    font-size: 0.78rem;
  }

  .mailbox-address {
    font-size: 1.1rem;
    line-height: 1.2;
  }

  .primary-btn,
  .ghost-btn {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  #copyBtn {
    width: 90px;
  }

  .no-mailbox .primary-btn {
    font-size: 0.92rem;
    padding: 10px 14px;
  }

  .status {
    font-size: 0.78rem;
  }

  .content-grid {
    margin-top: 8px;
  }

  .seo-content h2 {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }

  .seo-content h2:not(:first-child),
  .content-page h2:not(:first-child) {
    margin-top: 14px;
  }

  .seo-content p,
  .seo-content li,
  .seo-content summary {
    font-size: 0.78rem;
    margin-bottom: 8px;
  }

  .link-grid a,
  .content-page p,
  .content-page li {
    font-size: 0.76rem;
    margin-bottom: 8px;
  }

  .inbox-head h2,
  .panel h2 {
    font-size: 0.9rem;
  }

  .refresh-meta {
    margin: 3px 0 7px;
    font-size: 0.72rem;
  }

  .inbox-list {
    gap: 6px;
    max-height: none;
  }

  .inbox-item {
    padding: 7px;
  }

  .item-top {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .item-from {
    font-size: 0.68rem;
  }

  .item-date {
    font-size: 0.68rem;
  }

  .item-subject {
    font-size: 0.84rem;
    margin-top: 3px;
  }

  .item-preview {
    font-size: 0.74rem;
    margin-top: 2px;
  }

  .modal-content {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    margin: 6px auto;
    padding: 8px;
    box-shadow: 5px 5px 0 var(--accent-soft);
  }

  .modal-head {
    margin-bottom: 6px;
  }

  .modal-head h3 {
    font-size: 0.95rem;
  }

  .message-detail {
    padding: 7px;
  }

  .message-header {
    margin-bottom: 8px;
    padding: 6px;
  }

  .html-preview {
    min-height: 180px;
  }

  .item-top {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }
}
