:root {
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --transition: 180ms ease;
}

html[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-soft: #edf2fa;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #edf2fb;
  --line: rgba(17, 24, 39, 0.12);
  --line-strong: rgba(17, 24, 39, 0.18);
  --text: #1f1f1f;
  --text-soft: #5f6368;
  --text-dim: #80868b;
  --accent: #0b57d0;
  --accent-soft: rgba(11, 87, 208, 0.12);
  --compose: #c2e7ff;
  --compose-text: #001d35;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.view {
  display: none;
}

.view-active {
  display: block;
}

html[data-route='login'] #login-view,
html[data-route='mail'] #workspace-view {
  display: block;
}

html[data-route='mail'] #login-view,
html[data-route='login'] #workspace-view {
  display: none;
}

.surface-card,
.subtle-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 24%);
}

.login-card {
  width: min(100%, 520px);
  border-radius: 30px;
  padding: 34px;
}

.login-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  margin: 0 auto 20px;
  color: #10a37f;
  background: rgba(16, 163, 127, 0.1);
}

.login-icon svg {
  width: 28px;
  height: 28px;
}

.login-head {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow,
.brand-subtitle,
.toolbar-subtitle,
.field span,
.footnote,
.account-provider,
.account-inline,
.detail-folder,
.detail-date,
.detail-meta,
.message-head-row,
.page-inline,
.message-row-preview,
.message-footer-row {
  color: var(--text-soft);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-head h1,
.toolbar-title,
.detail-subject,
.brand-title,
.account-email {
  letter-spacing: -0.03em;
}

.login-head h1 {
  margin: 10px 0 8px;
  font-size: 42px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field input,
.field select,
.topbar-search input,
.jump-page-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 16px;
  outline: none;
}

.provider-chips,
.login-options,
.topbar-actions,
.toolbar-actions,
.account-inline,
.detail-toolbar-left,
.detail-toolbar-right,
.pagination-controls,
.account-status-row {
  display: flex;
  gap: 10px;
}

.provider-chip,
.icon-btn,
.text-btn,
.nav-item,
.message-row,
.primary-btn,
.danger-btn {
  transition: background var(--transition), transform var(--transition), border-color var(--transition);
}

.provider-chip,
.icon-btn,
.text-btn,
.danger-btn {
  cursor: pointer;
}

.provider-chip,
.icon-btn,
.text-btn,
.nav-item {
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
}

.provider-chip {
  padding: 9px 14px;
  border-radius: var(--radius-pill);
}

.login-options {
  justify-content: space-between;
  align-items: center;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
}

.primary-btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  background: #10a37f;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.footnote {
  margin: 18px 0 0;
  font-size: 13px;
  text-align: center;
}

.mail-app {
  min-height: 100vh;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 4px 6px;
}

.topbar-brand,
.detail-toolbar,
.account-panel,
.nav-item,
.page-inline {
  display: flex;
}

.topbar-brand {
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--accent);
  font-weight: 700;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 4px;
  font-size: 13px;
}

.topbar-search input {
  border-radius: 28px;
  padding-left: 20px;
  background: var(--surface-2);
}

.icon-btn,
.text-btn,
.danger-btn {
  border-radius: 999px;
  padding: 10px 14px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.back-btn {
  font-size: 24px;
  line-height: 1;
  padding: 0 1px 2px 0;
}

.text-btn {
  background: transparent;
}

.danger-btn {
  border: 1px solid #ef4444;
  background: #fff5f5;
  color: #dc2626;
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 110px);
}

.left-nav {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  min-width: 0;
  border-radius: 28px;
  padding: 18px 14px;
  display: grid;
  align-content: start;
  gap: 16px;
  border-color: var(--line-strong);
}

.compose-btn {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 16px 20px;
  background: var(--compose);
  color: var(--compose-text);
  font-weight: 700;
  text-align: left;
  cursor: default;
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-radius: 999px;
  padding: 12px 14px;
  text-align: left;
  font-weight: 500;
}

