/* ==========================================================================
   Articles — feed, card, detail, editor
   --------------------------------------------------------------------------
   Replaces ~900 lines of per-template <style> blocks. Everything is built on
   the canonical --theme-* / --green-* / --leaf-* tokens from
   theme-overrides.css. The old inline styles were hardcoded and had drifted
   off-brand (Medium's #1a8917 green on avatars and links, a mint #d1fae5
   border on the green Edit button).
   ========================================================================== */

/* ── Shell ──────────────────────────────────────────────────────────────── */
.ar-shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}
.ar-shell--wide { max-width: 920px; }

/* ── Feed toolbar ───────────────────────────────────────────────────────── */
.ar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 18px;
}
.ar-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ar-tab {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--theme-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.ar-tab:hover { color: var(--theme-ink); background: var(--theme-surface-alt); text-decoration: none; }
.ar-tab.is-active {
  color: var(--theme-primary);
  background: var(--theme-primary-soft);
  border-color: var(--green-200);
}

.ar-write {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--theme-cta);
  color: #fff;
  border: none;
  border-radius: var(--theme-radius-md);
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}
.ar-write:hover { background: var(--theme-cta-hover); color: #fff; text-decoration: none; transform: translateY(-1px); }
.ar-write svg { width: 16px; height: 16px; }

/* ── Feed list ──────────────────────────────────────────────────────────── */
.ar-feed { display: flex; flex-direction: column; gap: 14px; }

/* ── Card ───────────────────────────────────────────────────────────────── */
.ar-card {
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-lg);
  overflow: hidden;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.ar-card:hover {
  border-color: var(--green-200);
  box-shadow: var(--theme-shadow-md);
  transform: translateY(-2px);
}
.ar-card.is-busy { opacity: 0.6; pointer-events: none; }

.ar-repost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--theme-primary-soft);
  border-bottom: 1px solid var(--theme-border);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--theme-primary);
}
.ar-repost svg { width: 14px; height: 14px; flex-shrink: 0; }
.ar-repost a { color: var(--theme-primary); font-weight: 700; text-decoration: underline; }

.ar-card__body { display: flex; gap: 18px; padding: 18px 20px 14px; }
.ar-card__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.ar-cover {
  flex-shrink: 0;
  align-self: flex-start;
  display: block;
  border-radius: var(--theme-radius-md);
  overflow: hidden;
  background: var(--theme-surface-alt);
}
.ar-cover img { width: 156px; height: 110px; object-fit: cover; display: block; }

