:root {
  --wm-bg: #f0f3f7;
  --wm-surface: #ffffff;
  --wm-ink: #1a2332;
  --wm-muted: #5c6b7a;
  --wm-line: #d8e0e8;
  --wm-accent: #0b6e4f;
  --wm-accent-soft: #e6f4ef;
  --wm-danger: #b42318;
  --wm-star: #c9a227;
  --wm-unread: #0f2744;
  --wm-sidebar: #e8eef4;
  --wm-shadow: 0 12px 40px rgba(26, 35, 50, 0.12);
  --wm-radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --font-display: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--wm-ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9e8ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d7f0e6 0%, transparent 50%),
    var(--wm-bg);
}

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

.wm-topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.65rem 1rem;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--wm-line);
  position: sticky; top: 0; z-index: 20;
}
.wm-brand { display: flex; align-items: center; gap: 0.55rem; min-width: 180px; }
.wm-brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(145deg, var(--wm-accent), #1a4d7a);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.wm-brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.wm-search { flex: 1; max-width: 640px; }
.wm-search input {
  width: 100%; padding: 0.65rem 1rem; border-radius: 999px;
  border: 1px solid transparent; background: var(--wm-sidebar);
  font: inherit;
}
.wm-search input:focus { outline: 2px solid var(--wm-accent); background: #fff; }
.wm-top-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.wm-select {
  border: 1px solid var(--wm-line); border-radius: 8px;
  padding: 0.4rem 0.6rem; background: #fff; font: inherit; max-width: 220px;
}

.wm-shell { display: flex; flex: 1; min-height: 0; }
.wm-sidebar {
  width: 220px; flex-shrink: 0;
  padding: 1rem 0.75rem;
  background: linear-gradient(180deg, rgba(232,238,244,0.9), rgba(232,238,244,0.55));
  border-right: 1px solid var(--wm-line);
  display: flex; flex-direction: column; gap: 1rem;
}
.wm-compose-btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--wm-accent); color: #fff;
  font: inherit; font-weight: 600;
  padding: 0.85rem 1.1rem; border-radius: 999px;
  box-shadow: 0 8px 20px rgba(11,110,79,0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.wm-compose-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(11,110,79,0.3); }

.wm-folders { display: flex; flex-direction: column; gap: 0.15rem; }
.wm-folder {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.55rem 0.75rem; border-radius: 8px; border: 0;
  background: transparent; font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.wm-folder:hover { background: rgba(255,255,255,0.7); }
.wm-folder.active { background: var(--wm-accent-soft); color: var(--wm-accent); font-weight: 600; }

.wm-labels-block { margin-top: auto; }
.wm-labels-head { display: flex; justify-content: space-between; align-items: center; color: var(--wm-muted); font-size: 0.85rem; padding: 0 0.5rem; }
.wm-labels { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.wm-labels li { padding: 0.35rem 0.75rem; border-radius: 6px; cursor: default; font-size: 0.92rem; }

.wm-quota {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--wm-line);
  font-size: 0.8rem;
  color: var(--wm-muted);
}
.wm-quota-label { font-weight: 600; color: var(--wm-ink); margin-bottom: 0.35rem; }
.wm-quota-bar {
  height: 6px; border-radius: 999px; background: #d7dee6; overflow: hidden; margin-bottom: 0.35rem;
}
.wm-quota-fill {
  height: 100%; width: 0%; background: var(--wm-accent); border-radius: inherit; transition: width 0.25s ease;
}
.wm-quota-fill.is-high { background: #b45309; }
.wm-quota-fill.is-full { background: var(--wm-danger); }
.wm-quota-text { line-height: 1.35; }

.wm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--wm-surface); }
.wm-toolbar {
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
  padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--wm-line);
  background: #fafcfd;
}
.wm-toolbar-spacer { flex: 1; }
.wm-text-btn, .wm-icon-btn {
  appearance: none; border: 0; background: transparent; font: inherit;
  color: var(--wm-muted); cursor: pointer; padding: 0.4rem 0.55rem; border-radius: 6px;
}
.wm-text-btn:hover:not(:disabled), .wm-icon-btn:hover { background: var(--wm-sidebar); color: var(--wm-ink); }
.wm-text-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.wm-primary-btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--wm-accent); color: #fff; font: inherit; font-weight: 600;
  padding: 0.55rem 1.1rem; border-radius: 8px;
}

