:root {
  --bg: #fafafa;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #8b8b8b;
  --line: #e6e6e6;
  --accent: #1a1a1a;
  --accent-soft: #292929;
  --focus: #2a6f5f;
  --danger: #a33;
  --code-bg: #f6f8fa;
  --shadow: 0 12px 40px rgba(26, 26, 26, 0.06);
  --font-display: "Literata", "Iowan Old Style", Palatino, Georgia, serif;
  --font-body: "Literata", Georgia, serif;
  --font-ui: "Source Sans 3", "Segoe UI", sans-serif;
  --col: min(56rem, 94vw);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 1.0625rem;
}

body.page-editor,
body.page-article {
  background: var(--paper);
}

a {
  color: var(--focus);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--accent-soft); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.75rem;
  z-index: 100;
}

.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(250, 250, 250, 0.86);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}

body.is-scrolled .site-header {
  border-bottom-color: var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.site-header__inner,
.site-footer__inner,
.site-main {
  max-width: var(--col);
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  max-width: min(26rem, 52vw);
  font-family: var(--font-display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.brand__name {
  font-size: clamp(1.45rem, 2.4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.15;
}

.brand__motto {
  font-family: var(--font-ui);
  font-size: clamp(0.92rem, 1.4vw, 1.05rem);
  font-weight: 400;
  line-height: 1.3;
  color: var(--muted);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.05rem;
  font-family: var(--font-ui);
  font-size: clamp(1.02rem, 1.5vw, 1.12rem);
}

.nav-link,
.nav-btn {
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.nav-link:hover,
.nav-btn:hover,
.nav-link--accent {
  color: var(--ink);
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.nav-cta:hover {
  background: var(--ink);
  color: #fff;
}

.nav-cta--muted {
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}

.nav-cta--muted:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.nav-icon:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.nav-form { display: inline; margin: 0; }

.site-main {
  flex: 1 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
  padding-top: 1.75rem;
  padding-bottom: 3.5rem;
  background: transparent;
}

body.page-feed {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.page-feed .site-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 0.85rem;
  padding-bottom: 0.65rem;
  overflow: hidden;
}

body.page-feed .feed {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.page-feed .site-footer {
  padding: 0.7rem 0 0.9rem;
  flex-shrink: 0;
}

.site-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 0;
  width: 100%;
  margin-top: 0;
  padding: 1.35rem 0 2rem;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, #ebe8e2);
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer__copy {
  margin: 0;
  color: var(--muted);
}

.site-footer__social {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.site-footer__social-link {
  display: inline-flex;
  color: var(--ink);
  opacity: 0.75;
  transition: opacity 0.2s var(--ease);
}

.site-footer__social-link:hover { opacity: 1; }

/* Setup wizard */
.setup-shell .setup-bar-label {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  pointer-events: none;
}

.setup-step-indicator {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.setup-fields { margin-bottom: 1rem; }

.setup-fields .auth-title { margin-bottom: 0.35rem; }

.setup-fields .auth-lead {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.98rem;
  line-height: 1.45;
  min-height: 2.8em;
}

.setup-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.setup-progress__dot {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.setup-progress__dot:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.setup-progress__dot.is-done {
  border-color: color-mix(in srgb, var(--accent-soft) 55%, var(--line));
  color: var(--ink);
}

.setup-progress__dot.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.setup-wizard {
  position: relative;
  min-height: 16rem;
}

.setup-step {
  animation: setup-step-in 0.35s var(--ease) both;
}

.setup-step[hidden],
.setup-step:not(.is-active) {
  display: none !important;
}

@keyframes setup-step-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

.setup-fieldset {
  margin: 0;
  padding: 1.1rem 1.15rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--paper) 92%, #f0f2f5);
  display: grid;
  gap: 0.85rem;
  max-width: 28rem;
}

.setup-fieldset--socials { max-width: none; }

.setup-fieldset legend {
  padding: 0 0.35rem;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.95rem;
}

.setup-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-family: var(--font-ui);
}

.setup-note {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85em;
}

.setup-social-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.75rem;
}

.setup-social-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.setup-social-card__label { font-weight: 600; color: var(--muted); }

.setup-social-card input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.35rem 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
}

.setup-social-card input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.35rem;
}

.setup-actions .tl-publish {
  margin-left: auto;
}

.setup-actions [hidden],
.setup-actions .is-hidden {
  display: none !important;
}

.field input[type="number"],
.field input[type="url"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.field input[type="number"]:focus,
.field input[type="url"]:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 35%, white);
  border-color: var(--focus);
}

/* Page enter motion — без transform на всём main (ломает stacking со sticky footer) */
.page-enter {
  animation: page-in 0.45s var(--ease) both;
}

@keyframes page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-panel > * {
  animation: rise 0.5s var(--ease) both;
}

.page-panel > *:nth-child(2) { animation-delay: 0.05s; }
.page-panel > *:nth-child(3) { animation-delay: 0.1s; }

@keyframes rise {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Feed */
.feed-hero {
  margin-bottom: 0.45rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.feed-section-title,
.auth-title,
.tl-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0;
}

.feed-section-title {
  font-size: clamp(1.55rem, 3.2vw, 1.9rem);
}

.auth-title {
  margin: 0 0 0.75rem;
}

.auth-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 34rem;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0;
}

.feed-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.25rem;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  overflow: hidden;
}

.feed-item:last-child {
  border-bottom: 0;
}

.feed-item__title {
  display: block;
  margin: 0;
  width: 100%;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.2vw, 1.4rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.feed-item__title:hover { color: var(--focus); }

.feed-item__meta,
.tl-meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-style: normal;
  line-height: 1.35;
}

.feed-item__summary {
  margin: 0;
  width: 100%;
  max-width: none;
  color: #4a4a4a;
  font-size: 0.98rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.feed-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin: 0.7rem 0 0;
  padding-top: 0;
  font-family: var(--font-ui);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.feed-pager__link,
.feed-pager__current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  border-radius: 0.4rem;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--paper);
}

.feed-pager__link:hover {
  border-color: var(--ink);
}

.feed-pager__current {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  pointer-events: none;
}

.feed-pager__nav {
  min-width: auto;
  padding: 0 0.85rem;
}

.feed-pager__nav.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.feed-empty { color: var(--muted); }

.dot { margin: 0 0.25rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.2s var(--ease);
}

.btn:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-soft);
  color: #fff;
}

