:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-raised: #f5f7f8;
  --surface-hover: #edf3f7;
  --border: #dce3e7;
  --border-strong: #c8d2d8;
  --text: #172128;
  --text-soft: #46545e;
  --muted: #788690;
  --blue: #2869d8;
  --blue-soft: #e9f1ff;
  --green: #009e72;
  --green-soft: #e4f7f0;
  --amber: #b7791f;
  --amber-soft: #fff4dd;
  --red: #d44d4d;
  --red-soft: #fff0ef;
  --ink: #152126;
  --ink-raised: #1c2a30;
  --ink-hover: #263940;
  --ink-border: #31434a;
  --mint: #76dfbd;
  --shadow: 0 22px 60px rgba(33, 50, 59, 0.18);
  --header-height: 68px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  background: var(--bg);
  color: var(--text);
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #4d8ef0;
  outline-offset: 2px;
}

::selection {
  background: #cfe0ff;
  color: #102b52;
}

.app-shell {
  background: var(--bg);
}

.app-header {
  grid-template-columns: 288px minmax(240px, 1fr) auto;
  gap: 22px;
  height: var(--header-height);
  padding: 0 20px;
  border-bottom: 1px solid #26363d;
  background: #111b20;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.brand {
  gap: 11px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
  border: 1px solid #3c5a60;
  border-radius: 8px;
  background: #20343a;
  color: var(--mint);
  box-shadow: inset 0 0 0 1px rgba(118, 223, 189, 0.05);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.brand strong {
  color: #f7fbfa;
  font-size: 15px;
  font-weight: 750;
}

.brand small {
  margin-top: 3px;
  color: #91a3aa;
  font-size: 10px;
}

.header-status {
  justify-self: center;
  min-width: 0;
  padding: 6px 11px;
  border: 1px solid #2a3c43;
  border-radius: 999px;
  background: #17252b;
  color: #b8c5ca;
  font-size: 11px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #49d6a6;
  box-shadow: 0 0 0 3px rgba(73, 214, 166, 0.12);
}

.header-status.busy .status-dot {
  background: #ffc35a;
  box-shadow: 0 0 0 3px rgba(255, 195, 90, 0.12);
}

.header-actions {
  gap: 9px;
}

.account-counter {
  padding-right: 4px;
  color: #8fa0a7;
  font-size: 11px;
}

.button,
.icon-button,
.folder-tab,
.format-tabs button,
.mobile-nav button {
  border-radius: 6px;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
}

.button.primary {
  border-color: #3f7de4;
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(40, 105, 216, 0.22);
}

.button.primary:hover {
  border-color: #2c65c3;
  background: #225fc5;
  transform: translateY(-1px);
}

.button.secondary {
  border-color: var(--border-strong);
  background: #ffffff;
  color: var(--text-soft);
}

.button.secondary:hover {
  border-color: #aebcc4;
  background: #f7f9fa;
  color: var(--text);
}

.button.text-button {
  color: var(--blue);
}

.button.warning-button {
  border-color: #d89b3b;
  background: #c98926;
  color: #ffffff;
}

.button.danger-button {
  border-color: #d85d5d;
  background: #c94747;
  color: #ffffff;
}

.icon-button {
  border-color: var(--border);
  background: #ffffff;
  color: #5c6a73;
  box-shadow: 0 1px 2px rgba(26, 44, 54, 0.04);
}

.icon-button:hover {
  border-color: #b8c4ca;
  background: #f5f8fa;
  color: var(--text);
}

.app-header .icon-button {
  border-color: #31444c;
  background: #19282e;
  color: #aab8bd;
  box-shadow: none;
}

.app-header .icon-button:hover {
  border-color: #46616b;
  background: #22343b;
  color: #ffffff;
}

.icon-button.quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.icon-button.warning {
  color: var(--amber);
}

.icon-button.danger {
  color: var(--red);
}

.mail-workspace {
  grid-template-columns: 288px minmax(390px, 430px) minmax(500px, 1fr);
  background: var(--bg);
}

.workspace-panel {
  background: var(--surface);
}

.workspace-panel + .workspace-panel {
  border-left: 1px solid var(--border);
}

.accounts-panel {
  background: var(--ink);
  color: #edf5f3;
}

.messages-panel {
  background: #f4f7f8;
}

.detail-panel {
  background: #ffffff;
}

.panel-header {
  min-height: 70px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.accounts-panel .panel-header {
  border-bottom-color: #2c3d44;
  background: #17252b;
}

.panel-header h2 {
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
}

.accounts-panel .panel-header h2 {
  color: #f5fbf9;
}

.panel-header p {
  margin-top: 4px !important;
  color: var(--muted);
  font-size: 10px;
}

.accounts-panel .panel-header p {
  color: #8ea1a8;
}

.accounts-panel .panel-header .icon-button {
  color: #b2c1c5;
}

.account-list,
.message-list {
  scrollbar-color: #b8c4ca transparent;
}

.account-list {
  padding: 8px 0;
}

.account-row {
  grid-template-columns: 38px minmax(0, 1fr) 28px;
  gap: 10px;
  min-height: 66px;
  padding: 9px 12px;
  border-bottom: 1px solid #24353c;
  background: transparent;
  color: #eaf2f1;
}

.account-row:hover {
  background: #1d2d33;
}

.account-row.active {
  background: #24383d;
  box-shadow: inset 3px 0 0 var(--mint);
}

.account-avatar {
  width: 38px;
  height: 38px;
  border: 1px solid #3b5158;
  border-radius: 7px;
  background: #25383f;
  color: #b8cac9;
  font-size: 13px;
}

.account-row.active .account-avatar {
  border-color: #4a766b;
  background: #285046;
  color: #a7efd6;
}

.account-copy strong {
  color: #f0f6f5;
  font-size: 11px;
  font-weight: 700;
}

.account-copy span {
  margin-top: 5px;
  color: #8ea1a8;
  font-size: 10px;
}

.account-row.active .account-copy span {
  color: #9fc6ba;
}

.account-remove {
  color: #73868d;
}

.account-remove:hover {
  background: #492f31;
  color: #ffaaa7;
}

.privacy-note {
  min-height: 46px;
  padding: 9px 14px;
  border-top: 1px solid #2d3e45;
  background: #111d22;
  color: #81959c;
  font-size: 9px;
}

.privacy-note svg {
  color: var(--mint);
}

.messages-header {
  height: 70px;
  padding: 12px 13px;
}

.folder-tabs,
.format-tabs {
  gap: 2px;
  padding: 3px;
  border-color: #d8e0e4;
  border-radius: 7px;
  background: #edf1f3;
}

.folder-tab,
.format-tabs button {
  min-height: 32px;
  padding: 0 10px;
  color: #687781;
  font-size: 10px;
  font-weight: 650;
}

.folder-tab:hover,
.format-tabs button:hover {
  color: var(--text);
}

.folder-tab.active,
.format-tabs button.active {
  border-color: #d3dde2;
  background: #ffffff;
  color: #1c2b33;
  box-shadow: 0 1px 4px rgba(34, 53, 63, 0.08);
}

.search-row {
  min-height: 50px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  color: #87949c;
}

.search-row input {
  color: var(--text);
  font-size: 11px;
}

.search-row input::placeholder {
  color: #a0abb1;
}

.search-row span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf1f3;
  color: #73818a;
  font-size: 9px;
}

.message-list {
  background: #f7f9fa;
}

.message-row {
  min-height: 88px;
  padding: 13px 14px;
  border-bottom: 1px solid #e1e7ea;
  background: #ffffff;
  color: var(--text);
}

.message-row:hover {
  background: #f1f6f8;
}

.message-row.active {
  background: #eaf3fb;
  box-shadow: inset 3px 0 0 #2275c9;
}

.message-from {
  color: #5f6f79;
  font-size: 10px;
  font-weight: 650;
}

.message-subject-line {
  margin-top: 6px;
  color: #23323a;
  font-size: 12px;
  font-weight: 720;
}

.message-preview {
  margin-top: 6px;
  color: #87949c;
  font-size: 10px;
}

.message-row.unread .message-from,
.message-row.unread .message-subject-line {
  color: #14242d;
  font-weight: 780;
}

.message-side {
  gap: 12px;
  color: #8c989f;
  font-size: 9px;
}

.unread-dot {
  width: 7px;
  height: 7px;
  background: #2475d0;
  box-shadow: 0 0 0 3px rgba(36, 117, 208, 0.1);
}

.empty-state,
.detail-empty {
  color: #7e8b93;
}

.empty-state strong,
.detail-empty h2 {
  color: #34434c;
  font-weight: 740;
}

.empty-state p,
.detail-empty p {
  color: #849199;
}

.accounts-panel .empty-state {
  color: #81949b;
}

.accounts-panel .empty-state strong {
  color: #e5efed;
}

.accounts-panel .empty-state p {
  color: #84969d;
}

.empty-icon {
  border-color: #d6dfe3;
  background: #f3f6f7;
  color: #667780;
}

.accounts-panel .empty-icon {
  border-color: #34484f;
  background: #1e3036;
  color: #91aba9;
}

.accounts-panel .empty-state .button.secondary {
  border-color: #40575f;
  background: #20343a;
  color: #d1e0dd;
}

.list-loading,
.detail-loading {
  background: rgba(247, 249, 250, 0.92);
  color: #53636d;
  backdrop-filter: blur(5px);
}

.spinner {
  border-color: #d5dee3;
  border-top-color: var(--blue);
}

.message-detail {
  width: min(900px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 34px clamp(24px, 4vw, 52px) 64px;
}

.detail-header {
  gap: 24px;
  padding-bottom: 22px;
  border-bottom-color: #e1e7ea;
}

.eyebrow {
  color: #2770cc;
  font-size: 9px;
  font-weight: 780;
}

.detail-heading h1 {
  margin: 8px 0 10px;
  color: #14232b;
  font-size: 23px;
  font-weight: 780;
  line-height: 1.35;
}

.message-meta {
  color: #77858e;
  font-size: 10px;
}

.meta-separator {
  background: #b7c2c8;
}

.detail-actions {
  gap: 7px;
}

.analysis-strip {
  grid-template-columns: minmax(160px, 1.35fr) minmax(130px, 1fr) minmax(100px, 0.8fr);
  gap: 10px;
  margin: 24px 0 8px;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.analysis-item {
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid #dce4e7;
  border-radius: 8px;
  background: #f7f9fa;
}

.analysis-item + .analysis-item {
  border-left: 1px solid #dce4e7;
}

.analysis-item span {
  color: #849199;
  font-size: 8px;
  font-weight: 720;
}

.analysis-item strong {
  color: #34444d;
  font-size: 12px;
}

.analysis-item.emphasis {
  border-color: #b9e7d7;
  background: var(--green-soft);
}

.analysis-item.emphasis span {
  color: #548b79;
}

.analysis-item.emphasis strong {
  color: #007e5d;
  font-size: 20px;
  font-weight: 780;
}

.summary-block,
.link-block,
.body-block {
  padding: 22px 0;
  border-top: 1px solid #e1e7ea;
}

.summary-block {
  border-top: 0;
}

.section-label {
  color: #3c4c55;
  font-size: 10px;
  font-weight: 760;
}

.section-label svg {
  color: #2d70c8;
}

.summary-block p {
  margin-top: 11px;
  color: #52626c;
  font-size: 12px;
  line-height: 1.8;
}

.link-list {
  gap: 8px;
  margin-top: 12px;
}

.mail-link {
  min-height: 42px;
  padding: 7px 11px;
  border-color: #d8e1e5;
  background: #f7f9fa;
  color: #42545f;
}

.mail-link:hover {
  border-color: #9dbbe0;
  background: #edf4fc;
}

.mail-link svg {
  color: #2b70ca;
}

.body-block pre {
  margin-top: 14px;
  color: #293a43;
  font-size: 12px;
  line-height: 1.85;
}

.modal-backdrop {
  background: rgba(13, 24, 30, 0.58);
  backdrop-filter: blur(6px);
}

.modal {
  border-color: #d5dfe4;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 20px 20px 13px;
}

.modal-header h2,
.compact-modal h2 {
  color: #192830;
  font-size: 18px;
  font-weight: 770;
}

.format-tabs {
  margin: 0 20px 12px;
}

.modal textarea {
  width: calc(100% - 40px);
  height: 270px;
  margin: 0 20px;
  padding: 14px;
  border-color: #cfd9de;
  background: #f7f9fa;
  color: #1d2d35;
  font-size: 11px;
}

.modal textarea:focus,
.form-stack input:focus,
.password-field:focus-within {
  border-color: #6b9de5;
  box-shadow: 0 0 0 3px rgba(48, 113, 208, 0.1);
}

.parse-report {
  padding: 10px 20px 0;
  color: #77858e;
}

.parse-report.success {
  color: #00865f;
}

.parse-report.danger {
  color: #c64545;
}

.modal-footer {
  padding: 16px 20px 20px;
}

.form-stack {
  gap: 15px;
  padding: 8px 20px;
}

.form-stack label span,
.login-form label {
  color: #45555f;
  font-size: 10px;
}

.form-stack input,
.password-field input {
  border-color: #cfd9de;
  background: #f8fafb;
  color: #1c2b33;
}

.confirm-icon.danger {
  background: var(--red-soft);
  color: var(--red);
}

.compact-modal p {
  color: #5e6d76;
}

.toast-region {
  top: 80px;
  right: 18px;
}

.toast {
  border-color: #34484f;
  background: #18262c;
  box-shadow: 0 14px 34px rgba(23, 39, 48, 0.24);
  color: #d9e4e1;
}

.toast.success {
  border-color: #287960;
}

.toast.danger {
  border-color: #8c4444;
}

.mobile-nav {
  background: #ffffff;
}

.login-body {
  min-height: 100vh;
  padding: 24px;
  background: #eaf0f2;
}

.login-shell {
  max-width: 430px;
}

.login-card {
  position: relative;
  padding: 30px;
  overflow: hidden;
  border: 1px solid #d4dee3;
  border-top: 4px solid #2869d8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(31, 51, 61, 0.16);
}

.login-card::after {
  position: absolute;
  top: 0;
  right: 28px;
  width: 62px;
  height: 4px;
  background: #00a978;
  content: "";
}

.brand-login {
  margin-bottom: 34px;
}

.brand-login .brand-mark {
  border-color: #c6d6dc;
  background: #17262c;
  color: #70dfbc;
}

.brand-login strong {
  color: #18272f;
}

.brand-login small {
  color: #849198;
}

.login-heading h1 {
  color: #15252d;
  font-size: 23px;
  font-weight: 780;
}

.login-heading p {
  margin: 9px 0 24px;
  color: #7d8a92;
  font-size: 11px;
}

.login-form {
  gap: 14px;
}

.password-field {
  height: 46px;
  border-color: #cfd9de;
  background: #f7f9fa;
}

.password-field > svg {
  color: #7f8d95;
}

.password-field .icon-button {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.inline-alert {
  border-color: #d4dde1;
  background: #f7f9fa;
  color: #4f5e67;
}

.inline-alert.danger {
  border-color: #efc1bf;
  background: var(--red-soft);
  color: #ad3838;
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 248px minmax(180px, 1fr) auto;
  }

  .mail-workspace {
    grid-template-columns: 248px minmax(340px, 390px) minmax(430px, 1fr);
  }

  .message-detail {
    padding-inline: 24px;
  }
}

@media (max-width: 820px) {
  :root {
    --header-height: 62px;
  }

  .app-shell {
    grid-template-rows: var(--header-height) minmax(0, 1fr) 62px;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 0 12px;
  }

  .header-actions {
    gap: 7px;
  }

  .header-actions .button,
  .app-header .icon-button {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .workspace-panel {
    border-left: 0 !important;
  }

  .messages-panel,
  .detail-panel {
    background: #ffffff;
  }

  .mobile-nav {
    border-top: 1px solid #d9e2e6;
    background: #ffffff;
    box-shadow: 0 -6px 20px rgba(30, 50, 60, 0.05);
  }

  .mobile-nav button {
    color: #7d8a92;
    font-size: 9px;
    font-weight: 650;
  }

  .mobile-nav button.active {
    color: #2169c9;
    background: #f2f6fb;
  }

  .analysis-strip {
    gap: 8px;
  }

  .analysis-item:last-child {
    border-top: 1px solid #dce4e7;
    border-left: 1px solid #dce4e7;
  }

  .detail-header {
    gap: 14px;
  }

  .detail-heading h1 {
    font-size: 21px;
  }

  .message-detail {
    padding: 22px 16px 40px;
  }
}

@media (max-width: 520px) {
  .brand strong {
    font-size: 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .panel-header,
  .messages-header {
    min-height: 64px;
    height: 64px;
  }

  .message-row {
    min-height: 84px;
    padding: 12px;
  }

  .modal,
  .large-modal,
  .compact-modal {
    border-color: #d5dfe4;
    background: #ffffff;
  }

  .modal textarea {
    height: 230px;
  }

  .login-body {
    padding: 14px;
  }

  .login-card {
    padding: 24px 20px;
  }
}
