/* ── Reset ──────────────────────────────────────────────────────────────── */

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

/* Reserve scrollbar gutter so the flex-centered .app card doesn't shift left
   when page content overflows and the scrollbar appears (Windows/Linux). */
html {
  scrollbar-gutter: stable;
}

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

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #111827;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: env(safe-area-inset-top)  env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── App card ───────────────────────────────────────────────────────────── */

/* Intentionally narrow and centred on all screen sizes.
   The unused space on wide desktop screens is a deliberate product choice:
   it enforces focus and keeps the capture interaction feeling lightweight.
   A multi-column "Desktop Workspace Mode" is planned for a future phase —
   see docs/strategy/PRODUCT_EVOLUTION.md (Tier 5) — but must not be built
   until the core capture + retrieve loop is validated by real users. */
.app {
  width: 90%;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 32px 0;
}

.app-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

/* Network status sits in the left slot — balances the sign-out button on the right
   so the title is optically centred regardless of right-side element widths. */
.app-topbar .network-status {
  grid-column: 1;
  justify-self: start;
  margin: 0;
}

.app-topbar h1 {
  grid-column: 2;
  text-align: center;
  margin: 0;
  font-size: 28px;
}

.app-topbar .sign-out-btn {
  grid-column: 3;
  justify-self: end;
}

.sign-out-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  transition: color 0.15s;
}

.sign-out-btn:hover { color: #9ca3af; }

.tagline {
  margin: 0;
  color: #9ca3af;
  font-size: 15px;
}

/* ── Online / Offline indicator ─────────────────────────────────────────── */

.network-status {
  margin: 0;
  font-size: 13px;
  font-weight: bold;
  min-height: 18px;
}

.network-status.online  { color: #22c55e; }
.network-status.offline { color: #f87171; }

/* ── Status message & timer ─────────────────────────────────────────────── */

#statusMsg {
  margin: 0;
  font-size: 18px;
  color: #9ca3af;
  min-height: 27px;
}

.timer {
  margin: 0;
  font-size: 56px;
  font-weight: bold;
  letter-spacing: 4px;
  font-family: monospace;
  color: #f9fafb;
}

/* ── Main action buttons (Record, Stop, Download) ───────────────────────── */

#recordBtn, #stopBtn, #downloadLink {
  display: block;
  width: 100%;
  padding: 20px;
  border-radius: 16px;
  border: none;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  color: white;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.15s;
}

#recordBtn { background: #22c55e; }
#stopBtn   { background: #ef4444; }

#recordBtn:disabled,
#stopBtn:disabled {
  opacity: 0.35;
  cursor: default;
}

#downloadLink {
  background: #3b82f6;
  text-decoration: none;
  text-align: center;
}

/* ── Audio player ───────────────────────────────────────────────────────── */

audio {
  width: 100%;
}

/* Hidden until recording.js assigns a src after a recording completes */
#audioPreview {
  display: none;
}

/* ── Recordings section ──────────────────────────────────────────────────── */

.recordings-section {
  margin-top: 8px;
}

/* Header row: title on the left, 2×2 button grid on the right.
   flex-wrap: wrap means the grid drops to its own row on screens too narrow
   to show both the title and buttons side by side. */
.recordings-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.recordings-header h2 {
  margin: 0;
  font-size: 17px;
  color: #f9fafb;
  white-space: nowrap;
  flex-shrink: 0;   /* title never compresses — the button grid moves instead */
}

/* 2×2 button grid.
   flex: 1 takes all remaining row width so buttons fill the space right of
   the title on desktop, or the full card width when wrapped on mobile.
   min-width: 210px triggers the wrap when the remaining space is too tight
   to show both columns comfortably (phones narrower than ~400 px). */
.recordings-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  flex: 1;
  min-width: 210px;
}

#exportBtn, #clearAllBtn, #syncBtn, #pullBtn {
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  color: white;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

#exportBtn   { background: #0891b2; }  /* teal   */
#clearAllBtn { background: #b91c1c; }  /* red    */
#syncBtn     { background: #6366f1; }  /* indigo */
#pullBtn     { background: #16a34a; }  /* green  */

/* ── Search row (input + semantic toggle side by side) ───────────────────── */

.search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 10px;
}

/* ── Search input ────────────────────────────────────────────────────────── */

