/* ==========================================================================
   brannonblair — Observatory visual system
   ========================================================================== */

/* ============ PALETTE ============ */
:root {
  --bg-deep:        #07091a;
  --bg-base:        #0a0e1f;
  --surface-1:      rgba(15, 20, 38, 0.65);
  --surface-2:      rgba(20, 26, 48, 0.78);
  --surface-solid:  #11162a;

  --border-dim:     rgba(94, 234, 212, 0.10);
  --border-active:  rgba(94, 234, 212, 0.45);

  --text-primary:   #e6edf6;
  --text-secondary: #9aa6b7;
  --text-tertiary:  #5e6a82;

  --accent-cyan:        #5eead4;
  --accent-cyan-dim:    rgba(94, 234, 212, 0.18);
  --accent-violet:      #a78bfa;
  --accent-violet-dim:  rgba(167, 139, 250, 0.18);

  --status-open:        #6b7a99;
  --status-in_progress: #5eead4;
  --status-blocked:     #f59e0b;
  --status-done:        #4ade80;
  --status-abandoned:   #4a5366;

  --category-work:      #60a5fa;
  --category-personal:  #4ade80;
  --category-undecided: #5e6a82;

  --danger:        #f87171;
  --danger-dim:    rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.4);

  --shadow-glow: 0 0 24px rgba(94, 234, 212, 0.08);

  --grid-line: rgba(154, 166, 183, 0.08);

  /* Back-compat aliases used by older selectors so a single source of truth
     keeps everything in sync. */
  --bg:           var(--bg-deep);
  --surface:      var(--surface-1);
  --text:         var(--text-primary);
  --muted:        var(--text-secondary);
  --accent:       var(--accent-cyan);
  --accent-hover: var(--accent-cyan);
  --border:       var(--border-dim);
  --error-bg:     rgba(248, 113, 113, 0.10);
  --error-text:   #fecaca;
}

/* ============ RESET / BASE ============ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 140ms ease;
}
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; color: var(--text-primary); }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
small { font-size: 13px; }

.mono,
.micro {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.micro {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.muted { color: var(--text-secondary); }

::selection { background: var(--accent-cyan-dim); color: var(--text-primary); }

/* ============ SCROLLBAR ============ */
* { scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

/* ============ BACKGROUND LAYERS ============ */
.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
.bg-nebula {
  background:
    radial-gradient(circle at 15% 20%, rgba(94, 234, 212, 0.15), transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(167, 139, 250, 0.14), transparent 45%),
    radial-gradient(circle at 70% 30%, rgba(45, 212, 191, 0.06), transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(236, 72, 153, 0.07), transparent 50%);
  filter: blur(30px);
}
.bg-stars .star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
}
.bg-stars .twinkle {
  animation: twinkle var(--twinkle-duration, 6s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: var(--twinkle-max, 1); }
  50%      { opacity: var(--twinkle-min, 0.3); }
}
.bg-drifters .drifter {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(230, 237, 246, 0.55);
  will-change: transform;
  animation: drift var(--drift-duration, 120s) linear infinite;
  animation-delay: var(--drift-delay, 0s);
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(var(--drift-dx, 100vw), var(--drift-dy, 0), 0); }
}

body.bg-paused .twinkle,
body.bg-paused .drifter { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .twinkle, .drifter { animation: none !important; }
}

/* ============ LAYOUT ============ */
.container,
.container-narrow {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 32px);
  flex: 1;
}
.container-wide {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 32px);
  flex: 1;
}
.container-fluid {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 32px clamp(16px, 4vw, 48px);
  flex: 1;
}

/* Pages that need the dashboard width get it via body class (set by
   layout.ejs from the view name). */
body.page-journal-current .container,
body.page-journal-week .container,
body.page-journal-items .container,
body.page-journal-history .container,
body.page-journal-analytics .container { max-width: 1280px; }

