:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d9d2c5;
  --accent: #0f6b5c;
  --accent-2: #184e77;
  --danger: #9b2226;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
  --radius: 14px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #efe7d6, var(--bg) 45%);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
}
button, input, textarea {
  font: inherit;
}
button {
  border: 0;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
button.secondary { background: var(--accent-2); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.folder {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  margin-bottom: 0.4rem;
}
button.folder.active, button.folder:hover {
  background: #e8f3f0;
  border-color: #b7d9d1;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card {
  width: min(420px, 100%);
  padding: 2rem;
}
.login-card h1 { margin: 0 0 0.25rem; }
.login-card form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.2rem;
}
label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: white;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,248,0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  min-height: calc(100vh - 70px);
}
.sidebar {
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: rgba(255,253,248,0.7);
}
.content {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 0;
}
.list-pane, .detail-pane {
  min-height: calc(100vh - 70px);
  overflow: auto;
}
.list-pane { border-right: 1px solid var(--line); }
.message-list { display: grid; }
.message-item {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: transparent;
}
.message-item:hover, .message-item.active { background: #eef6f3; }
.message-item.unread .subject { font-weight: 700; }
.message-item .subject { margin: 0 0 0.25rem; }
.message-item .sub {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  color: var(--muted);
}
.message-detail { padding: 1.25rem; }
.message-detail header h2 { margin: 0 0 0.75rem; }
.meta { display: grid; gap: 0.25rem; margin-bottom: 0.9rem; }
.detail-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.body {
  white-space: pre-wrap;
  line-height: 1.55;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}
.body.html-mode { white-space: normal; }

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  width: min(640px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(18, 24, 32, 0.35); }
.compose-form {
  display: grid;
  gap: 0.8rem;
  padding: 1.25rem;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    display: flex;
    gap: 0.4rem;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  button.folder { width: auto; margin: 0; }
  .content { grid-template-columns: 1fr; }
  .list-pane, .detail-pane { min-height: 40vh; }
}
