/* ═══════════════════════════════════════════════════
   PERSONAL STREAM — Stylesheet
   Aesthetic: Editorial serif warmth meets mono precision
   ═══════════════════════════════════════════════════ */

:root {
  --ink:       #1a1614;
  --paper:     #f7f3ee;
  --warm:      #e8e0d4;
  --accent:    #c8410a;
  --accent2:   #4a7c59;
  --muted:     #8a7f76;
  --border:    #d4ccc4;
  --card-bg:   #fdfaf7;
  --code-bg:   #ede9e2;
  --serif:     'Fraunces', Georgia, serif;
  --serif2:    'Instrument Serif', Georgia, serif;
  --mono:      'DM Mono', 'Courier New', monospace;
  --radius:    4px;
  --shadow:    0 1px 3px rgba(26,22,20,0.08), 0 4px 16px rgba(26,22,20,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; scroll-behavior: smooth; }
body { background: var(--paper); color: var(--ink); font-family: var(--serif2); line-height: 1.65; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header { border-bottom: 1px solid var(--border); background: rgba(247,243,238,0.92); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(8px); }
.header-inner { max-width: 680px; margin: 0 auto; padding: 0.85rem 1.5rem; display: flex; align-items: center; justify-content: space-between; }
.site-brand { font-family: var(--serif); font-size: 1.25rem; font-weight: 300; color: var(--ink); letter-spacing: 0.01em; }
.site-brand:hover { text-decoration: none; opacity: 0.75; }
.site-nav { display: flex; gap: 1.2rem; align-items: center; }
.site-nav a { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav .nav-admin { color: var(--accent); }

.site-main { flex: 1; max-width: 680px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; width: 100%; }
.site-footer { border-top: 1px solid var(--border); text-align: center; padding: 1.5rem; font-family: var(--mono); font-size: 0.68rem; color: var(--muted); letter-spacing: 0.04em; }
.site-footer a { color: var(--muted); }

.compose-area { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 2.5rem; box-shadow: var(--shadow); }
.compose-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; flex-wrap: wrap; }
.tab-btn { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; background: none; border: 1px solid transparent; padding: 0.3rem 0.75rem; border-radius: 2px; cursor: pointer; color: var(--muted); transition: all 0.15s; }
.tab-btn:hover { color: var(--ink); border-color: var(--border); }
.tab-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(200,65,10,0.06); }
.compose-panel { display: none; }
.compose-panel.active { display: block; }

textarea, input[type=text], input[type=url], input[type=password], input[type=email], select { width: 100%; padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); color: var(--ink); font-family: var(--serif2); font-size: 1rem; resize: vertical; transition: border-color 0.15s; margin-bottom: 0.6rem; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); }

.form-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.form-row > * { flex: 1; }

.btn { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.6rem 1.2rem; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: var(--radius); cursor: pointer; transition: all 0.15s; white-space: nowrap; display: inline-block; }
.btn:hover { background: #a33408; border-color: #a33408; text-decoration: none; }
.btn-outline { background: transparent; color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.65rem; }
.btn-danger { border-color: #c0392b; background: #c0392b; }
.btn-danger:hover { background: #a93226; border-color: #a93226; }
.btn-green { border-color: var(--accent2); background: var(--accent2); }
.btn-green:hover { background: #3a6347; border-color: #3a6347; }

.syndi-options { display: flex; gap: 1rem; align-items: center; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.syndi-options label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.04em; color: var(--muted); display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.syndi-options input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }
.syndi-options .btn { margin-left: auto; }

.timeline { display: flex; flex-direction: column; }
.post-card { padding: 1.4rem 0; border-bottom: 1px solid var(--border); position: relative; animation: fadeSlide 0.3s ease both; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.post-meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.65rem; }
.post-type-icon { font-size: 0.75rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--warm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.post-time { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); letter-spacing: 0.04em; }
.post-time a { color: var(--muted); }
.post-time a:hover { color: var(--ink); text-decoration: none; }
.syndication-badges { display: flex; gap: 0.3rem; margin-left: auto; align-items: center; }
.badge { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.05em; padding: 0.1rem 0.45rem; border-radius: 20px; border: 1px solid var(--border); color: var(--muted); }
.badge-bs { border-color: #0085ff40; color: #0055bb; background: #0085ff08; }
.badge-ma { border-color: #6364ff40; color: #4444cc; background: #6364ff08; }

.post-content { font-size: 1.05rem; line-height: 1.7; color: var(--ink); }
.post-content p { margin-bottom: 0.5em; }
.post-content p:last-child { margin-bottom: 0; }

.post-image { margin-top: 0.85rem; border-radius: var(--radius); overflow: hidden; background: var(--warm); }
.post-image img { width: 100%; display: block; max-height: 500px; object-fit: cover; }
.post-video { margin-top: 0.85rem; border-radius: var(--radius); overflow: hidden; }
.post-video video { width: 100%; display: block; border-radius: var(--radius); }

.post-location { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.72rem; color: var(--accent2); letter-spacing: 0.03em; margin-top: 0.5rem; background: rgba(74,124,89,0.08); padding: 0.3rem 0.7rem; border-radius: 20px; }
.post-link-card { margin-top: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1rem; background: var(--warm); }
.post-link-card .link-title { font-weight: 400; font-size: 0.95rem; color: var(--ink); display: block; margin-bottom: 0.25rem; }
.post-link-card .link-desc { font-size: 0.82rem; color: var(--muted); display: block; margin-bottom: 0.35rem; }
.post-link-card .link-url { font-family: var(--mono); font-size: 0.65rem; color: var(--accent); letter-spacing: 0.03em; word-break: break-all; }

.reactions { margin-top: 0.85rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.reaction-likes { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.6rem; }
.reaction-count { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); letter-spacing: 0.04em; }
.like-avatar { width: 1.4rem; height: 1.4rem; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.like-avatar-placeholder { width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--warm); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 0.6rem; color: var(--muted); }

.reaction-replies { display: flex; flex-direction: column; gap: 0.6rem; }
.reply-item { display: grid; grid-template-columns: 1.5rem 1fr; gap: 0.5rem; align-items: flex-start; }
.reply-avatar { width: 1.5rem; height: 1.5rem; border-radius: 50%; object-fit: cover; }
.reply-body {}
.reply-author { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); letter-spacing: 0.03em; margin-bottom: 0.15rem; }
.reply-text { font-size: 0.9rem; line-height: 1.55; }

.post-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; padding-top: 0.6rem; }
.load-more-wrap { text-align: center; padding: 2rem 0; }

.auth-wrap { max-width: 360px; margin: 6rem auto; padding: 0 1.5rem; }
.auth-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow); }
.auth-title { font-family: var(--serif); font-size: 1.8rem; font-weight: 300; margin-bottom: 0.35rem; font-style: italic; }
.auth-sub { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); letter-spacing: 0.04em; margin-bottom: 1.5rem; }
.error-msg { background: rgba(192,57,43,0.08); border: 1px solid rgba(192,57,43,0.25); color: #c0392b; padding: 0.6rem 0.85rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; }
.success-msg { background: rgba(74,124,89,0.08); border: 1px solid rgba(74,124,89,0.25); color: var(--accent2); padding: 0.6rem 0.85rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; }

.admin-wrap { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }
.admin-grid { display: grid; grid-template-columns: 200px 1fr; gap: 2rem; align-items: start; }
.admin-sidebar { position: sticky; top: 5rem; }
.admin-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.admin-nav a { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 0.5rem 0.75rem; border-radius: var(--radius); transition: all 0.15s; }
.admin-nav a:hover { color: var(--ink); background: var(--warm); text-decoration: none; }
.admin-nav a.active { color: var(--accent); background: rgba(200,65,10,0.06); }
.admin-section { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.admin-section h2 { font-family: var(--serif); font-size: 1.1rem; font-weight: 300; margin-bottom: 1rem; color: var(--ink); }
.admin-section label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 0.3rem; margin-top: 0.75rem; }
.admin-section .hint { font-size: 0.78rem; color: var(--muted); margin-top: -0.3rem; margin-bottom: 0.5rem; }
.admin-section h3 { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-top: 1.5rem; margin-bottom: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }

.post-single { padding-top: 2rem; }
.back-link { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); display: inline-block; margin-bottom: 1.5rem; }
.back-link:hover { color: var(--ink); text-decoration: none; }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state .big { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state p { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; }
.visibility-private { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); padding: 0.1rem 0.4rem; border-radius: 2px; }
.refresh-note { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); letter-spacing: 0.03em; margin-top: 0.4rem; }

