:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: rgba(29, 47, 68, 0.14);
  --text: #182435;
  --muted: #657486;
  --accent: #1d6f8f;
  --accent-2: #6c5ce7;
  --success: #21855f;
  --danger: #c53f58;
  --shadow: 0 20px 46px rgba(29, 47, 68, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "IBM Plex Sans KR", sans-serif;
  background:
    linear-gradient(135deg, rgba(29, 111, 143, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(108, 92, 231, 0.12), transparent 32%),
    var(--bg);
  color: var(--text);
}

body {
  padding: 22px;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 38px;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1520px, 100%);
  margin: 0 auto;
}

.top-bar,
.toolbar-card,
.card,
.summary-card,
.sidebar,
.guest-shell,
.compose-dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.top-bar,
.toolbar-card,
.card,
.sidebar,
.guest-shell {
  border-radius: 24px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
}

.top-eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions,
.toolbar-actions,
.submit-row,
.detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.icon-btn,
.primary-btn,
.ghost-btn,
.folder-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.icon-btn:hover,
.primary-btn:hover,
.ghost-btn:hover,
.folder-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(29, 111, 143, 0.34);
}

.icon-btn {
  width: 42px;
  padding: 0;
  border-radius: 999px;
}

.primary-btn,
.ghost-btn {
  border-radius: 999px;
  padding: 0 16px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #31a1b8);
  border-color: transparent;
  color: #fff;
}

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

.status-line {
  min-height: 32px;
  padding: 12px 6px 0;
  color: var(--muted);
}

.guest-shell {
  margin-top: 18px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.8fr);
  gap: 22px;
}

.guest-copy,
.guest-highlights {
  display: grid;
  gap: 16px;
  align-content: start;
}

.guest-copy h2 {
  font-size: 28px;
}

.guest-text {
  color: var(--muted);
  line-height: 1.7;
}

.mail-view {
  display: grid;
  grid-template-columns: 220px minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: stretch;
  height: calc(100dvh - 150px);
  min-height: 560px;
  overflow: hidden;
}

.mail-view.list-collapsed {
  grid-template-columns: 220px minmax(0, 1fr);
}

.mail-view.list-collapsed .message-column {
  display: none;
}

.mail-view.list-collapsed .detail-card {
  grid-column: 2;
}

.sidebar {
  padding: 16px;
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
}

.compose-wide {
  width: 100%;
}

.folder-list {
  display: grid;
  gap: 8px;
}

.folder-btn {
  border-radius: 14px;
  min-height: 44px;
  padding: 0 12px;
  justify-content: space-between;
  text-align: left;
}

.folder-btn.active {
  background: rgba(29, 111, 143, 0.12);
  border-color: rgba(29, 111, 143, 0.28);
  color: var(--accent);
}

.folder-left {
  min-width: 0;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  color: var(--muted);
  font-size: 13px;
}

.message-column {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.toolbar-card {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-wrap {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  border-radius: 18px;
  padding: 16px;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.summary-card strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 24px;
}

.card {
  padding: 18px;
}

.list-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.chip {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(108, 92, 231, 0.1);
  color: var(--accent-2);
  font-size: 13px;
}

.message-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.message-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 7px;
}

.message-item.active {
  border-color: rgba(29, 111, 143, 0.34);
  background: rgba(29, 111, 143, 0.08);
}

.message-item.unread .message-subject {
  font-weight: 700;
}

.message-subject-row {
  min-width: 0;
  display: flex;
  gap: 7px;
  align-items: center;
}

.message-subject-row .message-subject {
  flex: 1;
}

.message-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
}

.message-sender,
.message-subject,
.message-snippet {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-date,
.message-snippet {
  color: var(--muted);
  font-size: 13px;
}

.spam-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.spam-spam {
  color: #9f1239;
  background: rgba(197, 63, 88, 0.12);
  border-color: rgba(197, 63, 88, 0.26);
}

.spam-suspicious {
  color: #9a5a00;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.28);
}

.spam-pass {
  color: #176649;
  background: rgba(33, 133, 95, 0.12);
  border-color: rgba(33, 133, 95, 0.24);
}

.spam-reasons {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

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

.detail-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.message-meta {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.message-meta h3 {
  font-size: 25px;
  line-height: 1.32;
}

.message-meta dl {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  color: var(--muted);
}

.message-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.message-body {
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-body.html-mode {
  white-space: normal;
}

.remote-image-bar {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(29, 111, 143, 0.18);
  border-radius: 14px;
  background: rgba(29, 111, 143, 0.08);
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.remote-image-bar .ghost-btn {
  min-height: 34px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.72);
}

.html-message {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.html-message :is(h1, h2, h3, h4, p, ul, ol, blockquote, pre, table) {
  margin-top: 0;
  margin-bottom: 0.9rem;
}

.html-message a {
  color: var(--accent);
  text-decoration: underline;
}

.html-message img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.html-message table {
  max-width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}

.html-message th,
.html-message td {
  border: 1px solid var(--line);
  padding: 6px 8px;
}

.html-message blockquote {
  border-left: 3px solid rgba(29, 111, 143, 0.32);
  padding-left: 12px;
  color: var(--muted);
}

.html-message pre {
  white-space: pre-wrap;
  padding: 12px;
  border-radius: 12px;
  background: rgba(24, 36, 53, 0.06);
}

.blocked-image {
  display: inline-flex;
  max-width: 100%;
  min-height: 38px;
  align-items: center;
  padding: 8px 10px;
  border: 1px dashed rgba(101, 116, 134, 0.45);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.text-fallback {
  margin-top: 16px;
  color: var(--muted);
}

.text-fallback pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}

.compose-dialog {
  width: min(720px, calc(100vw - 28px));
  border-radius: 24px;
  padding: 0;
  color: var(--text);
}

.compose-dialog::backdrop {
  background: rgba(24, 36, 53, 0.42);
}

.compose-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

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

.field-wrap span {
  color: var(--muted);
  font-size: 13px;
}

.field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  padding: 12px 14px;
  outline: 0;
}

textarea.field {
  resize: vertical;
}

.submit-row {
  justify-content: flex-end;
}

.callback-shell {
  min-height: calc(100vh - 44px);
  display: grid;
  place-items: center;
}

.callback-card {
  width: min(520px, 100%);
}

@media (max-width: 1120px) {
  .mail-view {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .mail-view.list-collapsed {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .detail-card {
    grid-column: 1 / -1;
    min-height: 420px;
    position: static;
  }

  .mail-view.list-collapsed .detail-card {
    grid-column: 2;
  }
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 30px;
  }

  .top-bar,
  .guest-shell,
  .toolbar-card,
  .summary-row,
  .mail-view {
    grid-template-columns: 1fr;
  }

  .top-bar {
    align-items: flex-start;
  }

  .sidebar {
    position: static;
  }

  .folder-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-row {
    display: grid;
  }

  .toolbar-card {
    display: grid;
  }

  .mail-view,
  .mail-view.list-collapsed {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .mail-view.list-collapsed {
    grid-template-columns: 1fr;
  }

  .mail-view.list-collapsed .detail-card {
    grid-column: 1;
  }

  .message-list,
  .detail-panel {
    max-height: 68dvh;
  }
}
