:root {
  --bg-main: #fffbff;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-soft: #f5f8f4;
  --bg-soft-2: #eef3ed;
  --ink-main: #000500;
  --ink-soft: #5d6c63;
  --ink-muted: #8d9991;
  --line-soft: rgba(0, 5, 0, 0.08);
  --shadow-soft: 0 22px 60px rgba(7, 19, 10, 0.08);
  --shadow-strong: 0 26px 70px rgba(8, 18, 10, 0.14);
  --success-main: #1f8f5f;
}

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

body,
input,
button,
textarea {
  font-family: 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background:
    radial-gradient(circle at top left, rgba(143, 183, 149, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(0, 5, 0, 0.06), transparent 24%),
    var(--bg-main);
  color: #111;
}

.page {
  min-height: 100vh;
  position: relative;
}

.page-glow {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(18px);
  pointer-events: none;
  opacity: .45;
}

.page-glow-left {
  top: 10%;
  left: 8%;
  background: rgba(133, 192, 145, 0.28);
}

.page-glow-right {
  right: 10%;
  bottom: 10%;
  background: rgba(0, 5, 0, 0.08);
}

.btn-primary {
  background: linear-gradient(135deg, #000500 0%, #1b3120 100%);
  color: #fffbff;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 16px 30px rgba(0, 5, 0, 0.16);
}

.btn-primary:hover {
  opacity: .88;
}

.btn-primary:active {
  transform: scale(.98);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  color: #222;
  border: 1.5px solid #e0e7e1;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:hover {
  background: #f5f8f5;
}

.card {
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.78);
}

.hidden {
  display: none !important;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 456px;
  padding: 46px 38px;
  backdrop-filter: none;
  background: #ffffff;
  border: 1px solid rgba(0, 5, 0, 0.08);
}

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

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, #000500 0%, #18301c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 28px rgba(0, 5, 0, 0.18);
}

.brand-title {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--ink-main);
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  background: transparent;
  border: 1px solid #dce4de;
  color: #516157;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.icon-theme-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid #dce4de;
  background: rgba(255, 255, 255, 0.72);
  color: #253128;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-theme-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.brand-kicker {
  text-align: center;
  color: #7c8a81;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  margin-bottom: 10px;
}

.login-lead {
  text-align: center;
  color: #506056;
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 28px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #7d8c81;
  letter-spacing: .05em;
}

.field input {
  width: 100%;
  padding: 14px 14px;
  border: 1.5px solid #e2e8e3;
  border-radius: 14px;
  font-size: 14px;
  outline: none;
  background: rgba(247, 250, 247, 0.94);
}

.field input:focus {
  border-color: #bad0bf;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(31, 143, 95, 0.08);
}

.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #edf1ee;
  text-align: center;
  font-size: 12px;
  color: #9ba79f;
  line-height: 1.7;
  min-height: 18px;
}

.auth-message {
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: #fff4f4;
  color: #b42318;
  font-size: 12px;
  line-height: 1.5;
}

.btn-primary:disabled,
.btn-ghost:disabled,
.icon-btn:disabled {
  opacity: .55;
  cursor: wait;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  height: 66px;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 14px;
  flex-shrink: 0;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
}

.header-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-brand-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-main);
  letter-spacing: -0.03em;
}

.header-brand-subtitle {
  font-size: 11px;
  color: #8e9a92;
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
}

.header-add-account {
  border: 1px dashed #cfe0d3;
  background: #f3faf4;
  color: #1f8f5f;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.mail-address-box {
  max-width: 360px;
  width: auto;
  flex: 0 1 360px;
  background: linear-gradient(180deg, #f8faf8 0%, #eef4ee 100%);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid rgba(0, 5, 0, 0.05);
}

.mail-address-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #546359;
  font-weight: 600;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 8px;
  color: #7d8b83;
}

.icon-btn:hover {
  background: #f3f6f3;
}

.main {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

.sidebar {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 16px;
  border-bottom: 1px solid rgba(0, 5, 0, 0.05);
  flex-shrink: 0;
}

.account-switcher {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
}

.account-chip {
  border: 1px solid #dce6dd;
  background: #f7faf7;
  color: #4f5f55;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.account-chip.active {
  background: #000500;
  border-color: #000500;
  color: #fffbff;
}

.account-chip.add {
  background: #edf6ef;
  color: #1f8f5f;
  border-style: dashed;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #f7faf6 0%, #eff4ef 100%);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: #334139;
}

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

.filter-btn {
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 12px;
  background: #eff3ef;
  color: #66736b;
}

.filter-btn.active {
  background: #000500;
  color: #fff;
}

.mail-count {
  margin-left: auto;
  font-size: 11px;
  color: #97a49a;
  font-weight: 600;
}

.mail-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.mail-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: background .12s, transform .12s, box-shadow .12s;
}