/* ============ HEADER ============ */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 14px clamp(16px, 4vw, 32px);
  background: linear-gradient(180deg, rgba(7, 9, 26, 0.85), rgba(7, 9, 26, 0.55));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  font-size: 15px;
}
.site-header nav {
  display: flex;
  align-items: center;
  gap: 28px;
}
.site-header nav a {
  position: relative;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  padding: 6px 0;
}
.site-header nav a:hover { color: var(--text-primary); text-decoration: none; }
.site-header nav a.is-active { color: var(--accent-cyan); }
.site-header nav a.is-active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-cyan);
}
.user-name {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 10px;
  border: 1px solid var(--border-dim);
  border-radius: 999px;
  background: var(--surface-1);
}
.inline-form { display: inline; margin: 0; }

/* ============ BUTTONS ============ */
.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 160ms ease;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}
.btn:disabled,
.button:disabled { opacity: 0.55; cursor: not-allowed; }

/* Primary — default .button + .btn-primary */
.btn-primary,
.button {
  background: var(--accent-cyan);
  color: var(--bg-deep);
  border-color: transparent;
}
.btn-primary:hover,
.button:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

/* Secondary */
.btn-secondary,
.button-secondary {
  background: transparent;
  border: 1px solid var(--border-active);
  color: var(--text-primary);
}
.btn-secondary:hover,
.button-secondary:hover {
  background: var(--accent-cyan-dim);
  text-decoration: none;
}

/* Ghost */
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); text-decoration: none; }

/* Danger */
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger-border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-dim); text-decoration: none; }

/* AI — actions that invoke Claude */
.btn-ai {
  background: var(--accent-violet);
  color: var(--bg-deep);
  border-color: transparent;
}
.btn-ai:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ai:focus-visible { box-shadow: 0 0 0 3px var(--accent-violet-dim); }

/* Small */
.btn-small,
.button-small {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
}

/* Inline link-style button */
.link-button {
  background: none;
  border: 0;
  color: var(--accent-cyan);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover { text-decoration: underline; }

/* ============ FORMS ============ */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  width: 100%;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}
input::placeholder,
textarea::placeholder { color: var(--text-tertiary); }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
                    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.control {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}
.control > span { font-size: 12px; font-weight: 500; letter-spacing: 0.02em; }

/* ============ CARDS ============ */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.card:hover { border-color: var(--border-active); }
.card.is-elevated { box-shadow: var(--shadow-glow), 0 1px 3px rgba(0, 0, 0, 0.4); }
.card .card {
  background: var(--surface-2);
  padding: 16px;
}

/* Apply card look to legacy panel classes for zero-effort migration. */
.capture,
.capture-form,
.item-create-form,
.active-items-summary,
.analytics-card,
.history-card,
.item {
  background: var(--surface-1);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: border-color 180ms ease;
}
.capture:hover,
.item:hover,
.history-row:hover,
.analytics-card:hover { border-color: var(--border-active); }

/* ============ ALERTS ============ */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 14px;
}
.alert-error {
  background: rgba(248, 113, 113, 0.10);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.empty-state {
  color: var(--text-secondary);
  padding: 1.5rem;
  border: 1px dashed var(--border-dim);
  border-radius: 12px;
  text-align: center;
  background: var(--surface-1);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============ STATUS + CATEGORY BADGES ============ */
.status-badge,
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  background: transparent;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.status-badge::before,
.category-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-open        { color: var(--status-open); }
.status-in_progress { color: var(--status-in_progress); }
.status-blocked     { color: var(--status-blocked); }
.status-done        { color: var(--status-done); }
.status-abandoned   { color: var(--status-abandoned); opacity: 0.85; }
.category-work       { color: var(--category-work); }
.category-personal   { color: var(--category-personal); }
.category-undecided  { color: var(--category-undecided); }

/* ============ FILTER PILLS ============ */
.filter-pills,
.items-filter,
.captures-filter,
.analytics-range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 999px;
}
.filter-pill,
.items-filter a,
.captures-filter a,
.analytics-range a {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 140ms ease;
}
.filter-pill:hover,
.items-filter a:hover,
.captures-filter a:hover,
.analytics-range a:hover { color: var(--text-primary); text-decoration: none; }
.filter-pill.is-active,
.items-filter a.is-active,
.captures-filter a.is-active,
.analytics-range a.is-active {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

/* ============ HERO / HOME ============ */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.hero h1 { font-size: 2.25rem; margin-bottom: 0.5rem; }
.hero p { margin: 0.5rem 0; }
.lede { color: var(--text-secondary); font-size: 1.05rem; margin-top: 0; }

/* ============ JOURNAL — current week ============ */
.journal { display: flex; flex-direction: column; gap: 1.5rem; }

.week-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.capture-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}
.capture-form textarea {
  min-height: 110px;
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
}
.capture-form textarea:focus { border-color: var(--accent-cyan); }
.capture-form button[type="submit"] { align-self: flex-end; }
.capture-form button[disabled] { opacity: 0.55; cursor: progress; }

.capture-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.category-toggle {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 999px;
}
.category-toggle-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 6px;
}
.category-toggle-btn {
  background: none;
  border: 0;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  transition: all 140ms ease;
}
.category-toggle-btn:hover { color: var(--text-primary); }
.category-toggle-btn.is-active {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

.capture-group { margin-bottom: 1.5rem; }
.capture-group:last-child { margin-bottom: 0; }

.day-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 0.6rem;
}

