/* ──────────────────────────────────────────────────────────────────────────
   Video Assistant Dashboard — cream theme (matches extension)
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --bg-primary: #f5efe6;
  --bg-secondary: #ebe0d0;
  --bg-tertiary: #fff4d0;
  --bg-card: rgba(255, 255, 255, 0.5);
  --text-primary: #3d2817;
  --text-heading: #2b1810;
  --text-muted: #6b5a4a;
  --accent: #8b4513;
  --accent-hover: #a0522d;
  --accent-soft: rgba(139, 69, 19, 0.08);
  --border: #d4c4a8;
  --border-strong: #b8a384;
  --code-bg: #ebe0d0;
  --code-text: #5c3317;
  --warning-bg: var(--bg-tertiary);
  --warning-text: #5c4a00;
  --warning-border: #d4b94e;
  --success-bg: #dde8d4;
  --success-text: #3f6421;
  --error-bg: #f4d8d6;
  --error-text: #a0413e;
  /* ── Replay signal colours — keep in sync with CLR object in app.js ── */
  --replay-buy:        #3f6421;
  --replay-sell:       #a0413e;
  --replay-trade-buy:  #1a5fa8;
  --replay-trade-sell: #c07800;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

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

button {
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 14px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: var(--accent-soft); }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input[type=text], input[type=search], input[type=url], input[type=password], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

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

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
}

.sidebar-header h1 {
  margin: 0 0 18px;
  color: var(--text-heading);
  font-size: 18px;
  font-weight: 700;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

.sidebar-nav a:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }

.sidebar-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.topbar-search {
  flex: 1;
  max-width: 560px;
}

.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.empty {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

.muted { color: var(--text-muted); font-size: 12px; }

/* ── Pills / badges ────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pill-ok { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }
.pill-warn { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.pill-err { background: var(--error-bg); color: var(--error-text); border-color: var(--error-text); }

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  background: var(--bg-secondary);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.badge-low { background: var(--error-bg); color: var(--error-text); }
.badge-mid { background: #faf0d4; color: #8a6d00; }
.badge-high { background: var(--success-bg); color: var(--success-text); }

.tag {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 9px;
  margin: 2px 4px 2px 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
}

/* ── Cards / lists ─────────────────────────────────────────────────────── */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(61, 40, 23, 0.05);
  transition: border-color 0.15s, transform 0.05s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.card-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
  background: var(--bg-secondary);
}

