/* === Статьи === */

.main-content:has(.articles-page) { padding-top: 0; }

.articles-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 0 40px;
}

.articles-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 4px;
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 5;
  border-bottom: 1px solid var(--color-border);
}

.articles-toolbar__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-on-surface);
  flex-shrink: 0;
}

.articles-toolbar__title--ellipsis {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 500;
}

.articles-toolbar__search-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
}

.articles-toolbar__search {
  width: 100%;
  height: 32px;
  padding: 0 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-on-surface);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.articles-toolbar__search::placeholder {
  color: var(--color-on-surface-secondary);
}

.articles-toolbar__search:focus {
  border-color: var(--color-primary);
}

.articles-toolbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  color: var(--color-on-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.articles-toolbar__btn:hover {
  color: var(--color-primary);
}

.articles-toolbar__btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.articles-toolbar__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px 0 6px;
  background: transparent;
  color: var(--color-on-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.articles-toolbar__back:hover {
  color: var(--color-primary);
  background: var(--color-hover);
}

.articles-body {
  padding: 16px 0 0;
}

.articles-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-on-surface-secondary);
  font-size: 14px;
}

.articles-state--error {
  color: #c62828;
}

.articles-state__retry {
  margin-top: 12px;
  padding: 6px 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.articles__mark {
  background: color-mix(in srgb, var(--color-primary) 25%, transparent);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}


/* === Сетка карточек === */

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  width: 100%;
}

.articles-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  background-color: var(--color-primary);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 3px 30px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, box-shadow 0.15s;
}

.articles-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.articles-card--no-image {
  background-image: linear-gradient(135deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 60%, #000));
}

.articles-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  color: #fff;
  /* Повторяем мобильный градиент: прозрачный сверху → плотный у низа,
     чтобы текст читался даже на светлом фоне обложки. */
  background: linear-gradient(to bottom,
    rgba(0, 0, 0, 0.05) 0%,
    rgba(0, 0, 0, 0.25) 45%,
    rgba(0, 0, 0, 0.72) 100%);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.articles-card__title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.articles-card__short {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.92);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.articles-card__footer {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.articles-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 11px;
  color: #fff;
}

.articles-card__meta-label {
  color: rgba(255, 255, 255, 0.65);
}

.articles-card__author,
.articles-card__date {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.articles-card__stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  flex-shrink: 0;
}

.articles-card__stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}


/* === Детальный просмотр === */

.articles-detail {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 4px;
}

.articles-detail__hero {
  aspect-ratio: 16 / 7;
  background-color: var(--color-hover);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: var(--radius-md, 12px);
  margin-top: 8px;
}

.articles-detail__header {
  padding: 20px 4px 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
}

.articles-detail__title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-on-surface);
  margin: 0 0 12px;
}

.articles-detail__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--color-on-surface-secondary);
}

.articles-detail__author {
  font-weight: 600;
  color: var(--color-on-surface);
}