/* Auth */
.auth-panel {
  max-width: 26rem;
  margin: 0.5rem auto 0;
  padding: 1.5rem 1.5rem 2rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.auth-title { font-size: 1.85rem; }

.auth-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

.field span { color: var(--muted); }

.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.field input:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 35%, white);
  border-color: var(--focus);
}

.field--inline {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

.field-error,
.form-errors {
  color: var(--danger);
  font-size: 0.85rem;
}

.form-errors ul { margin: 0; padding-left: 1.1rem; }

.auth-switch {
  margin-top: 1.25rem;
  font-family: var(--font-ui);
  color: var(--muted);
}

/* Article / editor Telegra.ph-like */
.tl-article__top,
.tl-editor-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  font-family: var(--font-ui);
}

.page-editor .tl-editor-bar {
  position: sticky;
  top: 3.5rem;
  z-index: 18;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
}

body.is-scrolled.page-editor .tl-editor-bar {
  border-bottom-color: var(--line);
}

.tl-back,
.tl-edit {
  color: var(--muted);
  text-decoration: none;
}

.tl-back:hover,
.tl-edit:hover { color: var(--ink); }

.tl-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}

/* Fix broken contenteditable focus ring (рис. 1) */
.tl-title--editable {
  display: block;
  width: 100%;
  max-width: 100%;
  outline: none !important;
  border: 0 !important;
  box-shadow: none !important;
  -webkit-user-modify: read-write-plaintext-only;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  caret-color: var(--ink);
  min-height: 1.15em;
}

.tl-title--editable:focus,
.tl-title--editable:focus-visible {
  outline: none !important;
  border: 0 !important;
  box-shadow: none !important;
}

.tl-title--editable.has-error {
  caret-color: var(--danger);
}

