/* Анонсы из коммитов — стили панели.
   Шкала отступов: 4 / 8 / 12 / 16 / 24 / 32. Шрифт: 12 / 13 / 14 / 16 / 20. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  --radius: 6px;
  --topbar-h: 48px;
  --t: 150ms ease;

  /* Светлая тема: нейтральные с тёплым оттенком, один акцент */
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #efefeb;
  --line: #e2e2dc;
  --line-strong: #cfcfc7;
  --text: #1c1c1a;
  --text-2: #55554f;
  --text-3: #6b6b64;
  --accent: #0f6b62;
  --accent-hover: #0c5a52;
  --accent-soft: #e3f0ee;
  --on-accent: #ffffff;
  --ok: #2f7d32;
  --warn: #9a6100;
  --danger: #b42318;
  --danger-soft: #fbeceb;
  --warn-soft: #fbf3e4;
  --focus: #0f6b62;

  /* Предпросмотр: цвета Telegram */
  --tg-bg: #dfe6dc;
  --tg-bubble: #ffffff;
  --tg-name: #2f80c4;
  --tg-text: #111111;
  --tg-link: #2481cc;
  --tg-meta: #8a9aa6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #2d2d2a;
    --line-strong: #3d3d39;
    --text: #ececE7;
    --text-2: #b4b4ad;
    --text-3: #96968f;
    --accent: #4fb6a8;
    --accent-hover: #67c4b7;
    --accent-soft: #1d3330;
    --on-accent: #0c1f1c;
    --ok: #6cc070;
    --warn: #e0a23c;
    --danger: #f08a80;
    --danger-soft: #3a1f1d;
    --warn-soft: #362b18;
    --focus: #67c4b7;

    --tg-bg: #0e1621;
    --tg-bubble: #182533;
    --tg-name: #71baf2;
    --tg-text: #f5f5f5;
    --tg-link: #6ab3f3;
    --tg-meta: #6d7f8f;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md) / 1.5 var(--font);
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
}

kbd {
  font: var(--fs-xs) var(--mono);
  padding: 0 var(--s1);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sprite {
  display: none;
}

.i {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mono,
.count,
.pi-time,
.commit-time,
.tg-meta {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 32px;
  padding: 0 var(--s3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: 500 var(--fs-md) / 1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t), border-color var(--t), color var(--t);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-3);
}

.btn-ghost {
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.danger-text {
  color: var(--danger);
}

.btn-sm {
  min-height: 28px;
  padding: 0 var(--s2);
  font-size: var(--fs-sm);
}

.btn-icon {
  width: 32px;
  padding: 0;
}

.btn-block {
  width: 100%;
}

.btn.is-busy {
  cursor: progress;
}

.btn .kbd-hint {
  font: var(--fs-xs) var(--mono);
  opacity: 0.75;
}

/* ===== Шапка ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s4);
  height: var(--topbar-h);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.views {
  display: flex;
  align-self: stretch;
  gap: var(--s1);
}

.view-link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--s2);
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--t), border-color var(--t);
}

.view-link:hover {
  color: var(--text);
}

.view-link[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.count {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.count:empty {
  display: none;
}

.view-link .count {
  min-width: 18px;
  padding: 0 var(--s1);
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  text-align: center;
  line-height: 18px;
}

.conn {
  display: flex;
  gap: var(--s1);
  margin-left: auto;
}

.conn-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: none;
  color: var(--text-2);
  font: var(--fs-sm) var(--font);
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
}

.conn-btn:hover,
.conn-btn[aria-expanded="true"] {
  border-color: var(--line-strong);
  color: var(--text);
}

.conn-icon {
  display: none;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--line-strong);
}

.dot.is-accent {
  background: var(--accent);
}

.dot.is-ok {
  background: var(--ok);
}

.dot.is-warn {
  background: var(--warn);
}

.dot.is-error {
  background: var(--danger);
}

.topbar-actions {
  display: flex;
  gap: var(--s1);
}

/* Плашка под шапкой: что-то не настроено */
.banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--warn-soft);
  color: var(--text);
  font-size: var(--fs-sm);
}

