/* ─── TOKENS ─────────────────────────────────────────────── */
:root {
  --bg:          #f1f4f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #dde3ed;
  --border-focus: #93afd4;
  --accent:      #1d4ed8;
  --accent-hover: #1e40af;
  --accent-light: #eff6ff;
  --text:        #0f172a;
  --text-dim:    #475569;
  --text-muted:  #94a3b8;
  --green:       #16a34a;
  --green-light: #f0fdf4;
  --red:         #dc2626;
  --divider:     #e8edf4;
  --shadow-sm:   0 1px 2px rgba(15,23,42,0.06);
  --shadow:      0 2px 8px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.05);
  --shadow-md:   0 4px 16px rgba(15,23,42,0.1), 0 2px 4px rgba(15,23,42,0.06);
  --radius:      6px;
  --radius-sm:   4px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --font-mono:   'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── LAYOUT ─────────────────────────────────────────────── */
.app-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}
.app-container.fluid {
  max-width: 100% !important;
  width: 100%;
  margin: 0;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* ─── TOP NAV ────────────────────────────────────────────── */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
  margin: 0 0 2rem 0;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.site-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-title .badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  margin-left: 0.25rem;
}

.header-time {
  margin-left: auto;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ─── SECTION LABELS ─────────────────────────────────────── */
.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

/* ─── PANELS / CARDS ─────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.email-list-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ─── EMAIL LIST ─────────────────────────────────────────── */
.email-list { display: flex; flex-direction: column; }

.email-item {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--divider);
  transition: background 0.1s;
}

.email-item:last-child { border-bottom: none; }
.email-item:hover { background: var(--accent-light); }

.email-item .recipient {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
}

.email-item .subject {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.email-item .time {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

.inbox-empty {
  padding: 3rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── CALENDAR ───────────────────────────────────────────── */
.calendar-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--divider);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.calendar-controls span:first-child,
.calendar-controls span:last-child {
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.25rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0.75rem;
}

.cal-header-cell {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.2rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.calendar-day.today {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  border: 1px solid var(--border-focus);
}

.calendar-day.has-emails {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.calendar-day.today.has-emails {
  background: var(--accent);
  border-color: var(--accent-hover);
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.01em;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-focus);
  color: var(--text);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: white;
  box-shadow: 0 1px 3px rgba(29,78,216,0.3), 0 1px 2px rgba(29,78,216,0.2);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
  box-shadow: 0 2px 6px rgba(29,78,216,0.35);
}

.btn--full { width: 100%; display: flex; }

.btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

.form-input::placeholder { color: var(--text-muted); }

textarea.form-input {
  resize: vertical;
  min-height: 130px;
  font-family: var(--font);
  line-height: 1.5;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 1.2rem 0;
}

/* ─── RICH TEXT & CENSORSHIP ─────────────────────────────── */
.censor-mark {
  background-color: var(--text);
  color: var(--text);
  border-radius: 2px;
  padding: 0 4px;
  cursor: default;
  user-select: none;
}
.censor-mark::selection {
  background: var(--text);
  color: var(--text);
}

/* ─── DETAIL VIEW ────────────────────────────────────────── */
.detail-meta {
  padding: 1.25rem;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}

.detail-meta p {
  font-size: 0.825rem;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}

.detail-meta strong { color: var(--text); font-weight: 600; }

.detail-subject {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.75rem;
  line-height: 1.35;
}

.detail-body {
  line-height: 1.75;
  font-size: 0.95rem;
  color: var(--text-dim);
  padding: 1.5rem 1.25rem;
  font-family: var(--font);
}

.detail-body p { margin-bottom: 1rem; }
.detail-body p:last-child { margin-bottom: 0; }
.detail-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 1rem 0; box-shadow: var(--shadow-sm); }
.detail-body blockquote { border-left: 3px solid var(--border); padding-left: 1rem; color: var(--text-muted); margin: 1rem 0; font-style: italic; }
.detail-body ul, .detail-body ol { margin: 1rem 0 1rem 1.5rem; }

/* ─── PAGINATION ─────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── BACK LINK ──────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 1rem;
  transition: color 0.1s;
}
.back-link:hover { color: var(--accent); }

/* ─── STATUS ─────────────────────────────────────────────── */
.status-ok  { color: var(--green); }
.status-err { color: var(--red); }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 680px) {
  .main-grid { grid-template-columns: 1fr !important; }
  .smtp-grid { grid-template-columns: 1fr !important; }
  .email-item { grid-template-columns: 1fr auto; }
  .email-item .subject { display: none; }
  .topnav .site-subtitle { display: none; }
}