.tl-title--editable:empty:before {
  content: attr(data-placeholder);
  color: #c4c4c4;
  pointer-events: none;
}

.tl-author {
  display: block;
  margin: 0 0 1.75rem;
  font-style: normal;
  font-family: var(--font-ui);
  color: var(--muted);
}

.tl-content {
  margin-top: 1.75rem;
  font-size: 1.125rem;
}

.tl-content p { margin: 0 0 1.1rem; }

/* ColorCode — фон как у страницы (белый / paper), цвет токенов из inline style */
.tl-content pre,
.tl-md-preview pre,
.tl-content div[style*="background"],
.tl-md-preview div[style*="background"] {
  margin: 0 0 1.25rem;
  overflow: auto;
  border-radius: 0;
  font-size: 0.95rem;
  line-height: 1.55;
}

.tl-content pre,
.tl-md-preview pre {
  padding: 0.15rem 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: "Cascadia Code", "Cascadia Mono", Consolas, "Courier New", monospace;
  tab-size: 4;
}

.tl-content div[style*="background-color"],
.tl-md-preview div[style*="background-color"],
.tl-content div[style*="background:"],
.tl-md-preview div[style*="background:"] {
  background: transparent !important;
  background-color: transparent !important;
  color: var(--ink) !important;
  padding: 0 !important;
  border: 0 !important;
}

.tl-content pre code,
.tl-md-preview pre code {
  display: block;
  padding: 0;
  background: transparent !important;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-shadow: none;
}

.tl-content .tl-code,
.tl-md-preview .tl-code {
  margin: 0 0 1.25rem;
  background: transparent;
}

/* Math (Markdig → KaTeX) */
.tl-content .math,
.tl-md-preview .math {
  overflow-x: auto;
  overflow-y: hidden;
}

.tl-content div.math,
.tl-md-preview div.math {
  display: block;
  margin: 1rem 0 1.35rem;
  text-align: center;
  padding: 0.35rem 0;
}

.tl-content span.math,
.tl-md-preview span.math {
  padding: 0 0.1em;
}

.tl-content .katex-display,
.tl-md-preview .katex-display {
  margin: 0.85rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.tl-content img,
.tl-content video {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
}

.tl-content figure { margin: 0 0 1.5rem; }

.tl-content figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  text-align: center;
}

.tl-content iframe {
  width: 100%;
  min-height: 360px;
  border: 0;
  border-radius: 0.35rem;
}

.tl-publish {
  appearance: none;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tl-editor-bar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.tl-help {
  appearance: none;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.tl-help:hover {
  background: color-mix(in srgb, var(--ink) 6%, white);
}

.tl-help[aria-expanded="true"] {
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.tl-editor-layout {
  position: relative;
  overflow: visible;
}

.tl-editor-doc {
  position: relative;
  padding-left: 0;
  overflow: visible;
}

.tl-editor-shell {
  padding-left: 0;
  overflow: visible;
}

body.page-editor .site-main,
body.page-article .site-main,
body.page-about .site-main {
  overflow: visible;
}

.tl-editor-help {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 16;
  width: min(24rem, calc(100% - 0.5rem));
  max-height: min(62vh, calc(100dvh - 11rem));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family: var(--font-ui);
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.95rem 1.05rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.28s var(--ease) both;
  pointer-events: auto;
}

.tl-editor-help[hidden] {
  display: none !important;
}

/* Center the panel in the right browser gutter (equal gaps). */
@media (min-width: 1200px) {
  .tl-editor-help {
    position: fixed;
    top: 6.75rem;
    bottom: 7.25rem;
    right: auto;
    left: calc(75% + var(--col) / 4);
    transform: translateX(-50%);
    width: min(26rem, calc((100vw - var(--col)) / 2 - 1.25rem));
    max-height: none;
    height: auto;
  }
}

.tl-editor-help__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tl-editor-help__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.tl-editor-help__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
}

.tl-editor-help__close:hover {
  color: var(--ink);
}

.tl-editor-help__section {
  margin: 0;
}

.tl-editor-help__section--keys {
  margin: 0 -0.35rem 0.9rem;
  padding: 0.75rem 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--bg) 65%, #ebe8e2);
}

.tl-editor-help__section--md {
  margin: 0;
  padding-top: 0.15rem;
  border-top: 0;
}

.tl-editor-help__subtitle {
  margin: 0 0 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
}

.tl-editor-help__lead {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}

.tl-editor-help__note {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.tl-editor-help__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.tl-editor-help__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  line-height: 1.35;
}

.tl-editor-help__table th,
.tl-editor-help__table td {
  padding: 0.28rem 0.35rem 0.28rem 0;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, white);
}

