:root {
  /* MindSync brand tokens (mirrors the landing page light theme) */
  --background: 0 0% 100%;
  --foreground: 215 25% 27%;
  --muted: 215 16% 47%;
  --primary: 217 91% 35%;
  --primary-hover: 217 91% 40%;
  --primary-foreground: 0 0% 98%;
  --accent: 173 80% 40%;
  --border: 214 32% 91%;
  --panel: 210 40% 98%;
  --danger: 0 72% 51%;
}

* {
  box-sizing: border-box;
}

/* Author styles that set `display` would otherwise override the HTML hidden attribute. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: hsl(var(--foreground));
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 20px 96px;
}

.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 20px 96px;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  border-bottom: 1px solid hsl(var(--border));
}

.brand {
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  width: 112px;
  height: auto;
}

.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover {
  color: hsl(var(--primary));
}

.muted {
  color: hsl(var(--muted));
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 36px 0 0;
}

.post-list li {
  border-bottom: 1px solid hsl(var(--border));
  padding: 22px 0;
}

.post-list h2 {
  margin: 0 0 4px;
  font-size: 1.3rem;
  font-weight: 700;
}

.post-list a:hover h2 {
  color: hsl(var(--primary));
}

/* Blog index rows */
.post-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px;
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
}

.post-row {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  background: hsl(var(--background));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.01), 0 1px 2px rgba(0, 0, 0, 0.02);
}

.post-row:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px -10px hsl(var(--foreground) / 0.08);
  border-color: hsl(var(--primary) / 0.35);
}

.post-row-thumb-link {
  width: 100%;
}

.post-row-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  background: hsl(var(--panel));
  transition: transform 0.2s ease;
}

.post-row:hover .post-row-thumb {
  transform: scale(1.02);
}

.post-row-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: hsl(var(--primary));
  background: linear-gradient(135deg, hsl(var(--panel)), hsl(var(--accent) / 0.12));
}

.post-row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.post-row-text h2 {
  margin: 0 0 8px;
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.post-row:hover .post-row-text h2 {
  color: hsl(var(--primary));
}

.post-row-excerpt {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: hsl(var(--muted));
}

.post-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  font-size: 0.8rem;
}

@media (max-width: 560px) {
  .post-row {
    padding: 16px;
  }
}

/* Like button */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted));
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.like-btn:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.08);
  border-color: hsl(var(--primary) / 0.35);
  color: hsl(var(--primary));
}

.like-btn.liked {
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.4);
  color: hsl(var(--primary));
  opacity: 1;
}

.like-btn:not(.liked) span[aria-hidden] {
  opacity: 0.45;
}

.like-btn:disabled {
  cursor: default;
}

.like-btn-lg {
  padding: 10px 20px;
  font-size: 1rem;
}

.post-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid hsl(var(--border));
}

/* Share buttons */
.share-buttons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.share-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 2px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted));
  border-radius: 999px;
  cursor: pointer;
  font-size: 0;
  line-height: 1;
}

.share-btn:hover {
  background: hsl(var(--primary) / 0.08);
  border-color: hsl(var(--primary) / 0.35);
  color: hsl(var(--primary));
}

.share-buttons-lg .share-btn {
  width: 38px;
  height: 38px;
}

.share-copied {
  font-size: 0.8rem;
  color: hsl(var(--accent));
  font-weight: 600;
}

/* Rendered admin HTML */
.post-content {
  margin-top: 28px;
  font-size: 1.05rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

.post-content a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 8px 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid hsl(var(--border));
  margin: 2.5em 0;
}

.post-content pre {
  overflow-x: auto;
  background: hsl(var(--panel));
  border: 1px solid hsl(var(--border));
  padding: 16px;
  border-radius: 10px;
}

.post-content blockquote {
  border-left: 3px solid hsl(var(--accent));
  margin: 1.5em 0;
  padding-left: 1.2em;
  color: hsl(var(--muted));
}

/* Form controls (admin) */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: hsl(var(--muted));
}

input[type="text"],
input[type="password"],
textarea {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  color: hsl(var(--foreground));
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-height: 320px;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
}

button {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover {
  background: hsl(var(--primary-hover));
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

button.ghost:hover {
  background: hsl(var(--panel));
}

button.danger {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--danger));
  padding: 6px 12px;
  font-size: 0.8rem;
}

