* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f6f8; --panel: #fff; --line: #e3e6ea; --text: #1f2933;
  --muted: #6b7280; --accent: #2563eb; --accent-soft: #eef3ff; --unread: #0b1f44;
}
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }

/* Login / Connect */
.login-page, .connect-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-box, .connect-box { background: var(--panel); padding: 40px; border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08); width: 340px; text-align: center; }
.login-box h1, .connect-box h1 { margin-bottom: 18px; font-size: 24px; }
.login-box input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; font-size: 15px; }
.login-box button, .btn-primary { background: var(--accent); color: #fff; border: 0; padding: 12px 18px;
  border-radius: 8px; font-size: 15px; cursor: pointer; text-decoration: none; display: inline-block; }
.error { color: #c0392b; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 13px; margin-top: 14px; }
.muted a { color: var(--muted); }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--panel);
  border-bottom: 1px solid var(--line); padding: 10px 16px; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 17px; }
.actions { display: flex; align-items: center; gap: 10px; }
.actions #search { width: 320px; max-width: 40vw; padding: 8px 12px; border: 1px solid var(--line); border-radius: 20px; font-size: 14px; }
.actions button { background: var(--accent-soft); color: var(--accent); border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.actions .account { color: var(--muted); font-size: 13px; }
.actions a { text-decoration: none; font-size: 18px; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 360px 1fr; height: calc(100vh - 55px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.folder { display: block; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; font-size: 14px; }
.folder:hover { background: var(--bg); }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.section-title { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.events { font-size: 13px; }
.event { padding: 8px; border-radius: 8px; margin-bottom: 6px; background: var(--bg); }
.event .e-time { color: var(--accent); font-weight: 600; display: block; }
.event .e-loc { color: var(--muted); }

/* Mailliste */
.maillist { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.mail-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mail-item:hover { background: var(--bg); }
.mail-item.active { background: var(--accent-soft); }
.mail-item.unread .mi-subject, .mail-item.unread .mi-from { font-weight: 700; color: var(--unread); }
.mi-top { display: flex; justify-content: space-between; font-size: 13px; }
.mi-from { color: var(--text); }
.mi-date { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: 8px; }
.mi-subject { font-size: 14px; margin: 2px 0; }
.mi-snippet { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-star { color: #d4a017; }
.loading, .placeholder { padding: 30px; color: var(--muted); text-align: center; }
.loadmore { padding: 12px; text-align: center; color: var(--accent); cursor: pointer; }

/* Reader */
.reader { overflow-y: auto; padding: 0; background: var(--panel); }
.reader-head { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.reader-head h2 { font-size: 19px; margin-bottom: 8px; }
.reader-meta { color: var(--muted); font-size: 13px; }
.reader-toolbar { display: flex; gap: 8px; padding: 12px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.reader-toolbar button { background: var(--bg); border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.reader-toolbar button:hover { background: var(--accent-soft); }
.reader-body { padding: 22px; line-height: 1.55; }
.reader-body iframe { width: 100%; border: 0; min-height: 60vh; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); padding: 24px; border-radius: 12px; width: 540px; max-width: 92vw; }
.modal-box h3 { margin-bottom: 14px; }
.modal-box label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.modal-box input, .modal-box textarea { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; margin-top: 3px; font-family: inherit; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions button { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; background: var(--bg); }
#summary-text { white-space: pre-wrap; font-family: inherit; line-height: 1.5; max-height: 60vh; overflow-y: auto; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
  .sidebar { display: flex; flex-wrap: wrap; gap: 6px; }
  .sidebar .events, .sidebar .section-title { width: 100%; }
}

.reader iframe { width:100%; min-height:75vh; border:0; background:#fff; }
