/* ── CSS Variables ───────────────────────────────────────────── */
:root {
  --bg:      #f4f6f9;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
  --accent:  #d97706;
  --green:   #16a34a;
  --red:     #dc2626;
  --radius:  10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.08);
}

/* Override Bootstrap light theme base */
[data-bs-theme="light"] { --bs-body-bg: var(--bg); --bs-body-color: var(--text); }
html, body { overflow-x: clip; }   /* clip, not hidden: hidden breaks position: sticky (header, Claude activity panel) */
body {
  background: var(--bg); color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Sticky header ──────────────────────────────────────────── */
.tj-header {
  position: sticky; top: 0; z-index: 1030;
  background: rgba(244,246,249,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.tj-header .brand { color: var(--accent); font-weight: 700; font-size: 1rem; white-space: nowrap; }

/* ── Nav pills ───────────────────────────────────────────────── */
.tj-nav { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.tj-nav .nav-link {
  flex: 1; text-align: center;
  color: var(--muted); font-size: 0.8rem; font-weight: 600;
  padding: 6px 14px; border-radius: 6px; white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.tj-nav .nav-link.active { background: var(--accent) !important; color: #0f1117 !important; }
.tj-nav .nav-link:not(.active):hover { color: var(--text); }

/* ── Profit mode toggle ──────────────────────────────────────── */
.pct-toggle {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 0.8rem; font-weight: 700;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.pct-toggle.active { background: rgba(217,119,6,0.1); border-color: var(--accent); color: var(--accent); }

/* ── Settings modal ─────────────────────────────────────────── */
#settingsModal .modal-content {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
#settingsModal .modal-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}
#settingsModal .modal-title { font-size: 1rem; font-weight: 700; }
#settingsModal .modal-body  { padding: 0; }

.settings-group { padding: 4px 20px 14px; }
.settings-group + .settings-group { border-top: 1px solid var(--border); }
.settings-group-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); padding: 12px 0 8px;
}
.settings-group-sub { font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; margin-top: -4px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 0;
}
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row-title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.settings-row-sub   { font-size: 0.74rem; color: var(--muted); margin-top: 3px; }

/* Segmented control (profit mode) */
.settings-segmented {
  display: flex; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.seg-opt {
  background: none; border: none; padding: 5px 14px;
  font-size: 0.8rem; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s; white-space: nowrap;
}
.seg-opt + .seg-opt { border-left: 1px solid var(--border); }
.seg-opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Toggle switch */
.settings-switch {
  position: relative; display: inline-block;
  width: 44px; height: 24px; cursor: pointer; flex-shrink: 0;
}
.settings-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.settings-switch-track {
  position: absolute; inset: 0;
  background: var(--border); border-radius: 999px;
  transition: background .2s;
}
.settings-switch input:checked ~ .settings-switch-track { background: var(--accent); }
.settings-switch-track::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  top: 3px; left: 3px; transition: transform .2s;
}
.settings-switch input:checked ~ .settings-switch-track::after { transform: translateX(20px); }

.bal-input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.78rem; padding: 4px 8px; width: 90px; outline: none;
}
.bal-input:focus { border-color: var(--accent); }

.tj-badge {
  font-size: 0.72rem; padding: 3px 9px; border-radius: 999px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}

.refresh-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); padding: 5px 9px; font-size: 1rem; cursor: pointer; line-height: 1;
  transition: color .15s, border-color .15s;
}
.refresh-btn:hover { color: var(--accent); border-color: var(--accent); }
.spinning { animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Custom select / filter dropdown ────────────────────────── */
.trades-filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tj-select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.82rem; font-weight: 600;
  padding: 6px 32px 6px 12px; cursor: pointer; outline: none;
  transition: border-color .15s;
  flex: 1; min-width: 140px;
}
.tj-select:focus  { border-color: var(--accent); }
.tj-select:hover  { border-color: var(--accent); }
.tj-select option { background: var(--surface); color: var(--text); }

/* Status pills (All / Open / Closed) */
.status-pills { display: flex; gap: 4px; flex-shrink: 0; }
.status-pill {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 0.75rem; font-weight: 600; padding: 5px 13px;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s, background .15s;
}
.status-pill.active { background: rgba(217,119,6,0.1); border-color: var(--accent); color: var(--accent); }
.status-pill:not(.active):hover { color: var(--text); border-color: #94a3b8; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  position: sticky; top: var(--header-h, 84px); z-index: 1029;
  background: rgba(244,246,249,0.97); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.chips { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 0.75rem; font-weight: 600; padding: 4px 12px;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s, background .15s;
}
.chip.active { background: rgba(217,119,6,0.1); border-color: var(--accent); color: var(--accent); }
.chip:not(.active):hover { color: var(--text); border-color: #444; }
/* ── Pair filter chips ────────────────────── */
.filter-divider { display: inline-block; width: 1px; height: 20px; background: var(--border); align-self: center; flex-shrink: 0; }
.pair-chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 0.75rem; font-weight: 600; padding: 4px 12px;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s, background .15s;
}
.pair-chip.active { background: rgba(14,165,233,0.1); border-color: #0ea5e9; color: #0ea5e9; }
.pair-chip:not(.active):hover { color: var(--text); border-color: #444; }
.custom-dates { display: flex; align-items: center; gap: 6px; }
.custom-dates input[type="date"] {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.78rem; padding: 4px 8px; outline: none;
}
.custom-dates input[type="date"]:focus { border-color: var(--accent); }

/* ── Cards ──────────────────────────────────────────────────── */
.tj-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 1rem;
}
.tj-card .label { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.3rem; }
.tj-card .value { font-size: 1.2rem; font-weight: 700; }
.trades-sub    { font-size: 0.72rem; margin-top: 4px; }
.trades-open   { color: var(--accent); font-weight: 600; }
.trades-closed { color: var(--muted); }
.trades-sep    { color: var(--border); }
.positive { color: var(--green); }
.negative { color: var(--red); }

/* ── Section title ───────────────────────────────────────────── */
.section-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }

/* ── Strategy card ───────────────────────────────────────────── */
.strat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.strat-card.strat-pos { border-top: 3px solid var(--green); }
.strat-card.strat-neg { border-top: 3px solid var(--red); }
.strat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); gap: 0.5rem;
}
.strat-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strat-profit { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.strat-stats { display: grid; grid-template-columns: repeat(4,1fr); text-align: center; }
.strat-stat { padding: 0.5rem 0.25rem; border-right: 1px solid var(--border); }
.strat-stat:last-child { border-right: none; }
.strat-stat .sl { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.strat-stat .sv { font-size: 0.82rem; font-weight: 600; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th, .table-wrap td { padding: 0.7rem 0.9rem; text-align: left; white-space: nowrap; }
.table-wrap th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
}
.table-wrap tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.table-wrap tr:hover td { background: rgba(0,0,0,0.025); }
.profit-cell { font-weight: 600; }
.thumb {
  width: 64px; height: 40px; object-fit: cover; border-radius: 4px;
  border: 1px solid var(--border); cursor: pointer; transition: transform .15s;
}
.thumb:hover { transform: scale(1.15); }
.status-msg { text-align: center; padding: 3rem; color: var(--muted); font-size: 0.95rem; }

/* ── Mobile trade card ───────────────────────────────────────── */
.trade-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.trade-card.card-win  { border-left: 3px solid var(--green); }
.trade-card.card-loss { border-left: 3px solid var(--red); }
.tc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); gap: 0.5rem;
}
.tc-left { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.dir-badge { font-size: 0.8rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.dir-buy  { background: rgba(34,197,94,0.15);  color: var(--green); }
.dir-sell { background: rgba(239,68,68,0.15);   color: var(--red); }

/* ── Quality grade badges ────────────────────────────────────── */
.quality-cell { white-space: nowrap; }
.q-wrap  { display: inline-flex; align-items: center; gap: 4px; cursor: default; }
.q-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 1px 8px; border-radius: 999px; letter-spacing: 0.3px;
}
.q-sub { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.2px; }
.q-a { background: rgba(34,197,94,0.18);  color: #22c55e; }
.q-b { background: rgba(59,130,246,0.15); color: #3b82f6; }
.q-c { background: rgba(245,158,11,0.15); color: #f59e0b; }
.q-d { background: rgba(239,68,68,0.15);  color: #ef4444; }

.tc-symbol { font-weight: 600; font-size: 0.95rem; }
.tc-meta   { font-size: 0.75rem; color: var(--muted); }
.tc-profit { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.tc-body   { display: grid; grid-template-columns: 1fr 1fr; }
.tc-field  { padding: 0.55rem 1rem; border-bottom: 1px solid var(--border); }
.tc-field:nth-child(odd) { border-right: 1px solid var(--border); }
.tc-field.tc-full { grid-column: 1 / -1; border-right: none; }
.tc-field .fl { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }
.tc-field .fv { font-size: 0.85rem; font-weight: 500; }
.tc-field.tc-remark { background: var(--bg-alt, rgba(0,0,0,0.04)); }
.tc-field.tc-remark .fl { color: var(--muted); }
.tc-field.tc-remark .remark-text { font-size: 0.78rem; font-weight: 400; color: var(--text-secondary, var(--muted)); font-style: italic; line-height: 1.45; white-space: pre-wrap; }
.tc-images { display: grid; grid-template-columns: 1fr 1fr; }
.tc-img-wrap { padding: 0.6rem 1rem; border-top: 1px solid var(--border); }
.tc-img-wrap:first-child { border-right: 1px solid var(--border); }
.tc-img-wrap .fl { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 0.4rem; }
.tc-thumb { width: 100%; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; }
.tc-no-img { font-size: 0.8rem; color: var(--muted); }

/* ── Lightbox ────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; cursor: zoom-out; padding: 1rem;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: var(--radius); }

/* ── Responsive visibility ───────────────────────────────────── */
@media (min-width: 768px) { .mobile-only  { display: none !important; } }
@media (max-width: 767px) { .desktop-only { display: none !important; } }
@media (min-width: 768px) {
  #page-summary, #page-analytics { max-width: 1400px; margin-left: auto; margin-right: auto; }
}

/* ── Analytics ───────────────────────────────────────────────── */
.chart-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 0.6rem; font-weight: 600; }
.chart-wrap  { position: relative; }
.an-stat-card .value { font-size: 1.05rem; }

/* ── Diary page ──────────────────────────────────────────────── */

/* Entry list card */
.diary-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
  margin-bottom: 10px; min-height: 60px;
  -webkit-tap-highlight-color: transparent;
}
.diary-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(217,119,6,0.12); }
.diary-card-date {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0; min-width: 46px; padding: 6px 6px;
  background: rgba(217,119,6,0.08); border-radius: 8px;
}
.diary-day  { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--accent); letter-spacing: 0.04em; }
.diary-date { font-size: 0.65rem; color: var(--muted); white-space: normal; text-align: center; line-height: 1.3; }
.diary-card-body { flex: 1; min-width: 0; /* allow flex child to shrink below content size */ }
.diary-card-title {
  font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 4px;
  overflow-wrap: break-word; word-break: break-word;
}
.diary-badge {
  display: inline-block; font-size: 0.67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 8px; border-radius: 20px;
  background: rgba(217,119,6,0.12); color: var(--accent);
}
.diary-badge.live  { background: rgba(22,163,74,0.1);  color: var(--green); }
.diary-badge.daily { background: rgba(59,130,246,0.12); color: #3b82f6; }
.diary-card-arrow { color: var(--muted); font-size: 0.9rem; }

/* Back button */
.diary-back-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 0.85rem; font-weight: 600;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  min-height: 40px; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}
.diary-back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Diary review reminder banner ───────────────────────────── */
.diary-reminder {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius);
  font-size: 0.85rem; line-height: 1.3;
}
.diary-reminder--weekly {
  background: rgba(59,130,246,0.09); border: 1px solid rgba(59,130,246,0.25);
  color: #1e40af;
}
.diary-reminder--monthly {
  background: rgba(217,119,6,0.09); border: 1px solid rgba(217,119,6,0.3);
  color: #92400e;
}
.diary-reminder > i { font-size: 1.1rem; flex-shrink: 0; }
.diary-reminder-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.diary-reminder-text strong { font-weight: 700; }
.diary-reminder-text span   { opacity: 0.8; font-size: 0.78rem; }
.diary-reminder-badge {
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.diary-reminder--weekly  .diary-reminder-badge { background: rgba(59,130,246,0.18); color: #1d4ed8; }
.diary-reminder--monthly .diary-reminder-badge { background: rgba(217,119,6,0.18);  color: #b45309; }

/* Filter bar */
.diary-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.diary-filter-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 0.8rem; font-weight: 600;
  padding: 6px 14px; border-radius: 20px; cursor: pointer;
  min-height: 34px; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.diary-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.diary-filter-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}

/* Asset (XAU / BTC) tabs inside an open diary entry */
.asset-tab-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.asset-tab-btn {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  color: var(--muted); font-size: 0.82rem; font-weight: 700;
  padding: 6px 12px 8px; cursor: pointer;
  letter-spacing: 0.03em; text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, border-color 0.15s;
}
.asset-tab-btn:hover { color: var(--accent); }
.asset-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.asset-hidden { display: none !important; }

/* Rendered Markdown entry body */
.diary-entry-body {
  padding: 20px 24px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  overflow-x: hidden;   /* prevent any child from blowing out the card */
  word-break: break-word;
  overflow-wrap: break-word;
}
.diary-entry-body h1 {
  font-size: 1.3rem; font-weight: 700; margin-bottom: 4px;
  border-bottom: 2px solid var(--accent); padding-bottom: 8px; margin-bottom: 16px;
}
.diary-entry-body h2 {
  font-size: 1.05rem; font-weight: 700; color: var(--accent);
  margin-top: 24px; margin-bottom: 10px;
}
.diary-entry-body h3 {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
  margin-top: 18px; margin-bottom: 8px;
}
.diary-entry-body h4 { font-size: 0.88rem; font-weight: 700; margin-top: 14px; margin-bottom: 6px; }
.diary-entry-body p  { margin-bottom: 10px; }
.diary-entry-body hr { border-color: var(--border); margin: 20px 0; }
.diary-entry-body ul, .diary-entry-body ol { padding-left: 1.5em; margin-bottom: 10px; }
.diary-entry-body li { margin-bottom: 4px; }
.diary-entry-body strong { color: var(--text); }

/* Tables inside markdown */
.diary-table-wrap  { overflow-x: auto; margin-bottom: 16px; -webkit-overflow-scrolling: touch; max-width: 100%; }
.diary-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.8rem; white-space: nowrap;
}
.diary-table th, .diary-table td {
  padding: 6px 12px; border: 1px solid var(--border);
  text-align: left;
}
.diary-table th {
  background: rgba(217,119,6,0.08);
  font-weight: 700; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent);
}
.diary-table tr:nth-child(even) td { background: rgba(0,0,0,0.025); }
.diary-table tr:hover td { background: rgba(217,119,6,0.04); }

/* Inline code & code blocks */
.diary-code {
  background: rgba(0,0,0,0.06); border-radius: 4px;
  padding: 1px 5px; font-size: 0.82em; color: var(--text);
}
.diary-entry-body pre {
  background: #1e293b; color: #e2e8f0;
  border-radius: 8px; padding: 14px 16px; overflow-x: auto;
  font-size: 0.8rem; margin-bottom: 14px; max-width: 100%;
  white-space: pre; /* preserve formatting but allow scroll */
}
.diary-entry-body pre code { background: none; color: inherit; padding: 0; font-size: inherit; white-space: inherit; }
/* Images in diary entries must never exceed card width */
.diary-entry-body img { max-width: 100%; height: auto; border-radius: 6px; }

/* Blockquotes */
.diary-blockquote {
  border-left: 3px solid var(--accent);
  margin: 10px 0; padding: 8px 16px;
  background: rgba(217,119,6,0.05);
  border-radius: 0 6px 6px 0;
  color: var(--muted);
}
@media (max-width: 540px) {
  .diary-entry-body { padding: 14px 12px; font-size: 0.85rem; }
  .diary-table { font-size: 0.72rem; }
  .diary-table th, .diary-table td { padding: 5px 7px; }
  /* Tighter card layout on small phones */
  .diary-card { padding: 10px 12px; gap: 10px; }
  .diary-card-date { min-width: 40px; padding: 5px 4px; }
  .diary-card-title { font-size: 0.84rem; }
  .diary-entry-body h1 { font-size: 1.1rem; }
  .diary-entry-body h2 { font-size: 0.97rem; }
  .diary-entry-body h3 { font-size: 0.9rem; }
  /* Make entry header (back bar + title) always wrap comfortably */
  #diaryBackBar { margin-bottom: 10px; }
}

/* ── Mobile optimisations ──────────────────────────────────────── */

/* Nav tabs — tighter padding on very small phones */
@media (max-width: 400px) {
  .tj-nav .nav-link { font-size: 0.7rem; padding: 6px 6px; }
  .tj-header .brand { font-size: 0.9rem; }
}

/* Filter-bar sticky offset — use CSS variable set by JS, fallback to 84px */
.filter-bar { top: var(--header-h, 84px); }

/* Trades / Analytics filter bar — stack on mobile */
@media (max-width: 640px) {
  .trades-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .status-pills { flex-wrap: wrap; }
  .tj-select { min-width: 0; flex: 1 1 auto; }
}

/* Custom date picker — stack vertically on mobile */
@media (max-width: 540px) {
  .custom-dates { flex-direction: column; align-items: stretch; gap: 4px; }
  .custom-dates > span { display: none; }
  .custom-dates input[type="date"] { width: 100%; }
}

/* Charts — cap height on mobile so the page doesn't become a scroll marathon */
@media (max-width: 767px) {
  .chart-wrap { max-height: 240px; overflow: hidden; }
  .chart-wrap canvas { max-height: 240px; }
  /* Doughnut charts can be shorter */
  #chartWinLoss,
  #chartCorrelation { max-height: 200px; }
  #chartWinLoss canvas,
  #chartCorrelation canvas { max-height: 200px; }
}

/* Settings modal — scrollable body on small screens */
@media (max-width: 576px) {
  #settingsModal .modal-dialog { margin: 0.5rem; }
  #settingsModal .modal-content { max-height: 92vh; display: flex; flex-direction: column; }
  #settingsModal .modal-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
}

/* Analytics / Summary cards — ensure text doesn't clip */
@media (max-width: 480px) {
  .tj-card .value { font-size: 1.05rem; }
  .an-stat-card .value { font-size: 0.95rem; }
  .strat-stat .sv { font-size: 0.78rem; }
}

/* Trade cards — single col body on tiny screens */
@media (max-width: 360px) {
  .tc-body { grid-template-columns: 1fr; }
  .tc-field:nth-child(odd) { border-right: none; }
  .tc-images { grid-template-columns: 1fr; }
  .tc-img-wrap:first-child { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ═══════════════════════════════════════════════════════════
   AIFinex Section Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Top-level section toggle (Own / AIFinex) ─────────────── */
.section-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.section-toggle-btn {
  flex: 1;
  padding: 5px 14px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.section-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}
.section-toggle-btn:not(.active):hover { color: var(--text); }

/* ── AIFinex tab sub-nav ──────────────────────────────────── */
#aifPageNav { display: none; }
#aifPageNav.visible { display: flex; }
#pageNav { display: flex; }

/* ── AIFinex status badges ────────────────────────────────── */
.aif-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.aif-badge-op { background: #dcfce7; color: #15803d; }
.aif-badge-pa { background: #fef9c3; color: #a16207; }
.aif-badge-re { background: #f1f5f9; color: #64748b; }

/* ── AIFinex Target Card ─────────────────────────────────── */
.aif-target-badge {
  font-size: .78rem; font-weight: 600; padding: 3px 11px;
  border-radius: 999px; background: rgba(217,119,6,.08);
  border: 1px solid rgba(217,119,6,.22); color: var(--accent);
  white-space: nowrap;
}
.aif-prog-panel {
  background: var(--bg); border-radius: 8px;
  padding: .75rem 1rem; border-left: 3px solid var(--border);
  height: 100%;
}
.aif-prog-panel--monthly { border-left-color: var(--accent); }
.aif-prog-panel--pace    { border-left-color: #7c3aed; }
.aif-prog-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; opacity: .5; margin-bottom: .45rem;
}
.aif-prog-amount { font-size: .9rem; font-weight: 700; }
.aif-prog-pct    { font-size: .78rem; font-weight: 600; color: var(--muted); }
.aif-bar-track   { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; }
.aif-bar-fill    { height: 100%; border-radius: 999px; transition: width .5s ease, background .3s; }
.aif-prog-hint   { font-size: .74rem; color: var(--muted); margin-top: .4rem; min-height: 1.1rem; }

/* ── AIFinex tables ───────────────────────────────────────── */
.aif-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.aif-table th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.aif-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.aif-table tbody tr:hover { background: rgba(0,0,0,0.02); }
.aif-total-row td {
  background: rgba(0,0,0,0.03);
  font-weight: 700;
  border-top: 2px solid var(--border);
}

/* ── Icon buttons ─────────────────────────────────────────── */
.aif-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.aif-btn-icon:hover { color: var(--text); border-color: var(--accent); }
.aif-btn-del:hover  { color: var(--red); border-color: var(--red); background: #fff5f5; }

/* ── Insight cards ────────────────────────────────────────── */
.aif-insight-card  { padding: 12px; }
.aif-insight-strat { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.aif-insight-net   { font-size: 1.1rem; font-weight: 800; margin-bottom: 6px; }
.aif-insight-row   { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 2px; color: var(--muted); }
.aif-insight-eff   { margin-top: 8px; font-size: 0.75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; display: inline-block; }
.aif-eff-green { background: #dcfce7; color: #15803d; }
.aif-eff-yellow{ background: #fef9c3; color: #a16207; }
.aif-eff-red   { background: #fee2e2; color: #b91c1c; }

/* ── Budget sim ───────────────────────────────────────────── */
.aif-sim-summary { font-size: 0.88rem; padding: 6px 0; }

/* Step labels */
.aif-sim-step { border-left: 3px solid var(--border); padding-left: 12px; }
.aif-sim-badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; padding: 2px 10px; border-radius: 999px; }
.aif-sim-badge-from { background: rgba(255,59,48,.12); color: #c0392b; }
.aif-sim-badge-to   { background: rgba(48,199,90,.12);  color: #1a9e40; }

/* Divider arrow */
.aif-sim-divider { display: flex; align-items: center; gap: 10px; margin: 8px 0 8px 0; padding-left: 12px; color: var(--muted); font-size: .85rem; }
.aif-sim-arrow   { font-size: 1.2rem; color: var(--accent); }
.aif-sim-total-chip { font-size: .75rem; background: var(--surface2, #f3f4f6); border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; color: var(--muted); }

/* Row layout */
.aif-sim-row { margin-bottom: 8px; }
.aif-sim-row-inputs { display: flex; gap: 8px; align-items: center; }
.aif-sim-strat-sel  { flex: 1 1 0; min-width: 0; }
.aif-sim-amount-wrap { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.aif-sim-dollar      { color: var(--muted); font-size: .85rem; }
.aif-sim-amount-inp  { width: 90px; }
.aif-sim-remove-btn  { flex-shrink: 0; background: none; border: 1px solid var(--red, #ff3b30); color: var(--red, #ff3b30); border-radius: 6px; font-size: .72rem; padding: 2px 7px; cursor: pointer; line-height: 1.4; }
.aif-sim-remove-btn:hover { background: rgba(255,59,48,.08); }
.aif-sim-remove-placeholder { width: 28px; flex-shrink: 0; }
.aif-sim-add-btn { margin-top: 4px; background: none; border: 1px dashed var(--border); border-radius: 6px; color: var(--muted); font-size: .78rem; padding: 4px 12px; cursor: pointer; width: 100%; }
.aif-sim-add-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb, 0,122,255),.04); }

/* Capacity bar */
.aif-cap-bar-wrap { padding-left: 2px; }
.aif-cap-bar  { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-bottom: 2px; }
.aif-cap-fill { height: 100%; border-radius: 2px; transition: width .2s, background .2s; }
.aif-cap-label { font-size: .7rem; color: var(--muted); }

/* ── Import result feedback ───────────────────────────────── */
.aif-import-result { margin-top: 8px; font-size: 0.85rem; font-weight: 600; }
.aif-import-result.success { color: var(--green); }
.aif-import-result.error   { color: var(--red); }

/* ── Profit color helpers (reused in AIFinex tables) ──────── */
.profit-pos { color: var(--green); }
.profit-neg { color: var(--red); }

/* ═══════════════════════════════════════════════════════════
   Mobile Bottom Navigation Bar
   ═══════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none; /* hidden on desktop */
}

@media (max-width: 767px) {
  /* Show bottom nav on mobile */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1040;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
  }
  .mbn-group {
    display: flex;
    flex: 1;
    width: 100%;
  }
  .mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px;
    min-height: 56px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
    position: relative;
  }
  .mbn-item i {
    font-size: 1.25rem;
    transition: transform 0.15s;
  }
  .mbn-item.active {
    color: var(--accent);
  }
  .mbn-item.active i {
    transform: translateY(-1px);
  }
  .mbn-item.active::after {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 4px 4px;
  }

  /* Body padding so content isn't hidden behind bottom nav */
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

  /* Hide top sub-navs on mobile (replaced by bottom nav) */
  #pageNav, #aifPageNav { display: none !important; }

  /* Tighten the header since sub-nav is gone */
  .tj-header .container-fluid { padding-top: 10px !important; padding-bottom: 10px !important; }

  /* Section toggle — smaller on tight screens */
  .section-toggle-btn { padding: 5px 10px; font-size: 0.75rem; }

  /* Chips row scrollable without blowing layout */
  .filter-bar .container-fluid { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .filter-bar .container-fluid::-webkit-scrollbar { display: none; }
  .filter-divider { flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════════════
   Global UX improvements
   ═══════════════════════════════════════════════════════════ */

/* Card hover lift on desktop */
@media (hover: hover) {
  .tj-card { transition: box-shadow 0.18s, border-color 0.18s; }
  .strat-card { transition: box-shadow 0.18s, border-color 0.18s; }
  .tj-card:hover { box-shadow: var(--shadow); }
}

/* Slightly richer card shadow */
.tj-card { box-shadow: var(--shadow-sm); }
.strat-card { box-shadow: var(--shadow-sm); }

/* Smooth page transition (fade via opacity + translate) */
#page-summary, #page-details, #page-analytics, #page-diary,
#page-aif-summary, #page-aif-accounts, #page-aif-report, #page-aif-trades {
  animation: pageFadeIn 0.18s ease forwards;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Better tap targets — ensure all interactive elements are at least 44px tall */
.chip, .pair-chip, .status-pill, .diary-filter-btn { min-height: 36px; display: inline-flex; align-items: center; }
.refresh-btn { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.section-toggle-btn { min-height: 36px; }

/* Scrollable table: show a subtle right fade as overflow hint */
.table-responsive, .table-wrap { position: relative; }
.table-responsive::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 32px; height: 100%;
  background: linear-gradient(to left, var(--surface) 0%, transparent 100%);
  pointer-events: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  opacity: 0;
  transition: opacity 0.2s;
}
/* Only show fade when actually overflowing — handled via JS class or always-on on mobile */
@media (max-width: 767px) {
  .table-responsive::after { opacity: 1; }
}

/* Improve section title readability */
.section-title { font-size: 0.75rem; letter-spacing: 0.5px; }

/* Import result feedback — more visible */
.aif-import-result { margin-top: 10px; font-size: 0.88rem; font-weight: 700; padding: 8px 12px; border-radius: 8px; }
.aif-import-result.success { color: var(--green); background: rgba(22,163,74,0.08); border: 1px solid rgba(22,163,74,0.2); }
.aif-import-result.error   { color: var(--red);   background: rgba(220,38,38,0.08);  border: 1px solid rgba(220,38,38,0.2); }

/* CSV preview badge */
#aif-csv-preview { padding: 6px 10px; background: rgba(217,119,6,0.07); border-radius: 7px; border: 1px solid rgba(217,119,6,0.2); color: var(--accent) !important; font-weight: 600; }

/* Strategy cards on summary — 2 stats per row when cards are side-by-side (col-6) */
@media (max-width: 767px) {
  .strat-stats { grid-template-columns: repeat(2,1fr); }
  .strat-stat:nth-child(2) { border-right: none; }
  .strat-stat:nth-child(3), .strat-stat:nth-child(4) { border-top: 1px solid var(--border); }
  /* Trim strategy name on small cards */
  .strat-name { font-size: 0.78rem; }
  .strat-profit { font-size: 0.92rem; }
}

/* AIFinex insight cards — side-scroll on mobile */
@media (max-width: 767px) {
  #aif-summary .row, .aif-insights-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  #aif-summary .row::-webkit-scrollbar { display: none; }
}

/* Analytics stat cards — smaller label on mobile */
@media (max-width: 480px) {
  .tj-card .label { font-size: 0.72rem; }
  .an-stat-card .value { font-size: 1rem; }
}

/* ── PIN Lock Overlay ─────────────────────────────────────── */
#pin-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .25s;
}
.pin-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 2rem 1.5rem 1.5rem;
  width: 100%; max-width: 340px;
}
.pin-logo {
  font-size: 2.2rem; color: var(--accent);
  background: rgba(217,119,6,.1); border-radius: 50%;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.pin-brand    { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .4; margin-bottom: 1.25rem; }
.pin-title    { font-size: 1.25rem; font-weight: 700; margin-bottom: .3rem; text-align: center; }
.pin-subtitle { font-size: .82rem; color: var(--muted); text-align: center; margin-bottom: 1.6rem; }
.pin-dots     { display: flex; gap: 14px; margin-bottom: .6rem; }
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent;
  transition: background .15s, border-color .15s, transform .1s;
}
.pin-dot--filled,
.pin-dot.filled {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.15);
}
.pin-error {
  font-size: .78rem; min-height: 1.2rem; margin-bottom: .8rem;
  color: var(--red, #dc2626); transition: opacity .2s; text-align: center;
}
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 80px);
  gap: 10px; margin-bottom: 1.25rem;
}
.pin-key {
  height: 72px; border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text); font-size: 1.4rem; font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .1s, transform .08s, box-shadow .1s;
  -webkit-tap-highlight-color: transparent;
}
.pin-key:not(.pin-key--empty):active {
  background: rgba(217,119,6,.12);
  border-color: var(--accent);
  transform: scale(.94);
  box-shadow: none;
}
.pin-key--empty { border: none; background: none; box-shadow: none; cursor: default; }
.pin-forgot {
  background: none; border: none; color: var(--muted);
  font-size: .8rem; cursor: pointer; padding: 4px 8px;
  transition: color .15s;
}
.pin-forgot:hover { color: var(--accent); }
@keyframes pin-shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}
.pin-shake { animation: pin-shake .4s ease; }

/* ── Claude Trader tab (js/claude.js) ─────────────────────── */
.ct-page { max-width: 1400px; margin: 0 auto; min-width: 0; }
.ct-page * { min-width: 0; }
.ct-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
           box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; margin-bottom: 0.9rem; }
.ct-card-flush { padding: 0; overflow: hidden; }
.ct-pad { padding: 0.9rem 1.1rem 0.6rem; }
.ct-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.ct-h2 { font-size: 1.15rem; font-weight: 700; margin: 0.25rem 0 0.4rem; }
.ct-h3 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 0 0 0.6rem; }
.ct-card-head .ct-h3 { margin: 0; }
.ct-muted { color: var(--muted); }
.ct-small { font-size: 0.78rem; }
.ct-fine { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0 0; line-height: 1.4; }
.ct-err { color: var(--red); font-size: 0.85rem; }
.ct-err:empty { display: none; }
#ct-error:not(:empty) { margin-bottom: 0.75rem; padding: 0.5rem 0.75rem; border-radius: 8px; background: rgba(220,38,38,0.07); }

/* login */
.ct-login { max-width: 400px; margin: 2rem auto; text-align: center; padding: 1.6rem; }
.ct-login-icon { font-size: 2rem; color: var(--accent); }
.ct-login .ct-err { margin-top: 0.6rem; }

/* hero */
.ct-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
           border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 0.9rem; border: 1px solid var(--border);
           border-left-width: 5px; background: var(--surface); box-shadow: var(--shadow-sm); }
.ct-tone-ok   { border-left-color: var(--green); }
.ct-tone-info { border-left-color: #2563eb; }
.ct-tone-warn { border-left-color: var(--accent); background: #fffbeb; }
.ct-tone-bad  { border-left-color: var(--red); background: #fef2f2; }
.ct-hero-main { display: flex; gap: 0.85rem; align-items: flex-start; flex: 1 1 420px; }
.ct-hero-icon { font-size: 1.6rem; line-height: 1; margin-top: 0.1rem; }
.ct-tone-ok .ct-hero-icon { color: var(--green); }
.ct-tone-info .ct-hero-icon { color: #2563eb; }
.ct-tone-warn .ct-hero-icon { color: var(--accent); }
.ct-tone-bad .ct-hero-icon { color: var(--red); }
.ct-hero-title { font-size: 1.2rem; font-weight: 700; }
.ct-hero-text { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; max-width: 62ch; }
.ct-hero-side { display: grid; gap: 0.5rem; justify-items: end; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.ct-quotes { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.ct-quote { display: flex; flex-direction: column; align-items: flex-end; background: var(--bg); border: 1px solid var(--border);
            border-radius: 10px; padding: 0.3rem 0.75rem; min-width: 110px; }
.ct-quote span { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.5px; color: var(--muted); }
.ct-quote b { font-size: 1.05rem; }
.ct-quote-gold span { color: #b8860b; }
/* host services: one segmented pill  [icon Host · BTC · Gold] */
.ct-svcs { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.22rem 0.7rem; border-radius: 999px;
           border: 1px solid var(--border); background: var(--bg); cursor: default; white-space: nowrap; }
.ct-svcs-icon { color: var(--muted); font-size: 0.85rem; }
.ct-svcs-bad { border-color: rgba(220,38,38,0.45); background: rgba(220,38,38,0.06); }
.ct-svcs-bad .ct-svcs-icon { color: var(--red); }
.ct-svc { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 600; color: var(--text); }
.ct-svc small { font-weight: 600; font-size: 0.68rem; color: var(--muted); }
.ct-svc-sep { width: 1px; height: 0.8rem; background: var(--border); }
.ct-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.ct-svc-ok .ct-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.18); animation: ct-pulse 2s ease-in-out infinite; }
.ct-svc-bad { color: var(--red); }
.ct-svc-bad .ct-dot { background: var(--red); }
.ct-svc-bad small { color: var(--red); }
.ct-svc-unknown { color: var(--muted); }
.ct-svc-unknown .ct-dot { background: #94a3b8; }
@keyframes ct-pulse { 50% { box-shadow: 0 0 0 5px rgba(22,163,74,0.05); } }
@media (prefers-reduced-motion: reduce) { .ct-svc-ok .ct-dot { animation: none; } }
.ct-next { font-size: 0.78rem; color: var(--muted); }
.ct-next b { color: var(--text); }
.ct-tag-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.ct-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.55rem; }
.ct-tag { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.3px; padding: 0.15rem 0.55rem; border-radius: 999px; }
.ct-tag-info { background: rgba(37,99,235,0.10); color: #1d4ed8; }
.ct-tag-warn { background: rgba(217,119,6,0.15); color: #b45309; }
.ct-tag-bad  { background: rgba(220,38,38,0.12); color: var(--red); }

/* layout */
.ct-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 0.9rem; }
@media (min-width: 992px) { .ct-layout { grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr); } }

/* stats */
.ct-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
@media (min-width: 768px) { .ct-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ct-stat { background: var(--bg); border-radius: 8px; padding: 0.6rem 0.75rem; }
.ct-stat-label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.ct-stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ct-stat-sub { font-size: 0.75rem; color: var(--muted); }
.ct-bar { height: 5px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 0.3rem 0 0.2rem; }
.ct-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* trial */
.ct-check { display: grid; grid-template-columns: auto 1fr; column-gap: 0.5rem; align-items: center; font-size: 0.88rem; margin-bottom: 0.5rem; }
.ct-check i { color: var(--muted); }
.ct-check.done i { color: var(--green); }
.ct-check .ct-bar { grid-column: 2; margin: 0.25rem 0 0; }
.ct-mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.75rem; }
.ct-mini-stats div { background: var(--bg); border-radius: 8px; padding: 0.45rem 0.6rem; }
.ct-mini-stats span { display: block; font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }
.ct-mini-stats b { font-variant-numeric: tabular-nums; }
.ct-empty-small { font-size: 0.82rem; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 0.6rem 0.75rem; margin: 0.6rem 0 0; }

/* position */
.ct-position { border-left: 4px solid #2563eb; }
.ct-pos-up { border-left-color: var(--green); }
.ct-pos-down { border-left-color: var(--red); }
.ct-pos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 1rem; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
@media (min-width: 768px) { .ct-pos-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ct-pos-grid .ct-muted { margin-right: 0.3rem; }
.ct-side { font-size: 0.68rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 4px; }
.ct-side-long { background: rgba(22,163,74,0.12); color: var(--green); }
.ct-side-short { background: rgba(220,38,38,0.12); color: var(--red); }

/* controls */
.ct-control { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
              padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.ct-control:last-of-type { border-bottom: 0; }
.ct-control-title { font-weight: 600; font-size: 0.9rem; }
.ct-control .btn { flex-shrink: 0; min-width: 84px; }
.ct-control-alert { background: #fef2f2; border-radius: 8px; padding: 0.6rem 0.7rem; border-bottom: 0; margin-top: 0.4rem; }

/* limits */
.ct-limit-list { display: grid; gap: 0.1rem; }
.ct-limit { display: grid; grid-template-columns: 1fr auto; column-gap: 0.75rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.ct-limit:last-child { border-bottom: 0; }
.ct-limit b { text-align: right; font-variant-numeric: tabular-nums; }
.ct-limit small { grid-column: 1 / -1; font-size: 0.72rem; }
.ct-details { margin-top: 0.6rem; }
.ct-details summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--accent); }
.ct-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.5rem; }
.ct-field span { display: block; font-size: 0.75rem; margin-bottom: 0.15rem; }
.ct-details .ct-err { margin-top: 0.4rem; }

.ct-footer { display: flex; gap: 0.9rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); padding: 0 0.2rem 1rem; }

/* activity */
.ct-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.ct-chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 0.75rem;
           padding: 0.2rem 0.65rem; border-radius: 999px; cursor: pointer; }
.ct-chip:hover { color: var(--text); }
.ct-chip.active { background: var(--text); color: #fff; border-color: var(--text); }
#ct-feed { max-height: 72vh; overflow-y: auto; border-top: 1px solid var(--border); }
.ct-day { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
          padding: 0.5rem 1.1rem; border-bottom: 1px solid var(--border);
          background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
          -webkit-backdrop-filter: blur(8px); box-shadow: 0 1px 0 var(--border); }
.ct-day-name { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text);
               background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem 0.6rem; }
.ct-day-sum { font-size: 0.75rem; color: var(--muted); }
.ct-ev { padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.ct-ev-head { display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: baseline; }
.ct-ev-icon { color: var(--muted); }
.ct-ev-decision .ct-ev-icon { color: var(--accent); }
.ct-ev-title { font-weight: 600; overflow-wrap: anywhere; }
.ct-ev-time { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ct-ev-meta { font-size: 0.8rem; margin: 0.2rem 0 0 1.6rem; overflow-wrap: anywhere; }
.ct-why { margin: 0.35rem 0 0 1.6rem; line-height: 1.45; overflow-wrap: anywhere; }
.ct-arrow { color: var(--muted); margin: 0 0.15rem; }
.ct-act { font-size: 0.72rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.ct-act-take { background: rgba(22,163,74,0.13); color: var(--green); }
.ct-act-skip { background: rgba(100,116,139,0.13); color: var(--muted); }
.ct-act-warn { background: rgba(217,119,6,0.15); color: #b45309; }
.ct-act-info { background: rgba(37,99,235,0.10); color: #1d4ed8; }
.ct-conf { font-size: 0.72rem; color: var(--muted); margin-left: 0.3rem; }
.ct-ev-muted .ct-ev-title { font-weight: 500; color: var(--muted); }
.ct-ev-win { border-left: 3px solid var(--green); }
.ct-ev-loss { border-left: 3px solid var(--red); }
.ct-ev-open .ct-ev-icon { color: #2563eb; }
.ct-ev-error { background: #fef2f2; }
.ct-ev-error .ct-ev-icon { color: var(--red); }
.ct-ev-system { font-size: 0.75rem; color: var(--muted); padding: 0.4rem 1.1rem; border-bottom: 1px solid var(--border); }
.ct-empty { display: flex; gap: 0.85rem; padding: 1.3rem 1.1rem; border-bottom: 1px solid var(--border); }
.ct-empty > i { font-size: 1.4rem; color: var(--accent); }
.ct-empty p { font-size: 0.85rem; color: var(--muted); margin: 0.2rem 0 0.3rem; max-width: 60ch; }

@media (max-width: 767px) {
  .ct-hero-side { justify-items: start; width: 100%; }
  .ct-quotes, .ct-svcs { justify-content: flex-start; }
  .ct-quote { align-items: flex-start; }
  .ct-hero-main { flex-basis: 100%; }
  .ct-ev-meta, .ct-why { margin-left: 0; }
  #ct-feed { max-height: none; }
  .ct-page { padding-bottom: 4.5rem; }
}

/* Claude tab: trading-mode switch + LIVE confirmation dialog */
.ct-mode { padding-bottom: 0.7rem; margin-bottom: 0.2rem; border-bottom: 1px solid var(--border); }
.ct-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border: 1px solid var(--border);
          border-radius: 10px; padding: 4px; margin-top: 0.45rem; }
.ct-seg button { border: 0; background: transparent; border-radius: 7px; padding: 0.45rem 0.5rem; font-weight: 600;
                 font-size: 0.88rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.ct-seg button small { font-weight: 400; font-size: 0.7rem; }
.ct-seg button:not(:disabled):hover { background: var(--surface); color: var(--text); }
.ct-seg button.active { background: var(--surface); color: #1d4ed8; box-shadow: var(--shadow-sm); }
.ct-seg button.active.ct-seg-live { background: #fef3c7; color: #b45309; }
.ct-seg button:disabled { cursor: default; opacity: 1; }
.ct-dialog { border: 0; border-radius: 14px; padding: 1.4rem 1.5rem; max-width: min(480px, calc(100vw - 32px));
             box-shadow: 0 20px 50px rgba(0,0,0,0.25); color: var(--text); }
.ct-dialog::backdrop { background: rgba(15,23,42,0.45); }
.ct-dialog p { font-size: 0.92rem; }
.ct-dialog-box { border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.85rem; margin: 0.6rem 0; }
.ct-ok-box { background: rgba(22,163,74,0.09); }
.ct-warn-box { background: #fef3c7; }
.ct-dialog-list { font-size: 0.85rem; padding-left: 1.1rem; margin: 0.4rem 0; }
.ct-dialog-list li { margin-bottom: 0.2rem; }

/* Claude tab: folded risk limits + per-strategy table */
.ct-limits-fold { border-top: 1px solid var(--border); margin-top: 0.3rem; padding-top: 0.55rem; }
.ct-limits-fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ct-limits-fold > summary::-webkit-details-marker { display: none; }
.ct-limits-fold > summary .ct-control-title { margin-right: auto; }
.ct-fold-icon { color: var(--muted); transition: transform 0.15s; }
.ct-limits-fold[open] .ct-fold-icon { transform: rotate(180deg); }
.ct-limit-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.ct-chip-static { font-size: 0.72rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0.1rem 0.5rem; color: var(--muted); }
.ct-chip-static b { color: var(--text); }
.ct-chip-bad { background: rgba(220,38,38,0.1); color: var(--red); border-color: transparent; font-weight: 700; }
.ct-limits-fold #ct-limits { margin-top: 0.5rem; }
.ct-det-table { width: 100%; font-size: 0.82rem; margin-top: 0.6rem; font-variant-numeric: tabular-nums; }
.ct-det-table th { font-size: 0.68rem; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-bottom: 0.2rem; }
.ct-det-table td, .ct-det-table th { padding: 0.2rem 0.3rem; }
.ct-det-table td:not(:first-child), .ct-det-table th:not(:first-child) { text-align: right; }
.ct-exp { font-size: 0.65rem; background: #fef3c7; color: #b45309; border-radius: 4px; padding: 0 0.3rem; }

/* Claude tab: learning + playbook */
.ct-ev-lesson .ct-ev-icon { color: #7c3aed; }
.ct-rule { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem; margin-top: 0.5rem; font-size: 0.86rem; }
.ct-rule-active { border-left: 3px solid #2563eb; }
.ct-rule-proposed { border-left: 3px solid var(--accent); background: #fffbeb; }
.ct-rule-head { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; margin-bottom: 0.25rem; }

/* Claude tab layout v4: an app that fits exactly one screen. Status bar on top, then
   three columns (overview | activity | controls + learning), each scrolling on its own.
   Below 1100px the columns become tabs, each filling the remaining height. */
.ct-page { max-width: none; }
.ct-app { display: flex; flex-direction: column; gap: 0.7rem; min-height: 420px;
          height: calc(100vh - var(--header-h, 110px) - 2rem);
          height: calc(100dvh - var(--header-h, 110px) - 2rem); }
.ct-app > .ct-err:empty { display: none; }
.ct-app > .ct-err { margin: 0; }
.ct-grid { flex: 1 1 auto; min-height: 0; display: grid; gap: 0.75rem;
           grid-template-columns: minmax(290px, 340px) minmax(0, 1fr) minmax(310px, 390px); }
.ct-pane { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
           scrollbar-gutter: stable; padding-right: 2px; }
.ct-pane .ct-card { margin-bottom: 0.7rem; }
.ct-pane .ct-card:last-child { margin-bottom: 0; }
.ct-pane .ct-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ct-pane .ct-stat-value { font-size: 1.2rem; }
.ct-pane-feed { display: flex; flex-direction: column; overflow: hidden; padding-right: 0; margin-bottom: 0 !important; }
.ct-pane-feed .ct-pad { flex: 0 0 auto; margin-bottom: 0; }
.ct-pane-feed #ct-feed { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto;
                         overscroll-behavior: contain; scrollbar-width: thin; }
.ct-pane .ct-footer { padding: 0.2rem 0.2rem 0; }
.ct-tabs { display: none; }

/* status bar */
.ct-sbar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1.25rem; flex-wrap: wrap;
          background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
          border-radius: var(--radius); padding: 0.5rem 0.9rem; box-shadow: var(--shadow-sm); flex: 0 0 auto; }
.ct-sbar-status { display: flex; align-items: center; gap: 0.7rem; flex: 1 1 320px; }
.ct-sbar-icon { font-size: 1.35rem; line-height: 1; }
.ct-tone-ok .ct-sbar-icon { color: var(--green); }
.ct-tone-info .ct-sbar-icon { color: #2563eb; }
.ct-tone-warn .ct-sbar-icon { color: var(--accent); }
.ct-tone-bad .ct-sbar-icon { color: var(--red); }
.ct-sbar-text { flex: 1 1 auto; }
.ct-sbar-title { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.ct-sbar-sub { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sbar-right { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.ct-sbar .ct-quote { flex-direction: row; align-items: baseline; gap: 0.4rem; min-width: 0; padding: 0.22rem 0.6rem; border-radius: 8px; }
.ct-sbar .ct-quote b { font-size: 0.95rem; }
.ct-sbar .ct-svcs { justify-content: flex-start; }
.ct-next { display: inline-flex; align-items: baseline; gap: 0.3rem; font-size: 0.75rem; color: var(--muted); padding-left: 0.2rem; }

/* centre column: chart on top (about 45% of the height), activity below */
.ct-pane-center { display: flex; flex-direction: column; gap: 0.7rem; overflow: hidden; padding-right: 0; }
.ct-pane-center > .ct-card { margin-bottom: 0; }
.ct-chart-card { flex: 0 0 46%; min-height: 240px; display: flex; flex-direction: column; padding: 0.6rem 0.8rem 0.4rem; }
.ct-feed-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ct-feed-card .ct-pad { flex: 0 0 auto; margin-bottom: 0; }
.ct-feed-card #ct-feed { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto;
                         overscroll-behavior: contain; scrollbar-width: thin; }
.ct-chart-head { display: flex; align-items: center; gap: 0.4rem 0.6rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.ct-seg-sm { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.ct-seg-sm[hidden] { display: none; }
.ct-seg-sm button { border: 0; background: transparent; border-radius: 6px; padding: 0.15rem 0.6rem;
                    font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.ct-seg-sm button:hover { color: var(--text); }
.ct-seg-sm button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ct-chart-legend { margin-left: auto; font-size: 0.78rem; display: flex; align-items: center; gap: 0.25rem 0.7rem;
                   flex-wrap: wrap; justify-content: flex-end; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.ct-legend-key, .ct-legend-item { color: var(--muted); display: inline-flex; align-items: center; gap: 0.3rem; }
.ct-legend-key i { font-style: normal; font-size: 0.7rem; }
.ct-legend-item b { color: var(--text); }
.ct-key-line { display: inline-block; width: 14px; height: 2px; border-radius: 2px; }
.ct-legend-note { background: var(--bg); border-radius: 6px; padding: 0 0.4rem; }
.ct-chart-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.ct-chart { position: absolute; inset: 0; }
.ct-chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
                  text-align: center; padding: 1rem; font-size: 0.85rem; color: var(--muted); background: var(--surface); }
.ct-chart-empty[hidden] { display: none; }

/* tabs (tablet + phone) */
@media (max-width: 1099px) {
  .ct-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; flex: 0 0 auto;
             background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
  .ct-tabs button { border: 0; background: transparent; border-radius: 7px; padding: 0.45rem 0.3rem; font-weight: 600;
                    font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 0.35rem; }
  .ct-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
  .ct-tab-badge { font-size: 0.66rem; font-weight: 700; line-height: 1.5; min-width: 1.25rem; padding: 0 0.35rem;
                  border-radius: 999px; background: var(--text); color: var(--surface); }
  .ct-tab-badge-warn { background: var(--accent); color: #fff; }
  .ct-tab-badge:empty { display: none; }
  .ct-grid { grid-template-columns: minmax(0, 1fr); }
  .ct-pane { display: none; }
  .ct-pane.active { display: block; }
  .ct-pane-feed.active { display: flex; }
  /* phone/tablet: the Activity tab scrolls as one page; the chart gets a fixed, usable height */
  .ct-pane-center.active { display: block; overflow-y: auto; }
  .ct-pane-center > .ct-card { margin-bottom: 0.7rem; }
  .ct-chart-card { height: 340px; min-height: 0; }
  .ct-feed-card #ct-feed { overflow: visible; }
  .ct-pane .ct-card-flush { padding: 0; }
  .ct-chart-legend { margin-left: 0; justify-content: flex-start; width: 100%; }
}
@media (min-width: 768px) and (max-width: 1099px) {
  /* tablet: overview cards side by side */
  .ct-pane[data-pane="overview"].active { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; align-content: start; }
  .ct-pane[data-pane="overview"] .ct-card { margin: 0; }
}

/* phone: subtract the bottom nav; keep the bar to two short lines */
@media (max-width: 767px) {
  .ct-page { padding-bottom: 0; }
  .ct-app { gap: 0.5rem; height: calc(100vh - var(--header-h, 64px) - 2rem - 56px);
            height: calc(100dvh - var(--header-h, 64px) - 2rem - 56px - env(safe-area-inset-bottom)); }
  .ct-sbar { padding: 0.45rem 0.7rem; gap: 0.35rem; }
  .ct-sbar-status { flex-basis: 100%; align-items: flex-start; }
  .ct-sbar-icon { font-size: 1.15rem; margin-top: 0.1rem; }
  .ct-sbar-title { font-size: 0.95rem; }
  .ct-sbar-right { justify-content: flex-start; gap: 0.3rem; }
  .ct-sbar .ct-quote { padding: 0.12rem 0.45rem; }
  .ct-sbar .ct-quote b { font-size: 0.85rem; }
  .ct-svc { padding: 0.1rem 0.45rem; font-size: 0.7rem; }
  .ct-svc small, .ct-next { display: none; }
  .ct-tabs button { font-size: 0.8rem; }
  .ct-pane .ct-card { padding: 0.8rem 0.85rem; }
  .ct-pane .ct-card-flush { padding: 0; }
}

/* Gold instance */
.ct-sym { display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
          padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.ct-sym-gold { background: rgba(212, 160, 23, .16); color: #b8860b; border: 1px solid rgba(212, 160, 23, .45); }
[data-theme="dark"] .ct-sym-gold { color: #e6b422; }
.ct-gold-pos, .ct-market-pos { margin: 4px 0 10px; font-size: .9rem; }
.ct-sym-btc { background: rgba(247, 147, 26, .14); color: #c2410c; border: 1px solid rgba(247, 147, 26, .45); }
[data-theme="dark"] .ct-sym-btc { color: #fb923c; }
.ct-sym-other { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.ct-markets { display: contents; }
.ct-mini-stats small { display: block; font-size: .7rem; color: var(--muted); font-weight: 400; }
.ct-market-dets { display: flex; flex-wrap: wrap; gap: .25rem .7rem; margin-top: .55rem; font-size: .76rem; }
.ct-market-dets b { font-variant-numeric: tabular-nums; }
.ct-market-grid { margin-top: .45rem; font-size: .78rem; padding: .35rem .55rem; border-radius: 8px; background: var(--bg); }
/* host services card (localhost only) */
.ct-host-list { list-style: none; margin: .2rem 0 .7rem; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .8rem; }
.ct-host-list li { display: flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; }
.ct-host-list li span { margin-left: auto; font-weight: 400; font-size: .72rem; color: var(--muted); }
.ct-host-list li.ct-svc-bad span { color: var(--red); }
.ct-host-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.ct-tag-ok { background: rgba(22,163,74,0.14); color: #15803d; }


/* long Claude text: clamp + Show more; light markdown */
.ct-fold .ct-fold-body { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ct-fold.open .ct-fold-body { display: block; }
.ct-more { border: 0; background: none; padding: 0; margin-top: 0.2rem; font-size: 0.78rem; font-weight: 600; color: var(--accent); cursor: pointer; }
.ct-more-b, .ct-fold.open .ct-more-a { display: none; }
.ct-fold.open .ct-more-b { display: inline; }
.ct-md-list { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.ct-md-list li { margin-bottom: 0.15rem; }
.ct-fine.ct-fold { margin-top: 0.25rem; }
.ct-review-box { background: var(--bg); border-radius: 8px; padding: 0.6rem 0.75rem; margin-top: 0.75rem; }
.ct-viewonly { display: flex; gap: 0.7rem; align-items: flex-start; background: var(--bg); border-radius: 8px; padding: 0.7rem 0.8rem; margin-top: 0.4rem; }
.ct-viewonly > i { color: #2563eb; font-size: 1.1rem; }

/* market picker (status bar): All + one chip per market; clicking scopes the whole page */
.ct-mkts { gap: 0.35rem; }
button.ct-mkt { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--bg);
                transition: border-color .15s, background .15s, box-shadow .15s; }
button.ct-mkt:hover { border-color: var(--muted); }
button.ct-mkt.active { background: var(--surface); border-color: var(--text); box-shadow: var(--shadow-sm); }
button.ct-mkt:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
.ct-mkt-all span { color: var(--text); }
.ct-quote-btc span { color: #c2410c; }
[data-theme="dark"] .ct-quote-btc span { color: #fb923c; }
.ct-mkts { align-items: stretch; }
button.ct-mkt-all { display: flex; align-items: center; justify-content: center; min-width: 2.8rem; font-weight: 600; font-size: .8rem; }
button.ct-mkt-all span { font-size: .8rem; letter-spacing: 0; }

/* grouped services pill: HOST ... | TRADERS ... */
.ct-svc-group { display: inline-flex; align-items: center; gap: 0.45rem; }
.ct-svc-glabel { font-size: 0.6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ct-svc-gsep { width: 1px; height: 1.1rem; background: var(--border); margin: 0 0.15rem; }
.ct-host-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 1rem; }
.ct-host-groups .ct-host-list { grid-template-columns: 1fr; margin-top: 0.25rem; }
@media (max-width: 767px) { .ct-svc-glabel { display: none; } }


/* strategies, grouped per market (overview) */
.ct-strats { display: flex; flex-direction: column; gap: .45rem; }
.ct-strat { border: 1px solid var(--border); border-radius: 10px; padding: .45rem .6rem; cursor: pointer; background: var(--surface);
            transition: border-color .15s, box-shadow .15s; }
.ct-strat:hover { border-color: var(--muted); }
.ct-strat.selected { border-color: var(--text); box-shadow: var(--shadow-sm); }
.ct-strat-live { border-left: 3px solid #d97706; }
.ct-strat-off { opacity: .65; }
.ct-strat-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ct-strat-name { font-weight: 700; font-size: .9rem; }
.ct-strat-modes { margin-left: auto; }
.ct-strat-modes button.active.ct-seg-live { background: #d97706; color: #fff; }
.ct-strat-sub { display: flex; flex-wrap: wrap; gap: .1rem .7rem; font-size: .75rem; margin-top: .25rem; }
.ct-strat-alert { margin-top: .3rem; font-size: .75rem; color: var(--red); }
.ct-strat-tag-live { background: rgba(217,119,6,.15); color: #b45309; }
.ct-strat-tag-shadow { background: rgba(37,99,235,.10); color: #1d4ed8; }
.ct-strat-tag-off { background: var(--bg); color: var(--muted); }
.ct-select-sm { font-size: .76rem; font-weight: 600; border: 1px solid var(--border); border-radius: 8px; padding: .2rem .4rem;
                background: var(--bg); color: var(--text); }
.ct-strat-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .15rem .5rem;
                 border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.ct-strat-chip[hidden] { display: none; }
.ct-strat-chip button { border: 0; background: transparent; font-size: .9rem; line-height: 1; padding: 0 .1rem; color: var(--muted); }

/* ideas panel */
.ct-idea { border: 1px solid var(--border); border-radius: 10px; padding: .5rem .65rem; margin-bottom: .5rem; }
.ct-idea-proposed { border-left: 3px solid #2563eb; }
.ct-idea-queued, .ct-idea-testing { border-left: 3px solid #d97706; }
.ct-idea-passed { border-left: 3px solid #16a34a; }
.ct-idea-failed, .ct-idea-dismissed { opacity: .75; }

/* ═════════════════════════════════ KESTREL (2026-12-04) ═════════════════════════════════
   Calm ink + warm paper, with the kestrel rust as the one accent. LIVE stays amber, P&L green/red. */
:root {
  --bg:      #f5f4f0;
  --surface: #ffffff;
  --border:  #e5e2da;
  --text:    #1b2330;
  --muted:   #667085;
  --accent:  #c2410c;
  --accent-soft: #fdf0e7;
  --ink:     #141a23;
}
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* header: ink bar, brand, pills */
.tj-header.kx-header { background: var(--ink); border-bottom: 1px solid #0b0f15; color: #e5e7eb; }
.kx-brand { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: #fff !important; }
.kx-brand img { border-radius: 7px; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.kx-brand .kx-name { font-weight: 800; letter-spacing: .02em; font-size: 1.1rem; }
.kx-brand .kx-tag { color: #94a3b8; font-weight: 500; font-size: .72rem; letter-spacing: .02em; }
.kx-header .tj-nav { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); }
.kx-header .tj-nav .nav-link { color: #b6c0cd; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.kx-header .tj-nav .nav-link:not(.active):hover { color: #fff; background: rgba(255,255,255,.06); }
.kx-header .tj-nav .nav-link.active { background: var(--accent) !important; color: #fff !important; }
.kx-header .refresh-btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #cbd5e1; }
.kx-header .refresh-btn:hover { color: #fff; border-color: var(--accent); background: rgba(194,65,12,.25); }
.kx-nav-badge { font-size: .64rem; font-weight: 800; min-width: 1.2rem; padding: 0 .35rem; border-radius: 999px; background: #fff; color: var(--accent); }
.kx-nav-badge:empty { display: none; }
.kx-live-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; font-weight: 700; padding: .25rem .6rem;
                border-radius: 999px; background: rgba(37,99,235,.18); color: #bfdbfe; white-space: nowrap; }
.kx-live-pill[hidden] { display: none; }
.kx-live-pill.is-live { background: rgba(217,119,6,.22); color: #fde68a; }
.kx-live-pill .kx-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.kx-live-pill.is-live .kx-dot { animation: ct-pulse 2s ease-in-out infinite; }
@media (max-width: 767px) { .kx-brand .kx-tag, .kx-live-pill { display: none !important; } .kx-header .tj-nav .nav-link i { display: none; } }

/* buttons, accents */
.kx-btn-accent { background: var(--accent); color: #fff; border: 0; font-weight: 600; }
.kx-btn-accent:hover { background: #9a3412; color: #fff; }
.mbn-item.active { color: var(--accent); }

/* page heads */
.kx-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.kx-h1 { font-size: 1.3rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.kx-sub { color: var(--muted); font-size: .85rem; margin: .15rem 0 0; }

/* performance sub-nav */
.kx-subnav { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
             margin-bottom: .8rem; }
.kx-subnav button { border: 0; background: transparent; padding: .35rem .9rem; border-radius: 8px; font-size: .82rem; font-weight: 600; color: var(--muted);
                    display: inline-flex; gap: .35rem; align-items: center; }
.kx-subnav button.active { background: var(--ink); color: #fff; }
.kx-subnav button:not(.active):hover { color: var(--text); }

/* desk: two columns now that controls live in the System drawer */
@media (min-width: 1100px) {
  .ct-grid.kx-desk-grid { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
}

/* strategies page */
.kx-strat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: .9rem; align-items: start; }
.kx-strat-list { position: sticky; top: calc(var(--header-h, 100px) + .75rem); display: flex; flex-direction: column; gap: .8rem; }
.kx-list-group { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .5rem; }
.kx-list-head { display: flex; align-items: center; gap: .45rem; padding: .25rem .35rem .45rem; font-weight: 700; font-size: .85rem; }
.kx-list-item { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; width: 100%; text-align: left; border: 1px solid transparent;
                background: transparent; border-radius: 9px; padding: .45rem .55rem; color: var(--text); }
.kx-list-item:hover { background: var(--bg); }
.kx-list-item.selected { background: var(--accent-soft); border-color: rgba(194,65,12,.35); }
.kx-li-name { font-weight: 700; }
.kx-li-sub { grid-column: 1 / -1; font-size: .74rem; color: var(--muted); }
.kx-mode { font-size: .66rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: .1rem .45rem; border-radius: 999px; align-self: center; }
.kx-mode-live { background: rgba(217,119,6,.15); color: #b45309; }
.kx-mode-shadow { background: rgba(37,99,235,.1); color: #1d4ed8; }
.kx-mode-off { background: var(--bg); color: var(--muted); }
.kx-detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .8rem;
                  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; }
.kx-detail-title { font-size: 1.25rem; font-weight: 800; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.kx-detail-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.kx-big-seg button { padding: .3rem .9rem; font-size: .82rem; }
.kx-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.kx-detail-grid > .ct-card { margin-bottom: 0; }
.kx-span2 { grid-column: 1 / -1; }
.kx-facts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; font-size: .84rem; }
.kx-facts li { display: flex; gap: .6rem; justify-content: space-between; border-bottom: 1px dashed var(--border); padding-bottom: .25rem; }
.kx-facts li span { color: var(--muted); }
.kx-facts li b { text-align: right; font-weight: 600; }
.kx-now { font-size: .9rem; }
.kx-results td, .kx-results th { padding: .35rem .5rem; }
@media (max-width: 899px) {
  .kx-strat-layout { grid-template-columns: minmax(0, 1fr); }
  .kx-strat-list { position: static; }
  .kx-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* research page */
.kx-research-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: .9rem; align-items: start; }
.kx-col > .ct-card { margin-bottom: .8rem; }
.kx-review-list { display: flex; flex-direction: column; }
.kx-review-item { display: flex; align-items: center; gap: .5rem; padding: .45rem .3rem; border-bottom: 1px solid var(--border);
                  color: var(--text); text-decoration: none; font-size: .86rem; }
.kx-review-item:hover { background: var(--bg); }
.kx-review-item i { color: var(--accent); }
.kx-md { font-size: .82rem; }
.kx-md h2 { font-size: .9rem; margin-top: .7rem; }
.kx-md ul { padding-left: 1.1rem; }
@media (max-width: 899px) { .kx-research-grid { grid-template-columns: minmax(0, 1fr); } }

/* system drawer */
.kx-drawer { --bs-offcanvas-width: 460px; background: var(--bg); }
.kx-drawer .offcanvas-header { background: var(--ink); color: #fff; }
.kx-drawer .offcanvas-header .btn-close { filter: invert(1); }
.kx-drawer .ct-card { margin-bottom: .8rem; }

/* guide */
.kx-guide .modal-header { background: var(--ink); color: #fff; }
.kx-guide .modal-header .btn-close { filter: invert(1); }
.kx-guide-card { display: flex; gap: 1rem; align-items: flex-start; }
.kx-guide-icon { flex: 0 0 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent);
                 display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.kx-guide-card h4 { font-size: 1.1rem; font-weight: 800; margin: .1rem 0 .5rem; }
.kx-guide-card ul { padding-left: 1.1rem; margin-bottom: 0; }
.kx-guide-card li { margin-bottom: .35rem; }

/* status dots keep their shape in any flex layout (phone status pill) */
.ct-dot { flex: 0 0 auto; align-self: center; width: 7px; height: 7px; min-height: 0; }

/* ═══════════════ Ask Kestrel: chat drawer (js/chat.js) ═══════════════ */
.kc-head-btn { display: inline-flex; align-items: center; gap: .35rem; width: auto !important; padding: 0 .7rem; }
.kc-head-label { font-size: .8rem; font-weight: 700; }
@media (max-width: 575px) { .kc-head-label { display: none; } .kc-head-btn { padding: 0; width: 36px !important; justify-content: center; } }
.kc-drawer { --bs-offcanvas-width: 520px; display: flex; flex-direction: column; }
.kc-bar { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.kc-seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--bg); border: 1px solid var(--border); }
.kc-seg button { border: 0; background: transparent; padding: .2rem .7rem; border-radius: 7px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.kc-seg button.active { background: var(--ink); color: #fff; }
.kc-usage { font-size: .74rem; color: var(--muted); margin-right: auto; white-space: nowrap; }
.kc-msgs { flex: 1 1 auto; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .7rem; }
.kc-msg { max-width: 92%; border-radius: 12px; padding: .55rem .8rem; font-size: .88rem; line-height: 1.45; overflow-wrap: anywhere; }
.kc-user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.kc-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; width: 92%; }
.kc-error { border-color: rgba(220,38,38,.4); color: #b91c1c; }
.kc-thinking { width: auto; color: var(--muted); display: inline-flex; gap: .5rem; align-items: center; }
.kc-md > :last-child { margin-bottom: 0; }
.kc-md p { margin-bottom: .5rem; }
.kc-md ul, .kc-md ol { padding-left: 1.1rem; margin-bottom: .5rem; }
.kc-md h1, .kc-md h2, .kc-md h3, .kc-md h4 { font-size: .92rem; font-weight: 800; margin: .6rem 0 .3rem; }
.kc-md table { width: 100%; border-collapse: collapse; font-size: .78rem; margin: .3rem 0 .5rem; display: block; overflow-x: auto; }
.kc-md th, .kc-md td { border-bottom: 1px solid var(--border); padding: .25rem .4rem; text-align: left; white-space: nowrap; }
.kc-md th { color: var(--muted); font-weight: 700; }
.kc-md code { font-size: .8rem; background: var(--bg); padding: 0 .25rem; border-radius: 4px; }
.kc-meta { margin-top: .4rem; font-size: .7rem; color: var(--muted); }
.kc-card { margin-top: .6rem; border: 1px solid rgba(194,65,12,.35); background: var(--accent-soft); border-radius: 10px; padding: .55rem .7rem; }
.kc-card-title { font-weight: 600; display: flex; gap: .45rem; align-items: baseline; }
.kc-card-title i { color: var(--accent); }
.kc-card-why { font-size: .8rem; color: var(--muted); margin: .25rem 0 .1rem; }
.kc-card-actions { display: flex; gap: .45rem; align-items: center; margin-top: .45rem; flex-wrap: wrap; }
.kc-done { font-size: .8rem; font-weight: 600; color: var(--muted); }
.kc-empty { margin: auto 0; text-align: center; color: var(--muted); padding: 1rem .5rem; }
.kc-empty > i { font-size: 2rem; color: var(--accent); }
.kc-empty p { font-size: .86rem; margin: .6rem auto .9rem; max-width: 380px; }
.kc-suggest { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; }
.kc-suggest button { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: .45rem .7rem; font-size: .84rem;
                     color: var(--text); text-align: left; }
.kc-suggest button:hover { border-color: var(--accent); color: var(--accent); }
.kc-pin { display: flex; gap: .5rem; justify-content: center; max-width: 260px; margin: 0 auto .4rem; }
.kc-compose { display: flex; gap: .5rem; padding: .65rem .9rem calc(.65rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.kc-compose textarea { resize: none; font-size: .88rem; }
.kc-compose .btn { align-self: stretch; padding: 0 .9rem; }