.capture-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.capture {
  padding: 14px 16px;
}
.capture-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.capture-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.capture-category-select {
  width: auto;
  font-size: 12px;
  padding: 4px 24px 4px 8px;
  background: var(--surface-2);
}
.capture-delete {
  background: none;
  border: 0;
  color: var(--text-tertiary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 140ms ease;
}
.capture-delete:hover { color: var(--danger); background: var(--surface-2); }
.capture-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
  color: var(--text-primary);
}

.active-items-summary { padding: 16px 18px; }
.active-items-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}
.active-items-summary-header h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0;
}
.manage-link { font-size: 13px; }
.active-items-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.active-items-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.active-items-list li a { color: var(--text-primary); }

/* ============ ITEMS PAGE ============ */
.items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.items-header h1 { font-size: 1.5rem; margin: 0; }

.item-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  margin-bottom: 1.5rem;
}
.item-create-form button[type="submit"] { align-self: flex-end; }

.item-group { margin-bottom: 1.5rem; }
.item-group-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 0.6rem;
}
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item { padding: 0; overflow: hidden; }
.item details > summary { list-style: none; cursor: pointer; padding: 14px 16px; }
.item details > summary::-webkit-details-marker { display: none; }
.item-summary { display: flex; flex-direction: column; gap: 6px; }
.item-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.item-title { font-weight: 500; color: var(--text-primary); }
.item-summary-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.note-count { color: var(--text-tertiary); }
.item-description {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.item-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-dim);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.item-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
  padding-top: 12px;
}
.item-merge {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.add-note-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.add-note-form input { flex: 1 1 auto; }

.notes-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.note {
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 10px 12px;
}
.note-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.note-text { color: var(--text-primary); font-size: 14px; }
.note-empty {
  background: transparent;
  border: 1px dashed var(--border-dim);
  color: var(--text-tertiary);
  font-style: italic;
}

/* ============ WEEK WORKSPACE ============ */
.week-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.section-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 0.5rem;
}
.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.week-captures, .polish-panel, .actions-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  padding: 18px;
}
.capture-list-readonly .capture { background: var(--surface-2); }
.report-editor {
  width: 100%;
  min-height: 280px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}
