:root{
  --bg0: #030405;
  --bg1: #07090b;
  --bg2: #0b0e10;

  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.72);
  --faint: rgba(255,255,255,0.54);
  --border: rgba(255,255,255,0.14);

  --aqua: #39e6d2;
  --aqua2: #19b7ff;

  --shadow: 0 18px 48px rgba(0,0,0,0.55);
  --radius: 18px;
  --container: 980px;
  --pad: clamp(16px, 3vw, 28px);

  /* Reader / Article system (used by blog article view) */
  --article-width: 820px;              /* overall article shell width */
  --measure: 70ch;                     /* comfortable line length */
  --prose-font: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --prose-size: clamp(16px, 1.05vw, 18px);
  --prose-leading: 1.75;
  --prose-color: rgba(255,255,255,0.90);
  --prose-muted: rgba(255,255,255,0.68);
  --prose-rule: rgba(255,255,255,0.10);
  --prose-link: rgba(57,230,210,0.95);
  --prose-code-bg: rgba(255,255,255,0.06);
  --prose-code-border: rgba(255,255,255,0.12);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #000; /* solid black (replaces gradient) */
  color: var(--text);
  line-height:1.45;

  /* small quality-of-life improvements (safe site-wide) */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection{
  background: rgba(57,230,210,0.22);
}

a{ color: inherit; text-decoration:none; }

img{
  max-width: 100%;
  height: auto;
}

code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  padding: 0.15em 0.35em;
  border-radius: 10px;
}

pre{
  margin: 0;
  white-space: pre;
  overflow:auto;
}

.container{
  width: min(var(--container), calc(100% - (var(--pad) * 2)));
  margin: 0 auto;
}

