/* ============================================================
   Blog Platform — Standalone Stylesheet
   Color scheme: Telegram Desktop Dark
   ============================================================ */

:root {
  --bg:          #17212B;
  --field:       #242F3D;
  --text:        #FFFFFF;
  --text-sec:    #B4C1CD;
  --accent:      #0088CC;
  --accent-text: #FFFFFF;
  --icon:        #B4C1CD;
  --muted:       #4B5764;
  --border:      #2D3A47;
  --hover-field: #2A3849;
  --danger:      #E53935;
  --radius:      10px;
  --radius-sm:   6px;
  --max-w:       1440px;
  --article-w:   1440px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .8; }
img { max-width: 100%; display: block; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  background: var(--field);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.topbar-brand:hover { opacity: 1; }
.topbar-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-sec);
  font-size: 14px;
  transition: color .15s;
}
.topbar-back:hover { color: var(--text); opacity: 1; }
.topbar-back svg { width: 16px; height: 16px; }

/* ── Boxed container ─────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { opacity: .85; }
.btn-primary   { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: transparent; color: var(--text-sec); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--hover-field); opacity: 1; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 6px 14px; font-size: 13px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 20px; }
.alert-success { background: rgba(0,136,204,.15); border: 1px solid rgba(0,136,204,.3); color: #5bc0de; }
.alert-error   { background: rgba(220,53,69,.15);  border: 1px solid rgba(220,53,69,.3);  color: #ff7b7b; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: var(--text-sec); margin-bottom: 6px; font-weight: 500; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
.form-control:focus { border-color: var(--accent); }

/* ================================================================
   BLOG FEED (index.php)
   ================================================================ */

.blog-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}
.blog-header h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.blog-header p {
  color: var(--text-sec);
  margin-top: 8px;
  font-size: 16px;
}

/* Post card in feed */
.post-card {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
  transition: border-color .2s, transform .2s;
}
.post-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-card:last-child { margin-bottom: 0; }

.post-card-cover {
  display: block;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  background: var(--bg);
}
.post-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.post-card:hover .post-card-cover img { transform: scale(1.02); }

.post-card-cover-placeholder {
  aspect-ratio: 21 / 9;
  background: linear-gradient(135deg, var(--hover-field) 0%, var(--bg) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.post-card-cover-placeholder svg { width: 48px; height: 48px; opacity: .2; }

.post-card-body { padding: 24px 28px 28px; }

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.post-card-meta time { font-weight: 500; }
.post-card-meta .meta-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }

.post-card-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 10px;
  text-decoration: none;
  display: block;
}
.post-card-title:hover { color: var(--accent); opacity: 1; }

.post-card-excerpt {
  color: var(--text-sec);
  font-size: 15px;
  line-height: 1.65;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.post-read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.post-read-more svg { width: 14px; height: 14px; transition: transform .2s; }
.post-read-more:hover svg { transform: translateX(3px); }
.post-read-more:hover { opacity: 1; }

.post-card-stats {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.post-card-stats span { display: flex; align-items: center; gap: 4px; }
.post-card-stats svg { width: 14px; height: 14px; }

/* Feed empty state */
.feed-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}
.feed-empty svg { width: 56px; height: 56px; opacity: .3; margin: 0 auto 16px; }
.feed-empty p { font-size: 16px; }

/* Feed padding */
.feed-wrap { padding: 40px 0 80px; }

/* ================================================================
   SINGLE POST PAGE (post.php)
   ================================================================ */

/* Hero cover — full container width, 21:9 */
.post-hero {
  width: 100%;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  background: var(--field);
  border-radius: var(--radius);
  margin-bottom: 36px;
}
.post-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Article wrapper — narrower than container for readability */
.post-article-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
}
.post-content-inner {
  max-width: var(--article-w);
  margin: 0 auto;
}

.post-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.post-meta-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }

.post-title {
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin-bottom: 32px;
  color: var(--text);
}

/* Article body typography */
.post-body {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-sec);
}
.post-body p   { margin-bottom: 1.4em; }
.post-body p:last-child { margin-bottom: 0; }
.post-body h2  { font-size: 26px; font-weight: 700; color: var(--text); margin: 0; }
.post-body h3  { font-size: 21px; font-weight: 700; color: var(--text); margin: 1.8em 0 .5em; }
.post-body h4  { font-size: 18px; font-weight: 600; color: var(--text); margin: 1.5em 0 .4em; }
.post-body b, .post-body strong { color: var(--text); font-weight: 700; }
.post-body i, .post-body em     { font-style: italic; }
.post-body a   {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  word-break: break-word;
  transition: opacity .15s, text-decoration-thickness .15s;
}
.post-body a:hover { opacity: .8; text-decoration-thickness: 2px; }
.post-body ul, .post-body ol { margin: 1em 0 1em 1.5em; }
.post-body li  { margin-bottom: .4em; }
.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 1.5em 0;
  background: var(--field);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-sec);
  font-style: italic;
}
.post-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 1.5em auto;
}

/* Divider */
.post-divider {
  height: 1px;
  background: var(--border);
  margin: 40px 0;
}