.card-title {
  margin: 0 0 6px;
  color: var(--text-heading);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.card-meta > * { display: inline-flex; align-items: center; gap: 4px; }

.card-tags { display: flex; flex-wrap: wrap; margin-top: 8px; }

.card-summary {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Detail page ───────────────────────────────────────────────────────── */

.detail {
  max-width: 920px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.detail-header h1 {
  margin: 0;
  color: var(--text-heading);
  font-size: 26px;
  line-height: 1.2;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.detail-section {
  margin: 28px 0;
}

.detail-section h2 {
  margin: 0 0 12px;
  color: var(--text-heading);
  font-size: 18px;
  font-weight: 700;
}

.section-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}
.section-table th, .section-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.section-table tr:last-child td { border-bottom: 0; }
.section-table th { background: var(--bg-secondary); color: var(--text-heading); font-weight: 700; }

.watch-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
}
.watch-section .ts {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 700;
  color: var(--accent);
}

/* Markdown reader */

.markdown {
  padding: 6px 0 12px;
  font-size: 15px;
  line-height: 1.7;
}
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.3;
}
.markdown h1 { margin: 22px 0 10px; font-size: 22px; }
.markdown h2 { margin: 20px 0 8px; font-size: 18px; }
.markdown h3 { margin: 16px 0 8px; font-size: 16px; }
.markdown h4 { margin: 14px 0 8px; font-size: 15px; }
.markdown p, .markdown ul, .markdown ol { margin: 8px 0; }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown li::marker { color: var(--accent); }
.markdown strong, .markdown b { color: var(--text-heading); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.markdown blockquote {
  margin: 12px 0;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.markdown code {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.markdown pre {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  background: var(--code-bg);
  color: var(--code-text);
}
.markdown pre code { border: 0; padding: 0; background: transparent; }

details.transcript-collapse {
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--bg-card);
}
details.transcript-collapse > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}
.transcript-text {
  margin-top: 10px;
  max-height: 360px;
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* ── Filters bar ───────────────────────────────────────────────────────── */

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select, .filter-group input {
  font-size: 13px;
  padding: 6px 10px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
}

/* ── Settings panel ────────────────────────────────────────────────────── */

.settings-panel {
  position: fixed;
  inset: 0;
  background: rgba(61, 40, 23, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-panel[hidden] { display: none; }

.settings-card {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-primary);
  box-shadow: 0 6px 18px rgba(61, 40, 23, 0.25);
}

.settings-card h2 { margin-top: 0; color: var(--text-heading); }
.settings-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ── Stats page ────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
}
.stat-card .stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-card .stat-value {
  display: block;
  margin-top: 4px;
  color: var(--text-heading);
  font-size: 24px;
  font-weight: 700;
}

.bars { display: flex; flex-direction: column; gap: 6px; max-width: 520px; }
.bar-row { display: grid; grid-template-columns: 60px 1fr 80px; align-items: center; gap: 10px; font-size: 13px; }
.bar-fill { height: 14px; border-radius: 7px; background: var(--accent); min-width: 2px; }

/* ── Gold Review page ──────────────────────────────────────────────────── */

.gold-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 13px;
}
.gold-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}
.gold-progress-bar > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.gold-card {
  max-width: 820px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  background: var(--bg-card);
}
.gold-card h2 {
  margin: 0 0 4px;
  color: var(--text-heading);
  font-size: 18px;
}
.gold-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.gold-quote {
  margin: 14px 0 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: rgba(139, 69, 19, 0.05);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.55;
}
.gold-quote-meta {
  margin-top: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.gold-fields {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: 6px 14px;
  margin: 14px 0 18px;
  font-size: 13px;
}
.gold-fields dt {
  color: var(--text-muted);
  font-weight: 700;
}
.gold-fields dd {
  margin: 0;
  color: var(--text-primary);
  word-break: break-word;
}
.gold-fields dd.null { color: var(--text-muted); font-style: italic; }
.gold-fields dd code {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 12px;
}

.gold-reasoning {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.18);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.gold-reasoning.empty { font-style: italic; }

.gold-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.gold-actions button {
  flex: 1 1 auto;
  min-width: 140px;
  padding: 10px 14px;
  font-size: 14px;
}
.gold-actions .btn-approve {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-text);
}
.gold-actions .btn-approve:hover { background: #cce0c0; }
.gold-actions .btn-needs-fix {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}
.gold-actions .btn-needs-fix:hover { background: #fff0b0; }
.gold-actions .btn-reject {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-text);
}
.gold-actions .btn-reject:hover { background: #f2c5c2; }

.gold-form {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.45);
}
.gold-form label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.gold-form select, .gold-form textarea, .gold-form input[type=text] {
  width: 100%;
  margin-top: 4px;
}
.gold-form textarea { min-height: 80px; resize: vertical; }

.gold-summary .stat-card { text-align: center; }
.gold-summary-section { margin-top: 24px; }
.gold-summary-section h3 { margin: 0 0 10px; color: var(--text-heading); font-size: 16px; }

.gold-tf-question {
  margin: 14px 0 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.gold-tf-options { display: flex; gap: 8px; flex-wrap: wrap; }
.gold-tf-options button { flex: 0 0 auto; padding: 6px 14px; font-size: 12px; }

.gold-recommendation {
  margin-top: 22px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}
.gold-recommendation.warn { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.gold-recommendation.ok { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-text); }

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px 14px;
    align-items: center;
  }
  .sidebar-header { width: 100%; }
  .sidebar-header h1 { margin: 0 0 8px; font-size: 16px; }
  .sidebar-nav { flex-direction: row; flex: 1; gap: 2px; flex-wrap: wrap; }
  .sidebar-nav a { padding: 6px 10px; font-size: 12px; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: 0; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ──── Category tabs / back link / stat list (Gate 2) ──── */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px 0;
}
.category-tab {
  padding: 6px 14px;
  border: 1px solid var(--border, #d6d2c4);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.category-tab:hover {
  background: var(--surface-alt, #f6f0dc);
}
.category-tab.active {
  background: var(--accent, #b87333);
  color: #fff;
  border-color: var(--accent, #b87333);
}
.category-header {
  margin: 18px 0 10px 0;
  font-size: 16px;
  letter-spacing: 0.02em;
  opacity: 0.85;
}
.back-link {
  display: inline-block;
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--accent, #b87333);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }
.stat-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 0;
}
.stat-list dt { opacity: 0.7; }
.stat-list dd { margin: 0; }

/* ──── Knowledge (learning block — prompt v2.1+) ──── */
.knowledge-section { display: flex; flex-direction: column; gap: 12px; }
.knowledge-header { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
.k-pill, .k-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.02em;
  border: 1px solid var(--border, #d6d2c4);
}
.k-pill-subject  { background: var(--accent, #b87333); color: #fff; border-color: var(--accent, #b87333); font-weight: 600; }
.k-pill-content  { background: var(--surface-alt, #f6f0dc); color: inherit; }
.k-badge-skill   { background: transparent; opacity: 0.85; }
.k-badge-relevance.k-badge-high   { background: #2c7a3d; color: #fff; border-color: #2c7a3d; }
.k-badge-relevance.k-badge-medium { background: #cda03a; color: #fff; border-color: #cda03a; }
.k-badge-relevance.k-badge-low    { background: transparent; opacity: 0.7; }
.k-use-case { margin: 0 0 6px 0; font-style: italic; }
.k-block { padding: 6px 0; }
.k-block .k-label { font-size: 13px; margin: 0 0 6px 0; opacity: 0.8; font-weight: 600; }
.k-collapsible > summary { cursor: pointer; font-size: 13px; opacity: 0.85; font-weight: 600; padding: 4px 0; }
.k-collapsible[open] > summary { margin-bottom: 6px; }
.k-block-body { padding-left: 6px; }
.k-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.k-chip {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--surface-alt, #f6f0dc);
  border: 1px solid var(--border, #d6d2c4);
}
.k-chip-concept   { background: #efe7d2; }
.k-chip-tool      { background: #e6e0c8; }
.k-chip-framework { background: #ddd5bd; }
.k-chip-prereq    { background: transparent; opacity: 0.85; }
.k-list { margin: 0; padding-left: 22px; }
.k-list li { margin: 3px 0; line-height: 1.5; }
.k-list-timestamps li a { color: var(--accent, #b87333); text-decoration: none; }
.k-list-timestamps li a:hover { text-decoration: underline; }

/* ──── Pass A failure badge / banner (session 3) ──── */
.pill-warn {
  background: #cd6a1a;
  color: #fff;
  border-color: #cd6a1a;
  font-weight: 600;
}
.pass-a-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 0 0 14px 0;
  background: #fdf1dc;
  border: 1px solid #cd6a1a;
  border-radius: 8px;
  color: #5b3300;
}
.pass-a-banner-text { flex: 1 1 auto; font-size: 14px; }
.pass-a-banner-btn {
  padding: 6px 14px;
  border: 1px solid #cd6a1a;
  background: #cd6a1a;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.pass-a-banner-btn:hover:not(:disabled) { background: #b95a14; }
.pass-a-banner-btn:disabled { opacity: 0.7; cursor: wait; }

/* ──── Thumbnail placeholder (session 5) ──── */
.card-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt, #f6f0dc);
  border: 1px dashed var(--border, #d6d2c4);
  font-size: 36px;
  color: var(--accent, #b87333);
  opacity: 0.55;
}
.card-thumb-placeholder-icon { line-height: 1; }

/* ──── Replay Dashboard ─────────────────────────────────────────────────── */
.replay-root { display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 0; }

.replay-controls {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px;
}
.replay-ctrl-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.replay-ctrl-sep { color: var(--border-strong); padding: 0 2px; }
.replay-t-display { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

.replay-speed-btn { padding: 5px 10px; font-size: 12px; }
.replay-speed-btn.active { background: var(--accent); color: #fff; }

.replay-body {
  display: flex; gap: 12px; align-items: flex-start; min-height: 0;
}
.replay-charts { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.replay-chart-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.replay-chart-label { padding: 4px 10px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.replay-svg-wrap { width: 100%; }
.replay-svg-wrap svg { display: block; width: 100%; user-select: none; -webkit-user-select: none; }
.replay-svg-wrap svg.panning { cursor: grabbing !important; }
/* MTF state bands panel — compact, no extra padding */
.replay-mtf-outer .replay-chart-label { font-size: 11px; font-weight: 500; padding: 3px 10px; }

.replay-side-panel {
  width: 280px; flex-shrink: 0; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; font-size: 13px; max-height: 380px; overflow-y: auto;
}
.replay-sp-section { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.replay-sp-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.replay-sp-heading { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.05em; }
.replay-sp-row { display: flex; justify-content: space-between; gap: 6px; line-height: 1.7; }
.replay-sp-label { color: var(--text-muted); white-space: nowrap; }
.replay-sp-val { font-weight: 600; text-align: right; }
.replay-sp-reason { margin-top: 4px; font-size: 12px; color: var(--text-muted); white-space: pre-wrap; line-height: 1.5; }

.replay-event-log { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; max-height: 200px; overflow-y: auto; }
.replay-ev-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.replay-ev-table th { padding: 6px 10px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-secondary); }
.replay-ev-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.replay-event-row { cursor: pointer; transition: background 0.1s; }
.replay-event-row:hover { background: var(--accent-soft); }
.replay-event-row.active { background: var(--bg-tertiary); }
.replay-event-row.future td { opacity: 0.4; }
.replay-ev-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-muted); }

.replay-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.replay-badge-utbot    { background: #dde8d4; color: #3f6421; }
.replay-badge-signal   { background: #e8dff5; color: #5a3580; }
.replay-badge-decision { background: var(--bg-tertiary); color: #5c4a00; }
.replay-badge-telegram { background: #d4e8f5; color: #1a5a80; }
.replay-badge-command  { background: #f5e8d4; color: #7a4a1a; }
.replay-badge-trade    { background: #dde8d4; color: #1a5040; }

.replay-empty { padding: 12px; color: var(--text-muted); font-size: 13px; font-style: italic; }

.replay-csv-wrap { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.replay-csv-btn { font-size: 12px; padding: 5px 10px; }
.replay-csv-area { font-family: monospace; font-size: 12px; width: 360px; }

.replay-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; padding: 4px 0; }
.replay-legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); }
/* UT Bot legend: thin tall band */
.replay-legend-dash   { display: inline-block; width: 4px; height: 12px; border-radius: 1px; opacity: 0.75; }
/* Trade legend: slightly wider */
.replay-legend-tbuy, .replay-legend-tsell { width: 5px; height: 14px; opacity: 0.9; }
/* Cursor: horizontal dash */
.replay-legend-cursor { width: 14px; height: 2px; opacity: 1; }
.replay-legend-utbuy   { background: #3f6421; }
.replay-legend-utsell  { background: #a0413e; }
.replay-legend-tbuy    { background: #1a5fa8; }
.replay-legend-tsell   { background: #c07800; }
.replay-legend-cursor  { background: #8b4513; }
.replay-legend-mtflong { background: #3f8c1a; opacity: 0.8; width: 18px; height: 9px; border-radius: 1px; }
.replay-legend-mtfshort{ background: #c0392b; opacity: 0.8; width: 18px; height: 9px; border-radius: 1px; }

.replay-sp-focused { border-left: 3px solid #d4a017; background: rgba(212,160,23,0.06); padding-left: 8px; border-radius: 0 4px 4px 0; }
/* Focused panel: signal-type border + tint */
.replay-sp-focused--buy   { border-left-color: #3f8c1a; background: rgba(63,140,26,0.07); }
.replay-sp-focused--sell  { border-left-color: #c0392b; background: rgba(192,57,43,0.07); }
.replay-sp-focused--tbuy  { border-left-color: #1a5fa8; background: rgba(26,95,168,0.07); }
.replay-sp-focused--tsell { border-left-color: #c07800; background: rgba(192,120,0,0.07); }
/* Focused panel headings */
.replay-sp-heading--buy   { color: #4caf2a; }
.replay-sp-heading--sell  { color: #e05040; }
.replay-sp-heading--tbuy  { color: #4a90d9; }
.replay-sp-heading--tsell { color: #e09020; }
/* UT Bot state row value colors */
.replay-sp-val--long  { color: #4caf2a; font-weight: 600; }
.replay-sp-val--short { color: #e05040; font-weight: 600; }
/* Speed select dropdown */
.replay-speed-sel { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font-size: 12px; cursor: pointer; max-width: 75px; min-width: 0; }
.replay-speed-sel:focus { outline: none; border-color: var(--accent); }

/* ── Day nav + LIVE button / label (P2/P3) ──────────────────────────── */
.replay-live-btn   { color: #c0392b; font-weight: 700; }
.replay-live-label { display: inline-block; font-size: 11px; font-weight: 700;
                     color: #fff; background: #c0392b; border-radius: 3px;
                     padding: 1px 6px; letter-spacing: 0.04em; }
/* display:inline-block above would override UA [hidden]; this rule restores it */
.replay-live-label[hidden] { display: none; }

/* ── Freshness / status badge bar (P4) ──────────────────────────────── */
.replay-status-bar   { display: flex; gap: 6px; align-items: center; padding: 3px 0 2px; flex-wrap: wrap; min-height: 24px; }
.replay-status-badge { font-size: 11px; font-weight: 600; border-radius: 10px; padding: 2px 9px; }
.replay-badge-fresh      { background: #dde8d4; color: #1a5040; }
.replay-badge-stale      { background: #f5e8d4; color: #7a3a00; }
.replay-badge-no-signals { background: #ebe0d0; color: #6b5a4a; }
.replay-badge-historical { background: #e8e0f0; color: #4a3a70; }

/* ── MTF band hover tooltip (P2) ────────────────────────────────────── */
.replay-mtf-tip {
  position: fixed; pointer-events: none; z-index: 9999;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  padding: 8px 10px; font-size: 12px; color: var(--text);
  min-width: 220px; max-width: 280px; display: none;
}
.mtip-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.mtip-tbl  { width: 100%; border-collapse: collapse; }
.mtip-k    { color: var(--text-muted); padding: 1px 8px 1px 0; white-space: nowrap; vertical-align: top; }
.mtip-v    { font-weight: 600; text-align: right; padding: 1px 0; }
.mtip-mono { font-family: monospace; font-size: 11px; font-weight: 400; }
.mtip-sep-r td { padding: 3px 0 0; border-top: 1px solid var(--border); }

/* ── T212 import toggle + status (bug-fix session) ───────────────────── */
.replay-t212-toggle-lbl { font-size: 12px; cursor: pointer; user-select: none;
                          display: flex; align-items: center; gap: 4px; }
.replay-import-status   { font-size: 11px; color: var(--text-muted); font-style: italic;
                          align-self: center; }

/* ── Real-time event ticker ────────────────────────────────────────── */
.replay-ticker {
  display: flex; align-items: center; gap: 0; flex-wrap: nowrap;
  padding: 4px 12px; font-size: 12px; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; white-space: nowrap; overflow: hidden;
  margin-bottom: 0;
}
.replay-ticker-sep  { color: var(--border); padding: 0 7px; user-select: none; }
.replay-ticker-lbl  { color: var(--text-muted); }
.replay-ticker-time { font-variant-numeric: tabular-nums; }
.replay-ticker-val  { font-variant-numeric: tabular-nums; }
.replay-ticker-val--long  { color: #4caf2a; font-weight: 700; }
.replay-ticker-val--short { color: #e05040; font-weight: 700; }
.replay-ticker-badge { display: inline-block; padding: 1px 6px; border-radius: 8px;
                       font-size: 11px; font-weight: 700; white-space: nowrap;
                       vertical-align: middle; }
.replay-ticker-badge--utbuy   { background: #dde8d4; color: #1a5040; }
.replay-ticker-badge--utsell  { background: #f5d5d5; color: #8b1c1c; }
.replay-ticker-badge--tbuy    { background: #d4e0f5; color: #1a3a80; }
.replay-ticker-badge--tsell   { background: #f5e8c0; color: #7a4a00; }
.replay-ticker-badge--decision { background: #ede0f5; color: #5a2080; }
.replay-ticker-badge--telegram { background: #d4e8f5; color: #1a5a80; }
.replay-ticker-badge--signal   { background: #e8dff5; color: #5a3580; }
.replay-ticker-badge--command  { background: #f5e8d4; color: #7a4a1a; }

@media (max-width: 800px) {
  .replay-body { flex-direction: column; }
  .replay-side-panel { width: 100%; max-height: none; }
  .replay-ticker { flex-wrap: wrap; }
}

/* ──── Guest / share mode (no auth) ──────────────────────────────────────── */
body.guest .sidebar,
body.guest .topbar,
body.guest #settings-panel { display: none !important; }

body.guest #app { grid-template-columns: 1fr; }

body.guest .main {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

body.guest .content { padding: 24px 20px; }

.guest-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.guest-brand strong { color: var(--text-heading); font-size: 15px; }

/* ──── Profilo / Memoria ─────────────────────────────────────────────────── */
.profile-memory-box {
  width: 100%;
  box-sizing: border-box;
  min-height: 260px;
  resize: vertical;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 13px;
  line-height: 1.7;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.usefulness-card {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-size: 14px;
  line-height: 1.65;
}
