:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #111827;
  --accent-soft: #f3f4f6;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.error {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 13px;
}

button {
  font: inherit;
  cursor: pointer;
}

.primary {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

/* login */
.login {
  display: grid;
  place-items: center;
  height: 100%;
  background: var(--panel);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-card p {
  margin: 0.25rem 0 0;
}

#login-form {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

input,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
  color: inherit;
  background: #fff;
}

input:focus,
textarea:focus {
  outline: 2px solid #c7d2fe;
  border-color: #9ca3af;
}

.email-row {
  display: flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
}

.email-row input {
  border: 0;
  border-radius: 0;
}

.email-row input:focus {
  outline: none;
}

.suffix {
  padding: 0 0.7rem;
  color: var(--muted);
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.hint {
  margin-top: 0.9rem;
  font-size: 12px;
  text-align: center;
}

/* app */
.app {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0.75rem;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.account {
  display: grid;
  padding: 0 0.25rem;
  overflow: hidden;
}

.account strong,
.account span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account span {
  font-size: 12px;
}

.compose-button {
  padding: 0.55rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

#folders {
  display: grid;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.folder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  font-size: 13px;
}

.folder:hover {
  background: #f3f4f6;
}

.folder.active {
  background: #e5e7eb;
  font-weight: 600;
  color: #111827;
}

.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.logout {
  padding: 0.5rem;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--muted);
  text-align: left;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pane-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 64px;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.pane-header h2 {
  margin: 0;
  font-size: 18px;
  text-transform: capitalize;
}

.search {
  margin-left: auto;
  width: min(320px, 45vw);
}

.search input {
  background: var(--accent-soft);
  border-color: transparent;
}

.list {
  flex: 1;
  overflow-y: auto;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: inherit;
}

.row:hover {
  background: #fafafa;
}

.row.unseen {
  background: #f8faff;
}

.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5e7eb;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
}

.row .from {
  width: 190px;
  flex: 0 0 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .subject {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .date {
  flex: 0 0 84px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}

.row.unseen .from,
.row.unseen .subject {
  font-weight: 600;
  color: #111827;
}

.star {
  border: 0;
  background: none;
  padding: 0;
  color: #d1d5db;
  font-size: 15px;
  line-height: 1;
}

.star.on {
  color: #eab308;
}

.empty {
  padding: 2rem 1.25rem;
  color: var(--muted);
}

/* reader */
.reader {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.reader-inner {
  max-width: 820px;
  margin: 0 auto;
}

.reader-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.icon-button {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #374151;
  font-size: 13px;
}

.icon-button:hover {
  background: var(--accent-soft);
}

.reader h1 {
  margin: 0.25rem 0 0.75rem;
  font-size: 22px;
}

.reader-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.reader-meta .who {
  overflow: hidden;
}

.reader-meta .who p {
  margin: 0;
}

.reader-meta .date {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

#body-frame {
  width: 100%;
  min-height: 420px;
  border: 0;
  margin-top: 1rem;
}

pre.plain {
  margin-top: 1rem;
  white-space: pre-wrap;
  font: inherit;
}

.attachments {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.attachments a {
  color: #2563eb;
}

/* compose */
.compose-dialog {
  width: min(680px, 92vw);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.compose-dialog::backdrop {
  background: rgb(17 24 39 / 35%);
}

.compose-dialog form {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
}

.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.compose-head h3 {
  margin: 0;
  font-size: 16px;
}

.icon {
  border: 0;
  background: none;
  font-size: 15px;
  color: var(--muted);
}

.compose-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.compose-actions .primary {
  width: auto;
}

@media (max-width: 720px) {
  .sidebar {
    width: 180px;
    flex-basis: 180px;
  }
  .row .from {
    width: 120px;
    flex-basis: 120px;
  }
}