/* Post footer: like + views */
.post-footer {
  display: flex;
  align-items: center;
  gap: 24px;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-sec);
  transition: border-color .2s, color .2s, background .2s;
  font-family: inherit;
}
.like-btn:hover { border-color: #e0245e; color: #e0245e; background: rgba(224,36,94,.07); }
.like-btn.liked  { border-color: #e0245e; color: #e0245e; background: rgba(224,36,94,.1); }
.like-btn svg { width: 20px; height: 20px; transition: transform .15s; }
.like-btn:hover svg, .like-btn.liked svg { transform: scale(1.15); }
.like-btn.liked svg path { fill: #e0245e; }

.view-count {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.view-count svg { width: 15px; height: 15px; }

/* ================================================================
   ADMIN PANEL (admin.php)
   ================================================================ */

.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}
.admin-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 28px;
}

/* Login box */
.login-box {
  max-width: 400px;
  margin: 80px auto;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
}
.login-box h1 { font-size: 22px; margin-bottom: 8px; }
.login-box p  { color: var(--text-sec); font-size: 14px; margin-bottom: 28px; }

/* Post list in admin */
.post-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 40px; }
.post-list-item {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.post-list-thumb {
  width: 80px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg);
  flex-shrink: 0;
}
.post-list-info { flex: 1; min-width: 0; }
.post-list-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-list-date  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.post-list-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Cover preview */
.cover-preview {
  aspect-ratio: 21 / 9;
  background: var(--bg);
  border: 1px dashed var(--muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s;
}
.cover-preview:hover { border-color: var(--accent); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.cover-preview .placeholder-text { color: var(--muted); font-size: 14px; text-align: center; pointer-events: none; }
.cover-preview .placeholder-text svg { width: 32px; height: 32px; margin: 0 auto 6px; display: block; opacity: .4; }

/* Rich-text editor */
.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tool-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-sec);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.tool-btn:hover  { background: var(--hover-field); color: var(--text); }
.tool-btn.active { background: var(--accent); color: #fff; }
.tool-sep { width: 1px; background: var(--border); margin: 4px 2px; align-self: stretch; }

.post-editor {
  width: 100%;
  min-height: 420px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  outline: none;
  font-family: inherit;
  overflow-y: auto;
  cursor: text;
}
.post-editor:focus { border-color: var(--accent); }
.post-editor p { margin-bottom: .8em; }
.post-editor b, .post-editor strong { color: var(--text); }
.post-editor a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.post-editor img { max-width: 100%; border-radius: 4px; margin: .5em 0; cursor: default; }
.post-editor blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: .8em 0;
  background: var(--field);
  border-radius: 0 4px 4px 0;
}
.post-editor [data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

/* Upload progress overlay for images */
.img-uploading {
  opacity: .5;
  pointer-events: none;
}

.topbar-label-mobile { display: none; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .container { padding: 0 16px; }
  .post-article-wrap { padding: 0 16px 60px; }
  .post-card-body { padding: 18px 20px 22px; }
  .blog-header { padding: 32px 0 24px; }
  .blog-header h1 { font-size: 28px; }
}

@media (max-width: 600px) {
  .post-card-title { font-size: 18px; }
  .post-card-meta  { font-size: 12px; }
  .post-hero       { border-radius: 0; margin-left: -16px; margin-right: -16px; width: calc(100% + 32px); }
  .post-title      { margin-bottom: 24px; }
  .post-body       { font-size: 16px; }
  .post-footer     { flex-wrap: wrap; gap: 14px; }
  .topbar          { padding: 0 16px; }
  .admin-wrap      { padding: 24px 14px 60px; }
  .post-list-thumb { display: none; }
  .topbar-label-desktop { display: none; }
  .topbar-label-mobile  { display: inline; }
}

/* ============================================================
   Short feed (Threads-style) — /blog/short/
   ============================================================ */

/* Single short post — extra space at the top of the body
   (no <h1> heading there, so content needs breathing room). */
.post-article-wrap.is-short .post-body { margin-top: 35px; }


.short-card {
  margin-bottom: 16px;
  padding: 20px 24px 16px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.short-card:hover { border-color: var(--hover-field); background: var(--hover-field); }
.short-meta-link {
  color: var(--text-sec);
  text-decoration: none;
}
.short-meta-link:hover { color: var(--text); opacity: 1; }

.short-preview,
.short-rest {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-sec);
}
.short-preview p,
.short-rest p { margin-bottom: .8em; }
.short-preview p:last-child,
.short-rest p:last-child { margin-bottom: 0; }
.short-preview b, .short-preview strong,
.short-rest b, .short-rest strong { color: var(--text); }
.short-preview a,
.short-rest a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-word;
}
.short-preview a:hover,
.short-rest a:hover { opacity: .8; }
.short-preview blockquote,
.short-rest blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 14px;
  margin: .8em 0;
  background: rgba(0,0,0,.15);
  border-radius: 0 4px 4px 0;
}
.short-rest { margin-top: .8em; }

.short-expand {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.short-expand:hover { opacity: .8; }
.short-expand:disabled { opacity: .5; cursor: wait; }

.short-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.short-meta time { color: var(--text-sec); }
.short-meta .meta-dot {
  width: 3px; height: 3px;
  background: var(--muted);
  border-radius: 50%;
}
.short-likes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.short-likes svg { width: 14px; height: 14px; }

/* ── Cross-recommendations on short-post page ──────────────── */
.reco {
  max-width: var(--article-w);
  margin: 28px auto 0;
  padding: 16px 20px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.reco-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sec);
  margin-bottom: 8px;
}
.reco-link {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}
.reco-link:hover { color: var(--accent); opacity: 1; }
.reco-arrow {
  color: var(--accent);
  font-size: 18px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .short-card { padding: 16px 18px 14px; border-radius: 8px; }
  .short-card-title { font-size: 16px; }
  .short-preview, .short-rest { font-size: 14.5px; }
  .reco { padding: 14px 16px; border-radius: 8px; }
  .reco-link { font-size: 15px; }
}
