/* ==========================================================================
   Aperture 22 — Central Stylesheet
   Design tokens, shared components, and responsive utilities.
   ========================================================================== */

/* ── Design Tokens ────────────────────────────────────────────────────────── */

:root {
  /* Aliases onto master tokens in shared.css */
  --color-bg:           var(--bg-secondary);
  --color-surface:      var(--bg-card);
  --color-border:       var(--border);
  --color-text:         var(--text-primary);
  --color-text-muted:   var(--text-secondary);
  --color-accent:       var(--accent-fill);
  --color-accent-halo:  var(--accent-glow);
  --color-overlay:      rgba(26, 26, 24, 0.55);
  /* NB: this was `--color-success: var(--color-success)` — a self-reference,
     which is guaranteed-invalid, so --color-success resolved to the empty
     string on every page loading this file. shared.css's #2F7D4F now stands. */
  --color-danger:       var(--color-error);

  --font-body: var(--font-primary);
  --font-ui: var(--font-primary);

  --max-width-content: 720px;
  --max-width-admin: 900px;

  --space-xs: 0.35rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */

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

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ui);
  font-weight: 500;
  line-height: 1.25;
  color: var(--accent-primary);
}

a {
  color: var(--accent-primary);
  text-decoration: underline;
}

a:hover {
  opacity: 0.75;
}

/* ── Layout Containers ────────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--max-width-content);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.container--wide {
  max-width: var(--max-width-admin);
}

/* ── Page Wrapper ─────────────────────────────────────────────────────────── */

.page-wrap {
  padding: var(--space-xl) var(--space-md);
}

/* ── Divider ──────────────────────────────────────────────────────────────── */

.divider {
  width: 48px;
  height: 1px;
  background: #E5E7EB;
  margin: var(--space-md) auto;
  border: none;
}

/* ── Page Header ──────────────────────────────────────────────────────────── */

.site-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.site-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.site-header h1 a {
  color: inherit;
  text-decoration: none;
}

.site-header p {
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* ── App Nav ──────────────────────────────────────────────────────────────── */

.app-nav {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.app-nav a {
  text-decoration: none;
  font-size: 14px;
  color: var(--text-secondary);
}

.app-nav a:hover {
  color: var(--text-heading);
}

.app-nav a.active {
  font-weight: 600;
  color: var(--text-heading);
}

[data-theme="dark"] .app-nav a {
  color: #E0E0E0;
}

[data-theme="dark"] .app-nav a:hover {
  color: #F5F5F7;
}

[data-theme="dark"] .app-nav a.active {
  color: var(--accent-primary);
}

/* ── Tag Chip ─────────────────────────────────────────────────────────────── */

.tag {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-family: var(--font-ui);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-family: var(--font-ui);
  font-weight: 500;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: var(--accent-on);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.2s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--text-secondary);
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--accent-primary);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.panel h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--accent-primary);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.panel-header h2 {
  margin-bottom: 0;
}

/* ── Form Inputs ──────────────────────────────────────────────────────────── */

.editor-group {
  margin-bottom: var(--space-md);
}

.editor-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--color-text-muted);
  font-family: var(--font-ui);
}

.editor-group input,
.editor-group textarea,
.editor-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  background: var(--color-surface);
  color: var(--color-text);
}

.editor-group input:focus,
.editor-group textarea:focus,
.editor-group select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.editor-group textarea {
  min-height: 250px;
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.6;
}

.editor-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

/* ── Status Messages ──────────────────────────────────────────────────────── */

.status-msg {
  padding: 0.75rem var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-family: var(--font-ui);
  margin-bottom: var(--space-md);
  display: none;
}

.status-msg.show {
  display: block;
}