.report-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.report-downloads {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.usage-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 4px 0 12px;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.action-card {
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.action-card:hover { border-color: var(--border-active); }
.action-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.action-accept {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.action-accept input { width: auto; }
.action-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border-dim);
  color: var(--text-secondary);
}
.action-badge-create        { color: var(--accent-cyan); border-color: var(--accent-cyan-dim); }
.action-badge-update_status { color: var(--status-blocked); border-color: rgba(245, 158, 11, 0.4); }
.action-badge-add_note      { color: var(--text-secondary); }
.action-badge-categorize_capture { color: var(--accent-violet); border-color: var(--accent-violet-dim); }
.action-target {
  font-weight: 500;
  color: var(--text-primary);
}
.action-fields { display: flex; flex-direction: column; gap: 8px; }
.action-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.action-field > span { font-size: 12px; }
.action-rationale {
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
  margin: 0;
}
.action-help { font-size: 13px; margin: 0 0 12px; }
.action-dup-warning {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--status-blocked);
  font-size: 13px;
}
.action-dup-choice {
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.action-dup-choice legend {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 4px;
}
.action-dup-choice label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.action-dup-choice input { width: auto; }
.capture-snippet {
  margin: 0;
  padding: 8px 12px;
  background: var(--bg-base);
  border-left: 2px solid var(--accent-cyan-dim);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ============ HISTORY ============ */
.history-header { margin-bottom: 1.25rem; }
.history-header h1 { margin: 0 0 4px; }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-row {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-row-main { display: flex; flex-direction: column; gap: 4px; }
.history-week { font-weight: 500; color: var(--text-primary); }
.history-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.history-report-yes { color: var(--status-done); }
.history-report-no  { color: var(--text-tertiary); }
.history-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (min-width: 720px) {
  .history-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ============ ANALYTICS ============ */
.analytics-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1rem;
}
.analytics-header h1 { margin: 0; font-size: 1.5rem; }

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.analytics-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.analytics-card h2 { font-size: 16px; margin: 0; color: var(--text-primary); }
.analytics-card .panel-error {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid var(--danger-border);
  padding: 8px 12px;
  border-radius: 8px;
  margin: 0;
  font-size: 13px;
}
.callouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.callout {
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}
.callout-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}
.callout-suffix { font-size: 12px; color: var(--text-tertiary); font-weight: 400; }
.callout-label { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; letter-spacing: 0.04em; text-transform: uppercase; font-family: 'JetBrains Mono', monospace; }
.delta { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500; }
.delta-up   { color: var(--status-done); }
.delta-down { color: var(--danger); }

.items-charts-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.items-charts-row > .chart-wrap { flex: 1 1 auto; }

.chart-wrap {
  position: relative;
  min-height: 280px;
  width: 100%;
  flex: 1 1 auto;
  overflow: hidden;
}
.chart-wrap-doughnut { min-height: 260px; }
.chart-wrap-short    { min-height: 110px; }
.chart-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.polish-squares { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.5rem; }
.polish-squares .sq {
  display: inline-block;
  width: 28px; height: 28px;
  border-radius: 5px;
  cursor: default;
}
.polish-legend {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}
.polish-legend li { display: inline-flex; align-items: center; gap: 6px; }
.polish-legend .sq { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sq-polished        { background: var(--status-done); }
.sq-captures_only   { background: var(--status-blocked); }
.sq-empty           { background: var(--status-abandoned); }

/* Analytics responsive grid + spans */
.analytics-card.span-1,
.analytics-card.span-2,
.analytics-card.span-3 { grid-column: 1 / -1; }

@media (min-width: 700px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-card.span-1 { grid-column: span 1; }
  .analytics-card.span-2,
  .analytics-card.span-3 { grid-column: 1 / -1; }
  .callouts { display: flex; flex-wrap: nowrap; }
  .callouts .callout { flex: 1 1 0; }
}
@media (min-width: 1100px) {
  .analytics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-card.span-1 { grid-column: span 1; }
  .analytics-card.span-2 { grid-column: span 2; }
  .analytics-card.span-3 { grid-column: 1 / -1; }
  .items-charts-row { flex-direction: row; align-items: stretch; }
  .items-charts-row > .chart-wrap-doughnut { flex: 0 0 55%; }
  .items-charts-row > .chart-wrap-short    { flex: 1 1 auto; min-height: 260px; }
}

/* Heatmaps */
.heatmap-block { display: flex; flex-direction: column; gap: 4px; }
.heatmap-block + .heatmap-block { margin-top: 1rem; }
.heatmap-title { margin: 0; font-size: 14px; color: var(--text-primary); font-weight: 500; }
.heatmap-desc { margin: 0 0 6px; font-size: 12px; color: var(--text-tertiary); }
.heatmap { width: 100%; overflow-x: auto; }
.heatmap-svg { display: block; max-width: 100%; }
.heatmap-dow {
  fill: var(--text-tertiary);
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
}
.heatmap-cell {
  fill: var(--surface-2);
  stroke: rgba(0, 0, 0, 0.25);
  stroke-width: 0.5;
}
#heatmap-captures .heatmap-l0 { fill: rgba(94, 234, 212, 0.04); }
#heatmap-captures .heatmap-l1 { fill: rgba(94, 234, 212, 0.22); }
#heatmap-captures .heatmap-l2 { fill: rgba(94, 234, 212, 0.42); }
#heatmap-captures .heatmap-l3 { fill: rgba(94, 234, 212, 0.65); }
#heatmap-captures .heatmap-l4 { fill: var(--accent-cyan); }
#heatmap-items .heatmap-l0 { fill: rgba(167, 139, 250, 0.04); }
#heatmap-items .heatmap-l1 { fill: rgba(167, 139, 250, 0.22); }
#heatmap-items .heatmap-l2 { fill: rgba(167, 139, 250, 0.42); }
#heatmap-items .heatmap-l3 { fill: rgba(167, 139, 250, 0.65); }
#heatmap-items .heatmap-l4 { fill: var(--accent-violet); }

/* ============ RESPONSIVE TWEAKS ============ */
@media (min-width: 640px) {
  body { font-size: 15px; }
  .hero h1 { font-size: 2.5rem; }
  .week-header h1 { font-size: 1.5rem; }
}

/* ============ PUBLIC SITE ============ */
/* Header right-side link shown only to the owner. */
.owner-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--accent-cyan);
}
.owner-link:hover { text-decoration: none; filter: brightness(1.1); }

.public-main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(8px, 3vw, 24px) clamp(16px, 4vw, 32px) clamp(48px, 8vw, 88px);
  flex: 1;
}

