:root {
  --cst-bg: #f4f5f7;
  --cst-card-border: #e6e7eb;
  --cst-text-muted: #6b7280;
  --cst-accent: #111827;
}

body {
  background-color: var(--cst-bg);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.cst-sidebar {
  width: 220px;
  flex-shrink: 0;
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid var(--cst-card-border);
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  transition: width 0.15s ease, padding 0.15s ease;
  overflow: hidden;
}

.cst-sidebar-brand {
  font-size: 1.1rem;
  padding: 0 0.5rem;
  white-space: nowrap;
}

.cst-sidebar-toggle {
  flex-shrink: 0;
}

.cst-sidebar-link {
  color: #374151 !important;
  border-radius: 10px;
  padding: 0.55rem 0.75rem !important;
  font-size: 0.92rem;
  white-space: nowrap;
}

.cst-sidebar-link:hover {
  background: #f3f4f6;
}

.cst-sidebar-link.active {
  background: #111827 !important;
  color: #fff !important;
}

.cst-sidebar-collapsed {
  width: 64px;
  padding: 1.25rem 0.5rem;
}

.cst-sidebar-collapsed .cst-sidebar-label {
  display: none;
}

.cst-sidebar-collapsed .cst-sidebar-brand {
  display: none;
}

.cst-sidebar-collapsed .d-flex.align-items-center.justify-content-between {
  justify-content: center !important;
}

.cst-sidebar-collapsed .cst-sidebar-link {
  text-align: center;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.cst-sidebar-collapsed .cst-sidebar-link i {
  margin-right: 0 !important;
}

.cst-sidebar {
  display: flex;
  flex-direction: column;
}

.cst-sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--cst-card-border);
}

.cst-sidebar-hidden {
  display: none;
}

.cst-auth-card {
  max-width: 440px;
  margin: 8vh auto 0;
}

.cst-pw-toggle {
  border: 1px solid #dee2e6;
  color: var(--cst-text-muted);
}

.cst-auth-brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.cst-main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 2rem;
}

.cst-card {
  background: #fff;
  border: 1px solid var(--cst-card-border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.cst-card h2, .cst-card h5 {
  font-weight: 600;
}

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

.cst-pill {
  display: inline-block;
  border-radius: 999px;
  border: 1px solid var(--cst-card-border);
  padding: 0.3rem 0.85rem;
  margin: 0.2rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: #fff;
  user-select: none;
  transition: all 0.12s ease;
}

.cst-pill:hover {
  border-color: #c7c9d1;
}

.cst-pill.active {
  background: var(--cst-accent);
  color: #fff;
  border-color: var(--cst-accent);
}

.cst-stage-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.cst-stage-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Active Workspace: narrow companion layout per brief 3.1. Designed for a
   ~400-500px browser window beside the AI tool; the sidebar is locked to
   icons there (.cst-sidebar-locked) and page margins shrink. */
.cst-workspace-shell {
  max-width: 520px;
  margin: 0 auto;
}

.cst-main-compact {
  padding: 0.75rem;
}

.cst-sidebar-locked .cst-sidebar-toggle {
  display: none;
}

.cst-workspace-shell .cst-card {
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.cst-workspace-shell h5 {
  font-size: 1.05rem;
}

.cst-workspace-shell .cst-compact-card {
  padding: 0.6rem 1rem;
}

.cst-header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cst-stage-select {
  flex: 1 1 50%;
  min-width: 0;
}

.cst-chrono {
  flex: 1 1 50%;
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: right;
}

/* W3: three equal buttons on their own row */
.cst-control-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.cst-collapse-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  user-select: none;
  min-height: 1.75rem;
}

.cst-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-width: 0;
}

.cst-chip {
  background: var(--cst-accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
}

.cst-prompt {
  display: flex;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
}

.cst-attach-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cst-audio-preview {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
}

.cst-audio-player {
  width: 100%;
  height: 36px;
}

.cst-note-line {
  border-top: 1px solid var(--cst-card-border);
  padding: 0.4rem 0.25rem;
  border-radius: 6px;
  cursor: pointer;
}

.cst-note-line:hover {
  background: #f9fafb;
}

/* W3: Pause / Resume / Finish share one look */
.cst-control-row .btn {
  border: 1px solid var(--cst-card-border);
}

/* Note detail pop-up (components/note_detail.py) */
.cst-note-text {
  white-space: pre-wrap;
}

.cst-note-image {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--cst-card-border);
}

.cst-transcript {
  background: #f9fafb;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

/* Rubber duck recorder pop-up (assets/cst_audio.js) */
.cst-duck-wrap {
  text-align: center;
}

.cst-duck {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0.25rem auto 0.5rem;
  display: block;
}

.cst-duck.recording {
  animation: cst-duck-bob 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.15);
}

@keyframes cst-duck-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-6px) rotate(-3deg); }
  75% { transform: translateY(-3px) rotate(3deg); }
}