@media (max-width: 600px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
}

/* ── DARK MODE BASE ── */
[data-theme="dark"] body,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { } }

[data-theme="dark"] .site-header,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-header { } }

/* Simpler approach: cascade overrides via data-theme on <html> */
[data-theme="dark"] textarea,
[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=url],
[data-theme="dark"] input[type=password],
[data-theme="dark"] input[type=email],
[data-theme="dark"] select {
  background: var(--warm);
  color: var(--ink);
  border-color: var(--border);
}

[data-theme="dark"] .btn {
  background: var(--accent);
  border-color: var(--accent);
}

[data-theme="dark"] .btn-outline {
  background: transparent;
  color: var(--accent);
}

[data-theme="dark"] .site-header {
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border-color: var(--border);
}

/* auto mode dark mirrors */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) input[type=text],
  :root:not([data-theme="light"]) input[type=url],
  :root:not([data-theme="light"]) input[type=password],
  :root:not([data-theme="light"]) input[type=email],
  :root:not([data-theme="light"]) select {
    background: var(--warm);
    color: var(--ink);
    border-color: var(--border);
  }
}

/* ── NAV APPEARANCE LINK ── */
.nav-appearance {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted) !important;
  opacity: 0.8;
  transition: opacity 0.15s, color 0.15s;
}
.nav-appearance:hover {
  color: var(--ink) !important;
  opacity: 1;
  text-decoration: none;
}

/* ── APPEARANCE PAGE ── */
.appearance-wrap { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
.appearance-wrap h1 {
  font-family: 'Instrument Serif', var(--font-body, serif);
  font-size: 1.8rem;
  font-weight: 300;
  font-style: italic;
  margin-bottom: 0.35rem;
}
.appear-subtitle {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}
.appear-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.appear-section-title {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  text-align: center;
}
.mode-card:hover { border-color: var(--muted); }
.mode-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.mode-card input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.mode-preview {
  height: 52px;
  border-radius: 3px;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: flex-end;
  padding: 0.4rem;
  gap: 3px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.1);
}
.mode-preview-light { background: #f7f3ee; }
.mode-preview-dark  { background: #1a1714; }
.mode-preview-auto  {
  background: linear-gradient(135deg, #f7f3ee 50%, #1a1714 50%);
}
.mode-bar {
  height: 4px;
  border-radius: 2px;
  flex: 1;
  background: #c8410a;
  opacity: 0.7;
}
.mode-bar.dark { background: #e06b3a; }
.mode-card-label {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
}
.mode-card-desc {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-family: var(--font-body, serif);
  font-style: italic;
}

/* Font grid */
.font-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.font-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.font-card:hover { border-color: var(--muted); }
.font-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.font-card input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.font-sample {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink);
  margin-bottom: 0.35rem;
}
.font-label {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.font-desc {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 0.1rem;
  letter-spacing: 0.02em;
}

/* Accent swatches */
.accent-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.accent-swatch {
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.15s;
  position: relative;
}
.accent-swatch:hover { transform: scale(1.1); }
.accent-swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.accent-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.accent-label {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--muted);
  margin-top: 0.35rem;
  text-transform: uppercase;
}

/* Size selector */
.size-row { display: flex; gap: 0.65rem; }
.size-card {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  position: relative;
}
.size-card:hover { border-color: var(--muted); }
.size-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.size-card input { position: absolute; opacity: 0; pointer-events: none; }
.size-example {
  display: block;
  color: var(--ink);
  margin-bottom: 0.25rem;
  line-height: 1;
}
.size-card-label {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Live preview panel */
.preview-panel {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.preview-panel::before {
  content: 'PREVIEW';
  position: absolute;
  top: 0.6rem;
  right: 0.875rem;
  font-family: var(--font-ui, var(--mono));
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  opacity: 0.5;
}
.preview-post-meta {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.preview-post-text {
  font-family: var(--font-body, serif);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
}
.preview-accent-link { color: var(--accent); }

.appear-save-bar {
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  margin: 0 -1.5rem -5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.saved-indicator {
  font-family: var(--font-ui, var(--mono));
  font-size: 0.68rem;
  color: #4a7c59;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.3s;
}
.saved-indicator.show { opacity: 1; }