.settings-body > .banner {
  margin-bottom: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.banner .i {
  color: var(--warn);
}

.tg-legacy {
  margin-top: var(--s3);
}

.tg-legacy p + p {
  color: var(--text-2);
}

/* ===== Поповер подключения ===== */
.popover {
  position: fixed;
  z-index: 30;
  width: min(320px, calc(100vw - 2 * var(--s4)));
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}

.pop-title {
  margin: 0 0 var(--s1);
  font-weight: 600;
}

.pop-text,
.pop-result {
  margin: 0 0 var(--s3);
  color: var(--text-2);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.pop-result.is-error {
  color: var(--danger);
}

.pop-result.is-ok {
  color: var(--ok);
}

.pop-actions {
  display: flex;
  gap: var(--s2);
}

/* ===== Посты: список и редактор ===== */
.view-posts {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
}

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.list-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--s3) var(--s4) 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s2);
  min-height: 20px;
  margin: 0 0 var(--s2);
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.status-line .is-error {
  color: var(--danger);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s3);
}

.filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font: 500 var(--fs-sm) var(--font);
  cursor: pointer;
  transition: color var(--t), border-color var(--t);
}

.filter:hover {
  color: var(--text);
}

.filter[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

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

.post-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 2px var(--s3);
  align-items: baseline;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background-color var(--t);
}

.post-item:hover {
  background: var(--surface-2);
}

.post-item[aria-selected="true"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.post-item .dot {
  align-self: center;
}

.pi-title {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-item.is-muted .pi-title {
  color: var(--text-2);
}

.pi-time {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.pi-meta {
  grid-column: 2 / 4;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.list-empty {
  padding: var(--s6) var(--s4);
  color: var(--text-2);
}

.list-empty .i {
  width: 24px;
  height: 24px;
  margin-bottom: var(--s2);
  color: var(--text-3);
}

.empty-title {
  margin: 0 0 var(--s1);
  color: var(--text);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.empty-text {
  margin: 0 0 var(--s4);
}

.setup-list {
  margin: 0 0 var(--s4);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.setup-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--line);
}

.setup-list .is-done {
  color: var(--text-3);
}

.setup-list .is-done span::before {
  content: "✓ ";
  color: var(--ok);
}

.list-more {
  padding: var(--s3) var(--s4);
}

.list-hint {
  margin: auto 0 0;
  padding: var(--s3) var(--s4);
  color: var(--text-3);
  font-size: var(--fs-xs);
}

/* Правая часть */
.detail-pane {
  min-height: 0;
  overflow-y: auto;
  outline: none;
}

.detail {
  max-width: 760px;
  padding: var(--s5) var(--s6) var(--s6);
}

.detail-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-3);
}

.detail-back {
  display: none;
  margin: 0 0 var(--s3) calc(-1 * var(--s2));
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2) var(--s3);
  margin-bottom: var(--s4);
}

.detail-title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.detail-meta {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.notice {
  display: flex;
  gap: var(--s2);
  margin: 0 0 var(--s4);
  padding: var(--s3);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-sm);
}

.notice .i {
  margin-top: 2px;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: var(--s1);
  color: var(--text-2);
}

.notice.is-error {
  background: var(--danger-soft);
}

.notice.is-error .i {
  color: var(--danger);
}

.notice.is-warn {
  background: var(--warn-soft);
}

.notice.is-warn .i {
  color: var(--warn);
}

.block {
  margin-bottom: var(--s5);
}

.block-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin: 0 0 var(--s2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.commits {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
}

.commits li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--s3);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.commits li:first-child {
  border-top: 1px solid var(--line);
}

.commit-sha {
  font-family: var(--mono);
  color: var(--accent);
  text-decoration: none;
}

.commit-sha:hover {
  text-decoration: underline;
}

.commit-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commits li.is-low .commit-msg {
  color: var(--warn, var(--text));
}

.commit-low,
.commit-note,
.commits .note-commit {
  grid-column: 1 / -1;
}

.commit-low {
  color: var(--warn, var(--text-2));
  font-size: var(--fs-xs);
}

.commit-note {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-xs);
  white-space: pre-wrap;
}