.cst-audio-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.cst-duck-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* One banner under the header: a calm "Next reflection in X min" line that
   turns into the red nudge panel (.cst-nudge-banner) when a nudge is due. */
.cst-reflection-banner {
  background: #fff;
  border: 1px solid var(--cst-card-border);
  border-left: 4px solid #9ca3af;
  border-radius: 12px;
  padding: 0.6rem 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--cst-text-muted);
  font-size: 0.9rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.cst-nudge-banner {
  color: inherit;
  font-size: 1rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-left: 4px solid #dc2626;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.cst-nudge-banner .fw-semibold {
  color: #b91c1c;
}

.cst-timeline-item {
  border-left: 2px solid var(--cst-card-border);
  padding-left: 1rem;
  padding-bottom: 1rem;
  position: relative;
}

.cst-timeline-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cst-accent);
}

/* Graph zoom toolbar (components/workflow_preview.py, assets/cst_graph.js) */
.cst-graph-wrap {
  position: relative;
  border: 1px solid var(--cst-card-border);
  border-radius: 10px;
}

.cst-graph-toolbar {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--cst-card-border);
  border-radius: 6px;
  padding: 2px;
  z-index: 5;
}

.cst-graph-btn {
  border: 0;
  background: transparent;
  color: var(--cst-text-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.cst-graph-btn:hover {
  background: #f3f4f6;
  color: var(--cst-accent);
}

/* N1: stage minutes the artist set themselves (locked) */
.cst-stage-min-locked {
  border-color: #111827;
  font-weight: 600;
}

.cst-stage-lock {
  color: #d1d5db !important;
  padding: 0 0.25rem;
}

.cst-stage-lock.locked {
  color: #111827 !important;
}

/* Post-session logged moments (pages/retrospective.py) */
.cst-moment {
  border-top: 1px solid var(--cst-card-border);
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
}

.cst-moment:hover {
  background: #f9fafb;
}

/* Journal (pages/journal.py) */
.cst-journal {
  max-width: 820px;
}

.cst-project-card:hover,
.cst-entry:hover {
  border-color: #9ca3af;
}

.cst-thumb-row {
  display: flex;
  gap: 0.4rem;
}

.cst-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--cst-card-border);
}

.cst-entry {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  cursor: pointer;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.cst-entry-image {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

/* Signposts (components/keyword_matrix.py, assets/cst_ui.js): one
   horizontally scrolling row per keyword group, label fixed on the left. */
.cst-chip-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  margin-bottom: 0.35rem;
}

.cst-chip-row-label {
  flex: 0 0 4.4rem;
  font-size: 0.78rem;
  color: var(--cst-text-muted);
}

/* Two lines per group that scroll sideways together. */
.cst-chip-scroll {
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 1;
}

.cst-chip-scroll::-webkit-scrollbar {
  display: none;
}

.cst-chip-line {
  display: flex;
  flex-wrap: nowrap;
  width: max-content;
}

.cst-chip-scroll .cst-pill {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Fade + "›" only while the row has more to the right (set by cst_ui.js). */
.cst-chip-group.has-more .cst-chip-scroll {
  -webkit-mask-image: linear-gradient(to right, #000 82%, transparent);
  mask-image: linear-gradient(to right, #000 82%, transparent);
}

.cst-chip-more {
  display: none;
  position: absolute;
  right: -0.15rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  line-height: 1;
  color: var(--cst-text-muted);
  cursor: pointer;
  padding: 0 0.2rem;
}

.cst-chip-group.has-more .cst-chip-more {
  display: block;
}

/* 5-step surprise scale */
.cst-surprise-group {
  align-items: flex-start;
  margin-top: 0.4rem;
}

.cst-scale {
  flex: 1;
  min-width: 0;
}

.cst-scale-track {
  display: flex;
  justify-content: space-between;
  position: relative;
  padding: 0.35rem 0.2rem 0;
}

.cst-scale-track::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: calc(0.35rem + 0.55rem);
  border-top: 2px solid var(--cst-card-border);
}

.cst-scale-step {
  position: relative;
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.cst-scale-dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #9ca3af;
}

.cst-scale-step:hover .cst-scale-dot {
  border-color: var(--cst-accent);
}

.cst-scale-step.active .cst-scale-dot {
  background: var(--cst-accent);
  border-color: var(--cst-accent);
}

.cst-scale-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--cst-text-muted);
  margin-top: 0.2rem;
}

.cst-scale-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.1rem;
}