.nav-item-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.mail-dot-legend {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface-2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.legend-dot-normal {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.legend-dot-spam {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.account-panel,
.sidebar-form {
  display: grid;
  border-radius: 20px;
  padding: 14px;
  gap: 12px;
}

.page-size-panel {
  display: grid;
  gap: 10px;
}

.page-size-label {
  color: var(--text-soft);
  font-size: 14px;
}

.page-size-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.page-size-option {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.page-size-option:hover {
  border-color: rgba(11, 87, 208, 0.32);
  background: var(--surface-3);
}

.page-size-option-active {
  border-color: rgba(11, 87, 208, 0.28);
  background: var(--accent-soft);
  color: var(--accent);
}

.account-title {
  font-size: 12px;
  color: var(--text-dim);
}

.account-email {
  flex: 1 1 auto;
  display: block;
  line-height: 1.2;
  font-size: 16px;
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
}

.account-status-row {
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.account-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
  margin-top: 0;
}

.account-status-offline {
  background: #9ca3af;
}

.account-status-pending {
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: pulse-orange 0.9s infinite;
}

.account-status-online {
  background: #16a34a;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45);
  animation: pulse-green 1.1s infinite;
}

.account-inline,
.page-inline {
  justify-content: space-between;
  font-size: 13px;
}

.translate-latency-row {
  padding-top: 2px;
  color: var(--text-soft);
}

.latency-value {
  font-weight: 800;
}

.latency-good {
  color: #16a34a;
}

.latency-warn {
  color: #d97706;
}

.latency-bad {
  color: #dc2626;
}

.account-inline,
.topbar-actions,
.pagination-controls {
  flex-wrap: wrap;
}

.topbar-actions {
  justify-content: flex-end;
}

.mail-main {
  min-width: 0;
  border-radius: 28px;
  padding: 0;
  overflow: hidden;
  border-color: var(--line-strong);
}

.content-view {
  display: none;
  min-height: 100%;
}

.content-view-active {
  display: block;
}

.list-toolbar,
.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.toolbar-title,
.detail-subject {
  font-size: 22px;
  font-weight: 700;
}

.toolbar-subtitle {
  margin-top: 4px;
  font-size: 13px;
}

.message-head-row {
  display: grid;
  grid-template-columns: 40px minmax(140px, 220px) minmax(0, 1fr) 180px;
  gap: 16px;
  padding: 14px 22px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
  align-items: center;
}

.message-table {
  display: grid;
}

.list-alert {
  margin: 0 22px 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  font-size: 13px;
  line-height: 1.6;
}

.list-alert[hidden] {
  display: none;
}

.list-alert-error {
  border-color: rgba(220, 38, 38, 0.22);
  background: #fff5f5;
  color: #b91c1c;
}

.list-alert-success {
  border-color: rgba(22, 163, 74, 0.22);
  background: #f0fdf4;
  color: #15803d;
}

.message-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 13px;
}

.pagination-controls {
  align-items: center;
}

.jump-page-input {
  width: 68px;
  padding: 8px 12px;
  text-align: center;
  border-radius: 999px;
  background: var(--surface);
}

.message-row {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(140px, 220px) minmax(0, 1fr) 180px;
  gap: 16px;
  align-items: center;
  padding: 12px 22px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.message-row:hover {
  background: var(--surface-2);
}

.message-row:focus-visible,
.message-row-focused {
  outline: 2px solid rgba(11, 87, 208, 0.26);
  outline-offset: -2px;
  background: var(--surface-2);
}

.message-row-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.message-row-check,
.message-check-all {
  display: grid;
  place-items: center;
}

.message-row-check input,
.message-check-all input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.message-row-sender,
.message-row-subject {
  font-weight: 500;
}

.message-row-sender,
.message-row-date {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-row-date {
  text-align: right;
  font-weight: 500;
}

.message-row-middle {
  min-width: 0;
}

.message-row-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--text-soft);
}

.message-row-mail-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.message-row-mail-dot-normal {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.message-row-mail-dot-spam {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.message-row-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 600;
}

.message-row-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-soft);
}

.detail-toolbar-left,
.detail-toolbar-right {
  align-items: center;
  min-width: 0;
}

.detail-toolbar-right {
  margin-left: auto;
}

.detail-folder,
.detail-date {
  font-size: 13px;
}

.detail-meta {
  margin: 18px 22px 0;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface-2);
  line-height: 1.7;
}

.translation-bar {
  margin: 12px 22px 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #ffffff;
}

.translation-bar[hidden] {
  display: none;
}

.translation-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.translation-copy strong {
  color: var(--text);
  font-size: 14px;
}

.translation-bar[data-tone='success'] #translation-status {
  color: #15803d;
}

.translation-bar[data-tone='error'] #translation-status {
  color: #dc2626;
}

.translation-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.detail-body {
  margin: 18px 22px 22px;
  min-height: calc(100vh - 250px);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface-2);
  overflow: auto;
  line-height: 1.72;
}

.detail-body img,
.detail-body table {
  max-width: 100%;
}

.detail-body-frame-wrap {
  padding: 0;
  background: #ffffff;
}

.detail-body-frame {
  display: block;
  width: 100%;
  min-height: calc(100vh - 270px);
  border: 0;
  border-radius: 20px;
  background: #ffffff;
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-dim);
}

.error-text {
  color: #ef6b7b !important;
}

@keyframes pulse-green {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.42);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
  }
}

@keyframes pulse-orange {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.38);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.provider-chip:hover,
.icon-btn:hover,
.text-btn:hover,
.primary-btn:hover,
.nav-item:hover,
.danger-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.primary-btn:disabled,
.icon-btn:disabled,
.text-btn:disabled,
.danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 1320px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .mail-layout {
    grid-template-columns: 1fr;
  }

  .left-nav {
    position: static;
    max-height: none;
    overflow: visible;
    order: 2;
  }

  .mail-main {
    order: 1;
  }
}

@media (max-width: 1100px) {
  .message-head-row,
  .message-row {
    grid-template-columns: 40px minmax(120px, 180px) minmax(0, 1fr) 164px;
    gap: 12px;
  }
}

@media (max-width: 800px) {
  .mail-app {
    padding: 8px;
  }

  .topbar {
    gap: 10px;
  }

  .topbar-search input,
  .field input,
  .field select {
    padding: 12px 14px;
  }

  .left-nav,
  .mail-main,
  .login-card {
    border-radius: 22px;
  }

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

  .message-head-row {
    display: none;
  }

  .message-row {
    gap: 8px;
    padding: 14px 16px;
  }

  .message-row-check {
    justify-content: start;
  }

  .message-row-date {
    text-align: left;
  }

  .message-footer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }

  .pagination-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .message-row-date {
    color: var(--text-dim);
  }

  .detail-toolbar,
  .list-toolbar,
  .topbar-actions,
  .detail-toolbar-left {
    flex-wrap: wrap;
  }

  .list-toolbar,
  .detail-toolbar,
  .list-alert,
  .detail-meta,
  .translation-bar,
  .detail-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .translation-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .translation-actions {
    flex-wrap: wrap;
  }

  .detail-body {
    min-height: 420px;
  }
}
