/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:        #f5f5f0;
  --surface:   #ffffff;
  --border:    #ddddd8;
  --text:      #1a1a1a;
  --muted:     #6b6b6b;
  --accent:    #2d6a4f;
  --accent-fg: #ffffff;
  --danger:    #c0392b;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,0.10);
}

html, body {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

body.main-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 1.5rem;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 1.75rem;
  color: var(--accent);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.field input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--accent);
}

.login-error {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--danger);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  margin-top: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.25rem 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--text);
}

/* ── Main layout ───────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2rem 1.5rem;
}

.placeholder {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.tag-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-tag {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn-sort {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  margin-left: auto;
  transition: background 0.15s;
}

.btn-sort:hover {
  background: var(--bg);
}

/* ── Tag sections ──────────────────────────────────────────────────────────── */
.session-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.tag-section-header {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

/* ── Session grid ──────────────────────────────────────────────────────────── */
.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.session-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.session-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.13);
}

.marked-card {
  border: 2px solid var(--danger);
}

.card-star {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  font-size: 1.1rem;
  line-height: 1;
  color: #f1c40f;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.card-notes-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  font-size: 0.95rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.card-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--bg);
  display: block;
}

.card-thumb-empty {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--bg);
}

.card-body {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.75rem;
  gap: 0.15rem;
}

.card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.card-date {
  font-size: 0.875rem;
  font-weight: 500;
}

.card-count {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Detail view ───────────────────────────────────────────────────────────── */
.detail-content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden; /* the page itself doesn't scroll — image area shrinks instead */
}

.viewer {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  flex: 1;
  min-height: 0; /* required for a flex child to actually shrink below content size */
}

.viewer-frame {
  flex: 1;
  min-height: 0;
  position: relative;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.img-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.viewer-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
}

.img-fullscreen-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  cursor: zoom-in;
  z-index: 10;
  font-size: 0;
  color: transparent;
  padding: 0;
}

.viewer-frame img.marked {
  border: 3px solid var(--danger);
}