.commits .note-commit {
  min-height: 30px;
  font-size: var(--fs-sm);
}

.style-sample + .style-sample {
  margin-top: var(--s2);
}

.note-label {
  margin-top: var(--s3);
}

.note-post {
  min-height: 56px;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s2);
}

.c-note {
  flex: 1 1 280px;
  max-width: 480px;
}

.commit-time {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.is-paused {
  color: var(--warn);
  font-weight: 600;
}

.cost-hint {
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

/* Варианты подачи */
.variant-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s2);
  margin-bottom: var(--s3);
}

.variant-tab {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.variant-tab:hover {
  border-color: var(--accent);
}

.variant-tab[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: default;
}

.variant-name {
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.variant-hook {
  font-weight: 600;
  line-height: 1.35;
}

.variant-status {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.variant-status.is-ok {
  color: var(--ok);
}

.variant-status.is-warn {
  color: var(--warn);
}

.variant-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.variants-focus {
  margin: 0 0 var(--s2);
}

.mark-style {
  text-decoration: underline dashed var(--text-3);
  text-underline-offset: 3px;
}

/* Проверка точности */
.accuracy-status {
  margin: 0 0 var(--s2);
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.accuracy-status.is-ok {
  color: var(--ok);
}

.accuracy-status.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.mark-issue {
  background: var(--warn-soft);
  color: inherit;
  text-decoration: underline wavy var(--warn);
  text-underline-offset: 3px;
}

.src-sent {
  text-decoration: underline dotted var(--text-3);
  text-underline-offset: 3px;
  cursor: help;
}

.issues,
.facts {
  margin: var(--s2) 0;
  padding-left: var(--s5);
  font-size: var(--fs-sm);
}

.issues li,
.facts li {
  margin-bottom: 6px;
}

.issue-src {
  color: var(--text-3);
}

.facts .evs {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.facts .ev + .ev::before {
  content: ", ";
}

.accuracy-more {
  margin-top: var(--s2);
}

.accuracy-more summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.accuracy-announced {
  margin-top: var(--s3);
}

.editor {
  display: block;
  width: 100%;
  min-height: 160px;
  padding: var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: var(--fs-md) / 1.6 var(--font);
  resize: vertical;
  transition: border-color var(--t);
}

.editor:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 1px var(--accent);
}

.editor.is-over {
  border-color: var(--danger);
}

.editor-foot {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: var(--s1);
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.editor-foot .is-over,
.editor-foot .is-error {
  color: var(--danger);
}

/* Предпросмотр сообщения в канале */
.tg {
  padding: var(--s4);
  border-radius: var(--radius);
  background: var(--tg-bg);
}

.tg-post {
  display: flex;
  gap: var(--s2);
  align-items: flex-end;
  max-width: 480px;
}

.tg-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: #5a9bd4;
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
}

.tg-bubble {
  position: relative;
  min-width: 120px;
  padding: 6px 10px 6px;
  border-radius: 12px 12px 12px 4px;
  background: var(--tg-bubble);
  color: var(--tg-text);
  font: 15px / 1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.08);
}

.tg-name {
  margin-bottom: 2px;
  color: var(--tg-name);
  font-size: 14px;
  font-weight: 600;
}

.tg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tg-text .tg-link {
  color: var(--tg-link);
}

.tg-text.is-empty {
  color: var(--tg-meta);
  font-style: italic;
}

.tg-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: var(--tg-meta);
  font-size: 12px;
}

.tg-meta .i {
  width: 14px;
  height: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

.actions .spacer {
  flex: 1;
}

/* Скелетоны */
.skeleton {
  display: block;
  border-radius: 4px;
  background: var(--surface-2);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-text {
  width: 60%;
  height: 12px;
  margin: 4px 0;
}

.skeleton-row {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
}

.skeleton-row .skeleton + .skeleton {
  width: 35%;
  margin-top: var(--s2);
}

.skeleton-block {
  height: 160px;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

/* ===== Коммиты ===== */
.view-commits {
  min-height: calc(100dvh - var(--topbar-h));
  display: flex;
  flex-direction: column;
}

.commits-pane {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--s5) var(--s6) var(--s4);
}

.c-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.c-field {
  flex: 1 1 140px;
  min-width: 0;
}

.c-field-wide {
  flex: 2 1 220px;
}

.c-field-btn {
  flex: 0 0 auto;
}

.c-field-btn .btn {
  min-height: 36px;
}

.c-branch-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.c-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.c-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 0 var(--s3);
  align-items: start;
  padding: var(--s3) var(--s2);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--t);
}

.c-item:hover {
  background: var(--surface-2);
}

.c-item[aria-selected="true"] {
  background: var(--accent-soft);
}

.c-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.c-check {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}

.c-item[aria-selected="true"] .c-check {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface);
}

.c-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s1) var(--s2);
}

