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

:root {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #252525;
  --border: #333;
  --text: #e0e0e0;
  --text2: #999;
  --accent: #4a9eff;
  --accent-hover: #6ab0ff;
  --danger: #e55;
  --success: #4c4;
  --radius: 8px;
  --sidebar-w: 220px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--bg3); color: var(--text); }
button.secondary:hover { background: var(--border); }
button.danger { background: var(--danger); }

input, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 200px; font-family: inherit; }

/* -- Login Screen -- */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 24px;
  text-align: center;
}
#login-screen .login-logo {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  object-fit: cover;
}
#login-screen h1 { font-size: 28px; font-weight: 300; }
#login-screen p { color: var(--text2); max-width: 400px; }

/* -- Login Creation -- */
#login-create {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}
#login-create .form-box {
  background: var(--bg2);
  padding: 32px;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-width: 420px;
  width: 100%;
}
#login-create h2 { margin-bottom: 16px; font-weight: 400; }
#login-create .hint { color: var(--text2); font-size: 13px; margin-top: 8px; }
#login-create .error { color: var(--danger); font-size: 13px; margin-top: 8px; }
#login-create .preview { color: var(--accent); margin: 12px 0; font-size: 15px; }
#login-create .actions { margin-top: 16px; display: flex; gap: 8px; }

/* -- Mailbox Picker -- */
.mailbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  max-width: 360px;
  width: 100%;
}
.mailbox-item {
  background: var(--bg2);
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
}
.mailbox-item:hover {
  border-color: var(--accent);
  background: #1a1a2e;
}

/* -- Password Display -- */
.password-reveal {
  background: var(--bg2);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-width: 420px;
  text-align: center;
}
.password-reveal code {
  font-size: 20px;
  background: var(--bg);
  padding: 8px 16px;
  border-radius: var(--radius);
  display: inline-block;
  margin: 12px 0;
  user-select: all;
}

/* -- Main Layout -- */
#mail-app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h2 { font-size: 16px; font-weight: 500; }
.sidebar-user { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sidebar-user .email { font-size: 13px; color: var(--accent); }
.sidebar-user .name { font-size: 12px; color: var(--text2); }

.folder-list { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; }
.sidebar-logo-wrap {
  margin-top: auto;
  padding: 20px 16px;
  display: flex;
  justify-content: center;
}
.sidebar-logo-large {
  width: 100%;
  max-width: 180px;
  border-radius: 16px;
  object-fit: cover;
  opacity: 0.85;
}
.folder-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  transition: background 0.15s;
}
.folder-item:hover { background: var(--bg3); }
.folder-item.active { background: var(--bg3); color: var(--accent); font-weight: 500; }
.folder-item .badge {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.sidebar-footer button { font-size: 12px; padding: 4px 8px; flex: 1; }

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}
.toolbar button { font-size: 13px; padding: 6px 12px; }
.toolbar .spacer { flex: 1; }
.toolbar .page-info { font-size: 13px; color: var(--text2); }

/* Message List */
.message-list {
  flex: 1;
  overflow-y: auto;
}
.message-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}
.message-row:hover { background: var(--bg2); }
.message-row.unread { font-weight: 600; }
.message-row.unread .msg-from { color: var(--text); }
.message-row .msg-from {
  width: 180px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text2);
}
.message-row .msg-subject {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.message-row .msg-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text2);
  width: 90px;
  text-align: right;
}

.empty-folder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text2);
  font-size: 15px;
}

/* Content Area — fills remaining space and scrolls */
#content-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Message View */
.message-view {
  padding: 24px;
}
.message-view .msg-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.message-view .msg-header h2 { font-size: 20px; font-weight: 400; margin-bottom: 8px; }
.message-view .msg-meta { font-size: 13px; color: var(--text2); line-height: 1.6; }
.message-view .msg-meta strong { color: var(--text); }
.message-view .msg-body {
  font-size: 14px;
  line-height: 1.6;
}
.message-view .msg-body iframe {
  width: 100%;
  border: none;
  min-height: 300px;
  max-height: 70vh;
}

/* Compose */
.compose {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.compose .field { display: flex; gap: 8px; align-items: center; }
.compose .field label { width: 60px; font-size: 14px; color: var(--text2); flex-shrink: 0; }
.compose .field input { flex: 1; }
.compose .actions { display: flex; gap: 8px; }

/* Responsive */
@media (max-width: 768px) {
  :root { --sidebar-w: 0; }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100vh;
    z-index: 100;
  }
  .message-row .msg-from { width: 100px; }
}

/* Attachments */
.msg-attachments {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.msg-attachments .att-title {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}
.att-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px 8px 0;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.att-item:hover { border-color: var(--accent); }
.att-item .att-size { color: var(--text2); font-size: 12px; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.2s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }
