@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@300;400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple:        #534AB7;
  --purple-light:  #AFA9EC;
  --purple-bg:     #F0EEFF;
  --purple-border: #D4CFEF;
  --bg:            #F9F8FC;
  --card:          #FFFFFF;
  --text:          #1A1A1A;
  --muted:         #6E6E8A;
  --faint:         #9B9BB4;
  --border:        #ECEAF8;
  --border-strong: #D4CFEF;
  --green:         #15803D;
  --green-bg:      #F0FDF4;
  --green-border:  #BBF7D0;
  --red:           #DC2626;
  --red-bg:        #FFF5F5;
  --red-border:    #FECACA;
  --serif:  'Playfair Display', Georgia, 'Times New Roman', serif;
  --mono:   'IBM Plex Mono', 'Courier New', monospace;
  --body:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max:    1160px;
  --r:      6px;
  --r-sm:   4px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

img, iframe, embed, video {
  max-width: 100%;
  height: auto;
}
iframe { aspect-ratio: 16/9; width: 100%; }

/* ── NAV ─────────────────────────────────────────────────── */
.site-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: -0.02em;
}
.nav-logo:hover { text-decoration: none; }
.nav-links { display: flex; gap: 28px; list-style: none; }
.nav-links a {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  transition: color 0.15s;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover { color: var(--purple); text-decoration: none; border-bottom-color: var(--purple); }
.nav-links a.active { color: var(--purple); text-decoration: none; }

/* ── HERO ────────────────────────────────────────────────── */
.hero {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 72px 24px 60px;
}
.hero-inner { max-width: var(--max); margin: 0 auto; }
.hero-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--purple-light);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-label::before { content: '//'; color: var(--purple); font-weight: 500; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 60px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.025em;
  color: var(--text);
  max-width: 680px;
  margin-bottom: 22px;
}
.hero h1 em { font-style: italic; color: var(--purple); }
.hero-sub {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  max-width: 520px;
  border-left: 2px solid var(--purple-light);
  padding-left: 14px;
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.main-layout {
  max-width: var(--max);
  margin: 0 auto;
  padding: 52px 24px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 52px;
  align-items: start;
}

/* ── SECTION HEADER ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.section-title {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}
.section-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

/* ── POST CARDS ──────────────────────────────────────────── */
.posts-grid { display: flex; flex-direction: column; gap: 18px; }

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r);
  padding: 28px 30px 28px 28px;
  transition: border-color 0.2s, border-left-color 0.25s, box-shadow 0.2s, transform 0.15s;
}
.post-card:hover {
  border-color: var(--purple-light);
  border-left-color: var(--purple-light);
  box-shadow: 0 8px 28px rgba(83,74,183,0.10), 0 2px 6px rgba(0,0,0,0.04);
  transform: translateY(-2px);
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.post-card-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.04em;
}
.post-card-title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 10px;
  transition: color 0.15s;
}
.post-card:hover .post-card-title { color: var(--purple); }
.post-card-excerpt {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 18px;
}
.read-more {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--purple);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.read-more:hover { text-decoration: none; opacity: 0.8; }
.read-more::after { content: ' →'; }

/* ── TICKER & BADGE ──────────────────────────────────────── */
.ticker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  background: #EEEDFE;
  color: #3C3489;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid #C9C5F0;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.irr {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  letter-spacing: 0.04em;
}
.irr-pos { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.irr-neg { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.empty-state-icon { font-size: 32px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
}
.sidebar-card-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--faint);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-card-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.positions-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.position-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Holding info: ticker pill + company name side by side */
.holding-info { display: flex; flex-direction: row; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.holding-name {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Neutral weight badge (no colour signal — just a label) */
.pos-badge-neutral {
  background: var(--purple-bg);
  color: var(--purple);
  border: 1px solid var(--purple-border);
}

/* Sector breakdown */
.sector-list { display: flex; flex-direction: column; gap: 7px; }
.sector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sector-pill {
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
}
.sector-pct {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Portfolio metadata */
.port-updated {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  letter-spacing: 0.03em;
}
.port-empty {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  line-height: 1.6;
}
.port-empty code {
  background: var(--purple-bg);
  color: var(--purple);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
}
.framework-quote {
  font-family: var(--serif);
  font-size: 14.5px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 10px;
}
.framework-attr {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}
.built-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.built-list li {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.5;
}
.built-list li::before { content: '>'; color: var(--purple); font-weight: 500; flex-shrink: 0; }

/* ── FOOTER ──────────────────────────────────────────────── */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  margin-top: 40px;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer-copy, .footer-disc, .footer-ready {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: 0.03em;
}
.cursor {
  display: inline-block;
  color: var(--purple);
  font-weight: 700;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100%{ opacity:1; } 50%{ opacity:0; } }

/* ── POST PAGE ───────────────────────────────────────────── */
.post-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px 24px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 52px;
  align-items: start;
}
.post-back {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  transition: color 0.15s;
}
.post-back:hover { color: var(--purple); text-decoration: none; }
.post-back::before { content: '←'; }
.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.post-date {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: 0.04em;
}
.post-title {
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
}
.post-divider { height: 1px; background: var(--border); margin: 32px 0; }
.post-body {
  font-size: 17px;
  line-height: 1.82;
  color: var(--text);
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}
.post-body h1,.post-body h2,.post-body h3 {
  font-family: var(--serif);
  margin-top: 2em;
  margin-bottom: 0.6em;
  letter-spacing: -0.015em;
}
.post-body h2 { font-size: 26px; }
.post-body h3 { font-size: 20px; }
.post-body p { margin-bottom: 1.4em; }
.post-body a { color: var(--purple); border-bottom: 1px solid var(--purple-border); }
.post-body a:hover { border-color: var(--purple); text-decoration: none; }
.post-body blockquote {
  border-left: 3px solid var(--purple-light);
  padding: 14px 22px;
  margin: 26px 0;
  background: var(--purple-bg);
  border-radius: 0 var(--r) var(--r) 0;
  font-style: italic;
  color: var(--muted);
}
.post-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--purple-bg);
  color: var(--purple);
  padding: 2px 6px;
  border-radius: 3px;
}
.post-body pre {
  background: #1E1B4B;
  color: #E8E5FF;
  padding: 22px 26px;
  border-radius: var(--r);
  overflow-x: auto;
  margin: 24px 0;
}
.post-body pre code { background: none; color: inherit; padding: 0; font-size: 13.5px; }
.post-body ul,.post-body ol { padding-left: 26px; margin-bottom: 1.4em; }
.post-body li { margin-bottom: 0.4em; }
.post-body table { width: 100%; border-collapse: collapse; margin: 26px 0; font-size: 15px; }
.post-body th {
  background: var(--purple-bg);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--purple-border);
  color: var(--purple);
}
.post-body td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.post-body tr:last-child td { border-bottom: none; }
.post-sidebar { display: flex; flex-direction: column; gap: 20px; }

