/* ---------- базовая палитра ---------- */
:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #555;
  --ink-faint: #888;
  --line: #e4e0d8;
  --line-strong: #c9c4b8;
  --accent: #661d1a;
  --accent-soft: #fdf3f2;

  --st-take: #2e7d32;
  --st-take-bg: #e8f5e9;
  --st-cand: #1565c0;
  --st-cand-bg: #e3f2fd;
  --st-disc: #ef6c00;
  --st-disc-bg: #fff3e0;
  --st-skip: #c62828;
  --st-skip-bg: #ffebee;
  --st-none: #b0a89a;
  --st-none-bg: #efece4;

  --font-body: Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

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

/* ---------- шапка ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.2px;
}
.topbar nav { display: flex; gap: 20px; }
.topbar nav a {
  color: var(--ink-soft);
  font-size: 14px;
}
.topbar nav a.active { color: var(--ink); font-weight: 600; }
.topbar .user { color: var(--ink-soft); font-size: 14px; }

/* ---------- статус-точки ---------- */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
}
.dot.take { background: var(--st-take); }
.dot.cand { background: var(--st-cand); }
.dot.disc { background: var(--st-disc); }
.dot.skip { background: var(--st-skip); }
.dot.none { background: var(--st-none); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-family: var(--font-ui);
}
.badge.take { background: var(--st-take-bg); color: var(--st-take); }
.badge.cand { background: var(--st-cand-bg); color: var(--st-cand); }
.badge.disc { background: var(--st-disc-bg); color: var(--st-disc); }
.badge.skip { background: var(--st-skip-bg); color: var(--st-skip); }
.badge.none { background: var(--st-none-bg); color: var(--ink-soft); }

/* ---------- прогресс-дашборд ---------- */
.dashboard {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
}
.dashboard .row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.dashboard .total {
  font-family: var(--font-body);
  font-size: 16px;
}
.dashboard .total strong { color: var(--st-take); font-size: 18px; }
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  min-width: 200px;
  max-width: 400px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--st-take);
  transition: width 0.3s;
}
.stats { display: flex; gap: 18px; color: var(--ink-soft); font-size: 13px; }
.stats span strong { color: var(--ink); }

/* ---------- лейаут списка ---------- */
.page {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 120px);
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 20px 40px;
}
.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-faint);
  margin: 22px 0 10px;
  font-weight: 600;
}
.sidebar .search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--font-ui);
  background: var(--bg);
}
.filter-group { margin-bottom: 4px; }
.filter-group label {
  display: flex;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
}
.filter-group label input { margin-right: 8px; }
.filter-group label .count {
  color: var(--ink-faint);
  font-size: 12px;
  margin-left: auto;
}
.more-tags-toggle {
  display: block;
  margin-top: 4px;
  padding: 3px 0;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.more-tags-toggle:hover { color: var(--accent); }

/* Фасет статей: компактные строки с разделителями + CSS-тултип. */
.charges-group .charge-row {
  padding: 4px 0;
  border-bottom: 1px solid var(--line, #eee);
  position: relative;
}
.charges-group .charge-row:last-of-type { border-bottom: none; }
#more-charges .charge-row:last-child { border-bottom: none; }
.charge-code { font-size: 13px; color: var(--ink); flex: 1; }

/* CSS-тултип через data-tooltip */
.charges-group .charge-row[data-tooltip]::after {
  content: attr(data-tooltip);
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 2px);
  z-index: 200;
  background: #222;
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  padding: 5px 8px;
  border-radius: 4px;
  max-width: 220px;
  white-space: normal;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.charges-group .charge-row[data-tooltip]:hover::after { display: block; }

/* ---------- список ---------- */
.main { padding: 20px 32px 60px; }
.status-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.status-tabs a {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.status-tabs a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.status-tabs .count {
  font-size: 12px;
  color: var(--ink-faint);
  margin-left: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--st-none);
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 16px;
  align-items: start;
  transition: box-shadow 0.15s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card.take { border-left-color: var(--st-take); }
.card.cand { border-left-color: var(--st-cand); }
.card.disc { border-left-color: var(--st-disc); }
.card.skip { border-left-color: var(--st-skip); }

.card .thumb {
  width: 80px; height: 80px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  background-size: cover;
  background-position: center top;
}
.card .body h2 {
  margin: 0 0 4px;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
}
.card .body h2 a { color: var(--ink); }
.card .body .subtitle {
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 6px;
}
.card .body .note {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--line-strong);
}
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}
.card .meta-right {
  text-align: right;
  color: var(--ink-faint);
  font-size: 12px;
  white-space: nowrap;
}
.card .meta-right .comments {
  display: inline-block; margin-top: 4px;
  color: var(--ink-soft);
}

/* ---------- страница чтения ---------- */
.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 720px) 280px;
  gap: 40px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 28px 80px;
}
.reader { min-width: 0; }
.backlink { font-size: 13px; color: var(--ink-soft); display: inline-block; margin-bottom: 12px; }