.search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #1f2937;
  color: #f9fafb;
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
}

.search-input::placeholder {
  color: #6b7280;
}

.search-input:focus {
  border-color: #6366f1;
}

/* ── Semantic mode toggle (✨ button to the right of search input) ────────── */

.semantic-toggle {
  flex-shrink: 0;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #1f2937;
  color: #9ca3af;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.semantic-toggle.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}

/* ── Semantic search button (full-width, shown only in semantic mode) ─────── */

.semantic-search-btn {
  width: 100%;
  padding: 11px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: none;
  background: #4f46e5;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.semantic-search-btn:active {
  background: #4338ca;
}

/* ── Filter pills ────────────────────────────────────────────────────────── */

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}

/* Dimmed when semantic mode is active — filters don't apply to semantic results */
.filter-pills.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.filter-pill {
  padding: 5px 14px;
  border-radius: 99px;
  border: 1px solid #374151;
  background: transparent;
  color: #9ca3af;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-pill.active,
.filter-pill:active {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

/* Empty-state message */
.list-empty {
  color: #6b7280;
  font-size: 14px;
  text-align: center;
  padding: 14px 0;
  margin: 0;
}

/* ── Timeline date section headings ──────────────────────────────────────── */

.timeline-date-heading {
  margin: 24px 0 8px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #6b7280;
  padding-left: 2px;
}

/* First heading sits flush below the filter pills — no extra top space */
.timeline-date-heading.first {
  margin-top: 2px;
}

/* Memory count shown after month headings: "April 2025 · 12" */
.timeline-group-count {
  font-weight: normal;
  opacity: 0.55;
  margin-left: 0.3em;
}

/* Quiet anchor at the bottom of an unfiltered timeline with real archive depth */
.timeline-archive-footer {
  margin: 28px 0 4px;
  font-size: 11px;
  color: #4b5563;
  text-align: center;
  letter-spacing: 0.03em;
}

/* Temporal span note above semantic search results */
.timeline-search-span {
  margin: 0 0 10px;
  font-size: 11px;
  color: #6b7280;
  padding-left: 2px;
}

/* Thematic context header above a tag-filtered timeline */
.thematic-tag-header {
  margin: 0 0 10px;
  font-size: 11px;
  color: #6b7280;
  padding-left: 2px;
}

/* ── Recording cards ─────────────────────────────────────────────────────── */

.rec-item {
  display: flex;
  align-items: flex-start;  /* top-align so buttons don't drift down on tall cards */
  gap: 10px;
  background: #1f2937;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

/* Left: filename, date, duration, badges, transcript */
.rec-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.rec-name {
  font-size: 13px;
  font-weight: bold;
  color: #f9fafb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-meta {
  font-size: 12px;
  color: #9ca3af;
}

/* Row of status pills — upload status + transcription status side by side */
.rec-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Status pill badge */
.rec-status {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 99px;
  width: fit-content;
}

/* Upload status colors */
.rec-status.pending   { background: #92400e; color: #fcd34d; }
.rec-status.uploaded  { background: #065f46; color: #6ee7b7; }
.rec-status.uploading {
  background: #1e3a5f; color: #93c5fd;
  animation: badge-pulse 1.2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Transcription status colors */
.rec-status.transcribed { background: #1e3a5f; color: #93c5fd; }
.rec-status.xfailed     { background: #450a0a; color: #fca5a5; }
.rec-status.unknown     { background: #1f2937; color: #6b7280; border: 1px solid #374151; }

/* Retry button — inline, next to the transcription-failed badge */
.rec-retry-btn {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: bold;
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid #7f1d1d;
  border-radius: 99px;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
}

.rec-retry-btn:hover  { background: #7f1d1d; color: #fecaca; }
.rec-retry-btn:active { background: #991b1b; }
.rec-retry-btn:disabled { opacity: 0.5; cursor: default; }

/* Semantic similarity score badge colors */
.rec-status.score-high { background: #065f46; color: #6ee7b7; }   /* ≥70% — strong match   */
.rec-status.score-mid  { background: #78350f; color: #fcd34d; }   /* ≥50% — decent match   */
.rec-status.score-low  { background: #1f2937; color: #6b7280; border: 1px solid #374151; }

/* Semantic result cards get a subtle left accent so they stand out from normal cards */
.rec-item.semantic-result {
  border-left: 3px solid #4f46e5;
}

/* Transcript text shown inside the card */
.rec-transcript {
  margin: 4px 0 0;
  font-size: 13px;
  color: #d1d5db;
  line-height: 1.5;
  font-style: italic;
  /* Allow long transcripts to wrap naturally */
  white-space: normal;
  word-break: break-word;
}

/* Collapsed transcript: clamp to 4 lines */
.rec-transcript.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Show more / Show less toggle button */
.transcript-toggle {
  background: none;
  border: none;
  padding: 0;
  margin: 2px 0 0;
  font-size: 12px;
  color: #6366f1;
  cursor: pointer;
  font-weight: bold;
}

.transcript-toggle:active {
  color: #818cf8;
}

/* Placeholder shown when there is no transcript */
.rec-transcript-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: #4b5563;
  font-style: italic;
}

/* Right: download + delete/menu buttons — small top padding to align with filename */
.rec-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 2px;
}

/* ── Options menu (⋮ button + dropdown for uploaded cards) ───────────────── */

.rec-menu {
  position: relative;
  flex-shrink: 0;
}

/* The ⋮ trigger button — same size as the download button */
.rec-menu-btn {
  width: 40px;
  height: 40px;
  background: #374151;
  border: none;
  border-radius: 9px;
  color: #9ca3af;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.rec-menu-btn:active {
  background: #4b5563;
  color: #f9fafb;
}

/* Dropdown panel — hidden by default, shown when parent has .open */
.rec-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  overflow: hidden;
  z-index: 20;
  min-width: 190px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.rec-menu.open .rec-menu-dropdown {
  display: block;
}

/* Each option row inside the dropdown */
.rec-menu-item {
  display: block;
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  color: #f9fafb;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

.rec-menu-item:active {
  background: #374151;
}

/* Thin separator between the two options */
.rec-menu-item + .rec-menu-item {
  border-top: 1px solid #374151;
}

/* "Delete everywhere" is destructive — use a red tint */
.rec-menu-item.danger {
  color: #fca5a5;
}

.rec-menu-item.danger:active {
  background: #450a0a;
}

/* Download icon button */
.rec-dl {
  width: 40px;
  height: 40px;
  background: #374151;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  text-decoration: none;
  color: white;
}

/* Delete icon button */
.rec-delete {
  width: 40px;
  height: 40px;
  background: #374151;
  border: none;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.rec-delete:active {
  background: #7f1d1d;
  color: #fca5a5;
}

/* Star / favorite button on timeline cards */
.rec-star-btn {
  width: 40px;
  height: 40px;
  background: #374151;
  border: none;
  border-radius: 9px;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}

.rec-star-btn.is-favorite { color: #fbbf24; }
.rec-star-btn:active      { background: #4b5563; }
.rec-star-btn:disabled    { opacity: 0.5; cursor: default; }

/* Star button in the modal header */
.modal-star {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  margin-right: 2px;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}

.modal-star.is-favorite { color: #fbbf24; }
.modal-star:active      { background: #374151; }

/* ── Memory intelligence ──────────────────────────────────────────────────── */

/* Memory type badge colors — one color per type */
.rec-status.type-idea       { background: #4a1d96; color: #c4b5fd; }
.rec-status.type-task       { background: #065f46; color: #6ee7b7; }
.rec-status.type-reflection { background: #1e3a5f; color: #93c5fd; }
.rec-status.type-content    { background: #713f12; color: #fde68a; }
.rec-status.type-business   { background: #312e81; color: #a5b4fc; }
.rec-status.type-technical  { background: #134e4a; color: #5eead4; }
.rec-status.type-personal   { background: #500724; color: #fda4af; }
.rec-status.type-unknown    { background: #1f2937; color: #6b7280; border: 1px solid #374151; }

/* Priority badge colors */
.rec-status.priority-high   { background: #450a0a; color: #fca5a5; }
.rec-status.priority-medium { background: #78350f; color: #fcd34d; }
.rec-status.priority-low    { background: #1f2937; color: #6b7280; border: 1px solid #374151; }

/* Short summary shown below the badges row */
.rec-summary {
  margin: 4px 0 0;
  font-size: 13px;
  color: #d1d5db;
  line-height: 1.4;
}

/* Row of small topic tag pills */
.rec-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.rec-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: #1e3a5f;
  color: #93c5fd;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.rec-tag:hover {
  background: #1e40af;
  color: #bfdbfe;
}

/* Highlighted when this tag is the active tag filter */
.rec-tag.active-tag {
  background: #1d4ed8;
  color: #fff;
  box-shadow: 0 0 0 2px #93c5fd;
}

/* Action items list shown below the transcript */
.rec-actions-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rec-action-item {
  font-size: 12px;
  color: #d1d5db;
  padding: 3px 8px;
  background: #111827;
  border-left: 2px solid #6366f1;
  border-radius: 0 5px 5px 0;
}

/* ── Card click affordance ───────────────────────────────────────────────── */

.rec-item {
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

/* 2-line clamp keeps summaries compact in timeline preview */
.rec-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Memory Detail Modal ─────────────────────────────────────────────────── */

/* Full-screen dark backdrop — hidden by default, shown via .is-open class.
   Using a class instead of the HTML [hidden] attribute avoids a browser
   specificity problem: [hidden]{display:none} has the same weight as
   .modal-overlay{display:flex}, so in some browsers the author stylesheet
   wins and [hidden] never actually hides the element. A class-based toggle
   is unambiguous and works identically in every browser. */
.modal-overlay {
  display: none;             /* hidden until JS adds .is-open */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: flex-end;     /* slide up from bottom on mobile */
  justify-content: center;
  z-index: 1000;
  padding: 0 env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* JS calls modal.classList.add('is-open') to show the overlay */
.modal-overlay.is-open {
  display: flex;
  animation: modal-backdrop-in 0.18s ease-out;
}

.modal-overlay.is-open .modal-panel {
  animation: modal-panel-in 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
}

/* The white-on-dark panel that holds all the detail content */
.modal-panel {
  background: #1f2937;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  /* 90vh cap guarantees the panel never grows taller than the viewport,
     keeping the header (and close button) always on-screen. */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* On wider screens, center the modal vertically instead of anchoring it
   to the bottom — avoids the close button being near the screen edge. */
@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }
  .modal-panel {
    border-radius: 16px;   /* fully rounded when floating */
    max-height: 85vh;
  }
}

/* Header row: title on the left, close button on the right */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #374151;
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: bold;
  color: #f3f4f6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.modal-close:hover {
  color: #f3f4f6;
}

/* Scrollable body — all detail content lives here */
.modal-body {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Detail body sections ─────────────────────────────────────────────────── */

/* Timestamp and duration line */
.detail-meta {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

/* Status + intelligence badges row */
.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Audio player or "not on device" notice */
.detail-audio {
  display: block;    /* audio is inline by default; block makes width:100% resolve against the container */
  width: 100%;
  min-width: 0;      /* flex children won't shrink below their content size without this */
  flex-shrink: 0;    /* prevent the player from compressing when transcript or other content is long */
  box-sizing: border-box;
  margin: 4px 0;
}

.detail-notice {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
}

/* A collapsible section (Summary, Transcript, Actions) */
.detail-section {
  background: #111827;
  border-radius: 8px;
  padding: 12px;
}

/* Header row inside a section: title + copy button */
.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.detail-section-title {
  margin: 0;
  font-size: 12px;
  font-weight: bold;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Quiet temporal note in section headings (e.g. "going back 4 months") */
.related-timespan {
  font-size: 10px;
  font-weight: normal;
  color: #6b7280;
  text-transform: none;
  letter-spacing: 0;
}

.detail-copy-btn {
  background: none;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.detail-copy-btn:hover {
  background: #374151;
  color: #f3f4f6;
}

/* Body text inside a section (summary, general) */
.detail-text {
  margin: 0;
  font-size: 14px;
  color: #d1d5db;
  line-height: 1.5;
}

/* Full transcript block */
.detail-transcript {
  margin: 0;
  font-size: 13px;
  color: #9ca3af;
  line-height: 1.5;
  font-style: italic;
}

/* Tags row inside the modal */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Modal tags are labels, not filters — remove interactive affordance */
.detail-tags .rec-tag {
  cursor: default;
}
.detail-tags .rec-tag:hover {
  background: #1e3a5f;
  color: #93c5fd;
}

/* Empty / error state when memory can't be loaded */
.detail-empty {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
  text-align: center;
  padding: 24px 0;
}

/* ── Similarity score badges ─────────────────────────────────────────────── */

.rec-status.score-high { background: #166534; color: #4ade80; }
.rec-status.score-mid  { background: #78350f; color: #fbbf24; }
.rec-status.score-low  { background: #374151; color: #9ca3af; }

/* Numeric percentage shown as secondary text inside the relevance badge */
.score-pct {
  font-weight: normal;
  opacity: 0.65;
  font-size: 10px;
}

/* ── Keyword search highlight ────────────────────────────────────────────── */

mark.search-highlight {
  background: rgba(250, 204, 21, 0.28); /* subtle amber glow on dark background */
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Semantic search loading pulse ──────────────────────────────────────── */

@keyframes pulse-opacity {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.4; }
}

.semantic-searching {
  animation: pulse-opacity 1.4s ease-in-out infinite;
}

/* ── Semantic mode active state ─────────────────────────────────────────── */

/* Subtle indigo glow on the search input when semantic mode is on */
.recordings-section.semantic-mode .search-input {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* ── Related memories section ───────────────────────────────────────────── */

.related-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

/* Each related memory is a button so it's keyboard-accessible and tappable */
.related-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.related-item:hover {
  background: #1f2937;
  border-color: #6366f1;
}

.related-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.related-name {
  font-size: 13px;
  font-weight: bold;
  color: #f3f4f6;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-date {
  font-size: 11px;
  color: #6b7280;
  flex-shrink: 0;
}

.related-summary {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.4;
}

/* ── Phase 5G: Sticky search & filter bar ────────────────────────────────────
   Wraps the search row, semantic button, and filter pills so they remain
   visible as the memory timeline scrolls beneath them.
   Background matches the page exactly; a hair-line divider appears below. */
.sticky-controls {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #111827;
  padding-top: 4px;
  padding-bottom: 2px;
  box-shadow: 0 1px 0 #1f2937;  /* subtle separator line */
}

/* ── Phase 5G: Transcript snippet preview ────────────────────────────────────
   Shown on cards that have a transcript but no AI summary yet.
   Single line, italic, clearly secondary to any summary text. */
.rec-preview {
  margin: 2px 0 0;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Phase 5G: Card hover lift ───────────────────────────────────────────────
   Subtle upward shift on hover gives physical affordance to card clickability. */
.rec-item:hover {
  background: #252f3e;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Phase 5G: Filter pill touch targets ─────────────────────────────────────
   Minimum 36 px height for comfortable mobile tapping. */
.filter-pill {
  min-height: 36px;
}

/* ── Phase 5G: Modal entrance animations ────────────────────────────────────
   The backdrop fades in; the panel slides up from a resting offset.
   Only fires on open (CSS animations trigger when the class is added;
   no exit animation — instant hide avoids a close-button delay). */
@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-panel-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Phase 5G: Improved empty-state legibility ───────────────────────────────
   Give empty state messages slightly more vertical space and a softer tone. */
.list-empty {
  padding: 24px 8px;
  line-height: 1.6;
}

/* ── Phase 5G: Reduced motion — disable all animations ─────────────────────
   Users who prefer reduced motion get instant open/close and no card lift. */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay.is-open,
  .modal-overlay.is-open .modal-panel,
  .semantic-searching,
  .update-banner,
  .rec-status.uploading {
    animation: none !important;
  }
  .rec-item {
    transition: none !important;
    transform: none !important;
  }
}

/* ── Phase 6B: Update available banner ──────────────────────────────────────
   Fixed pill at the bottom of the viewport. Appears when a new app version
   has been installed and is waiting. Hidden by default via [hidden] attribute. */
@keyframes banner-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.update-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: #1f2937;
  border: 1px solid #374151;
  color: #f9fafb;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  animation: banner-slide-up 0.25s ease-out;
}

/* [hidden] on the element hides it; removing hidden shows it with the animation */
.update-banner[hidden] { display: none; }

.update-reload-btn {
  background: #22c55e;
  color: #111827;
  border: none;
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Phase 6B: Install hint ──────────────────────────────────────────────────
   Subtle one-line row shown when the browser thinks the app is installable
   and it has not been added to the home screen yet. */
.install-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: #9ca3af;
}

.install-hint[hidden] { display: none; }

.install-hint-text {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.install-btn {
  flex-shrink: 0;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.install-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