/* ── ADMIN ───────────────────────────────────────────────── */
body.admin-bg { background: #EEECFB; min-height: 100vh; }

.admin-nav {
  background: var(--purple);
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-nav-logo { font-family: var(--mono); font-size: 13px; color: rgba(255,255,255,0.92); letter-spacing: 0.04em; }
.admin-nav-right { display: flex; gap: 18px; align-items: center; }
.admin-nav-link {
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.04em;
  transition: color 0.15s;
}
.admin-nav-link:hover { color: white; text-decoration: none; }

.admin-wrap { max-width: 920px; margin: 0 auto; padding: 36px 24px; }
.admin-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 30px 32px;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.admin-title { font-family: var(--serif); font-size: 22px; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary   { background: var(--purple); color: white; }
.btn-primary:hover { background: #4338A8; color: white; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--purple); border: 1px solid var(--purple-border); }
.btn-secondary:hover { background: var(--purple-bg); text-decoration: none; }
.btn-success   { background: var(--green); color: white; }
.btn-success:hover { background: #166534; color: white; text-decoration: none; }
.btn-danger    { background: transparent; color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover { background: var(--red-bg); text-decoration: none; }
.btn-sm  { padding: 4px 10px; font-size: 11px; }
.btn-xs  { padding: 3px 8px; font-size: 10.5px; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .title-cell { color: var(--text); font-weight: 500; max-width: 300px; }
.tbl-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.status-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 3px;
}
.pill-live  { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.pill-draft { background: #F3F4F6; color: #6B7280; border: 1px solid #E5E7EB; }

/* Form */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 7px;
}
.form-label span { color: var(--red); margin-left: 2px; }
.form-input, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: var(--body);
  color: var(--text);
  background: var(--card);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus, .form-textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(83,74,183,0.1);
}
.form-textarea {
  font-family: var(--mono);
  font-size: 13px;
  min-height: 420px;
  resize: vertical;
  line-height: 1.6;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-top: 5px;
}
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 6px;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.form-check input[type="checkbox"] { accent-color: var(--purple); width: 15px; height: 15px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 40px;
}
.login-logo { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--purple); margin-bottom: 6px; }
.login-sub  { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-bottom: 30px; }

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 18px;
}
.alert-err { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }
.alert-ok  { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

/* ── POSITION BADGES (sidebar) ───────────────────────────── */
.pos-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pos-badge-pos { background: #EAF3DE; color: #27500A; border: 1px solid #C0DAA0; }
.pos-badge-neg { background: #FCEBEB; color: #791F1F; border: 1px solid #EDBBBB; }

/* ── EDITOR TOOLBAR ─────────────────────────────────────── */
.fmt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--body);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.fmt-btn:hover { background: var(--purple-bg); border-color: var(--purple-light); color: var(--purple); }
.fmt-btn:active { background: var(--purple-border); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .main-layout { grid-template-columns: 1fr; padding: 36px 20px; gap: 32px; }
  .post-wrap   { grid-template-columns: 1fr; padding: 36px 20px; }
  .sidebar, .post-sidebar { display: none; }
  .hero { padding: 48px 20px 40px; }
  .hero h1 { font-size: 34px; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
  .form-row { grid-template-columns: 1fr; }
  .post-body { font-size: 16px; }
}

@media (max-width: 600px) {
  .nav-inner { padding: 0 16px; height: 54px; }
  .nav-links { gap: 18px; }
  .nav-links li:last-child { display: none; }

  .hero { padding: 36px 16px 30px; }
  .hero h1 { font-size: 28px; letter-spacing: -0.02em; }
  .hero-label { font-size: 10.5px; }
  .hero-sub { font-size: 12px; }

  .main-layout { padding: 24px 16px; }
  .post-wrap { padding: 24px 16px; }

  .post-card { padding: 20px 18px 20px 16px; }
  .post-card-title { font-size: 18px; }
  .post-card-excerpt { font-size: 14px; }

  .post-title { font-size: 26px; }
  .post-body { font-size: 15.5px; line-height: 1.75; }
  .post-body h2 { font-size: 22px; }
  .post-body h3 { font-size: 18px; }

  .section-header { margin-bottom: 16px; }
  .site-footer { padding: 22px 16px; }

  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 500px) {
  .nav-links li:nth-child(n+3) { display: none; }
  .admin-wrap { padding: 20px 16px; }
  .admin-panel { padding: 20px; }
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) { display: none; }
}

/* Tables always scroll on small screens rather than overflow */
@media (max-width: 700px) {
  .post-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--r);
  }
}