.mail-item:hover {
  background: #f7faf7;
  transform: translateY(-1px);
}

.mail-item.active {
  background: linear-gradient(180deg, #eff6f0 0%, #ecf4ed 100%);
  box-shadow: inset 0 0 0 1px rgba(31, 143, 95, 0.12);
}

.mail-item.empty {
  cursor: default;
  color: #9aa79d;
  background: transparent;
  padding: 30px 12px;
}

.mail-item.empty:hover {
  background: transparent;
  transform: none;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e7f3ea 0%, #ddeedf 100%);
  color: #1f6e47;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mail-item-main {
  flex: 1;
  min-width: 0;
}

.mail-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.sender {
  font-size: 13px;
  font-weight: 700;
  color: #131a15;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.time {
  font-size: 11px;
  color: #9ba79f;
  white-space: nowrap;
  flex-shrink: 0;
}

.subject {
  font-size: 13px;
  font-weight: 700;
  color: #1f2922;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  font-size: 12px;
  color: #87948b;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-scroll {
  overflow-y: auto;
  flex: 1;
}

.detail-head {
  padding: 24px 24px 0;
}

.mobile-back-btn {
  display: none;
  border: none;
  background: #f1f4f1;
  color: #1b2a20;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  cursor: pointer;
}

.mobile-back-btn:hover {
  background: #e8eee9;
}

.detail-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.detail-chip,
.detail-time-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.detail-chip {
  background: #eef7f0;
  color: #1c6f48;
  border: 1px solid rgba(31, 143, 95, 0.12);
}

.detail-time-pill {
  background: #f6f8f5;
  color: #6f7b73;
  border: 1px solid rgba(0, 5, 0, 0.05);
}

.otp-box {
  background: linear-gradient(135deg, #000500 0%, #223825 100%);
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.otp-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.otp-code {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 8px;
  color: #fff;
}

.otp-copy-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.otp-copy-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.detail-title {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.45;
  color: #111;
  margin-bottom: 14px;
  letter-spacing: -0.04em;
}

.detail-sender {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-sender-meta p:first-child {
  font-size: 14px;
  font-weight: 700;
  color: #111;
  line-height: 1.3;
}

.detail-sender-meta p:last-child {
  font-size: 12px;
  color: #8c9890;
  margin-top: 2px;
}

.divider {
  height: 1px;
  background: rgba(0, 5, 0, 0.06);
  margin-bottom: 22px;
}

.detail-body {
  padding: 0 24px 30px;
  font-size: 14px;
  line-height: 1.9;
  color: #33423a;
}

.detail-body p {
  margin-bottom: 16px;
}

.detail-empty-state {
  padding: 6px 0 10px;
}

.detail-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: #1d2920;
  margin-bottom: 8px;
}

.detail-empty-copy {
  color: #738077;
  font-size: 14px;
  line-height: 1.8;
}

.link-chip {
  display: inline-block;
  background: #eff4ef;
  color: #111;
  text-decoration: none;
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}

.mail-skeleton,
.detail-skeleton-line,
.detail-skeleton-block {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, #eef2ee 0%, #f9fbf8 50%, #eef2ee 100%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}

.mail-skeleton {
  height: 84px;
  border-radius: 16px;
  margin-bottom: 10px;
}

.detail-skeleton-line {
  height: 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.detail-skeleton-line.short {
  width: 42%;
}

.detail-skeleton-line.medium {
  width: 68%;
}

.detail-skeleton-block {
  height: 148px;
  border-radius: 22px;
  margin-bottom: 18px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.toast {
  position: fixed;
  top: 72px;
  right: 18px;
  transform: translateY(-10px) scale(.98);
  background: #20362b;
  color: #f7fff7;
  padding: 15px 22px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 18px 44px rgba(15, 37, 23, .28);
  border: 1px solid rgba(255, 255, 255, .12);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 50;
  min-width: 260px;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.mail-alert {
  background: linear-gradient(135deg, #1f8f5f 0%, #0f6b45 100%);
  color: #f5fff8;
  box-shadow: 0 22px 48px rgba(17, 111, 73, .34);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 5, 0, 0.38);
}

.modal-dialog {
  position: relative;
  width: min(440px, 100%);
  padding: 22px;
  background: #ffffff;
  backdrop-filter: none;
  border: 1px solid rgba(0, 5, 0, 0.08);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head h3 {
  font-size: 24px;
  letter-spacing: -0.04em;
  color: var(--ink-main);
}

.modal-kicker {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #7c8a81;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

@media (max-width: 760px) {
  .toast {
    top: 68px;
    right: 16px;
    left: 16px;
    min-width: 0;
  }

  .header {
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .detail-wrap {
    display: none;
  }

  .main.mobile-detail-open .sidebar {
    display: none;
  }

  .main.mobile-detail-open .detail-wrap {
    display: flex;
  }

  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .header-center {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    margin-top: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .mail-address-box {
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }

  .account-switcher {
    margin-bottom: 12px;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-dialog {
    width: 100%;
    border-radius: 22px 22px 0 0;
    padding: 20px 16px 16px;
  }

  .detail-title {
    font-size: 21px;
  }

  .theme-toggle {
    top: 14px;
    right: 14px;
  }
}

body.dark-theme {
  --bg-main: #0c120e;
  --bg-panel: rgba(18, 24, 20, 0.92);
  --bg-soft: #131b16;
  --bg-soft-2: #19231c;
  --ink-main: #f5fbf6;
  --ink-soft: #b7c4ba;
  --ink-muted: #8c9b90;
  --line-soft: rgba(255, 255, 255, 0.08);
  --shadow-soft: 0 22px 60px rgba(0, 0, 0, 0.35);
  --shadow-strong: 0 26px 70px rgba(0, 0, 0, 0.45);
  color: #edf6ef;
}

body.dark-theme {
  background:
    radial-gradient(circle at top left, rgba(31, 143, 95, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.05), transparent 24%),
    var(--bg-main);
}

body.dark-theme .btn-ghost,
body.dark-theme .theme-toggle {
  background: rgba(255, 255, 255, 0.04);
  color: #edf6ef;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .icon-theme-btn {
  background: rgba(255, 255, 255, 0.04);
  color: #edf6ef;
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .btn-ghost:hover,
body.dark-theme .theme-toggle:hover,
body.dark-theme .icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.dark-theme .login-card,
body.dark-theme .card {
  background: var(--bg-panel);
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .field label,
body.dark-theme .mail-count,
body.dark-theme .time,
body.dark-theme .detail-sender-meta p:last-child,
body.dark-theme .detail-empty-copy,
body.dark-theme .mail-address-text,
body.dark-theme .preview,
body.dark-theme .login-footer {
  color: #95a49a;
}

body.dark-theme .field input,
body.dark-theme .search-box {
  background: #121a15;
  border-color: rgba(255, 255, 255, 0.08);
  color: #edf6ef;
}

body.dark-theme .search-box input {
  color: #edf6ef;
}

body.dark-theme .header {
  background: rgba(13, 18, 15, 0.78);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.dark-theme .mail-address-box,
body.dark-theme .filter-btn,
body.dark-theme .detail-time-pill,
body.dark-theme .mobile-back-btn {
  background: #131b16;
  border-color: rgba(255, 255, 255, 0.08);
  color: #d8e3da;
}

body.dark-theme .header-add-account {
  background: #131b16;
  border-color: rgba(156, 225, 187, 0.26);
  color: #9ce1bb;
}

body.dark-theme .filter-btn.active {
  background: #edf6ef;
  color: #0c120e;
}

body.dark-theme .sender,
body.dark-theme .subject,
body.dark-theme .detail-title,
body.dark-theme .detail-sender-meta p:first-child,
body.dark-theme .detail-empty-title,
body.dark-theme .header-brand-title,
body.dark-theme .brand-title {
  color: #f5fbf6;
}

body.dark-theme .mail-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

body.dark-theme .mail-item.active {
  background: linear-gradient(180deg, rgba(31, 143, 95, 0.18) 0%, rgba(31, 143, 95, 0.1) 100%);
  box-shadow: inset 0 0 0 1px rgba(31, 143, 95, 0.18);
}

body.dark-theme .avatar {
  background: linear-gradient(135deg, #183124 0%, #214332 100%);
  color: #dff7e8;
}

body.dark-theme .detail-chip {
  background: rgba(31, 143, 95, 0.14);
  color: #9ce1bb;
  border-color: rgba(31, 143, 95, 0.18);
}

body.dark-theme .divider {
  background: rgba(255, 255, 255, 0.06);
}

body.dark-theme .detail-body {
  color: #d2ded5;
}

body.dark-theme .toast {
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .account-chip {
  background: #131b16;
  border-color: rgba(255, 255, 255, 0.08);
  color: #d8e3da;
}

body.dark-theme .account-chip.active {
  background: #edf6ef;
  border-color: #edf6ef;
  color: #0c120e;
}

body.dark-theme .account-chip.add {
  color: #9ce1bb;
}

body.dark-theme .modal-dialog {
  background: #121814;
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .modal-kicker {
  color: #9ab7a4;
}
