:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #69777d;
  --line: #dce4e2;
  --surface: #ffffff;
  --canvas: #f2f5f3;
  --accent: #087f6b;
  --accent-dark: #066251;
  --accent-soft: #dff3ed;
  --warn: #a96509;
  --danger: #a23c32;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: inherit; }
button, input, textarea { font: inherit; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.clipboard-fallback {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 48px max(5vw, 32px) 34px;
  color: #f7fffc;
  background: linear-gradient(125deg, #102e2a 0%, #164b42 54%, #087f6b 100%);
}
.topbar.compact { align-items: center; padding-top: 34px; }
.eyebrow { margin: 0 0 8px; color: #8cd5c4; font-size: 12px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin: 0 0 5px; font-size: 18px; }
p { margin: 0; }
.subtitle { margin-top: 12px; color: #c4d9d4; font-size: 15px; }
.top-actions, .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: white;
  background: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}
.button:hover { background: var(--accent-dark); }
.button.secondary { border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.1); }
.panel .button.secondary { color: var(--ink); border-color: var(--line); background: white; }
.button:disabled { cursor: wait; opacity: .55; }
.back { display: inline-block; margin-bottom: 20px; color: #b8d8d0; text-decoration: none; }

main { width: min(1380px, calc(100% - 48px)); margin: 28px auto 60px; }
.notice { margin-bottom: 18px; padding: 14px 17px; border: 1px solid #f0d199; border-radius: 10px; color: #704308; background: #fff7e7; }
.notice.ok { color: #155c4c; border-color: #b9dfd5; background: #eaf8f4; }
.notice:empty { display: none; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat, .panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 9px 26px rgba(19, 45, 39, .045); }
.stat { padding: 20px; }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 31px; letter-spacing: -.04em; }
.panel { margin-bottom: 18px; padding: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-header p, .sync-panel p { color: var(--muted); font-size: 13px; }
.sync-panel { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; align-items: center; gap: 24px; }
.progress { height: 8px; overflow: hidden; border-radius: 99px; background: #edf1f0; }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.progress.complete span { width: 100%; }
.progress.indeterminate span { width: 35%; }
.progress.indeterminate span { animation: sync-progress 1.2s ease-in-out infinite alternate; }
@keyframes sync-progress { from { transform: translateX(-90%); } to { transform: translateX(280%); } }
input[type="search"] { width: 260px; min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; }
input[type="search"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.file-button { cursor: pointer; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; letter-spacing: .03em; }
th, td { padding: 13px 10px; border-bottom: 1px solid #edf1f0; vertical-align: middle; }
td { font-size: 14px; }
tbody tr:hover { background: #f8faf9; }
.mono { font-family: "Cascadia Code", Consolas, monospace; }
.badge { display: inline-flex; padding: 4px 9px; border-radius: 99px; color: #176b59; background: var(--accent-soft); font-size: 12px; font-weight: 800; }
.badge.inactive { color: #727b7f; background: #ecefef; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.link-button { padding: 5px 8px; border: 0; color: var(--accent-dark); background: transparent; cursor: pointer; font-weight: 700; text-decoration: none; }
.link-button.danger { color: var(--danger); }
.alias-label-cell { min-width: 190px; }
.alias-label-stack { display: grid; justify-items: start; gap: 4px; }
.alias-note { display: -webkit-box; max-width: 260px; overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.alias-edit-button { margin-left: -8px; font-size: 12px; }
.empty { padding: 40px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(480px, calc(100% - 48px)); padding: 14px 18px; border-radius: 10px; color: white; background: #1c2b28; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(10, 25, 22, .54); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(760px, 100%); max-height: min(780px, calc(100vh - 40px)); overflow: auto; padding: 24px; border-radius: 16px; background: white; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.modal-compact { width: min(560px, 100%); }
.modal-header, .selection-toolbar, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-header { margin-bottom: 18px; }
.modal-header p, .import-summary, .privacy-warning { color: var(--muted); font-size: 13px; }
.modal-close { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: #eff3f2; cursor: pointer; font-size: 25px; line-height: 1; }
.modal textarea { width: 100%; resize: vertical; min-height: 210px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; line-height: 1.55; }
.modal textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.metadata-field { display: grid; gap: 7px; margin-top: 16px; color: var(--ink); font-weight: 700; }
.metadata-field input, .metadata-field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.metadata-field input { min-height: 44px; }
.metadata-field textarea { min-height: 140px; line-height: 1.55; }
.metadata-field input:focus, .metadata-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.metadata-field small { justify-self: end; color: var(--muted); font-size: 12px; font-weight: 500; }
.modal .button.secondary { color: var(--ink); border-color: var(--line); background: white; }
.import-summary { margin: 12px 0; }
.modal-actions { justify-content: flex-end; margin-top: 16px; }
.selection-toolbar { margin-bottom: 10px; }
.candidate-list { max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.candidate-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 13px; border-bottom: 1px solid #edf1f0; }
.candidate-row:last-child { border-bottom: 0; }
.candidate-row small { color: var(--muted); }
.privacy-warning { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #fff7e7; }
.check { color: var(--muted); font-size: 14px; }
.inbox-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.last-updated { min-width: 122px; color: var(--muted); font-size: 12px; text-align: right; }
.message-list { display: grid; gap: 8px; }
.message-row { display: grid; grid-template-columns: minmax(140px, .7fr) minmax(0, 1.5fr) 150px 120px; gap: 15px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.message-row:hover, .message-row.selected { border-color: #72b6a6; background: #f1faf7; }
.message-row.unread { border-left: 4px solid var(--accent); font-weight: 650; }
.message-sender, .message-summary, .message-subject, .message-snippet { min-width: 0; }
.message-sender, .message-snippet { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.message-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-open-button { display: grid; gap: 3px; width: 100%; padding: 5px 7px; border: 0; border-radius: 7px; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.message-open-button:hover { background: rgba(8, 127, 107, .07); }
.message-open-button:focus-visible { outline: 3px solid #a8d8cd; outline-offset: 2px; }
.message-open-hint { color: var(--accent-dark); font-size: 11px; font-weight: 700; }
.message-row time { color: var(--muted); font-size: 12px; text-align: right; }
.verification-code-button, .verification-code-empty { display: grid; min-width: 132px; min-height: 62px; place-items: center; padding: 7px 12px; border-radius: 10px; }
.verification-code-button { border: 1px solid #8fd1c1; color: #064c40; background: linear-gradient(145deg, #e8faf5, #ccefe6); cursor: copy; box-shadow: 0 4px 12px rgba(8, 127, 107, .1); }
.verification-code-button:hover { border-color: var(--accent); background: #d8f5ed; transform: translateY(-1px); }
.verification-code-button:focus-visible { outline: 3px solid #a8d8cd; outline-offset: 2px; }
.verification-code-button span, .verification-code-empty span { color: var(--accent-dark); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.verification-code-button strong { font-family: "Cascadia Code", Consolas, monospace; font-size: 23px; letter-spacing: .11em; line-height: 1.15; }
.verification-code-button small, .verification-code-empty small { color: var(--muted); font-size: 10px; }
.verification-code-button.copied { color: white; border-color: var(--accent); background: var(--accent); }
.verification-code-button.copied span, .verification-code-button.copied small { color: white; }
.verification-code-empty { border: 1px dashed var(--line); background: #f7f9f8; }
.message-head .verification-code-button { margin-top: 14px; }
.message-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.message-head h2 { font-size: 24px; }
.message-meta { display: grid; gap: 5px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.message-body { margin-top: 18px; white-space: pre-wrap; word-break: break-word; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; line-height: 1.65; }
.detail-loading { color: var(--muted); }
.detail-error { color: var(--danger); }
[aria-busy="true"] { cursor: progress; }
.attachment-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.attachment { padding: 8px 10px; border-radius: 8px; background: #edf4f2; color: var(--accent-dark); font-size: 13px; }
.shared-inbox main { width: min(980px, calc(100% - 48px)); }
.share-notice { line-height: 1.55; }
.login-page { min-height: 100vh; background: linear-gradient(135deg, #102e2a, #087f6b); }
.login-shell { display: grid; min-height: 100vh; place-items: center; margin: 0 auto; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 34px; border-radius: 18px; background: white; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.login-card .eyebrow { color: var(--accent); }
.login-card h1 { color: var(--ink); font-size: 32px; }
.login-description { margin: 10px 0 24px; color: var(--muted); }
.login-card form { display: grid; gap: 16px; }
.login-card label:not(.remember-row) { display: grid; gap: 7px; color: var(--ink); font-weight: 700; }
.login-card input[type="text"], .login-card input[type="password"] { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.login-card input[type="text"]:focus, .login-card input[type="password"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.remember-row { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; font-weight: 500; }
.login-error { padding: 10px 12px; border-radius: 8px; color: #842e25; background: #fff0ed; font-size: 14px; }
.login-submit { width: 100%; }

@media (max-width: 800px) {
  .topbar, .panel-header { align-items: flex-start; flex-direction: column; }
  .toolbar, .inbox-controls { width: 100%; justify-content: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-panel { grid-template-columns: 1fr; }
  main { width: min(100% - 24px, 1380px); }
  .message-row { grid-template-columns: 1fr; gap: 5px; }
  .message-row time { text-align: left; }
  .verification-code-button, .verification-code-empty { width: min(180px, 100%); justify-self: start; margin: 7px 0; }
  input[type="search"] { width: 100%; }
  .last-updated { text-align: left; }
  .link-button { min-height: 40px; padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