.reader h1 {
  font-family: var(--font-body);
  font-size: 30px;
  margin: 0 0 18px;
  line-height: 1.25;
}
.decision {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 22px;
}
.decision .row1 {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.decision button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 18px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
}
.decision button.active.take { background: var(--st-take-bg); color: var(--st-take); border-color: var(--st-take); font-weight: 600; }
.decision button.active.cand { background: var(--st-cand-bg); color: var(--st-cand); border-color: var(--st-cand); font-weight: 600; }
.decision button.active.disc { background: var(--st-disc-bg); color: var(--st-disc); border-color: var(--st-disc); font-weight: 600; }
.decision button.active.skip { background: var(--st-skip-bg); color: var(--st-skip); border-color: var(--st-skip); font-weight: 600; }
.decision .resolution {
  width: 100%;
  border: none;
  border-top: 1px solid var(--line);
  padding: 8px 0 0;
  font-size: 13px;
  font-family: var(--font-ui);
  background: transparent;
  color: var(--ink);
}
.decision .resolution:focus { outline: none; }
.decision .signature {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 6px;
  text-align: right;
}

.hero {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.hero .photo {
  width: 140px; height: 180px;
  background-size: cover;
  background-position: center top;
  border-radius: 4px;
  background-color: var(--bg);
}
.hero .subtitle { font-family: var(--font-body); font-size: 16px; margin: 0 0 8px; color: var(--ink); }
.hero .bio { color: var(--ink-soft); font-size: 14px; }
.hero .tags { margin-top: 10px; }

.last-word {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
}
.last-word p { margin: 0 0 1.2em; }
.last-word p:first-child strong, .last-word p:first-child em {
  font-style: normal;
  font-size: 19px;
}

/* ---------- правая колонка метаданных ---------- */
.aside {
  font-size: 13px;
  color: var(--ink-soft);
}
.aside section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.aside section:last-child { border-bottom: none; }
.aside h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-faint);
  margin: 0 0 8px;
  font-weight: 600;
}
.aside .field { margin-bottom: 10px; }
.aside .field .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-faint);
  letter-spacing: 0.6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.aside .field .label .edit {
  font-size: 12px;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.aside .field .value { color: var(--ink); margin-top: 2px; }
.aside .field .value.empty { color: var(--ink-faint); font-style: italic; }
.aside .field .chip {
  display: inline-block;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
  color: var(--ink);
}
.aside .charge-meaning {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 2px 0 6px 2px;
  line-height: 1.35;
}

.log { font-size: 12px; color: var(--ink-soft); }
.log .item { margin-bottom: 6px; }
.log .item time { color: var(--ink-faint); }

/* ---------- пометки ---------- */
.notes { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.notes h3 { font-family: var(--font-body); font-size: 20px; margin: 0 0 16px; }
.note-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.note-item .head {
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.note-item .head .author { color: var(--ink); font-weight: 600; }
.note-item .body { font-size: 14px; color: var(--ink); line-height: 1.5; }

.note-form {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
.note-form textarea {
  width: 100%;
  border: none;
  resize: vertical;
  min-height: 60px;
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  background: transparent;
}
.note-form .actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.note-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
}

/* ---------- логин ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 36px 40px;
  width: 360px;
}
.login-box h1 {
  font-family: var(--font-body);
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 22px;
  text-align: center;
}
.login-box .sub {
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-box label {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.login-box input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 14px;
  margin-bottom: 14px;
}
.login-box button {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-ui);
  margin-top: 4px;
}

/* ---------- лента активности ---------- */
.activity { max-width: 720px; margin: 0 auto; padding: 28px; }
.activity h1 { font-family: var(--font-body); font-size: 24px; margin: 0 0 24px; }
.activity .day-group { margin-bottom: 24px; }
.activity .day-group h3 {
  font-size: 12px; text-transform: uppercase;
  color: var(--ink-faint); letter-spacing: 0.8px;
  margin: 0 0 10px; font-weight: 600;
}
.activity .event {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 14px;
}
.activity .event .who { font-weight: 600; color: var(--ink); }
.activity .event .what { color: var(--ink-soft); }
.activity .event time { color: var(--ink-faint); font-size: 12px; float: right; }

/* ---------- модалка ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: 8px;
  padding: 24px 28px;
  width: 420px;
  max-width: 92vw;
}
.modal h3 { margin: 0 0 16px; font-family: var(--font-body); font-size: 18px; }
.modal .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.modal .chip-editable {
  background: var(--bg);
  padding: 4px 10px 4px 12px;
  border-radius: 14px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.modal .chip-editable .remove {
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.modal input[type=text] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 14px;
}
.modal .actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal .actions button {
  padding: 7px 14px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.modal .actions button.primary {
  background: var(--accent); color: white; border-color: var(--accent);
}
