:root {
  --bg: #0f1115;
  --panel: #161922;
  --panel-2: #1e2230;
  --border: #2a2f3d;
  --text: #e7e9ee;
  --muted: #9aa1b1;
  --accent: #6d8bff;
  --accent-hover: #8aa2ff;
  --danger: #ff6d6d;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: #262b3a; border-color: #3a4054; }
button.primary, button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }
button.primary:hover, button[type="submit"]:hover { background: var(--accent-hover); }

input, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 10px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.screen { height: 100%; }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 320px;
}
.login-card h1 {
  font-size: 18px;
  margin: 0 0 20px;
  text-align: center;
  color: var(--text);
}
.login-card button { width: 100%; margin-top: 4px; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; margin-right: 8px; }
.current-email { color: var(--muted); font-size: 13px; margin-right: auto; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100% - 53px);
}
.message-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--panel);
}
.message-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.message-item:hover { background: var(--panel-2); }
.message-item.active { background: #23283a; }
.message-item.unread .msg-subject { font-weight: 700; }
.msg-from { font-size: 13px; color: var(--muted); }
.msg-subject { font-size: 14px; margin: 3px 0; }
.msg-date { font-size: 11px; color: var(--muted); }

.reader {
  padding: 24px 28px;
  overflow-y: auto;
}
.reader .hint { color: var(--muted); }
.reader h2 { margin-top: 0; }
.reader .meta { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.reader .body { white-space: pre-wrap; line-height: 1.5; }
.reader iframe { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: var(--radius); background: white; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 420px;
}
.modal-card h2 { margin-top: 0; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.address-row { display: flex; align-items: center; gap: 8px; }
.address-row input { margin-bottom: 10px; }
.address-row span { color: var(--muted); white-space: nowrap; }

.error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 6px 0 0; }

/* Account switcher */
.spacer { flex: 1; }
.account-switcher { position: relative; }
.switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0e14;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.caret { font-size: 10px; color: var(--muted); }

.switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
  z-index: 20;
}
.switcher-account {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.switcher-account:hover { background: var(--panel-2); }
.switcher-account.active { background: #23283a; }
.switcher-account .email { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher-account .remove {
  background: none;
  border: none;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 13px;
}
.switcher-account .remove:hover { color: var(--danger); background: none; border: none; }

.switcher-action {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--accent);
  font-size: 13px;
}
.switcher-action:hover { background: var(--panel-2); }

/* Folder tabs */
.folder-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.folder-tab {
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
}
.folder-tab:hover { background: var(--panel-2); color: var(--text); }
.folder-tab.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