.c-sha {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: var(--fs-sm) var(--mono);
  cursor: copy;
}

.c-sha:hover {
  text-decoration: underline;
}

.c-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.c-meta {
  margin-top: 2px;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.c-meta time {
  font-variant-numeric: tabular-nums;
}

.c-post-link {
  color: var(--accent);
  font-size: var(--fs-xs);
  text-decoration: none;
  white-space: nowrap;
}

.c-post-link:hover {
  text-decoration: underline;
}

.c-expand {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-2);
  cursor: pointer;
}

.c-expand:hover {
  background: var(--surface-2);
}

.c-expand[aria-expanded="true"] .i {
  transform: rotate(180deg);
}

.c-expand .i {
  transition: transform var(--t);
}

.c-detail {
  grid-column: 2 / 4;
  margin-top: var(--s2);
  cursor: auto;
  user-select: text;
}

.c-message {
  margin: 0 0 var(--s2);
  font: var(--fs-sm) / 1.5 var(--font);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.c-files {
  margin: 0;
  padding: 0;
  list-style: none;
  font: var(--fs-xs) var(--mono);
}

.c-files li {
  display: flex;
  gap: var(--s2);
  padding: 2px 0;
}

.c-files .c-file {
  min-width: 0;
  overflow-wrap: anywhere;
}

.c-add {
  color: var(--ok);
}

.c-del {
  color: var(--danger);
}

/* Панель действий: закреплена внизу экрана, пока что-то выбрано */
.c-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s2);
  padding: var(--s2) var(--s6) calc(var(--s2) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.c-count {
  margin-right: auto;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ===== Настройки ===== */
.view-settings {
  display: grid;
  grid-template-columns: 200px minmax(0, 640px);
  gap: var(--s6);
  padding: var(--s5) var(--s6) var(--s6);
}

.settings-nav {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s5));
  display: flex;
  flex-direction: column;
  align-self: start;
  gap: 2px;
}

.settings-link {
  padding: 6px var(--s3);
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  transition: background-color var(--t), color var(--t);
}