.tl-editor-help__table th {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  padding-bottom: 0.4rem;
}

.tl-editor-help__table td:last-child {
  color: var(--ink);
  padding-left: 0.45rem;
  width: 38%;
}

.tl-editor-help__table code,
.tl-editor-help__list code,
.tl-editor-help__note code {
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.92em;
  color: var(--ink);
}

.tl-editor-help__list kbd,
.tl-editor-help__note kbd,
.tl-editor-hints kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: #f7f7f7;
  font-size: 0.8rem;
  color: var(--ink);
}

.tl-publish:hover:not(:disabled) {
  background: var(--ink);
  color: #fff;
}

.tl-publish:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tl-editor-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  margin: 0 0 1rem;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

.tl-editor-hints kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: #f7f7f7;
  font-size: 0.8rem;
  color: var(--ink);
}

.tl-mobile-actions {
  display: none;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tl-editor-errors {
  display: none; /* legacy top slot unused — ошибки рядом с полем */
}

.tl-inline-error {
  position: relative;
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 2rem 0.75rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, white);
  background: color-mix(in srgb, var(--danger) 9%, white);
  border-radius: 0.5rem;
  color: var(--danger);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  animation: rise 0.35s var(--ease) both;
  z-index: 2;
}

.tl-inline-error__close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

.tl-block__caption {
  display: block;
  margin: 0.55rem 0 0;
  padding: 0.15rem 0.1rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--muted);
  outline: none;
  min-height: 1.3em;
}

.tl-block__caption:empty:before {
  content: attr(data-placeholder);
  color: #c4c4c4;
}

.tl-block__caption:focus {
  color: var(--ink);
  border-bottom: 1px dashed var(--line);
}

.tl-block__media-url,
.tl-block__embed-caption:not(.tl-block__caption),
.tl-chip {
  display: none;
}

.tl-inline-error__title {
  margin: 0 0 0.3rem;
  font-weight: 700;
}

.tl-inline-error ul {
  margin: 0;
  padding-left: 1.1rem;
}

.page-editor .tl-editor-bar .tl-inline-error {
  flex: 1 1 100%;
  order: 3;
  margin: 0.35rem 0 0;
}

.tl-editor-errors__title {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.tl-editor-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

.tl-editor.has-error {
  outline: 1px dashed color-mix(in srgb, var(--danger) 50%, white);
  outline-offset: 6px;
  border-radius: 0.35rem;
}

.tl-editor {
  min-height: 12rem;
  overflow: visible;
}

.tl-block {
  position: relative;
  margin: 0 0 0.45rem;
  padding-left: 0;
}

.tl-block__gutter {
  position: absolute;
  top: 0;
  right: auto;
  left: calc(-2.5rem * 2 - 0.4rem - 0.65rem);
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  height: 2.5rem;
  z-index: 2;
}

.tl-block.is-empty.is-focused .tl-block__gutter,
.tl-block.is-empty:focus-within .tl-block__gutter {
  display: flex;
}

.tl-block__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: #fff;
  color: #6a6a6a;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.tl-block__action svg {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

.tl-block__action:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: #fafafa;
}

.tl-block__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.55rem;
  font-family: var(--font-ui);
}

.tl-block__toolbar .btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.tl-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

.tl-md-preview {
  cursor: text;
  min-height: 1.6em;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  white-space: normal;
}

