/* MConic — hand-rolled layout CSS. No build step, no Tailwind.
   Consumes only --mc-* tokens from tokens/theme.css so a future
   [data-theme="light"] override is a drop-in addition, not a rewrite. */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--mc-bg);
  color: var(--mc-ink);
  font-family: var(--mc-font);
  font-size: 14px;
}

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

/* ------------------------------------------------------------ */
/* Flash messages                                                */
/* ------------------------------------------------------------ */
.flash-stack {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--mc-radius);
  color: var(--mc-ink-inverse);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 0.875rem;
}

.flash-success { background: var(--mc-success); }
.flash-error   { background: var(--mc-danger); }
.flash-info    { background: var(--mc-accent); }

/* ------------------------------------------------------------ */
/* Loading overlay — shown immediately on link click/form submit */
/* so navigation never feels like a dead click.                  */
/* ------------------------------------------------------------ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 17, 22, 0.55);
}

.loading-overlay[hidden] { display: none; }

.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--mc-border);
  border-top-color: var(--mc-accent);
  border-radius: 50%;
  animation: mc-spin 0.7s linear infinite;
}

@keyframes mc-spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------ */
/* Guest layout (login)                                          */
/* ------------------------------------------------------------ */
.guest-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
}

.guest-footer {
  font-size: 0.75rem;
  color: var(--mc-ink-muted);
}

.guest-card {
  width: 100%;
  max-width: 380px;
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 0.75rem;
  padding: 2rem;
}

.guest-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
}

.brand-logo {
  height: 2.25rem;
  width: auto;
}

/* Only one theme exists today (dark), so show the white logo and hide
   the blue one — swap is data-theme driven so a future light mode is
   a drop-in, not a rewrite. */
.brand-logo--light { display: none; }
.brand-logo--dark  { display: block; }

[data-theme="light"] .brand-logo--light { display: block; }
[data-theme="light"] .brand-logo--dark  { display: none; }

.guest-brand .brand-tagline {
  font-size: 0.8rem;
  color: var(--mc-ink-muted);
  margin-top: 0.25rem;
}

/* ------------------------------------------------------------ */
/* Forms                                                          */
/* ------------------------------------------------------------ */
.field { margin-bottom: 1.1rem; }

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--mc-ink-muted);
  margin-bottom: 0.35rem;
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  color: var(--mc-ink);
  font-size: 0.9rem;
}

.field input:focus {
  outline: none;
  border-color: var(--mc-accent);
  box-shadow: 0 0 0 2px rgba(28, 125, 255, 0.25);
}

.field input.input-error { border-color: var(--mc-danger); }

.field-error {
  color: var(--mc-danger);
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border-radius: var(--mc-radius);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--mc-accent); color: var(--mc-ink-inverse); }
.btn-primary:hover { background: var(--mc-accent-strong); text-decoration: none; }
.btn-block { width: 100%; }

.btn-secondary {
  background: var(--mc-surface-raised);
  color: var(--mc-ink);
  border: 1px solid var(--mc-border);
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.btn-secondary:hover { border-color: var(--mc-accent); color: var(--mc-accent); text-decoration: none; }

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

/* ------------------------------------------------------------ */
/* App shell — three panes                                       */
/* ------------------------------------------------------------ */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
}

.app-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--mc-accent-strong);
  color: var(--mc-ink-inverse);
  border-bottom: 1px solid var(--mc-border);
}

.topbar-logo { height: 1.75rem; width: auto; }

.app-topbar .user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.app-topbar .user-menu a { color: var(--mc-ink-inverse); opacity: 0.85; }
.app-topbar .user-menu a:hover { opacity: 1; }

.app-sidebar {
  background: var(--mc-surface);
  border-right: 1px solid var(--mc-border);
  padding: 1rem 0.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.app-footer {
  margin-top: auto;
  padding: 0.75rem 0.5rem 0.25rem;
  font-size: 0.72rem;
  color: var(--mc-ink-muted);
  text-align: center;
}

.compose-btn {
  width: 100%;
  margin-bottom: 1rem;
}

.folder-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  color: var(--mc-ink-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.folder-group-toggle:hover { color: var(--mc-ink); }

.folder-group-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-group-chevron {
  flex-shrink: 0;
  margin-left: 0.5rem;
  transition: transform 0.15s ease;
}

.folder-group.collapsed .folder-group-chevron { transform: rotate(-90deg); }
.folder-group.collapsed .folder-nav { display: none; }

.folder-nav { list-style: none; margin: 0; padding: 0; }

.folder-nav li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--mc-radius);
  color: var(--mc-ink);
  font-size: 0.88rem;
}

.folder-nav li a:hover { background: var(--mc-surface-raised); text-decoration: none; }
.folder-nav li a.active { background: var(--mc-surface-raised); color: var(--mc-accent); font-weight: 600; }

.folder-nav .count {
  font-size: 0.75rem;
  color: var(--mc-ink-muted);
}

.app-main {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  overflow: hidden;
}

.app-main--single {
  display: block;
  overflow-y: auto;
}