.portfolio {
  display: flex;
  flex-direction: column;
  gap: clamp(48px, 9vw, 96px);
}

/* Hero */
.portfolio-hero {
  position: relative;
  text-align: center;
  padding: clamp(40px, 10vw, 96px) 0 clamp(8px, 2vw, 16px);
}
.portfolio-hero::before {
  content: '';
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 85%);
  height: 300px;
  background: radial-gradient(ellipse at center, rgba(94, 234, 212, 0.13), transparent 70%);
  filter: blur(24px);
  pointer-events: none;
  z-index: -1;
}
.portfolio-hero h1 {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 0.5rem;
  background: linear-gradient(180deg, var(--text-primary) 35%, #aebccf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.portfolio-tagline {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.85rem, 2.4vw, 1.05rem);
  letter-spacing: 0.04em;
  color: var(--accent-cyan);
  margin: 0 0 1.5rem;
}
.portfolio-intro {
  max-width: 580px;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: clamp(1rem, 2.4vw, 1.12rem);
  line-height: 1.7;
}

/* Section scaffolding */
.portfolio-section { scroll-margin-top: 80px; }
.section-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin: 0 0 0.4rem;
}
.section-title {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 1.6rem;
}

/* Skills grid */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.skill-card h3 { margin: 0 0 0.45rem; font-size: 1.05rem; }
.skill-card p { margin: 0; color: var(--text-secondary); font-size: 0.95rem; }

/* Projects grid */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.project-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.project-card h3 { margin: 0; font-size: 1.15rem; }
.project-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  flex: 1 1 auto;
}
.project-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tech-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
  padding: 3px 9px;
  border: 1px solid var(--border-dim);
  border-radius: 999px;
  background: var(--surface-2);
}
.project-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

@media (min-width: 760px) {
  .projects-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Contact */
.contact { text-align: center; }
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 1.3rem;
}