.sr-only{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

.glass{
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.34);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Header */
.site-header{
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(2,3,4,0.70);
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.nav{
  position: relative; /* anchors mobile menu */
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 0;
  gap: 14px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 10px;
}

.brand-logo{
  display:block;
  height: 75px;       /* keep native size when possible */
  width: auto;
  max-height: 75px;   /* never upscale */
  max-width: 300px;
  object-fit: contain;
}

.nav-links{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  flex: 1 1 auto;
}

.nav-link{
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav-link:hover{
  color: var(--text);
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

.nav-link.is-active{
  color: var(--text);
  border-color: rgba(57,230,210,0.35);
  background: rgba(57,230,210,0.10);
}

.nav-actions{
  display:flex;
  align-items:center;
  gap: 10px;
}

.nav-icon svg{
  width: 18px;
  height: 18px;
  stroke: rgba(255,255,255,0.90);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-toggle{
  display:none;
  appearance:none;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 10px 12px;
  cursor:pointer;
}

.nav-toggle-bars{
  display:block;
  width: 18px;
  height: 12px;
  position: relative;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after{
  content:"";
  position:absolute;
  left:0; right:0;
  height:2px;
  border-radius: 2px;
  background: rgba(255,255,255,0.85);
}
.nav-toggle-bars::before{ top:0; }
.nav-toggle-bars::after{ bottom:0; }

/* Inputs */
.input{
  background: rgba(0,0,0,0.32);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
  min-height: 42px;
}
.input::placeholder{ color: rgba(255,255,255,0.45); }

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 900;
  letter-spacing: 0.2px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor:pointer;
  min-height: 42px;
}

.btn:hover{
  border-color: rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
}

.btn-primary{
  border-color: rgba(57,230,210,0.45);
  background: linear-gradient(135deg, rgba(57,230,210,0.20), rgba(25,183,255,0.10));
  box-shadow: 0 10px 26px rgba(0,0,0,0.35), 0 0 0 6px rgba(57,230,210,0.07);
}
.btn-primary:hover{
  border-color: rgba(57,230,210,0.70);
  background: linear-gradient(135deg, rgba(57,230,210,0.26), rgba(25,183,255,0.14));
}

.btn-ghost{ background: rgba(0,0,0,0.22); }

.btn-link{
  border: none;
  background: transparent;
  padding: 0;
  min-height: unset;
  font-weight: 900;
  color: rgba(57,230,210,0.95);
}
.btn-link:hover{ text-decoration: underline; }

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor:pointer;
}
.icon-btn:hover{
  border-color: rgba(57,230,210,0.35);
  background: rgba(57,230,210,0.10);
}

/* Home layout */
.home{
  position: relative;
  min-height: 100vh;
  padding: 26px 0 18px;
}

.home-stack{
  position: relative;
  z-index: 2;
  display:flex;
  flex-direction: column;
  gap: 14px;
}

/* Welcome */
.welcome{ padding: 18px; }

.welcome-kicker{
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.welcome-title{
  margin: 10px 0 10px;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.05;
}
.welcome-text{
  margin: 0 0 14px;
  color: var(--muted);
  max-width: 70ch;
}
.welcome-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.welcome-meta{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}
.stat{
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 16px;
  padding: 12px 14px;
  min-width: 120px;
}
.stat-k{ font-weight: 900; font-size: 18px; }
.stat-v{ color: var(--faint); font-size: 13px; }

/* Latest */
.latest{ padding: 16px; }

.latest-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.latest-kicker{
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.latest-title{
  font-weight: 900;
  margin-top: 6px;
  font-size: 18px;
}

/* Segmented */
.segmented{
  display:inline-flex;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  overflow:hidden;
}
.seg-btn{
  appearance:none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  cursor:pointer;
  font-weight: 900;
  letter-spacing: 0.2px;
}
.seg-btn.is-active{
  color: var(--text);
  background: rgba(57,230,210,0.12);
  box-shadow: inset 0 0 0 1px rgba(57,230,210,0.25);
}

/* Carousel (DO NOT change these if you want a carousel) */
.carousel-viewport{
  overflow:hidden;
  border-radius: 16px;
}
.carousel-track{
  display:flex;
  gap: 12px;
  padding: 4px;
  transform: translateX(0);
  transition: transform 280ms ease;
  will-change: transform;
}
.carousel-item{
  flex: 0 0 240px;
  border-radius: 16px;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  box-shadow: 0 10px 26px rgba(0,0,0,0.40);
  cursor: pointer;
}
.carousel-thumb{
  height: 140px;
  background:
    radial-gradient(700px 260px at 20% 20%, rgba(57,230,210,0.16), transparent 60%),
    radial-gradient(700px 260px at 90% 20%, rgba(25,183,255,0.10), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.carousel-body{
  padding: 12px;
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.carousel-item-title{
  font-weight: 900;
  font-size: 14px;
  line-height: 1.2;
  margin:0;
}
.carousel-item-summary{
  margin:0;
  color: var(--muted);
  font-size: 13px;
}
.carousel-item-meta{
  color: var(--faint);
  font-size: 12px;
}
.latest-foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.carousel-controls{ display:flex; gap: 8px; }
.latest-hint{ color: var(--faint); font-size: 13px; }
.latest-links{ display:flex; gap: 12px; flex-wrap: wrap; }

/* -------------------------------------------------------
   Blog / Article Reader Styles
-------------------------------------------------------- */

.empty-state{
  margin-top: 12px;
  text-align: center;
  color: var(--faint);
  padding: 18px;
  border: 1px dashed rgba(255,255,255,0.16);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
}

/* Article wrapper inside the .latest glass panel */
.article-shell{
  width: 100%;
  max-width: min(var(--article-width), 100%);
  margin: 0 auto;
  padding: clamp(8px, 1.4vw, 18px) 0;
}

/* Back link above title */
.article-back{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
  font-weight: 900;
}

/* Title and metadata */
.article-title{
  margin: 0;
  font-size: clamp(26px, 2.2vw, 40px);
  font-weight: 1000;
  letter-spacing: -0.03em;
  line-height: 1.10;
  max-width: var(--measure);
}

.article-meta{
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: rgba(255,255,255,0.58);
}

/* Optional featured image */
.article-image{
  margin-top: 16px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  box-shadow: 0 10px 26px rgba(0,0,0,0.30);
}
.article-image img{
  width: 100%;
  height: auto;
  display: block;
}

/* Primary prose body
   FIX: preserve author line breaks even when JS renders entry as "HTML"
   (HTML collapses raw newlines unless white-space preserves them). */
.article-body{
  margin-top: 18px;
  max-width: var(--measure);

  font-family: var(--prose-font);
  font-size: var(--prose-size);
  line-height: var(--prose-leading);
  color: var(--prose-color);

  /* Line-break preservation (fix for "single blob of text") */
  white-space: pre-wrap;
  word-break: break-word;
}

/* If entry is plain text, preserve line breaks (kept for clarity / compatibility) */
.article-body.is-text{
  white-space: pre-wrap;
  word-break: break-word;
}

/* Spacing rhythm */
.article-body > *{
  margin-top: 0;
  margin-bottom: 0;
}
.article-body > * + *{
  margin-top: 0.95em;
}

/* Headings inside article body (if HTML entry includes them) */
.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4{
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  max-width: var(--measure);
}

.article-body h1{ font-size: clamp(24px, 1.9vw, 30px); font-weight: 950; }
.article-body h2{ font-size: clamp(20px, 1.6vw, 26px); font-weight: 950; }
.article-body h3{ font-size: clamp(18px, 1.35vw, 22px); font-weight: 900; }
.article-body h4{ font-size: 16px; font-weight: 900; color: rgba(255,255,255,0.88); }

.article-body p{
  max-width: var(--measure);
  color: var(--prose-color);
}

/* Links in articles should look like links */
.article-body a{
  color: var(--prose-link);
  text-decoration: underline;
  text-decoration-color: rgba(57,230,210,0.45);
  text-underline-offset: 3px;
}
.article-body a:hover{
  text-decoration-color: rgba(57,230,210,0.85);
}

/* Lists */
.article-body ul,
.article-body ol{
  padding-left: 1.25em;
  max-width: var(--measure);
  color: var(--prose-color);
}
.article-body li{
  margin: 0.35em 0;
}

/* Blockquotes */
.article-body blockquote{
  margin: 1.1em 0;
  padding: 0.8em 1.0em;
  border-left: 3px solid rgba(57,230,210,0.55);
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  color: rgba(255,255,255,0.86);
  max-width: var(--measure);
}
.article-body blockquote p{
  margin: 0;
}

/* Horizontal rule */
.article-body hr{
  border: none;
  height: 1px;
  background: var(--prose-rule);
  margin: 1.2em 0;
  max-width: var(--measure);
}

/* Inline code already styled; add block code styling */
.article-body pre{
  margin: 1.1em 0;
  padding: 14px 14px;
  border-radius: 16px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 26px rgba(0,0,0,0.28);
  max-width: var(--measure);
}
.article-body pre code{
  display: block;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.92em;
  line-height: 1.55;
}

/* Tables */
.article-body table{
  width: 100%;
  border-collapse: collapse;
  margin: 1.1em 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  overflow: hidden;
  max-width: var(--measure);
}
.article-body th,
.article-body td{
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.article-body th{
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.62);
  background: rgba(255,255,255,0.03);
}
.article-body td{
  color: rgba(255,255,255,0.86);
}

/* Images inside article body */
.article-body img{
  display: block;
  margin: 1.0em 0;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.02);
  box-shadow: 0 10px 26px rgba(0,0,0,0.25);
  max-width: 100%;
}

/* Small “kicker” style if you ever add it to entries */
.article-body .kicker{
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--prose-muted);
}

/* -------------------------------------------------------
   Chat FAB + Modal
-------------------------------------------------------- */
.chat-fab{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(57,230,210,0.45);
  background: linear-gradient(135deg, rgba(57,230,210,0.18), rgba(25,183,255,0.08));
  box-shadow: 0 14px 34px rgba(0,0,0,0.55), 0 0 0 8px rgba(57,230,210,0.08);
  color: var(--text);
  cursor:pointer;
}
.chat-fab:hover{ border-color: rgba(57,230,210,0.70); }
.chat-fab-icon{ display:block; font-size: 18px; }

.modal{
  position: fixed;
  inset: 0;
  z-index: 90;
  display:none;
}
.modal.is-open{ display:block; }
.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,0.60);
}
.modal-card{
  position:absolute;
  right: 18px;
  bottom: 90px;
  width: min(420px, calc(100% - 36px));
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.modal-kicker{
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.modal-title{
  font-weight: 900;
  margin-top: 6px;
}
.chat-body{
  padding: 12px 14px;
  height: 260px;
  overflow:auto;
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.msg{
  max-width: 85%;
  border-radius: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 14px;
}
.msg.user{
  align-self: flex-end;
  border-color: rgba(57,230,210,0.30);
  background: rgba(57,230,210,0.10);
}
.msg.bot{ align-self: flex-start; }
.chat-form{
  display:flex;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.10);
}
.chat-input{ flex: 1 1 auto; }
.chat-note{
  padding: 0 14px 14px;
  color: var(--faint);
  font-size: 12px;
}

/* Footer */
.footer{
  border-top: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.25);
  padding: 18px 0;
}
.footer-grid{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-left-line{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-brand-text{
  font-weight: 800;
  letter-spacing: 0.2px;
  color: rgba(255,255,255,0.92);
}
.footer-note-inline{
  color: rgba(255,255,255,0.54);
  font-size: 13px;
}
.footer-right{ display:flex; gap: 12px; flex-wrap: wrap; }
.footer-link{
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
}
.footer-link:hover{
  color: var(--text);
  border-color: rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}

/* Responsive */
@media (max-width: 760px){
  .brand-logo{
    height: 44px;
    max-height: 44px;
    max-width: 220px;
  }

  .nav-toggle{ display:inline-flex; }

  .nav-links{
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    display:none;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(4,6,7,0.92);
    box-shadow: var(--shadow);
    z-index: 60;
  }
  .nav-links.is-open{ display:flex; }

  /* Article spacing tweaks for small screens */
  .article-title{
    letter-spacing: -0.02em;
  }
  .article-meta{
    gap: 8px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* Admin page helpers (global; safe to keep) */
.admin-panel{ display:none; }
.admin-panel.is-active{ display:block; }

.admin-block{ margin-top: 10px; }
.admin-block.is-hidden{ display:none; }

.admin-row{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap: wrap;
}
.admin-row-end{ justify-content: flex-end; }

.admin-search{ flex: 1 1 260px; }

.admin-form{ margin-top: 8px; }

.admin-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}
.admin-field-full{ grid-column: 1 / -1; }

.admin-label{
  display:block;
  margin: 0 0 6px;
  color: var(--faint);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.admin-textarea{
  width: 100%;
  resize: vertical;
  min-height: 44px;
  padding-top: 10px;
}

.admin-table{
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.02);
}

/* 5 columns: Title, Author, Category, Date, Actions */
.admin-thead, .admin-tr{
  display:grid;
  grid-template-columns: 1.6fr 0.9fr 0.9fr 0.9fr 1.0fr;
  gap: 10px;
  align-items:center;
  padding: 12px;
}

.admin-thead{
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-th{
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
}

.admin-tr{
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.admin-tr:last-child{ border-bottom: none; }

.admin-td{ color: var(--muted); font-size: 14px; }
.admin-title{ color: var(--text); font-weight: 900; }
.admin-sub{ color: rgba(255,255,255,0.45); font-size: 12px; margin-top: 4px; }

.admin-actions{ display:flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.admin-mini{ min-height: 36px; padding: 8px 10px; border-radius: 12px; font-weight: 900; }

.admin-danger{
  border-color: rgba(255,120,120,0.25);
  background: rgba(255,120,120,0.06);
}
.admin-danger:hover{
  border-color: rgba(255,120,120,0.45);
  background: rgba(255,120,120,0.10);
}

@media (max-width: 760px){
  .admin-grid{ grid-template-columns: 1fr; }
  .admin-thead{ display:none; }         /* optional: hide header on mobile */
  .admin-tr{ grid-template-columns: 1fr; }
  .admin-actions{ justify-content: flex-start; }
}