.notice {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.notice.error {
  background: hsl(var(--danger) / 0.1);
  border: 1px solid hsl(var(--danger) / 0.35);
  color: hsl(var(--danger));
}

.notice.success {
  background: hsl(var(--accent) / 0.12);
  border: 1px solid hsl(var(--accent) / 0.4);
  color: hsl(173 80% 28%);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.admin-post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid hsl(var(--border));
  padding: 12px 0;
}

/* 404 */
.not-found {
  text-align: center;
  padding-top: 96px;
}

.not-found .nf-code {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0;
  color: hsl(var(--primary));
}

.not-found h1 {
  margin: 8px 0 8px;
}

.not-found .nf-link {
  display: inline-block;
  margin-top: 28px;
  font-weight: 600;
  color: hsl(var(--primary));
}

.not-found .nf-link:hover {
  color: hsl(var(--primary-hover));
}

/* Creative Hero Banner */
.blog-hero {
  position: relative;
  background: linear-gradient(135deg, hsl(217 91% 8%), hsl(217 60% 12%));
  color: #ffffff;
  padding: 96px 24px;
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid hsl(var(--border));
}

/* Glow radial gradient effect */
.blog-hero::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, hsl(var(--primary) / 0.25) 0%, transparent 70%);
  filter: blur(40px);
  pointer-events: none;
}

.blog-hero::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 200px;
  background: radial-gradient(ellipse at bottom, hsl(var(--accent) / 0.15) 0%, transparent 60%);
  filter: blur(30px);
  pointer-events: none;
}

.blog-hero-content {
  position: relative;
  max-width: 680px;
  margin: 0 auto;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.blog-hero-title {
  font-size: 3.8rem;
  font-weight: 800;
  line-height: 1.1;
  color: #ffffff;
  margin: 0 0 18px;
  letter-spacing: -0.03em;
}

.blog-hero-divider {
  width: 64px;
  height: 4px;
  background: hsl(var(--accent));
  border-radius: 2px;
  margin-bottom: 24px;
}

.blog-hero-subtitle {
  font-size: 1.15rem;
  line-height: 1.65;
  color: hsl(217 20% 82%);
  margin: 0;
  font-weight: 400;
}

@media (max-width: 560px) {
  .blog-hero {
    padding: 64px 20px;
  }
  .blog-hero-title {
    font-size: 2.8rem;
  }
  .blog-hero-subtitle {
    font-size: 1rem;
  }
}

/* Site Footer */
.site-footer {
  background: hsl(var(--panel));
  border-top: 1px solid hsl(var(--border));
  padding: 32px 24px;
  margin-top: 64px;
}

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-bottom p {
  font-size: 0.85rem;
  margin: 0;
}

@media (max-width: 768px) {
  .site-footer {
    padding: 24px 20px;
  }
}

.nav-links {
  display: flex;
  gap: 20px;
}

.footer-policies {
  display: flex;
  gap: 16px;
}

.footer-policies a {
  font-size: 0.85rem;
  color: hsl(var(--muted));
  transition: color 0.15s ease;
}

.footer-policies a:hover {
  color: hsl(var(--primary));
}

@media (max-width: 560px) {
  .footer-bottom {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

/* Admin Layout with Sidebar */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}

.admin-sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 160px);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid hsl(var(--border));
  padding-right: 32px;
}

.sidebar-header {
  padding-bottom: 12px;
  border-bottom: 1px solid hsl(var(--border));
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: hsl(var(--foreground));
  letter-spacing: -0.02em;
}

.sidebar-header .email {
  font-size: 0.8rem;
  color: hsl(var(--muted));
  display: block;
  margin-top: 4px;
  word-break: break-all;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: hsl(var(--muted));
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.sidebar-nav .nav-item span {
  font-size: 1.1rem;
}

.sidebar-nav .nav-item:hover {
  background: hsl(var(--panel));
  color: hsl(var(--foreground));
}

.sidebar-nav .nav-item.active {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.15);
}

.signout-btn {
  margin-top: auto;
  width: 100%;
}

.admin-content {
  min-width: 0;
}

@media (max-width: 860px) {
  .admin-layout {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-top: 36px;
  }
  
  .admin-sidebar {
    position: static;
    height: auto;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border));
    padding-right: 0;
    padding-bottom: 24px;
    gap: 16px;
  }
  
  .sidebar-header {
    border-bottom: none;
    padding-bottom: 0;
  }
  
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .sidebar-nav .nav-item {
    width: auto;
  }
  
  .signout-btn {
    margin-top: 0;
    width: auto;
    align-self: flex-start;
  }
}
