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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3347;
  --accent: #5b6af0;
  --accent-hover: #4a59e0;
  --text: #e2e4ef;
  --text-muted: #7b82a3;
  --green: #3ecf8e;
  --red: #f66;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 1100px;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header { text-align: center; }
header h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.5px; }
.subtitle { color: var(--text-muted); margin-top: 6px; font-size: .95rem; }

/* Address bar */
.inbox-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  flex-wrap: wrap;
}

.address-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#email-address {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.address-box button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 6px 8px;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
}
.address-box button:hover { color: var(--text); border-color: var(--accent); }

.ttl-badge {
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 12px;
  min-height: 500px;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  font-size: .72rem;
  padding: 2px 7px;
  font-weight: 700;
}
.badge.hidden { display: none; }

#email-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

#email-list li.email-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
#email-list li.email-item:hover { background: var(--surface2); }
#email-list li.email-item.active { background: var(--surface2); border-left: 3px solid var(--accent); }
#email-list li.email-item.unread .item-subject { font-weight: 700; }

.item-from {
  font-size: .82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-subject {
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}
.item-time {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
}

/* Viewer */
.viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 14px;
}
.viewer-empty p { font-size: .95rem; }

.email-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.email-subject { font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
.email-meta { font-size: .85rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 3px; }
.email-meta span { display: flex; gap: 6px; }
.email-meta strong { color: var(--text); }

.email-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  font-size: .92rem;
  line-height: 1.65;
}
.email-body iframe {
  width: 100%;
  border: none;
  min-height: 400px;
  background: #fff;
  border-radius: 6px;
}
.email-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* Attachments */
.att-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .82rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.att-chip:hover { border-color: var(--accent); color: var(--accent); }
.att-pdf { border-color: #e05252; }
.att-pdf:hover { border-color: #f87171; color: #f87171; }
.att-size { color: var(--text-muted); font-size: .75rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .9rem;
  z-index: 100;
  transition: opacity .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* Responsive */
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .viewer { min-height: 400px; }
}