.status-msg.success {
  background: rgba(34, 197, 94, 0.10);
  color: var(--color-success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-msg.error {
  background: #fce4ec;
  color: var(--color-danger);
  border: 1px solid #f8bbd0;
}

/* ── Actions Bar ──────────────────────────────────────────────────────────── */

.actions-bar {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* ── Drop Zone ────────────────────────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.dragover {
  border-color: var(--color-accent);
  background: rgba(44, 44, 42, 0.04);
}

.drop-zone input[type="file"] {
  display: none;
}

/* ── Image Previews ───────────────────────────────────────────────────────── */

.image-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: var(--space-md);
}

.image-preview {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  background: var(--color-surface);
}

.image-preview-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.image-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}

.image-preview .remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-alt {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.image-preview-alt label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.image-alt-row {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}

.image-alt-input {
  flex: 1;
  min-height: 3rem;
  resize: vertical;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  color: var(--color-text);
  background: var(--color-bg);
}

.image-alt-gen-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Editing Banner ───────────────────────────────────────────────────────── */

.editing-banner {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-family: var(--font-ui);
  color: #5d4037;
  margin-bottom: var(--space-md);
}

/* ── Utility — Muted hint text ────────────────────────────────────────────── */

.hint {
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.hint-block {
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.75rem 0;
  list-style: none;
}

.hint-center {
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 1rem;
  text-align: center;
}

.error-inline {
  color: var(--color-danger);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.hint-block--error {
  color: var(--color-danger);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.75rem 0;
  list-style: none;
}

.auth-gate > p {
  margin-bottom: var(--space-md);
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.loading,
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--color-text-muted);
  font-style: italic;
  font-family: var(--font-ui);
}

.error-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-danger);
  font-family: var(--font-ui);
}

/* ── Auth Gate ────────────────────────────────────────────────────────────── */

.auth-gate {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
}

.auth-gate input {
  width: 100%;
  padding: 0.75rem var(--space-md);
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-family: var(--font-ui);
  background: var(--color-surface);
  color: var(--color-text);
}

.auth-gate input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* ── Published Entries List ───────────────────────────────────────────────── */

.entry-list {
  list-style: none;
}

.entry-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.entry-item:last-child {
  border-bottom: none;
}

.entry-item-info {
  flex: 1;
  min-width: 0;
}

.entry-item-title {
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-item-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  margin-top: 0.2rem;
}

.entry-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ── Queue List ───────────────────────────────────────────────────────────── */

.queue-list {
  max-height: 500px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.queue-item:last-child {
  border-bottom: none;
}

.queue-item input[type="checkbox"] {
  margin-top: 0.3rem;
  accent-color: var(--color-accent);
  flex-shrink: 0;
}

.queue-item-details {
  flex: 1;
  font-size: 0.85rem;
  font-family: var(--font-ui);
  min-width: 0;
}

.queue-item-details .commit-msg {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.queue-item-details .commit-meta {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* ── Day Groups (Queue) ───────────────────────────────────────────────────── */

.day-group {
  margin-bottom: 0.25rem;
}

.day-group:last-child {
  margin-bottom: 0;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 2px solid var(--color-border);
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.day-label {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.day-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.day-items {
  list-style: none;
}

/* ── Phase Timeline ───────────────────────────────────────────────────────── */

.phase-timeline {
  margin: 0 0 2.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* subtle scroll hint on small screens */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.phase-timeline-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 480px;
  position: relative;
  padding: 0.5rem 0 0;
}

/* Background connector line */
.phase-timeline-inner::before {
  content: '';
  position: absolute;
  top: 1.25rem;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

/* Progress connector line (width driven by inline --timeline-progress) */
.phase-timeline-inner::after {
  content: '';
  position: absolute;
  top: 1.25rem;
  left: 0;
  width: var(--timeline-progress, 0%);
  height: 2px;
  background: var(--color-accent);
  transition: width 0.4s ease;
  z-index: 0;
}

.phase-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  position: relative;
  z-index: 1;
}

.phase-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}

/* Completed phases */
.phase-node.done .phase-dot {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

/* Active phase */
.phase-node.active .phase-dot {
  background: var(--color-surface);
  border-color: var(--color-accent);
  border-width: 2px;
  box-shadow: 0 0 0 3px var(--color-accent-halo);
}

.phase-node.active .phase-dot::after {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent);
}

.phase-label {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-align: center;
  letter-spacing: 0.03em;
  line-height: 1.3;
  max-width: 64px;
  text-transform: uppercase;
}

.phase-node.done .phase-label {
  color: var(--accent-primary);
}

.phase-node.active .phase-label {
  color: var(--accent-primary);
  font-weight: 700;
}

/* Mobile portrait: show a 5-phase sliding window, no forced horizontal scroll */
@media (max-width: 540px) and (orientation: portrait) {
  .phase-timeline {
    overflow-x: visible;
  }

  .phase-timeline-inner {
    min-width: 0;
  }

  .phase-timeline-inner::after {
    width: var(--timeline-progress-mobile, 0%);
  }

  .phase-mobile-hidden {
    display: none;
  }
}

/* ── Journal Card List ────────────────────────────────────────────────────── */

.journal-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.entry-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}

.entry-card:hover,
.entry-card:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  outline: none;
}

.entry-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.card-date {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 6rem;
}

.card-main {
  flex: 1;
  min-width: 0;
}

.card-meta {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.card-meta .tag {
  font-size: 0.7rem;
}

.card-title {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-excerpt {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-arrow {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
  align-self: center;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
  z-index: 1100;
  overflow-y: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: var(--max-width-content);
  width: 100%;
  position: relative;
  margin: auto;
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.2rem 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1.5;
}

.modal-close:hover {
  border-color: var(--color-accent);
  color: var(--accent-primary);
}

.modal-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.modal-meta .tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
}

.modal-title {
  font-family: var(--font-ui);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 1.25rem;
  padding-right: 3rem;
  line-height: 1.3;
}

.modal-divider {
  width: 32px;
  height: 1px;
  background: var(--color-border);
  margin: 0 0 1.25rem;
  border: none;
}

.modal-body {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text);
}

.modal-body p { margin-bottom: 0.85rem; }
.modal-body h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; font-family: var(--font-ui); font-weight: 600; }
.modal-body ul,
.modal-body ol { margin: 0.5rem 0 0.85rem 1.5rem; }
.modal-body li { margin-bottom: 0.25rem; }
.modal-body code { background: var(--color-bg); padding: 0.1em 0.3em; border-radius: var(--radius-sm); font-size: 0.9em; border: 1px solid var(--color-border); }
.modal-body pre { background: var(--color-accent); color: var(--color-bg); padding: var(--space-md); border-radius: var(--radius-md); overflow-x: auto; margin: 0.85rem 0; }
.modal-body pre code { background: none; color: inherit; border: none; }
.modal-body a { color: var(--accent-primary); }
.modal-body strong { font-weight: 600; }

.modal-images {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: var(--space-lg);
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.modal-image-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.modal-images img,
.modal-image-figure img {
  max-width: 100%;
  width: auto;
  max-height: 420px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  object-fit: cover;
}

.image-tagline {
  margin-top: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.45;
  max-width: 100%;
}

/* ── Demo Page ─────────────────────────────────────────────────────────────── */

.demo-page {
  font-family: var(--font-ui);
  padding: var(--space-xl) var(--space-md);
}

.demo-shell {
  max-width: 1300px;
  margin: 0 auto;
}

.demo-header {
  margin-bottom: var(--space-lg);
}

.demo-header p {
  font-family: var(--font-ui);
}

.demo-eyebrow {
  display: inline-block;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 0.2rem 0.55rem;
  margin-bottom: 0.6rem;
}

.demo-auth-gate {
  margin: 2.5rem auto;
}

.demo-auth-help {
  margin-top: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.demo-token-label {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  margin-bottom: 0.35rem;
  text-align: left;
}

.demo-content[hidden] {
  display: none;
}

.demo-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

.demo-column {
  min-width: 0;
}

.demo-panel {
  padding: var(--space-md);
}

.demo-panel + .demo-panel {
  margin-top: var(--space-md);
}

.demo-panel h3 {
  font-size: 1rem;
  margin-bottom: 0.55rem;
}

.demo-subtle {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.demo-upload-box {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  padding: var(--space-md);
}

.demo-upload-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}

.demo-chip-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.demo-chip {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.78rem;
  background: var(--color-bg);
}

.demo-keyvals {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.demo-kv {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.35rem;
}

.demo-kv span:first-child {
  color: var(--color-text-muted);
}

.demo-slider {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

.demo-slider-frame {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 260px;
}

.demo-photo {
  position: relative;
  background: linear-gradient(145deg, #dbdbd4, #f7f7f2);
}

.demo-photo::after {
  content: attr(data-label);
  position: absolute;
  left: 0.65rem;
  top: 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}

.demo-slider-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.demo-analysis-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

.demo-progress-item + .demo-progress-item {
  margin-top: 0.55rem;
}

.demo-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.demo-progress-track {
  margin-top: 0.3rem;
  height: 0.4rem;
  background: #eaeae3;
  border-radius: 999px;
  overflow: hidden;
}

.demo-progress-fill {
  height: 100%;
  background: var(--color-accent);
}

.demo-bullets {
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.demo-bullets li {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
}

.demo-zones {
  display: grid;
  gap: 0.45rem;
}

.demo-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
}

.demo-zone strong {
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.demo-chat {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  padding: 0.6rem;
  display: grid;
  gap: 0.4rem;
}

.demo-chat-bubble {
  border-radius: var(--radius-md);
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.demo-chat-bubble--assistant {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.demo-chat-bubble--user {
  background: rgba(44, 44, 42, 0.08);
  border: 1px solid rgba(44, 44, 42, 0.14);
}

.demo-list {
  list-style: none;
  display: grid;
  gap: 0.45rem;
}

.demo-list li {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.35rem;
  font-size: 0.82rem;
}

.demo-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

@media (min-width: 860px) {
  .demo-grid {
    grid-template-columns: 280px minmax(0, 1fr) 300px;
    align-items: start;
  }

  .demo-analysis-grid {
    grid-template-columns: 1.3fr 1fr;
  }
}

/* ==========================================================================
   Responsive — Mobile-first breakpoints
   ========================================================================== */

/* ── Small (≤ 520px) ──────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  body {
    padding-inline: 0;
  }

  .page-wrap {
    padding: var(--space-lg) var(--space-sm);
  }

  .site-header {
    margin-bottom: var(--space-xl);
  }

  .site-header h1 {
    font-size: 1.5rem;
  }

  /* Card list — stacked, boxed layout on mobile */
  .journal-list {
    gap: 0.75rem;
  }

  .entry-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 1rem;
    border-radius: var(--radius-xl);
  }

  .card-date {
    min-width: unset;
    font-size: 0.7rem;
  }

  .card-title {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: 1rem;
    line-height: 1.4;
  }

  .card-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    text-overflow: unset;
    font-size: 0.8rem;
    line-height: 1.5;
  }

  .card-arrow {
    display: none;
  }

  /* Modal */
  .modal {
    padding: 1.25rem;
  }

  .modal-title {
    font-size: 1.2rem;
  }

  /* Panel */
  .panel {
    padding: var(--space-md);
  }

  /* Entry item actions: stack below info */
  .entry-item {
    flex-wrap: wrap;
  }

  .entry-item-actions {
    width: 100%;
    justify-content: flex-start;
  }

  /* Actions bar: full-width buttons */
  .actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-bar .btn {
    text-align: center;
    justify-content: center;
  }

  /* Drop zone: tighten padding */
  .drop-zone {
    padding: var(--space-lg);
  }
}

/* ── Medium (≥ 521px) — 2-column editor row ──────────────────────────────── */
@media (min-width: 521px) {
  .editor-row {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    padding: 1.5rem;
  }
}

/* ── Large (≥ 769px) — 3-column editor row ───────────────────────────────── */
@media (min-width: 769px) {
  .editor-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Dark Mode Overrides — styles.css components ─────────────────────────── */
[data-theme="dark"] body {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

[data-theme="dark"] .modal {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}

[data-theme="dark"] .modal-header {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .modal-footer {
  border-top-color: var(--border);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--bg-input, #2A2A2A);
  border-color: var(--border-input);
  color: var(--text-primary);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--accent-fill);
  outline-color: var(--accent-fill);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #777777;
}

[data-theme="dark"] .btn,
[data-theme="dark"] button[type="submit"],
[data-theme="dark"] .btn-primary {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--accent-on);
}

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

[data-theme="dark"] pre,
[data-theme="dark"] .modal-body pre {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

[data-theme="dark"] .success-message,
[data-theme="dark"] .feedback-success-message {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-success);
  border-color: rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .error-message,
[data-theme="dark"] .feedback-error-message {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-error);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ── Mobile Touch Fixes ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Prevent iOS auto-zoom on input focus (requires font-size >= 16px) */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Minimum 44px touch targets (Apple HIG) */
  .overlay-rail button,
  .toolstrip button,
  .pack-weight-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .slider-grip {
    width: 32px;
    height: 32px;
  }
}
