:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-soft: #f6f6f5;
  --text: #16161a;
  --text-muted: #6f6f76;
  --text-faint: #a8a8ae;
  --border: #eaeae8;
  --pill-bg: #eeeeec;
  --pill-text: #55555c;
  --accent: #16161a;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(20,20,20,0.04), 0 8px 24px rgba(20,20,20,0.05);
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --gradient-1: linear-gradient(135deg, #9fd8e0, #4f93a8);
  --gradient-2: linear-gradient(135deg, #2f4d3a, #6b8f5c);
  --gradient-3: linear-gradient(135deg, #d9a441, #8a4f9e);
  --gradient-4: linear-gradient(135deg, #232323, #4a4a4a);
  --gradient-5: linear-gradient(135deg, #e6d5c3, #b98f6b);
}

:root[data-theme="dark"] {
  --bg: #131315;
  --surface: #1c1c1f;
  --surface-soft: #202023;
  --text: #f2f2f0;
  --text-muted: #a3a3a8;
  --text-faint: #6b6b70;
  --border: #2b2b2f;
  --pill-bg: #29292d;
  --pill-text: #c9c9cd;
  --accent: #f2f2f0;
  --accent-text: #16161a;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px rgba(0,0,0,0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131315;
    --surface: #1c1c1f;
    --surface-soft: #202023;
    --text: #f2f2f0;
    --text-muted: #a3a3a8;
    --text-faint: #6b6b70;
    --border: #2b2b2f;
    --pill-bg: #29292d;
    --pill-text: #c9c9cd;
    --accent: #f2f2f0;
    --accent-text: #16161a;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px rgba(0,0,0,0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 140px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 48px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.meta-text { white-space: nowrap; }
.meta-sep { color: var(--text-faint); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--surface-soft); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Profile card ---------- */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 32px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  background-size: cover;
  background-position: center;
}

.profile-id { flex: 1; min-width: 0; }

.profile-id h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

.profile-title {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.profile-social-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.intro-line {
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--pill-bg);
  color: var(--pill-text);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.bio {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bio p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.bio b {
  background: var(--pill-bg);
  color: var(--pill-text);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.93em;
}

/* ---------- Feed ---------- */
.feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 24px 20px;
  box-shadow: var(--shadow);
}

.post-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.post-meta .dot { color: var(--text-faint); }

.tag-pill {
  background: var(--pill-bg);
  color: var(--pill-text);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.post-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  margin: 0 0 4px;
}

.post-body {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 4px;
}

.post-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 16px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.post-gallery::-webkit-scrollbar { display: none; }

.post-gallery .ph-img {
  flex: 0 0 auto;
  width: 150px;
  height: 200px;
  border-radius: var(--radius-md);
}

.post-cover {
  margin-top: 16px;
}

.post-cover .ph-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
}

/* ---------- Placeholder image fills ---------- */
.ph-img { background: var(--gradient-1); }
.ph-img.g1 { background: var(--gradient-1); }
.ph-img.g2 { background: var(--gradient-2); }
.ph-img.g3 { background: var(--gradient-3); }
.ph-img.g4 { background: var(--gradient-4); }
.ph-img.g5 { background: var(--gradient-5); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------- Floating nav ---------- */
.floating-nav {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.tabs {
  display: flex;
  align-items: center;
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.send-btn { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.send-btn:hover { opacity: 0.9; background: var(--accent); }

/* ============================================================
   Detail pages (case studies, articles) — a single .post card
   with an intro hero + divided sections. Shared by work/*.html
   and writing/*.html so every detail page looks consistent.
   ============================================================ */

.detail-hero .eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 14px;
}
.detail-hero h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 14px;
}
.detail-hero .dek {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 22px;
}
.detail-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.detail-meta div { display: flex; flex-direction: column; gap: 3px; }
.detail-meta .label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.detail-meta .value { font-size: 13px; font-weight: 600; }

.detail-section {
  padding-top: 28px;
  margin-top: 28px;
  border-top: 1px solid var(--border);
}
.detail-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 14px;
}
.detail-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 10px;
}
.detail-section p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 14px;
}
.detail-section p:last-child { margin-bottom: 0; }
.detail-section ul, .detail-section ol {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.detail-section li { margin-bottom: 8px; }
.detail-section a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border); }
.detail-section a:hover { text-decoration-color: var(--text); }
.detail-section blockquote {
  margin: 0 0 14px;
  padding: 2px 16px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  font-style: italic;
}

figure { margin: 20px 0 0; }
figure img {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
figcaption {
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin-top: 8px;
}
figure.img-missing img { display: none; }
figure.img-missing::after {
  content: attr(data-fallback);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  aspect-ratio: 16 / 10;
  background: var(--surface-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-card .num {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.stat-card .cap { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.system-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0 16px;
}
.system-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.system-card h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.system-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.system-card li { font-size: 13px; line-height: 1.4; padding-left: 14px; position: relative; margin-bottom: 0; }
.system-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
}
.system-card li b { display: block; font-weight: 600; }
.system-card li span { color: var(--text-muted); font-size: 12px; }

.pairing-note {
  background: var(--pill-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 4px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.gallery-grid figure { margin-top: 0; }

.detail-quote {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  border-left: 2px solid var(--text);
  padding-left: 18px;
  margin: 0;
}

.impact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.impact-card {
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.impact-card .num { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.impact-card .cap { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.ref-card a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-faint);
}
.ref-card a:hover { border-color: var(--text); }

/* ---------- Initiative cards (a sub-project inside a case study) ---------- */
.initiative-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
}
.initiative-card:last-child { margin-bottom: 0; }
.initiative-card img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.initiative-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
}
.initiative-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
}
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-chip.shipped { color: #1a7a5e; background: rgba(26, 122, 94, 0.12); }
.status-chip.live { color: #2952cc; background: rgba(41, 82, 204, 0.12); }
.status-chip.hold { color: var(--text-muted); background: var(--pill-bg); }

/* ---------- Decision log (numbered timeline of choices in a case study) ---------- */
.decision-log {
  position: relative;
  padding-left: 44px;
  margin-top: 20px;
}
.decision-log::before {
  content: "";
  position: absolute;
  left: 15px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--border);
}
.decision-entry { position: relative; margin-bottom: 20px; }
.decision-entry:last-child { margin-bottom: 0; }
.decision-entry .idx {
  position: absolute;
  left: -44px; top: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.decision-entry .card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.decision-entry h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}
.decision-field { margin-bottom: 10px; }
.decision-field:last-child { margin-bottom: 0; }
.decision-field-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.decision-field-value { font-size: 13.5px; line-height: 1.6; color: var(--text); }
.decision-field-value.outcome {
  display: inline-block;
  background: var(--pill-bg);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
}
.decision-field ul { margin: 0; padding-left: 18px; }
.decision-field li { font-size: 13.5px; line-height: 1.6; margin-bottom: 4px; color: var(--text); }

.quote-tag {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

/* ---------- Destination grid, fare list, flight card, cabin chips (recreated app screens) ---------- */
.dest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0 8px;
}
.dest-card {
  color: #F2ECE0;
  border-radius: var(--radius-md);
  padding: 16px;
  height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}
.dest-card .km { font-size: 11px; opacity: 0.75; margin-bottom: 4px; }
.dest-card .name { font-size: 1.2rem; font-weight: 700; margin-bottom: 2px; }
.dest-card .tag { font-size: 12px; opacity: 0.75; }
.dest-card.moon { background: radial-gradient(circle at 70% 20%, #3a3a3a, #0d0d0d 70%); }
.dest-card.mars { background: linear-gradient(180deg, #8a7a6d, #6b4230); }
.dest-card.titan { background: linear-gradient(180deg, #2b1f45, #0e0a1c); }
.dest-card.belt { background: linear-gradient(180deg, #0d3b3f, #06181d); }

.fare-list {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 20px 0 8px;
}
.fare-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.fare-row:last-child { border-bottom: none; }
.fare-route { font-weight: 600; font-size: 14.5px; color: var(--text); }
.fare-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.fare-price { text-align: right; }
.fare-price .from { font-size: 11px; color: var(--text-muted); }
.fare-price .amt { font-weight: 600; color: var(--text); font-size: 14px; }

.flight-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin: 20px 0 8px;
}
.flight-card .crossing-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.flight-card h4 { font-size: 1.1rem; margin: 0 0 4px; font-weight: 700; color: var(--text); }
.flight-card .sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.flight-card .quote { font-style: italic; font-size: 14px; line-height: 1.6; color: var(--text); border-left: 2px solid var(--border); padding-left: 14px; margin: 0; }

.cabins { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.cabin-chip { font-size: 12px; padding: 8px 14px; border-radius: 999px; background: var(--pill-bg); color: var(--pill-text); }

/* ---------- Lock gate (password-protected detail pages) ---------- */
.fade-cutoff { position: relative; overflow: hidden; max-height: 220px; }
.fade-cutoff::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 120px;
  background: linear-gradient(to bottom, transparent, var(--surface));
}

.lock-gate {
  text-align: center;
  padding: 32px 16px 8px;
}
.lock-gate svg { color: var(--text-faint); margin-bottom: 16px; }
.lock-gate h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
.lock-gate p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin: 0 0 20px; max-width: 40ch; margin-inline: auto; }
.lock-gate a { color: var(--text); text-decoration: underline; }
.lock-gate input[type="password"] {
  width: 100%;
  max-width: 320px;
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--text);
  margin-bottom: 14px;
  text-align: center;
}
.lock-gate .unlock-btn {
  width: 100%;
  max-width: 320px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
.lock-gate .unlock-btn:hover { opacity: 0.9; }
.lock-gate .lock-error {
  display: none;
  font-size: 13px;
  color: #c0392b;
  margin: -6px 0 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .page { padding: 20px 14px 150px; }
  .profile-card { padding: 24px 20px 18px; }
  .floating-nav { padding: 5px; gap: 4px; }
  .tab { padding: 6px 10px; font-size: 12px; }
  .detail-meta { grid-template-columns: repeat(2, 1fr); }
  .stats-grid, .system-grid, .gallery-grid, .impact-grid { grid-template-columns: 1fr; }
  .decision-log { padding-left: 36px; }
  .decision-log::before { left: 11px; }
  .decision-entry .idx { left: -36px; width: 26px; height: 26px; font-size: 11px; }
  .dest-grid { grid-template-columns: 1fr; }
}
