.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: transparent;
  overflow: visible;
  border: none;
}
.thread-msg {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: none;
  overflow: visible;
  position: relative;
  margin-top: -1px;
  border-radius: 0;
  transition:
    background 0.14s ease,
    border-color 0.14s ease;
}
.thread-msg:first-child {
  border-radius: 12px 12px 0 0;
  margin-top: 0;
}
.thread-msg:last-child {
  border-radius: 0 0 12px 12px;
}
.thread-msg:only-child {
  border-radius: 12px;
}
.thread-msg:hover {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: none;
  z-index: 1;
}
.thread-msg:not(.collapsed) {
  background: var(--surface);
  z-index: 2;
}
.thread-msg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 12px;
  cursor: pointer;
  user-select: none;
  border-radius: 12px 12px 0 0;
}
.thread-msg-header .avatar {
  width: 32px;
  height: 32px;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 1px 3px rgba(0, 0, 0, 0.1);
}
.thread-msg-header .sender {
  font-weight: 640;
  font-size: 14px;
  color: var(--title);
}
.thread-msg-header time {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.thread-msg-body {
  padding: 4px 20px 18px 64px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  max-width: 72ch;
}
.thread-msg.collapsed {
  background: var(--canvas);
}
.thread-msg.unread {
  background: rgba(41, 119, 245, 0.04);
  border-color: rgba(41, 119, 245, 0.12);
}
.thread-msg.unread .thread-msg-header .sender {
  font-weight: 650;
}
.thread-msg.collapsed:hover {
  background: var(--card);
}
.thread-msg.collapsed .thread-msg-body {
  display: none;
}
.thread-msg.collapsed .thread-msg-header {
  border-bottom: none;
  padding-bottom: 8px;
  border-radius: 12px;
}
.thread-msg:not(.collapsed) .thread-msg-header {
  padding-bottom: 10px;
}
.thread-msg-header:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  background: var(--card);
  border-radius: 8px;
}
.mobile-back {
  display: none;
  padding: 0 0 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.mobile-back a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}
.mobile-back a:hover {
  color: var(--text);
  background: var(--card);
}
.mobile-back a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.thread-msg-snippet {
  padding: 0 20px 14px 64px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.thread-msg:not(.collapsed) .thread-msg-snippet {
  display: none;
}
.thread-msg.collapsed .thread-msg-snippet {
  display: block;
}
.thread-reply-bar {
  display: flex;
  gap: 8px;
  padding: 16px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.reading-panel {
  min-width: 0;
  padding: 28px 28px 48px;
  background: var(--surface);
  animation: fade-in 0.18s ease;
}
.mail-content .reading-panel {
  max-width: 820px;
  margin: 0 auto;
}
.thread-count-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 18px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.empty-state {
  width: min(100%, 360px);
  margin: 12vh auto 20vh;
  padding: 64px 24px;
  text-align: center;
}
.empty-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--blue-soft);
  border: 1px solid var(--line);
  color: var(--blue);
  font-size: 28px;
}
.empty-state h2 {
  margin: 0 0 8px;
  color: var(--title);
  font-size: 20px;
}
.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.detail-return {
  padding: 28px 24px;
}
.message-detail {
  padding: 28px clamp(24px, 4vw, 48px) 48px;
  background: var(--surface);
}
.message-detail.unread {
  background: rgba(41, 119, 245, 0.03);
}
.message-detail.unread .detail-author-name {
  font-weight: 650;
}
.detail-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.detail-tools-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.detail-tools form {
  margin: 0;
  display: flex;
}
.detail-tools .tool-button,
.detail-tools .secondary-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  transition:
    background 0.14s ease,
    color 0.14s ease,
    transform 0.14s ease;
}
.detail-tools .tool-button svg,
.detail-tools .secondary-button svg {
  display: block;
}
.detail-tools .tool-button:hover,
.detail-tools .secondary-button:hover {
  background: var(--card);
  color: var(--text);
  border-color: transparent;
}
.detail-tools .tool-button:active,
.detail-tools .secondary-button:active {
  transform: scale(0.95);
  background: var(--input);
}
.detail-tools .tool-button .icon,
.detail-tools .secondary-button .icon {
  display: block;
  width: 18px;
  height: 18px;
}
.tool-button.danger {
  color: var(--muted);
  border-color: transparent;
}
.tool-button.danger:hover {
  background: rgba(197, 34, 31, 0.08);
  color: #c5221f;
}
.message-detail h1,
.reading-panel h1 {
  margin: 0 0 18px;
  color: var(--title);
  font-size: clamp(22px, 2.6vw, 26px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.28;
}
.detail-author-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 2px;
}
.detail-author-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}
.detail-email-muted {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-to-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0;
  padding: 2px 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
}
.detail-to-toggle:hover {
  color: var(--text);
}
.detail-to-toggle svg {
  display: block;
  transition: transform 0.2s ease;
}
.detail-to-toggle.expanded svg {
  transform: rotate(180deg);
}
.detail-head-date {
  flex-shrink: 0;
  padding-top: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.detail-author {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.detail-author .avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 1px 3px rgba(0, 0, 0, 0.1);
}
.detail-author-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.detail-author-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--title);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-author-date {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}
.detail-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
}
.detail-expand-btn:hover {
  background: var(--card);
  color: var(--text);
}
.detail-expand-btn.expanded svg {
  transform: rotate(180deg);
}
.detail-expand-btn svg {
  transition: transform 0.2s ease;
}
.detail-header {
  position: relative;
}
.detail-summary-line {
  font-size: 13px;
  color: var(--muted);
  padding: 0 0 10px 48px;
  line-height: 1.4;
}
.thread-msg .detail-summary-line {
  padding: 0 20px 10px 64px;
}
.thread-msg .detail-expanded {
  left: 12px;
  right: 12px;
  width: auto;
  max-width: none;
}
.detail-expanded {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: fit-content;
  min-width: 240px;
  max-width: min(520px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 16px;
  z-index: 50;
  animation: dropdown-slide 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: top left;
}
.detail-expanded[hidden] {
  display: none !important;
}
.detail-fields {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 13px;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  max-width: none;
  margin: 0;
}
.detail-fields tr + tr {
  border-top: 1px solid var(--line);
}
.detail-field-label {
  color: var(--muted);
  padding: 6px 12px 6px 0;
  white-space: nowrap;
  vertical-align: top;
  font-weight: 500;
}
.detail-field-value {
  color: var(--text);
  padding: 6px 0;
  word-break: break-all;
}
.message-meta {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.message-meta div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  margin-bottom: 8px;
}
.message-meta dt {
  color: var(--muted);
  font-size: 13px;
}
.message-meta dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 14px;
}
.message-body {
  padding-top: 24px;
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  color: var(--text);
}
.message-body p {
  margin-bottom: 18px;
}
.message-body a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: rgba(41, 119, 245, 0.3);
  text-underline-offset: 2px;
}
.message-body a:hover {
  text-decoration-color: var(--blue);
}
.message-body blockquote {
  margin: 12px 0 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-style: italic;
}
.message-body pre,
.message-body code {
  background: var(--input);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
}
.message-body pre {
  padding: 12px 16px;
  overflow-x: auto;
}
.message-body ul,
.message-body ol {
  padding-left: 24px;
  margin-bottom: 16px;
}