/* Byline */
.ar-by { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; min-width: 0; }
.ar-av {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  /* was a Medium-green gradient; now the brand green ramp */
  background: var(--theme-gradient-strong);
  color: #fff;
  font-size: 0.66rem; font-weight: 800; text-transform: uppercase;
  object-fit: cover;
}
.ar-av--lg { width: 44px; height: 44px; font-size: 0.95rem; }
.ar-by__name {
  font-size: 0.82rem; font-weight: 700; color: var(--theme-ink);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ar-by__name:hover { color: var(--theme-primary); text-decoration: underline; }
.ar-by__meta { font-size: 0.76rem; color: var(--theme-muted); white-space: nowrap; }
.ar-dot { color: var(--ink-300, #d6c3cf); }

.ar-card__title {
  display: block;
  font-size: 1.24rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--theme-ink);
  text-decoration: none;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
}
.ar-card__title:hover { color: var(--theme-primary); text-decoration: none; }

.ar-card__desc {
  font-size: 0.87rem;
  line-height: 1.55;
  color: var(--theme-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
a.ar-card__desc-link { text-decoration: none; }
a.ar-card__desc-link:hover { text-decoration: none; }

.ar-card__foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: auto; padding-top: 10px;
  font-size: 0.74rem; color: var(--theme-muted); font-weight: 600;
}
.ar-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--theme-surface-alt);
  color: var(--theme-muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: capitalize;
}

/* ── Action bar ─────────────────────────────────────────────────────────── */
.ar-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 4px 12px 10px;
  border-top: 1px solid var(--theme-border);
  margin: 0 8px;
}
.ar-actions__group { display: flex; align-items: center; gap: 2px; }

.ar-act {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none;
  padding: 7px 11px;
  border-radius: var(--theme-radius-sm);
  font-size: 0.79rem; font-weight: 600;
  color: var(--theme-muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.ar-act:hover { color: var(--theme-ink-soft); background: var(--theme-surface-alt); text-decoration: none; }
.ar-act:focus-visible { outline: 2px solid var(--theme-primary); outline-offset: 1px; }
.ar-act svg { width: 17px; height: 17px; transition: transform 0.15s; }
.ar-act:active svg { transform: scale(0.85); }
.ar-act[aria-pressed="true"] { color: var(--theme-cta); }
.ar-act[aria-pressed="true"] svg { fill: currentColor; }
.ar-act[aria-pressed="true"]:hover { background: var(--theme-cta-soft); }
.ar-act--danger:hover { color: #b42318; background: #fef2f2; }
.ar-act[disabled] { opacity: 0.5; cursor: default; }

.ar-act__count { font-variant-numeric: tabular-nums; }

/* Small pill link (Edit) -- the old rule put a mint-green border on it */
.ar-act--edit {
  border: 1px solid var(--theme-border);
  padding: 6px 14px;
  font-weight: 700;
  color: var(--theme-ink-soft);
}
.ar-act--edit:hover {
  border-color: var(--green-200);
  background: var(--theme-primary-soft);
  color: var(--theme-primary);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.ar-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 1080;
  background: var(--green-900);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--theme-shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.ar-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Empty / load more ──────────────────────────────────────────────────── */
.ar-empty {
  text-align: center;
  padding: 56px 24px;
  background: var(--theme-surface);
  border: 1px dashed var(--theme-border);
  border-radius: var(--theme-radius-lg);
}
.ar-empty__icon { color: var(--ink-300, #d6c3cf); margin-bottom: 12px; }
.ar-empty__icon svg { width: 44px; height: 44px; }
.ar-empty__title { font-size: 1.1rem; font-weight: 700; color: var(--theme-ink); margin: 0 0 6px; }
.ar-empty__text { color: var(--theme-muted); font-size: 0.9rem; margin: 0 0 20px; }

.ar-more { text-align: center; padding-top: 18px; }
.ar-more__btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 10px 24px;
  font-size: 0.85rem; font-weight: 700;
  color: var(--theme-ink-soft);
  background: var(--theme-surface);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.ar-more__btn:hover { border-color: var(--green-200); color: var(--theme-primary); text-decoration: none; }
.ar-more__btn[disabled] { opacity: 0.6; cursor: default; }

/* ══════════════════════════════════════════════════════════════════════════
   Detail
   ══════════════════════════════════════════════════════════════════════════ */
.ar-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--theme-muted);
  font-size: 0.85rem; font-weight: 600;
  text-decoration: none;
  margin-bottom: 24px;
}
/* hover was Medium green */
.ar-back:hover { color: var(--theme-primary); text-decoration: none; }
.ar-back svg { width: 17px; height: 17px; }

.ar-detail__head { margin-bottom: 22px; }
.ar-detail__title {
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--theme-ink);
  margin: 0 0 12px;
}
.ar-detail__summary {
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--theme-muted);
  margin: 0 0 20px;
}
.ar-byline { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.ar-byline__name { font-size: 0.92rem; font-weight: 700; color: var(--theme-ink); text-decoration: none; }
.ar-byline__name:hover { color: var(--theme-primary); text-decoration: underline; }
.ar-byline__meta { display: flex; align-items: center; gap: 7px; margin-top: 2px; font-size: 0.8rem; color: var(--theme-muted); flex-wrap: wrap; }

.ar-detail__cover { margin: 0 0 28px; }
.ar-detail__cover img {
  width: 100%; height: auto; display: block;
  border-radius: var(--theme-radius-lg);
  background: var(--theme-surface-alt);
}

.ar-detail__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 4px;
  border-top: 1px solid var(--theme-border);
  border-bottom: 1px solid var(--theme-border);
  margin-bottom: 32px;
  position: sticky;
  top: 0;
  background: var(--theme-surface);
  z-index: 5;
}

/* Article body typography */
.ar-body {
  font-size: 1.06rem;
  line-height: 1.75;
  color: var(--theme-ink-soft);
  word-wrap: break-word;
}
.ar-body > * + * { margin-top: 1.35em; }
.ar-body h1, .ar-body h2, .ar-body h3, .ar-body h4 {
  color: var(--theme-ink);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-top: 1.9em;
  margin-bottom: 0.55em;
}
.ar-body h1 { font-size: 1.7rem; }
.ar-body h2 { font-size: 1.42rem; }
.ar-body h3 { font-size: 1.2rem; }
.ar-body h4 { font-size: 1.05rem; }
.ar-body p { margin: 0; }
.ar-body a { color: var(--theme-primary); text-decoration: underline; }
.ar-body a:hover { color: var(--green-700); }
.ar-body ul, .ar-body ol { padding-left: 1.5em; }
.ar-body li + li { margin-top: 0.4em; }
.ar-body img { max-width: 100%; height: auto; border-radius: var(--theme-radius-md); }
.ar-body blockquote {
  border-left: 3px solid var(--theme-cta);
  padding: 2px 0 2px 18px;
  color: var(--theme-ink);
  font-style: italic;
}
.ar-body pre {
  background: var(--green-950);
  color: #ebeef2;
  padding: 16px 18px;
  border-radius: var(--theme-radius-md);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
}
.ar-body code {
  background: var(--theme-surface-alt);
  color: var(--theme-ink);
  padding: 0.1em 0.36em;
  border-radius: 5px;
  font-size: 0.9em;
}
.ar-body pre code { background: none; color: inherit; padding: 0; }
.ar-body table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.ar-body th, .ar-body td { border: 1px solid var(--theme-border); padding: 9px 12px; text-align: left; }
.ar-body th { background: var(--theme-surface-alt); font-weight: 700; color: var(--theme-ink); }
.ar-body hr { border: none; border-top: 1px solid var(--theme-border); }

.ar-tail {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 40px 0 32px;
}
.ar-tail span { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-300, #d6c3cf); }

/* ── Comments ───────────────────────────────────────────────────────────── */
.ar-comments { border-top: 1px solid var(--theme-border); padding-top: 28px; }
.ar-comments__title { font-size: 1.15rem; font-weight: 700; color: var(--theme-ink); margin: 0 0 20px; }

.ar-cform { display: flex; gap: 12px; margin-bottom: 28px; }
.ar-cform__body { flex: 1; min-width: 0; }
.ar-cform textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--theme-ink);
  background: var(--theme-surface);
  font-family: inherit;
}
.ar-cform textarea:focus {
  outline: none;
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-primary-glow);
}
.ar-cform__actions { display: flex; justify-content: flex-end; margin-top: 9px; }
.ar-cform__submit {
  background: var(--theme-cta);
  color: #fff;
  border: none;
  border-radius: var(--theme-radius-md);
  padding: 9px 20px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.ar-cform__submit:hover { background: var(--theme-cta-hover); }
.ar-cform__submit[disabled] { opacity: 0.6; cursor: default; }

.ar-clogin {
  padding: 18px;
  background: var(--theme-surface-alt);
  border-radius: var(--theme-radius-md);
  text-align: center;
  font-size: 0.9rem;
  color: var(--theme-muted);
  margin-bottom: 26px;
}
.ar-clogin a { color: var(--theme-primary); font-weight: 700; }

.ar-clist { display: flex; flex-direction: column; gap: 20px; }
.ar-comment { display: flex; gap: 12px; }
.ar-comment__content { flex: 1; min-width: 0; }
.ar-comment__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.ar-comment__author { font-size: 0.86rem; font-weight: 700; color: var(--theme-ink); }
.ar-comment__time { font-size: 0.75rem; color: var(--theme-muted); }
.ar-comment__body { font-size: 0.9rem; line-height: 1.6; color: var(--theme-ink-soft); }
.ar-comment__tools { display: flex; gap: 10px; margin-top: 5px; }
.ar-comment__tool {
  background: none; border: none; padding: 0;
  font-size: 0.75rem; font-weight: 700; color: var(--theme-muted);
  cursor: pointer;
}
.ar-comment__tool:hover { color: var(--theme-primary); }
.ar-comment__tool--danger:hover { color: #b42318; }
.ar-nocomments { color: var(--theme-muted); font-size: 0.9rem; text-align: center; padding: 24px 0; }

/* ══════════════════════════════════════════════════════════════════════════
   Editor
   ══════════════════════════════════════════════════════════════════════════ */
.ar-editor__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.ar-editor__title { font-size: 1.5rem; font-weight: 800; color: var(--theme-ink); margin: 0; letter-spacing: -0.02em; }
.ar-editor__hint { margin: 3px 0 0; font-size: 0.85rem; color: var(--theme-muted); }

.ar-field { margin-bottom: 20px; }
.ar-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--theme-ink-soft);
}
.ar-label__opt { font-weight: 500; color: var(--theme-muted); }
.ar-help { margin: 6px 0 0; font-size: 0.76rem; color: var(--theme-muted); }
.ar-error { margin: 6px 0 0; font-size: 0.78rem; font-weight: 600; color: #b42318; }

.ar-input,
.ar-field input[type="text"],
.ar-field input[type="url"],
.ar-field select,
.ar-field textarea {
  width: 100%;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 11px 14px;
  font-size: 0.92rem;
  color: var(--theme-ink);
  background: var(--theme-surface);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ar-input:focus,
.ar-field input:focus,
.ar-field select:focus,
.ar-field textarea:focus {
  outline: none;
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px var(--theme-primary-glow);
}
.ar-field textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.ar-field input[type="file"] { font-size: 0.86rem; }

.ar-editor__actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 20px;
  margin-top: 4px;
  border-top: 1px solid var(--theme-border);
}
.ar-btn-primary {
  background: var(--theme-cta);
  color: #fff; border: none;
  border-radius: var(--theme-radius-md);
  padding: 11px 26px;
  font-size: 0.88rem; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.ar-btn-primary:hover { background: var(--theme-cta-hover); color: #fff; }
.ar-btn-secondary {
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 11px 22px;
  font-size: 0.88rem; font-weight: 700;
  color: var(--theme-ink-soft);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.ar-btn-secondary:hover { border-color: var(--green-200); color: var(--theme-primary); text-decoration: none; }
.ar-editor__spacer { flex: 1; }

.ar-cover-preview { margin-top: 10px; }
.ar-cover-preview img {
  max-width: 260px; width: 100%; height: auto;
  border-radius: var(--theme-radius-md);
  border: 1px solid var(--theme-border);
  display: block;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .ar-shell { padding: 8px 12px 44px; }
  .ar-card__body { flex-direction: column-reverse; gap: 12px; padding: 15px 15px 11px; }
  .ar-cover { width: 100%; }
  .ar-cover img { width: 100%; height: 180px; }
  .ar-card__title { font-size: 1.1rem; }
  .ar-actions { margin: 0 4px; padding: 4px 6px 8px; }
  .ar-act { padding: 7px 9px; }
  .ar-detail__title { font-size: 1.6rem; }
  .ar-detail__summary { font-size: 0.98rem; }
  .ar-body { font-size: 1rem; }
  .ar-detail__bar { position: static; }
  .ar-toolbar { padding-bottom: 14px; }
}
@media (max-width: 420px) {
  .ar-act__count { display: none; }
  .ar-act--has-count .ar-act__count { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  .ar-card, .ar-card:hover, .ar-write:hover, .ar-act svg, .ar-toast { transition: none; transform: none; }
}

@media print {
  .ar-toolbar, .ar-actions, .ar-detail__bar, .ar-back, .ar-comments, .ar-toast { display: none !important; }
  .ar-shell { max-width: none; padding: 0; }
}

/* Article listing: align the header and feed directly beside navigation. */
.articles-page .dash-main-layout { gap: 16px; }
.articles-page .dash-page-header {
  align-items: center;
  padding: 26px 28px;
  margin-bottom: 24px;
  border: 1px solid var(--theme-border);
  border-radius: 18px;
  background: linear-gradient(115deg, var(--theme-surface) 35%, var(--theme-primary-soft));
}
.articles-page .dash-page-header__title {
  font-size: clamp(1.75rem, 2.4vw, 2.25rem);
  letter-spacing: -0.045em;
}
.articles-page .dash-page-header__subtitle { max-width: 48ch; margin-top: 9px; }
.articles-page .ar-write { padding: 12px 18px; border-radius: 10px; }
.articles-page .ar-shell--feed { max-width: none; margin: 0; padding: 0 0 64px; }
.ar-feed-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 14px; }
.ar-feed-heading h2 { margin: 0; color: var(--theme-ink); font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.ar-feed-heading > span { color: var(--theme-muted); font-size: 0.75rem; }
.articles-page .ar-feed { gap: 18px; }
.articles-page .ar-card { border-radius: 16px; box-shadow: 0 2px 5px rgba(15, 46, 20, 0.025); }
.articles-page .ar-card:hover { transform: none; box-shadow: 0 6px 22px rgba(15, 46, 20, 0.06); }
.articles-page .ar-card__body { padding: 24px 26px 20px; gap: 24px; }
.articles-page .ar-by { margin-bottom: 18px; gap: 9px; }
.articles-page .ar-av { width: 34px; height: 34px; font-size: 0.75rem; }
.ar-card__heading { margin: 0; }
.articles-page .ar-card__title { font-size: 1.4rem; line-height: 1.35; letter-spacing: -0.03em; margin-bottom: 9px; overflow-wrap: anywhere; }
.articles-page .ar-card__desc { line-height: 1.7; overflow-wrap: anywhere; }
.articles-page .ar-card__foot { padding-top: 20px; flex-wrap: wrap; }
.ar-card__read { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--theme-primary); font-size: 0.78rem; font-weight: 700; text-decoration: none; }
.ar-card__read:hover { text-decoration: underline; }
.articles-page .ar-cover { margin-top: 2px; border-radius: 12px; }
.articles-page .ar-cover img { width: 180px; height: 144px; }
.articles-page .ar-actions { margin: 0; padding: 10px 16px; background: var(--theme-surface-alt); }
.articles-page .ar-actions form { margin-bottom: 0; }
.articles-page .ar-act { min-height: 36px; }
.articles-page .ar-act--edit { background: var(--theme-surface); }
.articles-page a:focus-visible { outline: 2px solid var(--theme-primary); outline-offset: 3px; }
@media (max-width: 767px) {
  .articles-page .dash-page-header { padding: 20px; gap: 18px; margin-bottom: 20px; }
  .articles-page .ar-card__body { padding: 18px; gap: 16px; }
  .articles-page .ar-card__title { font-size: 1.2rem; }
  .articles-page .ar-by { flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
  .articles-page .ar-by__name { max-width: calc(100% - 48px); }
  .articles-page .ar-cover img { width: 100%; height: 190px; }
  .articles-page .ar-actions { padding: 8px; flex-wrap: wrap; }
  .articles-page .ar-act { padding: 7px 8px; }
}
