:root {
  --bg: #ffffff;
  --fg: #18181b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --card: #f9fafb;
  --accent: #2563eb;
  --maxw: 680px;
}

[data-theme="dark"] {
  --bg: #0e0e10;
  --fg: #ededed;
  --muted: #9ca3af;
  --border: #262629;
  --card: #18181b;
  --accent: #7aa2ff;
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute always wins over display:flex/inline-block etc. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, "Apple Color Emoji", sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 8px;
}
.site-header a.brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-actions a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.header-actions a:hover { color: var(--fg); }

button.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.icon-btn:hover { border-color: var(--muted); }

/* Sections */
section { padding: 40px 0; }
.section-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 18px;
}

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.25; }
.intro h1 { font-size: 2rem; margin: 0 0 12px; }
.intro p { color: var(--fg); }
.muted { color: var(--muted); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.contacts { color: var(--muted); font-size: 0.95rem; margin-top: 18px; }
.contacts span { white-space: nowrap; }
.contacts .sep { margin: 0 10px; opacity: 0.5; }

hr.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* Post list */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 18px 0; border-bottom: 1px solid var(--border); }
.post-list li:last-child { border-bottom: none; }
.post-list a.post-link { color: var(--fg); font-size: 1.2rem; font-weight: 600; }
.post-list .post-meta { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.empty { color: var(--muted); font-style: italic; }

/* Article */
article.post h1 { font-size: 2rem; margin: 6px 0 6px; }
.post-date { color: var(--muted); font-size: 0.88rem; margin-bottom: 28px; }
.content { font-size: 1.05rem; }
.content h1, .content h2, .content h3 { margin-top: 1.6em; }
.content p, .content ul, .content ol { margin: 1em 0; }
.content pre {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9rem;
}
.content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}
.content :not(pre) > code {
  background: var(--card);
  padding: 2px 6px;
  border-radius: 4px;
}
.content blockquote {
  margin: 1em 0;
  padding-left: 16px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.content img { max-width: 100%; border-radius: 8px; }

.back-link { display: inline-block; margin: 24px 0; color: var(--muted); font-size: 0.9rem; }

/* Comments */
.comments { margin-top: 48px; border-top: 1px solid var(--border); padding-top: 28px; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment .who { font-weight: 600; font-size: 0.95rem; }
.comment .when { color: var(--muted); font-size: 0.8rem; margin-left: 8px; }
.comment .body { margin-top: 4px; white-space: pre-wrap; word-wrap: break-word; }

form.comment-form { margin: 20px 0 8px; display: flex; flex-direction: column; gap: 10px; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn.ghost { background: none; color: var(--fg); border: 1px solid var(--border); }
.btn.danger { background: none; color: #dc2626; border: 1px solid var(--border); padding: 5px 10px; font-size: 0.82rem; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.notice { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; color: var(--muted); font-size: 0.92rem; }
.error { color: #dc2626; font-size: 0.9rem; }
.field-label { font-size: 0.85rem; color: var(--muted); margin-bottom: -4px; }

/* Admin */
.admin-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.admin-row .title { font-weight: 600; }
.badge { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.live { color: #16a34a; border-color: #16a34a55; }

/* Likes */
.like-bar { margin: 4px 0 24px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--border); color: var(--fg);
  border-radius: 999px; padding: 6px 16px; font: inherit; cursor: pointer;
}
.like-btn:hover:not(:disabled) { border-color: var(--muted); }
.like-btn:disabled { cursor: default; opacity: 0.75; }
.like-btn.on { color: #dc2626; border-color: #dc262655; }
.like-btn .heart { font-size: 1.05rem; line-height: 1; }

.comment-del {
  background: none; border: none; color: var(--muted);
  font: inherit; font-size: 0.8rem; cursor: pointer; margin-left: 10px; padding: 0;
}
.comment-del:hover { color: #dc2626; }

/* Per-comment actions: like / reply / delete */
.comment-actions { display: flex; gap: 16px; margin-top: 6px; }
.clike-btn, .reply-btn {
  background: none; border: none; color: var(--muted);
  font: inherit; font-size: 0.8rem; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.clike-btn:hover:not(:disabled), .reply-btn:hover { color: var(--fg); }
.clike-btn.on { color: #dc2626; }
.clike-btn:disabled { cursor: default; }
.reply-children { margin-left: 18px; border-left: 1px solid var(--border); padding-left: 16px; }
.reply-form { margin: 10px 0 6px; }

/* Account: tabs + activity */
.auth-tabs { display: flex; gap: 20px; margin-bottom: 22px; }
.auth-tabs button {
  background: none; border: none; color: var(--muted);
  font: inherit; cursor: pointer; padding: 0 0 4px;
}
.auth-tabs button.active { color: var(--fg); font-weight: 600; border-bottom: 2px solid var(--accent); }

.agree-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.88rem; color: var(--muted); }
.agree-row input { width: auto; margin-top: 3px; flex: none; }

.signed-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.signed-in .who { font-weight: 600; }

.activity-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-item .meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

footer { padding: 40px 0; color: var(--muted); font-size: 0.85rem; text-align: center; }