/* ------------------------------------------------------------ */
/* Compose / Settings — single-pane forms                        */
/* ------------------------------------------------------------ */
.compose-pane,
.settings-pane {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.settings-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mc-ink-inverse);
  margin: 0 0 0.5rem;
}

.settings-hint {
  color: var(--mc-ink-muted);
  font-size: 0.85rem;
  margin: 0 0 1.5rem;
}

.compose-body,
.signature-textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  color: var(--mc-ink);
  font-size: 0.9rem;
  font-family: var(--mc-font);
  resize: vertical;
}

.compose-body:focus,
.signature-textarea:focus {
  outline: none;
  border-color: var(--mc-accent);
  box-shadow: 0 0 0 2px rgba(28, 125, 255, 0.25);
}

/* Message list pane */
.message-list {
  border-right: 1px solid var(--mc-border);
  overflow-y: auto;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--mc-border);
  color: var(--mc-ink);
}

.message-row:hover { background: var(--mc-surface); text-decoration: none; }
.message-row.active { background: var(--mc-surface-raised); border-left: 3px solid var(--mc-accent); }
.message-row.unread { background: rgba(28, 125, 255, 0.06); }
.message-row.unread .message-subject { font-weight: 700; color: var(--mc-ink-inverse); }

.message-row-body { flex: 1; min-width: 0; }

.unread-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 0.4rem;
  border-radius: 50%;
  background: transparent;
}

.message-row.unread .unread-dot { background: var(--mc-unread-dot); }

.message-row .message-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.message-from { font-size: 0.85rem; color: var(--mc-ink); }
.message-date { font-size: 0.75rem; color: var(--mc-ink-muted); white-space: nowrap; }
.message-subject { font-size: 0.85rem; margin-bottom: 0.15rem; }
.attachment-indicator { font-size: 0.75rem; opacity: 0.8; }
.message-snippet {
  font-size: 0.8rem;
  color: var(--mc-ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ */
/* New-mail banner                                                */
/* ------------------------------------------------------------ */
.new-mail-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--mc-accent);
  color: var(--mc-ink-inverse);
  font-size: 0.85rem;
}

.new-mail-refresh {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: var(--mc-ink-inverse);
  padding: 0.25rem 0.6rem;
  border-radius: var(--mc-radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.new-mail-refresh:hover { background: rgba(255, 255, 255, 0.3); }

.new-mail-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--mc-ink-inverse);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}

.new-mail-dismiss:hover { opacity: 1; }

.empty-state {
  padding: 2rem 1rem;
  color: var(--mc-ink-muted);
  text-align: center;
  font-size: 0.9rem;
}

/* Reading pane */
.reading-pane { overflow-y: auto; padding: 1.5rem; }

.reading-pane .msg-subject {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--mc-ink-inverse);
}

.reading-pane .msg-meta {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--mc-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--mc-ink-muted);
}

.reading-pane .msg-meta strong { color: var(--mc-ink); }

.reading-pane .msg-body {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  padding: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.reading-pane .msg-attachments {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  background: var(--mc-surface-raised);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  color: var(--mc-ink);
  font-size: 0.82rem;
}

.attachment-chip:hover { border-color: var(--mc-accent); color: var(--mc-accent); text-decoration: none; }

.attachment-size { color: var(--mc-ink-muted); }

/* ------------------------------------------------------------ */
/* Attach + drag-and-drop (composing)                             */
/* ------------------------------------------------------------ */
.attach-dropzone {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 1px dashed var(--mc-border-strong);
  border-radius: var(--mc-radius);
  color: var(--mc-ink-muted);
  font-size: 0.85rem;
}

.attach-dropzone.is-dragover {
  border-color: var(--mc-accent);
  color: var(--mc-accent);
  background: var(--mc-surface-raised);
}

.attach-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem 0.35rem 0.7rem;
  background: var(--mc-surface-raised);
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  font-size: 0.8rem;
  color: var(--mc-ink);
}

.attach-size { color: var(--mc-ink-muted); }

.attach-remove {
  background: none;
  border: none;
  color: var(--mc-ink-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}

.attach-remove:hover { color: var(--mc-danger); }

/* ------------------------------------------------------------ */
/* Inline Reply/Forward panel + floating Compose panel           */
/* ------------------------------------------------------------ */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--mc-accent-strong);
  color: var(--mc-ink-inverse);
  font-weight: 600;
  font-size: 0.9rem;
}

.panel-close {
  background: none;
  border: none;
  color: var(--mc-ink-inverse);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  padding: 0 0.25rem;
}

.panel-close:hover { opacity: 1; }

.inline-reply-panel {
  margin-top: 1.5rem;
  border: 1px solid var(--mc-border);
  border-radius: var(--mc-radius);
  overflow: hidden;
  background: var(--mc-surface);
}

.inline-reply-panel .compose-form,
.floating-compose .compose-form {
  padding: 1rem;
}

.floating-compose {
  position: fixed;
  bottom: 0;
  right: 2rem;
  width: 460px;
  max-width: calc(100vw - 2rem);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-bottom: none;
  border-radius: var(--mc-radius) var(--mc-radius) 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  z-index: 150;
}

.floating-compose[hidden] { display: none; }

.floating-compose .compose-form {
  overflow-y: auto;
}