.settings-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.settings-link[aria-current="true"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.settings-section {
  padding-bottom: var(--s6);
}

.settings-section + .settings-section {
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
}

.section-title {
  margin: 0 0 var(--s1);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.section-note {
  margin: 0 0 var(--s5);
  color: var(--text-2);
}

.field {
  margin-bottom: var(--s4);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s5);
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.field-value {
  margin: 0 0 var(--s2);
}

.input {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 6px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: var(--fs-md) var(--font);
  transition: border-color var(--t);
}

.input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 1px var(--accent);
}

.input:disabled {
  background: var(--surface-2);
  color: var(--text-2);
}

.input-short {
  max-width: 240px;
}

.input-mid {
  max-width: 360px;
}

.input-num {
  max-width: 120px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.textarea {
  min-height: 96px;
  line-height: 1.5;
  resize: vertical;
}

.secret {
  display: flex;
  gap: var(--s2);
}

.hint {
  margin: 6px 0 0;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.hint-tight {
  margin: calc(-1 * var(--s2)) 0 var(--s4);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--s2);
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.gh-hint {
  margin: 0 0 var(--s3);
}

.gh-url-warning {
  margin: var(--s3) 0 0;
}

.manual {
  margin-bottom: var(--s4);
}

.manual summary {
  width: fit-content;
  margin-bottom: var(--s2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}

.manual[open] summary {
  margin-bottom: var(--s3);
}

/* Поле «Модель»: список с поиском и свободным вводом */
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: 6px;
}

.label-row .label {
  margin-bottom: 0;
}

.combo {
  position: relative;
}

.combo-skeleton {
  display: none;
  position: absolute;
  top: 12px;
  left: var(--s3);
  width: 45%;
  height: 12px;
}

.combo.is-loading .combo-skeleton {
  display: block;
}

.combo.is-loading .input {
  color: transparent;
}

.combo.is-loading .input::placeholder {
  color: transparent;
}

.combo-list {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 10;
  max-height: 288px;
  margin: var(--s1) 0 0;
  padding: var(--s1);
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}

.combo-option {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--s2);
  padding: 6px var(--s2);
  border-radius: 4px;
  cursor: pointer;
}

.combo-option:hover {
  background: var(--surface-2);
}

/* Активный вариант при управлении с клавиатуры — видимая рамка */
.combo-option.is-active {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  background: var(--accent-soft);
}

.combo-option .mono {
  font-size: var(--fs-sm);
}

.combo-name {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.combo-note,
.combo-empty {
  padding: 6px var(--s2);
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.tag {
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text-2);
  font-size: var(--fs-xs);
}

.tag.is-warn {
  border-color: var(--warn);
  color: var(--warn);
}

.models-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.presets {
  margin-top: var(--s2);
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s5);
}

.result {
  margin: var(--s3) 0 0;
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.result.is-ok {
  color: var(--ok);
}

.result.is-error {
  color: var(--danger);
}

/* Память канала */
.memory-list,
.memory-edit {
  margin: 0 0 var(--s4);
  padding: 0;
  list-style: none;
}

.memory-list li {
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.memory-name {
  font-weight: 600;
}

.memory-summary,
.memory-src {
  color: var(--text-2);
}

.memory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

@media (max-width: 640px) {
  .memory-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .memory-row-summary {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.form-error {
  margin: var(--s2) 0 0;
  color: var(--danger);
  font-size: var(--fs-sm);
}

/* ===== Вход ===== */
.login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: var(--bg);
}

.login-box {
  width: min(360px, 100%);
}

.login-title {
  margin: 0 0 var(--s1);
  font-size: var(--fs-xl);
  font-weight: 600;
}

.login-note {
  margin: 0 0 var(--s5);
  color: var(--text-2);
}

.login-box .btn-block {
  min-height: 40px;
  margin-top: var(--s4);
}

/* ===== Диалог и уведомления ===== */
.dialog {
  width: min(420px, calc(100vw - 2 * var(--s4)));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.dialog-body {
  padding: var(--s5);
}

.dialog-title {
  margin: 0 0 var(--s2);
  font-size: var(--fs-lg);
}

.dialog-text {
  margin: 0;
  color: var(--text-2);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  margin-top: var(--s5);
}

.toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: min(420px, calc(100vw - 2 * var(--s4)));
}

.toast {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.1);
}

.toast.is-error {
  border-left-color: var(--danger);
}

/* ===== Узкий экран (телефон) ===== */
.hide-narrow {
  display: inline;
}

.btn.hide-narrow {
  display: inline-flex;
}

@media (max-width: 899px) {
  /* Шапка в две строки: подключения и действия сверху, разделы во всю ширину снизу */
  :root {
    --topbar-h: 92px;
  }

  .topbar {
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0 var(--s2);
    padding: 0 var(--s2) 0 var(--s3);
  }

  .topbar > .conn,
  .topbar > .topbar-actions {
    height: 48px;
    align-items: center;
  }

  .views {
    order: 3;
    flex: 1 1 100%;
    height: 44px;
    margin: 0 calc(-1 * var(--s2)) 0 calc(-1 * var(--s3));
    border-top: 1px solid var(--line);
  }

  .view-link {
    flex: 1;
    justify-content: center;
  }

  .brand,
  .hide-narrow,
  .btn.hide-narrow,
  .conn-label {
    display: none;
  }

  .conn {
    gap: 0;
  }

  .conn-btn {
    min-width: 36px;
    min-height: 36px;
    justify-content: center;
    border-color: transparent;
  }

  .conn-btn {
    gap: 2px;
    padding: 0 6px;
  }

  .conn-icon {
    display: block;
    color: var(--text-2);
  }

  .topbar-actions .btn {
    min-width: 40px;
    min-height: 40px;
  }

  .view-posts {
    display: block;
    height: auto;
  }

  .list-pane {
    min-height: calc(100dvh - var(--topbar-h));
    overflow: visible;
    border-right: 0;
  }

  .list-head {
    top: var(--topbar-h);
  }

  .post-item {
    padding: var(--s3) var(--s4);
    min-height: 56px;
  }

  .view-posts.has-selection .list-pane {
    display: none;
  }

  .view-posts:not(.has-selection) .detail-pane {
    display: none;
  }

  .detail-pane {
    overflow: visible;
  }

  .detail {
    padding: var(--s3) var(--s4) var(--s6);
  }

  .detail-back {
    display: inline-flex;
  }

  /* Нижняя панель действий черновика */
  .actions.is-sticky {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: var(--s5) calc(-1 * var(--s4)) 0;
    padding: var(--s2) var(--s4) calc(var(--s2) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .actions .btn {
    min-height: 44px;
  }

  .actions.is-sticky .btn-primary {
    flex: 1 1 100%;
  }

  .actions.is-sticky .btn:not(.btn-primary) {
    flex: 1 1 0;
  }

  .actions .spacer,
  .actions.is-sticky .danger-text,
  .btn .kbd-hint {
    display: none;
  }

  .commits li {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .commit-time {
    display: none;
  }

  .view-settings {
    display: block;
    padding: var(--s4);
  }

  .commits-pane {
    padding: var(--s3) var(--s4) var(--s4);
  }

  .c-field,
  .c-field-wide {
    flex: 1 1 100%;
  }

  .c-field:nth-child(3),
  .c-field:nth-child(4) {
    flex: 1 1 calc(50% - var(--s3));
  }

  .c-item {
    min-height: 56px;
    padding: var(--s2) 0;
  }

  /* Зоны нажатия не меньше 44 px */
  .c-sha,
  .c-post-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .c-expand {
    width: 44px;
    height: 44px;
  }

  .c-bar {
    padding: var(--s2) var(--s4) calc(var(--s2) + env(safe-area-inset-bottom));
  }

  .c-bar .btn-primary {
    flex: 1 1 100%;
    order: 3;
  }

  .c-bar .btn {
    min-height: 44px;
  }

  .settings-nav {
    display: none;
  }

  .settings-section[data-section] {
    display: block !important;
  }

  .secret {
    flex-wrap: wrap;
  }

  .section-actions .btn,
  .btn {
    min-height: 40px;
  }

  .toasts {
    right: var(--s3);
    bottom: var(--s3);
    left: var(--s3);
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