/* Public footer + discreet journal entrance */
.public-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 24px clamp(16px, 4vw, 32px);
  border-top: 1px solid var(--border-dim);
  color: var(--text-tertiary);
  font-size: 13px;
}
.public-footer-social {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.public-footer-social a { color: var(--text-tertiary); }
.public-footer-social a:hover { color: var(--text-secondary); }
.journal-entrance {
  font-size: 14px;
  line-height: 1;
  color: var(--text-tertiary);
  opacity: 0.4;
  text-decoration: none;
  transition: opacity 200ms ease, color 200ms ease;
}
.journal-entrance:hover {
  opacity: 1;
  color: var(--accent-cyan);
  text-decoration: none;
}

/* ============ TOAST ============ */
/* Fixed top-right stack so multiple toasts pile vertically without overlap.
   The positioning (top 70px / right 20px / z-index 1000) lives on the stack;
   each .toast is a card that slides in from the right. */
.toast-stack {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-dim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.is-visible { opacity: 1; transform: translateX(0); }
.toast-error { border-left: 3px solid #f87171; }
.toast-message { flex: 1 1 auto; }
.toast-close {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  transition: color 140ms ease;
}
.toast-close:hover { color: var(--text-primary); }

/* ==========================================================================
   IA RESTRUCTURE — two-pane items, three-col week, two-col journal, history grid
   ========================================================================== */

/* ============ DENSE-ROW PRIMITIVES (dots + compact rows) ============ */
.status-dot,
.category-dot {
  display: inline-block;
  border-radius: 50%;
  flex: 0 0 auto;
  background: currentColor;
}
.status-dot { width: 8px; height: 8px; }
.category-dot { width: 6px; height: 6px; }
.status-dot.status-open        { color: var(--status-open); }
.status-dot.status-in_progress { color: var(--status-in_progress); }
.status-dot.status-blocked     { color: var(--status-blocked); }
.status-dot.status-done        { color: var(--status-done); }
.status-dot.status-abandoned   { color: var(--status-abandoned); }
.category-dot.category-work       { color: var(--category-work); }
.category-dot.category-personal   { color: var(--category-personal); }
.category-dot.category-undecided  { color: var(--category-undecided); }

.row-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.compact-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.compact-items li > a,
.compact-items li > .compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  transition: background 140ms ease;
}
.compact-items li > a:hover,
.compact-items li > .compact-row:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.compact-items .row-title {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compact-items .row-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  flex: 0 0 auto;
}

/* ============ ITEMS PAGE — two-pane ============ */
.items-page {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.items-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.items-rail-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.items-rail-filters .filter-pills,
.items-rail-filters .items-filter { flex-wrap: wrap; }

.quick-create {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.quick-create input {
  flex: 1 1 auto;
  font-size: 14px;
  padding: 8px 12px;
}
.quick-create .btn-icon {
  width: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.items-rail-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.item-row-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.item-row { margin: 0; }
.item-row-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 8px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  padding: 10px 12px;
  font: inherit;
  transition: background 140ms ease, border-color 140ms ease;
}
.item-row-btn .row-dots { grid-row: 1 / span 2; }
.item-row-btn .row-title {
  grid-column: 2;
  grid-row: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-row-btn .row-meta {
  grid-column: 2;
  grid-row: 2;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
}
.item-row-btn:hover { background: var(--surface-2); }
.item-row.is-selected .item-row-btn {
  background: var(--surface-2);
  border-left-color: var(--accent-cyan);
}

.items-detail {
  background: var(--surface-1);
  border: 1px solid var(--border-dim);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  padding: 24px;
  min-height: 360px;
  position: relative;
}
.items-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  color: var(--text-tertiary);
}
.items-detail-card { display: flex; flex-direction: column; gap: 16px; }
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.detail-title { margin: 0; font-size: 20px; flex: 1 1 auto; min-width: 0; }
.detail-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-controls select { width: auto; min-width: 130px; }
.detail-menu { position: relative; }
.detail-menu-btn {
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.detail-menu-btn:hover { color: var(--text-primary); border-color: var(--border-active); }
.detail-menu-popup {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface-solid);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  min-width: 170px;
  z-index: 20;
  padding: 4px;
}
.detail-menu-popup .menu-item {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.detail-menu-popup .menu-item:hover { background: var(--surface-2); }
.detail-menu-popup .menu-item.is-danger { color: var(--danger); }

.detail-merge {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
}
.detail-merge select { flex: 1 1 200px; }

.detail-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
}

.detail-description {
  font-size: 15px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: text;
  min-height: 44px;
}
.detail-description:hover { border-color: var(--border-dim); }
.detail-description.is-empty { color: var(--text-tertiary); font-style: italic; }
.detail-description textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--accent-cyan);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text-primary);
  min-height: 80px;
  resize: vertical;
}

.detail-notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-notes .notes-timeline { display: flex; flex-direction: column; gap: 8px; }
.detail-notes .note { padding: 10px 12px; }
.detail-notes .note-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 4px;
}
.detail-notes .note-meta .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.detail-notes .note-text { white-space: pre-wrap; }
.detail-notes .add-note-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.detail-notes .add-note-form textarea {
  flex: 1 1 auto;
  min-height: 56px;
  font-size: 14px;
}

/* Two-pane on >=900px */
@media (min-width: 900px) {
  .items-page {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  .items-rail-list {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-right: 4px;
  }
  .items-detail { position: sticky; top: 84px; }
}

/* Mobile: detail hidden by default; JS toggles body.items-detail-open */
@media (max-width: 899px) {
  .items-detail { display: none; }
  body.items-detail-open .items-rail { display: none; }
  body.items-detail-open .items-detail { display: block; }
}
.detail-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
@media (min-width: 900px) { .detail-back-link { display: none; } }

/* ============ WEEK WORKSPACE — three-column ============ */
.week-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
.week-captures-col,
.week-items-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.week-center-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.back-link {
  font-size: 13px;
  color: var(--text-secondary);
}
.capture-stream {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.capture-stream-row {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-dim);
}
.capture-stream-row:last-child { border-bottom: 0; }
.stream-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.stream-row-meta .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.stream-row-meta .capture-delete {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--text-tertiary);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.stream-row-meta .capture-delete:hover { color: var(--danger); background: var(--surface-2); }
.stream-row-meta .capture-category-select {
  width: auto;
  font-size: 11px;
  padding: 2px 20px 2px 6px;
  background: var(--surface-2);
}
.capture-stream-row .capture-text {
  font-size: 14px;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.polish-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.polish-warning-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-blocked);
  box-shadow: 0 0 8px var(--status-blocked);
}

@media (min-width: 1100px) {
  .week-workspace-grid {
    grid-template-columns: 340px minmax(0, 1fr) 280px;
  }
  .week-captures-col,
  .week-items-col {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}

/* ============ JOURNAL HOME — two-column ============ */
.journal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
.journal-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.journal-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 900px) {
  .journal-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .journal-sidebar {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}

/* Capture-stream override on journal page: still uses .capture markup, but
   we want compact rows there too. */
.journal-grid .capture-list {
  gap: 0;
}
.journal-grid .capture {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-dim);
  border-radius: 0;
  box-shadow: none;
  padding: 10px 4px;
}
.journal-grid .capture:last-child { border-bottom: 0; }
.journal-grid .capture-meta { margin-bottom: 4px; }
.journal-grid .capture-text { font-size: 14px; }

/* Skip pill quieter than work/personal */
.category-toggle-btn[data-category="work"].is-active {
  background: var(--category-work);
  color: var(--bg-deep);
}
.category-toggle-btn[data-category="personal"].is-active {
  background: var(--category-personal);
  color: var(--bg-deep);
}
.category-toggle-btn-skip {
  font-size: 11px;
  padding: 2px 10px;
  color: var(--text-tertiary);
  border: 1px solid var(--border-dim) !important;
  background: transparent !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.category-toggle-btn-skip.is-active {
  background: transparent !important;
  color: var(--text-secondary);
  border-color: var(--border-active) !important;
}

/* ============ HISTORY — grid of compact cards ============ */
.history-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.history-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 180ms ease, transform 180ms ease;
}
.history-card:hover {
  text-decoration: none;
  border-color: var(--border-active);
}
.history-card h3 {
  font-size: 15px;
  font-weight: 500;
  margin: 0;
  color: var(--text-primary);
}
.history-card-state {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.history-card-state.is-polished { color: var(--accent-cyan); }
.history-card-state.is-captures_only { color: var(--status-blocked); }
.history-card-state.is-empty { color: var(--text-tertiary); }
.history-card-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-tertiary);
}
.history-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}
@media (min-width: 700px) {
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .history-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ============ MISC IA SUPPORT ============ */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}
