:root {
  --bg: #f4f5f7; --panel: #fff; --line: #e3e6ea; --ink: #1a2230; --muted: #6b7686;
  --accent: #1f5fae; --accent-soft: #e8f0fb; --mark: #fff2a8;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px;
  display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.search { display: flex; gap: 6px; flex: 1; max-width: 560px; }
.search input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.search button {
  padding: 8px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #fff;
  cursor: pointer; font-size: 14px;
}
.search #searchClear { background: var(--line); color: var(--ink); padding: 8px 12px; }
.whoami { color: var(--muted); font-size: 12px; white-space: nowrap; }

.layout { flex: 1; display: grid; grid-template-columns: 260px 380px 1fr; min-height: 0; }
.sidebar, .list, .reader { min-height: 0; overflow: auto; background: var(--panel); }
.sidebar { border-right: 1px solid var(--line); padding: 8px 0; }
.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; }

.acc-group > .acc-name {
  padding: 8px 14px 4px; font-weight: 700; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
}
.folder {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 6px 14px 6px 24px; cursor: pointer; border-left: 3px solid transparent;
}
.folder:hover { background: var(--accent-soft); }
.folder.active { background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.folder .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .fcount { color: var(--muted); font-size: 12px; flex-shrink: 0; }

.list-head { padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.list-body { flex: 1; overflow: auto; }
.row {
  padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:hover { background: #fafbfc; }
.row.active { background: var(--accent-soft); }
.row .r-top { display: flex; justify-content: space-between; gap: 8px; }
.row .r-from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-date { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.row .r-subj { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-snip { margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.row .r-snip mark { background: var(--mark); }
.row .clip { color: var(--muted); }
.row .r-loc { color: var(--muted); font-size: 11px; margin-top: 2px; }

.reader { display: flex; flex-direction: column; }
.reader-empty, .loading { padding: 24px; color: var(--muted); }
.reader-full { display: flex; flex-direction: column; height: 100%; }
.reader-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.reader-head h1 { font-size: 18px; margin: 0 0 8px; }
.reader-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.reader-meta b { color: var(--ink); font-weight: 600; }
.reader-att { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.reader-att a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--accent-soft); color: var(--accent);
  border-radius: 8px; text-decoration: none; font-size: 13px;
}
.reader-att a:hover { text-decoration: underline; }
#rBody { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .sidebar, .list { max-height: 38vh; }
}