.viewer-star {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.6rem;
  line-height: 1;
  color: #f1c40f;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.frame-label {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.viewer-nav-row {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* ── Filmstrip menu ────────────────────────────────────────────────────────── */
.filmstrip-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.menu-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.menu-btn:hover:not(:disabled) {
  background: var(--bg);
}

.menu-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.menu-spacer {
  flex: 1;
}

.menu-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.nav-btn {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--bg);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ── Film strip ────────────────────────────────────────────────────────────── */
.strip {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  flex-shrink: 0;
}

.strip-item {
  position: relative;
  flex-shrink: 0;
}

.strip-thumb {
  display: block;
  width: 60px;
  height: 80px;
  object-fit: cover;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s, border-color 0.15s;
}

.strip-thumb:hover {
  opacity: 1;
}

.strip-thumb.active {
  border-color: var(--accent);
  opacity: 1;
}

.strip-thumb.marked {
  border-color: var(--danger);
  opacity: 1;
}

.strip-thumb.marked.active {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px var(--accent);
}

.strip-checkbox {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.strip-star {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 0.9rem;
  line-height: 1;
  color: #f1c40f;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
}

.strip-select-all {
  width: 44px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 2px solid transparent;
  border-radius: 3px;
  background: var(--surface-1, rgba(127,127,127,0.08));
}

.strip-select-all-label {
  font-size: 0.65rem;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.strip-select-all-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Move modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1.25rem 1.25rem 0.75rem;
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 0 1.25rem;
  flex: 1;
}

.modal-actions {
  padding: 0.75rem 1.25rem 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.move-tag-group {
  margin-bottom: 1rem;
}

.move-tag-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.move-target-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.move-target-btn:hover:not(:disabled) {
  background: var(--bg);
}

.move-target-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.move-target-new {
  border-style: dashed;
  color: var(--accent);
  font-weight: 500;
}

/* ── Session notes ─────────────────────────────────────────────────────────── */
.notes-section {
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.notes-status {
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
}

/* Plain-textarea fallback (used if the EasyMDE CDN fails to load) */
.notes-section > textarea {
  width: 100%;
  height: 115px;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

/* EasyMDE overrides to match the app's design tokens */
.notes-section .EasyMDEContainer .editor-toolbar {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  padding: 0.3rem;
}

.notes-section .EasyMDEContainer .CodeMirror {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  color: var(--text);
  height: 115px;
  overflow-y: auto;
}

.notes-section .editor-toolbar button.active,
.notes-section .editor-toolbar button:hover {
  background: var(--bg);
  border-color: var(--border);
}




/* ── Responsive — mobile ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .main-content {
    padding: 1rem;
  }

  .detail-content {
    gap: 0.5rem;
  }

  /* Toolbar — sort button wraps to its own row */
  .toolbar {
    gap: 0.75rem;
  }

  .btn-sort {
    margin-left: 0;
  }

  /* Cards — 2 columns on mobile */
  .session-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .card-date {
    font-size: 0.8rem;
  }

  /* Detail — stack nav buttons below image on mobile */
  .viewer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .viewer-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  .viewer-nav-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-shrink: 0;
  }

  .nav-btn {
    width: 3rem;
    height: 3rem;
    font-size: 1.3rem;
  }

  /* Film strip — larger touch targets */
  .strip-thumb {
    width: 52px;
    height: 70px;
  }
}

/* ── Hamburger & nav drawer ─────────────────────────────────────────────────── */
.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.hamburger-btn span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: background 0.15s;
}

.hamburger-btn:hover span {
  background: var(--accent);
}

.nav-drawer {
  position: fixed;
  top: 0;
  right: -280px;
  width: 260px;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  transition: right 0.25s ease;
}

.nav-drawer.open {
  right: 0;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 199;
}

.nav-backdrop.open {
  display: block;
}

.nav-item {
  display: block;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-item:hover {
  background: var(--bg);
}

.nav-item-active {
  color: var(--accent);
  font-weight: 600;
}

.nav-item-signout {
  margin-top: auto;
  color: var(--danger);
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ── About page ─────────────────────────────────────────────────────────────── */
.about-box {
  max-width: 640px;
}

.about-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.about-version {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.about-section {
  margin-bottom: 1.5rem;
}

.about-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.about-section p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.about-section a {
  color: var(--accent);
}

/* ── Diagnostics page ───────────────────────────────────────────────────────── */
.diag-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  max-width: 680px;
}

.diag-upload-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.diag-status {
  font-size: 0.875rem;
  color: var(--muted);
}

.diag-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
  max-width: 860px;
}

.diag-result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.diag-index {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 1.2rem;
}

.diag-filename {
  font-size: 0.875rem;
  font-family: monospace;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-decision {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 2rem;
  flex-shrink: 0;
}

.decision-saved     { background: #d4edda; color: #155724; }
.decision-duplicate { background: #fff3cd; color: #856404; }
.decision-blank     { background: #d1ecf1; color: #0c5460; }
.decision-first     { background: #e2e3e5; color: #383d41; }
.decision-unknown   { background: var(--bg); color: var(--muted); }

/* Toggle buttons */
.diag-view-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.diag-view-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.diag-toggle-btn {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.diag-toggle-btn.diag-toggle-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.diag-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
}

.diag-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
}

.diag-legend-triggered { background: rgba(192,57,43,0.55); }
.diag-legend-masked    { background: rgba(10,10,10,0.88); }

/* Image + canvas */
.diag-canvas-wrap {
  position: relative;
  display: block;
  width: 100%;
  padding: 1rem;
  box-sizing: border-box;
}

.diag-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.diag-canvas {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: calc(100% - 2rem);
  height: calc(100% - 2rem);
  pointer-events: none;
}

/* Stats row */
.diag-stats {
  padding: 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-top: 1px solid var(--border);
}

.stat-row {
  font-size: 0.82rem;
  color: var(--text);
}

.stat-row.muted {
  color: var(--muted);
}

.stat-pass {
  color: #155724;
  font-weight: 600;
  margin-left: 0.4rem;
}

.stat-fail {
  color: var(--danger);
  font-weight: 600;
  margin-left: 0.4rem;
}

/* Copyable summary */
.diag-summary-wrap {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.diag-summary-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.diag-copy-btn {
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.diag-copy-btn:hover {
  background: var(--bg);
}

.diag-summary {
  font-family: monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

/* ── Manual process page ────────────────────────────────────────────────────── */
.mp-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  max-width: 600px;
}

.mp-picker {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.mp-picker .field {
  min-width: 180px;
}

.mp-picker select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  cursor: pointer;
}

.mp-results-header {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

.mp-log {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  max-width: 720px;
}

.mp-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 1rem;
}

.mp-log-row:last-child {
  border-bottom: none;
}

.mp-log-file {
  font-family: monospace;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-log-decision {
  font-weight: 600;
  flex-shrink: 0;
  font-size: 0.8rem;
}

.mp-saved     .mp-log-decision { color: #155724; }
.mp-duplicate .mp-log-decision { color: #856404; }
.mp-blank     .mp-log-decision { color: #0c5460; }
.mp-error     .mp-log-decision { color: var(--danger); }

.mp-saved     { background: #f8fff9; }
.mp-duplicate { background: #fffdf0; }
.mp-blank     { background: #f0fafc; }
.mp-error     { background: #fff5f5; }

.eye-sync-banner {
  background: #c0392b;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Check stats (session viewer) ─────────────────────────────────────────── */
.stats-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.stats-overlay {
  position: absolute;
  pointer-events: none;
}

.stats-panel {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: left;
}

.stats-row.muted {
  color: var(--muted);
}

.stats-error {
  color: var(--danger);
}

.stats-hist-heading {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-hist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.stats-hist-label {
  width: 60px;
  flex-shrink: 0;
  font-family: monospace;
}

.stats-hist-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.stats-hist-bar-fill {
  height: 100%;
  background: var(--accent);
}

.stats-hist-count {
  width: 110px;
  text-align: right;
  flex-shrink: 0;
  font-family: monospace;
}

.stats-legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.stats-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: -2px;
}

.stats-legend-ink      { background: rgba(255,170,0,0.4); }
.stats-legend-masked   { background: rgba(10,10,10,0.88); }
.stats-legend-changed  { background: transparent; border: 2px solid rgba(30,144,255,0.9); width: 8px; height: 8px; }
.stats-legend-marker   { background: transparent; border: 2px solid rgba(0,200,0,0.9); width: 8px; height: 8px; }

.decision-error { background: #f8d7da; color: var(--danger); }

.cell-grid {
  display: grid;
  gap: 2px;
  margin-top: 0.75rem;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 480px;
}

.cell-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  cursor: default;
}

.cell-grid-line {
  font-family: monospace;
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
}

.cell-grid-tag {
  font-family: monospace;
  font-size: 0.62rem;
  color: var(--muted);
}

.cell-grid-masked {
  background: rgba(10,10,10,0.88);
}

.cell-grid-masked .cell-grid-tag {
  color: #eee;
}

.cell-grid-ink {
  background: rgba(255,170,0,0.25);
}

.cell-grid-ink .cell-grid-line {
  color: #856404;
}

.cell-grid-changed {
  background: rgba(30,144,255,0.25);
  color: #084a91;
  border-radius: 2px;
  padding: 0 2px;
}

.cell-grid-na {
  opacity: 0.5;
}

/* ── Image fullscreen overlay (double-click) ──────────────────────────────── */
.img-fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: zoom-out;
}

.img-fullscreen-overlay img {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* ── Notes expand button ──────────────────────────────────────────────────── */
.notes-expand-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.notes-expand-btn:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Notes expanded state — full viewport overlay ─────────────────────────── */
.notes-section.notes-expanded {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: var(--surface);
  margin: 0;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  max-height: none;
}

.notes-section.notes-expanded .EasyMDEContainer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.notes-section.notes-expanded .EasyMDEContainer .CodeMirror {
  flex: 1;
  min-height: 0;
  height: 100%;
  resize: none;
}

/* ── All Notes page ────────────────────────────────────────────────────────── */
.notes-page {
  max-width: 720px;
}

.notes-page-list {
  display: flex;
  flex-direction: column;
}

.notes-entry {
  display: flex;
  flex-direction: column;
}

.notes-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.75rem 0 0.75rem;
}

.notes-entry:first-child .notes-divider {
  margin-top: 0;
}

.notes-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.notes-divider-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.notes-entry-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
}

.notes-entry-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 0.5rem;
}

.notes-entry-tag:hover {
  text-decoration: underline;
}

.notes-entry-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.notes-entry-content p {
  margin-bottom: 0.6rem;
}

.notes-entry-content p:last-child {
  margin-bottom: 0;
}

.notes-entry-content ul,
.notes-entry-content ol {
  margin: 0 0 0.6rem 1.25rem;
}

.notes-entry-content strong {
  font-weight: 700;
}

.notes-entry-content em {
  font-style: italic;
}

.notes-entry-content del {
  text-decoration: line-through;
}