.articles-detail__views {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.articles-detail__like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--color-on-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  margin-left: auto;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.articles-detail__like:hover {
  color: #e53935;
  border-color: color-mix(in srgb, #e53935 40%, var(--color-border));
}

.articles-detail__like--on {
  color: #e53935;
  border-color: color-mix(in srgb, #e53935 50%, var(--color-border));
  background: color-mix(in srgb, #e53935 8%, transparent);
}

.articles-detail__content {
  font-size: 16px;
  line-height: 1.65;
  color: var(--color-on-surface);
  padding-bottom: 40px;
}

/* Quill Delta content */
.ql-view p,
.ql-view h1,
.ql-view h2,
.ql-view h3,
.ql-view h4,
.ql-view h5,
.ql-view h6,
.ql-view ul,
.ql-view ol,
.ql-view blockquote,
.ql-view pre {
  margin: 0 0 16px;
}

.ql-view h1 { font-size: 26px; font-weight: 700; line-height: 1.25; }
.ql-view h2 { font-size: 22px; font-weight: 700; line-height: 1.3; }
.ql-view h3 { font-size: 19px; font-weight: 600; line-height: 1.35; }
.ql-view h4 { font-size: 17px; font-weight: 600; }

.ql-view ul,
.ql-view ol {
  padding-left: 24px;
}

.ql-view li {
  margin-bottom: 6px;
}

.ql-view blockquote {
  padding: 8px 16px;
  border-left: 3px solid var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
  color: var(--color-on-surface-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.ql-view pre {
  padding: 12px 16px;
  background: var(--color-hover);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-x: auto;
}

.ql-view code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  padding: 1px 6px;
  background: var(--color-hover);
  border-radius: 4px;
}

.ql-view pre code {
  padding: 0;
  background: transparent;
}

.ql-view a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ql-view .ql-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 12px auto;
}

.ql-view .ql-empty {
  height: 12px;
  margin: 0;
}


/* === Статьи: кнопка "Новая статья" в тулбаре === */

.articles-toolbar__create {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.articles-toolbar__create:hover { opacity: 0.9; }

[data-theme="dark"] .articles-toolbar__create { color: #000; }

.articles-toolbar__btn--danger {
  color: #c62828;
}

.articles-toolbar__btn--danger:hover {
  color: #fff;
  background: #c62828;
  border-color: #c62828;
}


/* === Статьи: редактор === */

.main-content:has(.articles-page--editor) { padding-top: 0; }

.articles-editor-tabs {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.articles-editor-tab {
  height: 32px;
  padding: 0 14px;
  background: transparent;
  color: var(--color-on-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.articles-editor-tab:hover {
  color: var(--color-primary);
}

.articles-editor-tab--active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

[data-theme="dark"] .articles-editor-tab--active {
  color: #000;
}

.articles-editor {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 0 160px;
}

.articles-editor__error {
  padding: 12px 16px;
  background: color-mix(in srgb, #c62828 10%, transparent);
  border: 1px solid color-mix(in srgb, #c62828 40%, transparent);
  color: #c62828;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.articles-editor__pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.articles-editor__pane--hidden {
  display: none;
}

.articles-editor__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.articles-editor__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-on-surface-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.articles-editor__input {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--color-on-surface);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.articles-editor__input:focus {
  border-color: var(--color-primary);
}

.articles-editor__textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.articles-editor__input--error {
  border-color: #c62828;
}

.articles-editor__field-error {
  color: #c62828;
  font-size: 12px;
}

.articles-editor__cover-btn {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  color: var(--color-on-surface);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.articles-editor__cover-btn:hover {
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.articles-editor__preview-label {
  font-size: 12px;
  color: var(--color-on-surface-secondary);
}

.articles-editor__preview {
  aspect-ratio: 16 / 9;
  max-height: 320px;
  padding: 20px;
  border-radius: var(--radius-md, 12px);
  background-color: var(--color-primary);
  background-size: cover;
  background-position: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.articles-editor__preview-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.articles-editor__preview-short {
  font-size: 14px;
  line-height: 1.3;
  opacity: 0.95;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.articles-editor__preview-meta {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  opacity: 0.85;
}

.articles-editor-quill-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.articles-editor-quill-wrap .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.articles-editor-quill-wrap .ql-container {
  border: none;
  font-family: inherit;
  font-size: 15px;
  min-height: 420px;
}

.articles-editor-quill-wrap .ql-editor {
  min-height: 420px;
  color: var(--color-on-surface);
}

.articles-editor-quill-wrap .ql-editor.ql-blank::before {
  color: var(--color-on-surface-secondary);
  font-style: normal;
  opacity: 0.6;
}

.articles-editor__input::placeholder,
.articles-editor__textarea::placeholder {
  color: var(--color-on-surface-secondary);
  opacity: 0.6;
}

[data-theme="dark"] .articles-editor-quill-wrap .ql-editor.ql-blank::before {
  color: var(--color-on-surface-secondary);
  opacity: 0.75;
}

[data-theme="dark"] .articles-editor__input::placeholder,
[data-theme="dark"] .articles-editor__textarea::placeholder {
  color: var(--color-on-surface-secondary);
  opacity: 0.75;
}

[data-theme="dark"] .articles-editor-quill-wrap .ql-snow .ql-stroke { stroke: var(--color-on-surface); }
[data-theme="dark"] .articles-editor-quill-wrap .ql-snow .ql-fill { fill: var(--color-on-surface); }
[data-theme="dark"] .articles-editor-quill-wrap .ql-snow .ql-picker { color: var(--color-on-surface); }
[data-theme="dark"] .articles-editor-quill-wrap .ql-snow .ql-picker-options {
  background: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme="dark"] .articles-editor-quill-wrap .ql-snow .ql-tooltip {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-on-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .articles-editor-quill-wrap .ql-snow .ql-tooltip input[type=text] {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-on-surface);
}

.articles-editor__footer {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.articles-editor__btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: 100px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}

.articles-editor__btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.articles-editor__btn--primary {
  background: var(--color-primary);
  color: #fff;
}

[data-theme="dark"] .articles-editor__btn--primary {
  color: #000;
}

.articles-editor__btn--primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.articles-editor__btn--danger {
  background: #c62828;
  color: #fff;
  flex: 0 0 auto;
  padding: 12px 20px;
}