.tl-md-preview p { margin: 0 0 1.1rem; }
.tl-md-preview p:last-child { margin-bottom: 0; }
.tl-md-preview h1,
.tl-md-preview h2,
.tl-md-preview h3,
.tl-md-preview h4,
.tl-content h1,
.tl-content h2,
.tl-content h3,
.tl-content h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 1.1rem 0 0.55rem;
}
.tl-md-preview h1, .tl-content .tl-md-from-block h1 { font-size: 1.75rem; }
.tl-md-preview h2, .tl-content h2 { font-size: 1.45rem; }
.tl-md-preview h3, .tl-content h3 { font-size: 1.25rem; }
.tl-md-preview ul,
.tl-md-preview ol,
.tl-content ul,
.tl-content ol {
  margin: 0 0 0.85rem;
  padding-left: 1.35rem;
}
.tl-md-preview table,
.tl-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
  font-size: 0.95rem;
}
.tl-md-preview th,
.tl-md-preview td,
.tl-content th,
.tl-content td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.55rem;
  text-align: left;
}
.tl-md-preview th,
.tl-content th {
  background: #f6f6f6;
  font-weight: 600;
}
.tl-md-preview :not(pre) > code,
.tl-content :not(pre) > code {
  background: var(--code-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.92em;
}
.tl-md-preview a { color: var(--focus); }

.tl-block.is-preview {
  padding-top: 0.2rem;
  padding-bottom: 0.45rem;
  border-left: 2px solid transparent;
}

.tl-block.is-preview:hover {
  border-left-color: var(--line);
}

.tl-block.is-editing {
  padding-top: 0.2rem;
  padding-bottom: 0.45rem;
}

.tl-block.is-editing .tl-block__body {
  font-family: var(--font-body);
  font-size: 1.22rem;
  line-height: 1.75;
}

.tl-block.is-editing:not(.is-empty) .tl-block__body {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 1.22rem;
  line-height: 1.75;
}

.tl-block__body {
  min-height: 1.6em;
  outline: none !important;
  border: 0;
  box-shadow: none;
  font-size: 1.125rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tl-block.is-empty.is-editing .tl-block__body {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.tl-block__body:focus,
.tl-block__body:focus-visible {
  outline: none !important;
}

.tl-block__body:empty:before {
  content: attr(data-placeholder);
  color: #c4c4c4;
  pointer-events: none;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.35;
}

.tl-special-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.55rem 0 0.25rem;
  padding-left: 0;
}

.tl-block__media img,
.tl-block__media video {
  display: block;
  max-width: 100%;
  border-radius: 0.35rem;
}

.tl-media-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 0.4rem;
  overflow: hidden;
}

.tl-media-wrap img,
.tl-media-wrap video,
.tl-content .tl-media-wrap img,
.tl-content .tl-media-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  background: #111;
}

.tl-block__media-url,
.tl-block__embed {
  margin: 0.45rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: var(--muted);
  word-break: break-all;
}

.tl-block__embed-figure {
  margin: 0;
}

.tl-embed-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f0f0f;
  border-radius: 0.4rem;
  overflow: hidden;
}

.tl-embed-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.tl-block__embed-caption {
  margin: 0.5rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-word;
  text-align: center;
}

.tl-content .tl-embed-wrap {
  margin: 0 0 0.35rem;
}

.tl-chip {
  display: none;
}

/* Error page extras */
.error-page .error-code,
.auth-panel .error-code {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  color: var(--ink);
}

.error-actions { margin-top: 1.25rem; }

@media (max-width: 640px) {
  .site-nav .nav-link { display: none; }
  .site-nav .nav-icon { display: inline-flex; }
  .auth-panel { border-radius: 0.75rem; padding: 1.15rem; }
  .tl-mobile-actions { display: flex; }
  .tl-editor-shell { padding-left: 0; }
  .tl-editor-doc { padding-left: 0; }
  .tl-block { padding-left: 0; }
  .tl-block__gutter {
    position: static;
    left: auto;
    right: auto;
    height: auto;
    flex-direction: row;
    margin-bottom: 0.4rem;
  }
  .tl-block.is-empty.is-focused .tl-block__gutter,
  .tl-block.is-empty:focus-within .tl-block__gutter {
    display: flex;
  }
}