.wm-split { display: grid; grid-template-columns: minmax(280px, 38%) 1fr; flex: 1; min-height: 0; }
.wm-list { overflow: auto; border-right: 1px solid var(--wm-line); }
.wm-msg {
  display: grid; grid-template-columns: 28px 28px 1fr auto; gap: 0.4rem; align-items: start;
  padding: 0.75rem 0.85rem; border-bottom: 1px solid var(--wm-line);
  cursor: pointer; transition: background 0.12s ease;
}
.wm-msg:hover { background: #f5f8fb; }
.wm-msg.active { background: var(--wm-accent-soft); }
.wm-msg.unread .wm-msg-from, .wm-msg.unread .wm-msg-subject { font-weight: 700; color: var(--wm-unread); }
.wm-msg-from { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-msg-subject { font-size: 0.9rem; color: var(--wm-ink); }
.wm-msg-snippet { font-size: 0.82rem; color: var(--wm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-msg-date { font-size: 0.78rem; color: var(--wm-muted); white-space: nowrap; }
.wm-star { color: var(--wm-line); border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; }
.wm-star.on { color: var(--wm-star); }

.wm-reading { overflow: auto; padding: 1.25rem 1.5rem; }
.wm-empty { margin-top: 18vh; text-align: center; color: var(--wm-muted); }
.wm-empty h2 { font-family: var(--font-display); color: var(--wm-ink); font-weight: 600; }
.wm-reading-head { margin-bottom: 1rem; animation: wm-fade 0.25s ease; }
.wm-reading-head h1 { font-family: var(--font-display); font-size: 1.55rem; margin: 0 0 0.5rem; font-weight: 600; }
.wm-meta { color: var(--wm-muted); font-size: 0.9rem; display: grid; gap: 0.2rem; }
.wm-body { line-height: 1.55; animation: wm-fade 0.35s ease; }
.wm-body img { max-width: 100%; height: auto; }
.wm-attachments { margin-top: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.wm-att {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.7rem; border: 1px solid var(--wm-line); border-radius: 8px;
  text-decoration: none; color: inherit; font-size: 0.88rem; background: #f7fafc;
}
.wm-reading-actions { display: flex; gap: 0.4rem; margin: 0.75rem 0 1rem; flex-wrap: wrap; }

.wm-modal {
  position: fixed; inset: 0; background: rgba(15, 27, 44, 0.35);
  display: grid; place-items: end center; padding: 1rem; z-index: 50;
}
.wm-modal[hidden] { display: none; }
.wm-compose-card {
  width: min(720px, 100%); background: #fff; border-radius: var(--wm-radius) var(--wm-radius) 0 0;
  box-shadow: var(--wm-shadow); animation: wm-slide 0.22s ease;
}
.wm-compose-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1rem; background: #2b3645; color: #fff; border-radius: var(--wm-radius) var(--wm-radius) 0 0;
}
.wm-compose-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.wm-compose-head .wm-icon-btn { color: #fff; }
.wm-compose-form { display: grid; gap: 0.55rem; padding: 0.85rem 1rem 1rem; }
.wm-compose-form label { display: grid; gap: 0.25rem; font-size: 0.85rem; color: var(--wm-muted); }
.wm-compose-form input, .wm-compose-form textarea {
  border: 0; border-bottom: 1px solid var(--wm-line); padding: 0.45rem 0; font: inherit; resize: vertical;
}
.wm-compose-form input:focus, .wm-compose-form textarea:focus { outline: none; border-color: var(--wm-accent); }
.wm-compose-foot { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.wm-compose-status { color: var(--wm-muted); font-size: 0.85rem; }

.wm-toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: #1a2332; color: #fff; padding: 0.7rem 1.1rem; border-radius: 999px;
  z-index: 60; box-shadow: var(--wm-shadow); animation: wm-fade 0.2s ease;
}
.wm-toast[hidden] { display: none; }

.wm-auth-body, .wm-admin-body { min-height: 100vh; }
.wm-auth-card {
  max-width: 420px; margin: 10vh auto; padding: 2rem;
  background: #fff; border-radius: 16px; box-shadow: var(--wm-shadow);
}
.wm-auth-card h1 { font-family: var(--font-display); margin-top: 0; }
.wm-auth-card label { display: grid; gap: 0.35rem; margin: 1rem 0; }
.wm-auth-card input { padding: 0.6rem 0.75rem; border: 1px solid var(--wm-line); border-radius: 8px; font: inherit; }
.wm-result { white-space: pre-wrap; background: #f5f8fb; padding: 1rem; border-radius: 8px; }
.wm-admin-main { padding: 1.25rem; }
.wm-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.wm-table th, .wm-table td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--wm-line); font-size: 0.92rem; }
.wm-table th { background: #f3f6f9; color: var(--wm-muted); font-weight: 600; }

@keyframes wm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wm-slide { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 900px) {
  .wm-split { grid-template-columns: 1fr; }
  .wm-reading:not(.has-message) { display: none; }
  .wm-list.hide-mobile { display: none; }
  .wm-sidebar { width: 72px; }
  .wm-brand-name, .wm-folder span:last-child, .wm-labels-block, .wm-quota { display: none; }
  .wm-compose-btn { border-radius: 50%; width: 48px; height: 48px; padding: 0; font-size: 1.4rem; }
}
