:root {
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --surface-subtle: #FAF9F6;
  --surface-hover: #EFEDE7;
  --surface-active: #EEF4F1;
  --border: #E4E2DC;
  --border-strong: #D9D6CE;
  --border-input: #CFCCC3;
  --border-divider: #EEECE6;
  --text: #15171A;
  --muted: #5C6168;
  --subtle: #787D85;
  --accent: #0B6B57;
  --accent-hover: #085545;
  --accent-border: #BFD8D0;
  --danger: #B3261E;
  --danger-bg: #FDF2F2;
  --danger-border: #F5C2C0;
  --warn: #B45309;
  --warn-bg: #FEF6E7;
  --radius-card: 14px;
  --radius-input: 10px;
  --radius-btn: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.lbl {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* Buttons & Links */
.btn {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn.lg {
  height: 48px;
  padding: 0 18px;
}

.btn.sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.danger {
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.btn.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-color: transparent;
  background: transparent;
}

.btn.icon:hover {
  background: var(--surface-hover);
}

.link {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 8px 10px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.link:hover {
  background: #EAE8E2;
  color: var(--text);
}

.chip {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.chip:hover {
  background: #EAE8E2;
}

.chip.active {
  background: var(--surface);
  border-color: var(--border-input);
}

.chip.otp-chip {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
}

.chip.otp-chip:hover {
  background: var(--surface-active);
}

.chip.static-chip {
  cursor: default;
  font-family: 'Inter', system-ui, sans-serif;
}

/* Cards & Containers */
.wrap {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 0 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

/* Login Page */
.login-body {
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pro-pill {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border-input);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.alert-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-success {
  background: var(--surface-active);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-divider);
  font-size: 12px;
  color: var(--muted);
}

/* Header */
.topbar {
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 245px;
  box-shadow: 0 8px 24px rgba(21, 23, 26, 0.08);
  z-index: 50;
  padding: 6px;
}

.dropdown-content.show {
  display: block;
}

.dropdown-content a {
  display: block;
  padding: 9px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
}

.dropdown-content a:hover {
  background: var(--surface-hover);
}

/* Main Content */
.main-content {
  padding-top: 28px;
  padding-bottom: 40px;
  flex: 1;
}

.hero-card {
  padding: 28px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-top h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero-desc {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  max-width: 580px;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  flex-wrap: wrap;
}

.sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

.sync-toggle:hover {
  background: var(--bg);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.sync-toggle.paused .status-dot {
  background: var(--warn);
}

.sync-toggle.paused {
  color: var(--muted);
}

.ttl-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
}

.ttl-time {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* Email Bar */
.mailbox-bar {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.email-input-group {
  flex: 1;
  min-width: 260px;
  height: 48px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  background: var(--surface);
  overflow: hidden;
}

.email-input-group:focus-within {
  border-color: var(--accent);
}

.email-input-group input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0 16px;
  font-size: 15px;
  background: transparent;
  color: var(--text);
}

.at-symbol {
  padding: 0 4px;
  font-size: 15px;
  color: var(--muted);
}

.email-input-group select {
  height: 100%;
  border: 0;
  border-left: 1px solid var(--border);
  background: var(--surface-subtle);
  padding: 0 14px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.mailbox-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Meta / Recent Row */
.mailbox-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-divider);
  font-size: 13px;
}

.current-address-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.recent-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recent-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Two-column Workspace */
.workspace-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 24px;
  margin-top: 24px;
  align-items: stretch;
}

.list-panel {
  min-height: 580px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 20px;
  border-bottom: 1px solid var(--border-divider);
}

.tabs {
  display: flex;
  align-items: center;
}

.tab {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: 0;
  padding: 13px 4px;
  margin-right: 20px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab.on {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--text);
}

.list-actions {
  display: flex;
  gap: 2px;
}

.message-list {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  max-height: 680px;
}

.msg-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  margin-bottom: 4px;
  transition: background-color 0.12s ease;
}

.msg-item:hover {
  background: var(--surface-subtle);
}

.msg-item.active {
  background: var(--surface-active);
}

.msg-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.msg-sender {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-unread-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
}

.msg-time {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.msg-subject {
  font-size: 14px;
  color: var(--text);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-item.unread .msg-subject {
  font-weight: 600;
}

.msg-preview {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-badges {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.list-empty-footer {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Detail Panel */
.detail-panel {
  min-height: 580px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.empty-state {
  margin: auto;
  text-align: center;
  padding: 40px 24px;
  max-width: 420px;
}

.empty-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 14px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--muted);
}

.detail-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* OTP Banner */
.otp-hero-box {
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-divider);
  background: var(--surface);
}

.otp-digits {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.1;
  margin-top: 6px;
  color: var(--accent);
}

.detail-body-header {
  padding: 24px 28px 0;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-title-row h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.detail-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr;
  gap: 20px;
  margin-top: 22px;
  padding: 18px 0;
  border-top: 1px solid var(--border-divider);
  border-bottom: 1px solid var(--border-divider);
}

.meta-val {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.meta-msgid {
  padding: 12px 0 0;
  font-size: 12px;
  word-break: break-all;
}

.attachments-box {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}

.attachment-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* Body Tabs & Preview */
.body-section {
  padding: 18px 28px 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.body-tabs {
  border-bottom: 1px solid var(--border-divider);
}

.body-content-wrap {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  flex: 1;
  min-height: 300px;
  display: flex;
}

.html-sandbox-frame {
  width: 100%;
  min-height: 320px;
  border: 0;
  background: #FFFFFF;
}

.text-body-pre {
  width: 100%;
  min-height: 320px;
  padding: 24px 28px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  background: #FFFFFF;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 23, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(21, 23, 26, 0.18);
  z-index: 200;
}

.footer {
  text-align: center;
  padding: 18px 16px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Responsive */
@media (max-width: 900px) {
  .wrap {
    padding: 0 16px;
  }
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .meta-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .otp-digits {
    font-size: 38px;
  }
  .hero-card,
  .otp-hero-box,
  .detail-body-header,
  .body-section {
    padding-left: 18px;
    padding-right: 18px;
  }
}
