/* trajectory/trajectory.css — ultra-compact, rounded, glanceable */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Carlito","Helvetica Neue",Arial,sans-serif;
  background: #fafafa;
  color: #333;
}
.tj-plain-page {
  max-width: 880px;
  margin: 1.5rem auto;
  padding: 0 16px 48px;
}
.tj-plain-page h1 { margin-top: 0; }

/* ---------- Wrapper ---------- */
.tj-wrap { width: 100%; max-width: none; margin: 0; padding: 0 12px 56px; }

/* ---------- Top bar / Header ---------- */
.tj-header, .tj-topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,.06);
}
.tj-header h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}
.tj-topbar { justify-content: flex-end; }
.tj-topbar .tj-back { font-size: .88rem; color: #0b5cab; text-decoration: none; }

.tj-header-actions {
  display: inline-flex;
  align-items: stretch;
  gap: .4rem;
  flex-wrap: wrap;
}
.tj-preset-picker {
  display: inline-flex;
  align-items: stretch;
}
.tj-preset-picker label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}
.tj-header-control {
  border: 1px solid rgba(0,0,0,.14);
  background: #fff;
  border-radius: 4px;
  height: 31px;
  padding: 0 .52rem;
  cursor: pointer;
  font-size: .72rem;
  line-height: 1;
  color: #111827;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: top;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.tj-header-control:hover {
  background: rgba(37,99,235,.06);
  color: #0b5cab;
  border-color: rgba(37,99,235,.25);
}
.tj-header-control:focus-visible {
  outline: 2px solid rgba(37,99,235,.22);
  outline-offset: 1px;
}
.tj-preset-picker select.tj-header-control {
  appearance: auto;
  -webkit-appearance: menulist;
  display: block;
  width: auto;
  min-width: 0;
  height: 100%;
  padding: 0 .52rem 0 .32rem;
  font-weight: 600;
}
.tj-settings-btn {
  width: 31px;
  padding: 0;
  font-size: .88rem;
}
.tj-header-link {
  text-decoration: none;
}
.tj-title-link {
  color: #111827;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.tj-title-link:hover {
  color: #0b5cab;
}
.tj-title-link.is-current,
.tj-title-link[aria-current="page"] {
  color: #111827;
  cursor: default;
}
.tj-title-link.is-current:hover,
.tj-title-link[aria-current="page"]:hover {
  color: #111827;
}
.tj-header-link.is-current,
.tj-header-control[aria-current="page"] {
  background: #eef4ff;
  border-color: rgba(37,99,235,.25);
  color: #0b5cab;
  cursor: default;
}
.tj-header-link.is-current:hover,
.tj-header-control[aria-current="page"]:hover {
  background: #eef4ff;
  border-color: rgba(37,99,235,.25);
  color: #0b5cab;
}

/* ---------- Settings modal ---------- */
.tj-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.tj-modal.is-open { display: flex; }
.tj-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.22);
}
.tj-modal-panel {
  position: relative;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 10px;
  width: min(360px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  padding: .75rem .85rem .85rem;
}
.tj-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
.tj-modal-title {
  font-size: .85rem;
  font-weight: 700;
  color: #111827;
}
.tj-started-body {
  font-size: .74rem;
  color: #374151;
  line-height: 1.45;
}
.tj-started-body h2 {
  margin: .6rem 0 .25rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.tj-started-body p {
  margin: .25rem 0 .4rem;
}
.tj-started-body li {
  margin: .2rem 0;
}
.tj-started-body ol,
.tj-started-body ul {
  margin: .2rem 0 .5rem 1rem;
  padding: 0;
}
.tj-started-body strong { color: #111827; }
.tj-started-link a {
  font-size: .72rem;
  color: #0b5cab;
  text-decoration: none;
}
.tj-started-link a:hover { text-decoration: underline; }
.tj-modal-close {
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.tj-setting-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .35rem 0 0;
}
.tj-modal-body {
  overflow: auto;
  padding-right: .15rem;
}
.tj-setting-label {
  font-size: .72rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: .15rem;
}
.tj-check {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: #111827;
}

/* Explorer / Worksheet modal helpers */
.tj-explorer-row,
.tj-worksheet-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.tj-explorer-label,
.tj-worksheet-label {
  min-width: 50px;
  font-size: .72rem;
  color: #6b7280;
}
.tj-explorer-input,
.tj-worksheet-input {
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 6px;
  padding: .3rem .45rem;
  font-size: .75rem;
  min-width: 200px;
  background: #fff;
}
.tj-explorer-actions,
.tj-worksheet-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.tj-explorer-status,
.tj-worksheet-status {
  font-size: .72rem;
  color: #6b7280;
}
.tj-worksheet-summary {
  font-size: .72rem;
  color: #374151;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 8px;
  padding: .45rem .55rem;
  line-height: 1.35;
}
.tj-worksheet-summary strong {
  color: #111827;
}
.tj-worksheet-file {
  display: none;
}
.tj-worksheet-saved-list {
  display: grid;
  gap: .45rem;
}
.tj-worksheet-saved-item {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 8px;
  background: #fff;
  padding: .5rem .6rem;
  display: grid;
  gap: .45rem;
}
.tj-worksheet-saved-item.is-active {
  border-color: rgba(22,163,74,.25);
  background: #f0fdf4;
}
.tj-worksheet-saved-main {
  display: grid;
  gap: .2rem;
}
.tj-worksheet-saved-id {
  font-size: .76rem;
  font-weight: 600;
  color: #111827;
}
.tj-worksheet-saved-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .75rem;
  font-size: .7rem;
  color: #6b7280;
}
.tj-worksheet-saved-badge {
  display: inline-block;
  margin-left: .35rem;
  padding: .08rem .35rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: .66rem;
  font-weight: 600;
  vertical-align: middle;
}
.tj-worksheet-saved-empty {
  font-size: .72rem;
  color: #6b7280;
  border: 1px dashed rgba(0,0,0,.12);
  border-radius: 8px;
  padding: .55rem .6rem;
  background: #fff;
}
.tj-explorer-indicator {
  border: 1px solid rgba(0,0,0,.12);
  background: #f8fafc;
  border-radius: 999px;
  height: 31px;
  padding: 0 .6rem;
  font-size: .7rem;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.tj-explorer-indicator.is-active {
  background: #ecfdf5;
  border-color: rgba(22,163,74,.25);
  color: #0f5132;
}
.tj-data-note {
  font-size: .72rem;
  color: #4b5563;
  line-height: 1.45;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 8px;
  padding: .5rem .6rem;
}
.tj-data-summary {
  display: grid;
  gap: .45rem;
}
.tj-data-ledger {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 10px;
  background: #fff;
  padding: .55rem .65rem;
  display: grid;
  gap: .45rem;
}
.tj-data-ledger-empty {
  font-size: .72rem;
  color: #6b7280;
}
.tj-data-ledger-row {
  display: grid;
  gap: .15rem;
  padding: .2rem 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.tj-data-ledger-row:last-child {
  border-bottom: 0;
}
.tj-data-ledger-title {
  font-size: .75rem;
  font-weight: 600;
  color: #111827;
}
.tj-data-ledger-meta {
  font-size: .7rem;
  color: #6b7280;
  line-height: 1.4;
}
.tj-data-card {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 8px;
  background: #fff;
  padding: .5rem .6rem;
}
.tj-data-card-title {
  font-size: .72rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: .2rem;
}
.tj-data-card-copy {
  font-size: .72rem;
  color: #4b5563;
  line-height: 1.4;
}
.tj-data-card-copy strong {
  color: #111827;
}
.tj-data-status {
  font-size: .72rem;
  color: #6b7280;
}
.tj-btn-danger {
  border-color: rgba(185, 28, 28, .22);
  color: #991b1b;
}
.tj-btn-danger:hover {
  background: rgba(185, 28, 28, .06);
  border-color: rgba(185, 28, 28, .3);
  color: #7f1d1d;
}

/* Buttons (global baseline) */
.tj-btn {
  border: 1px solid rgba(0,0,0,.14);
  background: #fff;
  border-radius: 5px;
  padding: .22rem .38rem;
  cursor: pointer;
  font-size: .72rem;
  line-height: 1.15;
  color: #111827;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.tj-btn:hover { background: rgba(37,99,235,.06); color: #0b5cab; border-color: rgba(37,99,235,.25); }
.tj-btn-ghost { background: transparent; padding: .2rem .35rem; font-size: .75rem; }
.tj-btn[disabled] { opacity: .45; cursor: not-allowed; }
.tj-btn-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}

/* Worksheet page */
.tj-data-page {
  display: grid;
  gap: .7rem;
  margin: .85rem 0 1.25rem;
}
.tj-worksheet-page-head {
  margin: .85rem 0 .35rem;
}
.tj-worksheet-page-head h2 {
  margin: 0 0 .2rem;
  font-size: 1rem;
  color: #111827;
}
.tj-worksheet-page-head p {
  margin: 0;
  font-size: .78rem;
  color: #6b7280;
}
.tj-worksheet-page-controls {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin: .75rem 0 1rem;
}
.tj-worksheet-page-controls input,
.tj-worksheet-page-controls select {
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 6px;
  padding: .35rem .5rem;
  font-size: .75rem;
  background: #fff;
}
.tj-worksheet-empty {
  border: 1px dashed rgba(0,0,0,.15);
  border-radius: 10px;
  padding: .8rem;
  font-size: .78rem;
  color: #6b7280;
  background: #fff;
}
.tj-worksheet-resource {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px;
  padding: .8rem .9rem;
  background: #fffdf7;
  margin-bottom: .75rem;
  box-shadow: 0 1px 0 rgba(16,24,40,.03);
}
.tj-worksheet-resource h2 {
  margin: 0 0 .4rem;
  font-size: .88rem;
}
.tj-worksheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  font-size: .72rem;
  color: #6b7280;
  margin-bottom: .6rem;
}
.tj-worksheet-question {
  border-top: 1px dashed rgba(0,0,0,.08);
  padding-top: .6rem;
  margin-top: .6rem;
}
.tj-worksheet-question:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.tj-worksheet-question-title {
  font-size: .78rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: .3rem;
}
.tj-worksheet-answer {
  font-size: .76rem;
  color: #374151;
  margin-bottom: .4rem;
}
.tj-worksheet-answer .is-correct { color: #166534; }
.tj-worksheet-answer .is-incorrect { color: #9f1239; }
.tj-worksheet-edit {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
}
.tj-worksheet-edit input {
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 6px;
  padding: .3rem .45rem;
  font-size: .75rem;
  min-width: 180px;
}

/* ---------- Integrated panel filter chips ---------- */
.tj-filterbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0 0 10px;
  padding: 2px 0 2px;
}

.tj-filterchip {
  appearance: none;
  border: 1px solid rgba(0,0,0,.10);
  background: #fff;
  color: #4b5563;
  border-radius: 999px;
  padding: .24rem .56rem;
  font: inherit;
  font-size: .68rem;
  line-height: 1;
  cursor: pointer;
  transition: box-shadow .15s ease, border-color .15s ease, opacity .15s ease, transform .15s ease;
}

.tj-filterchip:hover {
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transform: translateY(-1px);
}

.tj-filterchip.is-active {
  font-weight: 700;
  color: #111827;
  border-color: rgba(0,0,0,.18);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.03);
}

.tj-filtercount {
  opacity: .72;
  font-weight: 500;
}

/* ---------- Index grid ---------- */
.tj-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  padding-bottom: 36px;
}

/* ---------- Card styling (ultra-compact + rounded) ---------- */
.tj-card {
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 16px;
  background: #fff;
  padding: .45rem .55rem .55rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.03);
  transition: transform .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tj-card:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.05); }

/* Card actions pinned to bottom */
.tj-actions {
  margin-top: auto !important;
  padding-top: 0.6rem;
}

/* --- Card Image --- */
.tj-card-img {
  display: block;
  width: calc(100% + 1.1rem);
  max-width: none !important;
  margin: -0.45rem -0.55rem 0.45rem;
  height: 100px;
  object-fit: contain;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

/* Title + Meta defaults */
.tj-card h3 {
  margin: 0 0 .08rem;
  font-weight: 700;
  display: flex; align-items: center; gap: .28rem;
}
.tj-meta { margin: 0 0 .2rem; color: #666; line-height: 1.28; }

/* ---------- Compact single-step cards ---------- */
.tj-card-single,
.tj-card-compact {
  padding: .42rem .55rem .6rem !important;
  min-height: 70px;
}
.tj-card-single h3,
.tj-card-compact h3 {
  margin-bottom: .15rem;
}
.tj-card-single .tj-meta,
.tj-card-compact .tj-meta {
  margin-bottom: .35rem;
}
.tj-card-single .tj-progress,
.tj-card-single .tj-steppeek,
.tj-card-compact .tj-progress,
.tj-card-compact .tj-steppeek {
  display: none !important;
}
.tj-card-single .tj-actions,
.tj-card-compact .tj-actions {
  margin-top: auto !important;
}

/* ---------- Progress bar ---------- */
.tj-progress {
  height: 4px;
  background: rgba(15, 23, 42, 0.18);
  border-radius: 999px;
  overflow: hidden;
  margin: .22rem 0 .3rem;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}
.tj-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1d7f45, #2f7d3a);
  transition: width .2s;
}
.tj-card.tj-done .tj-bar { background: #2f7d3a; }

/* ---------- Remove unused UI ---------- */
.tj-mini, .tj-resume-chip { display:none !important; }

/* ---------- Step list ---------- */
.tj-steppeek { margin-top: .22rem; border-top: 1px solid rgba(0,0,0,.06); padding-top: .22rem; }
.tj-steppeek-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}
.tj-steppeek-list::-webkit-scrollbar { width: 4px; }
.tj-steppeek-list::-webkit-scrollbar-track { background: transparent; }
.tj-steppeek-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

.tj-steppeek-list li { padding: .02rem 0; }
.tj-steppeek a.tj-step-link {
  font-size: .60rem; color: #07509a; text-decoration: none;
  font-weight: 700;
  line-height: 1.2;
  padding: .04rem .08rem; border-radius: 5px; display: block;
}
.tj-steppeek a.tj-step-link:hover { text-decoration: underline; }
.tj-steppeek a.tj-step-link.is-current{
  color: #000;
  font-weight: 700;
  background: rgba(255, 196, 0, 0.35);
}
.tj-steppeek a.tj-step-link:visited { color: #0b5cab; }
.tj-steppeek a.tj-step-link.visited-manual { color: #6b4eff !important; }

/* ---------- Viewer layout ---------- */
.tj-app {
  --tj-sticky-offset: 80px;
  display: grid;
  grid-template-columns: 1fr clamp(200px, 15vw, 260px);
  column-gap: .9rem;
  align-items: start;
}
.tj-content { max-width: none; padding: 0; margin: 0; overflow: visible; }
.tj-content iframe.tj-frame { display:block; width:100%; border:0; background:transparent; margin:0; box-shadow:none; border-radius:0; }

/* ---------- Sidebar ---------- */
.tj-panel {
  position: sticky; top: var(--tj-sticky-offset,80px);
  height: calc(100vh - var(--tj-sticky-offset,80px));
  max-height: calc(100vh - var(--tj-sticky-offset,80px));
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border-left: 1px solid rgba(0,0,0,.06);
  padding-left: 14px;
  min-width: 200px;
  line-height: 1.32;
  font-size: .74rem;
  color: #444;
  display: flex;
  flex-direction: column;
}
.tj-head { margin-bottom: .24rem; }
.tj-head h3 { margin: 0; font-size: .98rem; font-weight: 700; line-height: 1.15; }
.tj-desc { margin: 0 0 .52rem; color:#666; font-size:.82rem; line-height: 1.35; }

/* ---------- Player progress ---------- */
.tj-progress-lg {
  height: 4px;
  background: rgba(15, 23, 42, 0.16);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 0 .55rem;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}
.tj-bar-lg {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1d7f45, #2f7d3a);
  transition: width .2s;
}

/* ---------- Steps in player ---------- */
.tj-steps {
  list-style: none;
  margin: 0;
  padding: 0 .2rem .12rem 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.tj-steps::-webkit-scrollbar { width: 5px; }
.tj-steps::-webkit-scrollbar-track { background: transparent; }
.tj-steps::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 999px; }
.tj-steps li {
  display: grid; grid-template-columns: 16px 1fr;
  align-items: start; column-gap: .32rem;
  padding: .14rem 0; font-size: .84rem;
}
.tj-steps li.tj-current { font-weight: 700; box-shadow: inset 2px 0 0 rgba(37,99,235,.28); background: rgba(255,235,59,.16); border-radius: 6px; }
.tj-steps li.tj-done { color: #2f7d3a; }
.tj-badge {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.18);
  display: grid; place-items: center;
  font-size: .66rem; line-height: 1;
  background: #fff; flex-shrink: 0;
  color: #111827;
}
.tj-done .tj-badge { border-color: rgba(0,0,0,.15); color: #2f7d3a; }
.tj-step-btn { all: unset; cursor: pointer; color: inherit; line-height: 1.2; padding: .05rem 0; }
.tj-step-btn:hover { text-decoration: underline; }
.tj-step-btn:focus-visible { outline: 2px solid rgba(37,99,235,.35); outline-offset: 2px; border-radius: 4px; }

/* ---------- Controls ---------- */
.tj-controls {
  display:flex;
  gap:.34rem;
  padding:.42rem 0 0;
  margin-top: .24rem;
  border-top: 1px solid rgba(0,0,0,.06);
  flex: 0 0 auto;
}
.tj-view-links {
  display: grid;
  gap: .34rem;
  margin-top: auto;
}
.tj-home-btn {
  display: block;
  width: 100%;
  margin-top: 0;
  text-align: center;
  text-decoration: none;
  padding: .28rem .42rem;
}
.tj-controls button {
  flex:1; border:1px solid rgba(0,0,0,.14); border-radius:4px;
  background:#fff; cursor:pointer; padding:.18rem .34rem;
  font-size:.72rem; line-height: 1.15;
  color: #111827;
  transition: background .2s, color .2s, border-color .2s, opacity .2s;
}
.tj-controls #tj-next {
  background: rgba(37,99,235,.1);
  color: #0b5cab;
  border-color: rgba(37,99,235,.22);
}
.tj-controls #tj-next:hover { background: rgba(37,99,235,.14); }
.tj-controls #tj-prev[disabled], .tj-controls #tj-next[disabled] { opacity:.45; cursor:not-allowed; }
.tj-controls #tj-prev:hover { background: rgba(37,99,235,.06); color:#0b5cab; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .tj-header {
    align-items: flex-start;
  }
  .tj-header-actions {
    justify-content: space-between;
    width: 100%;
  }
  .tj-preset-picker {
    flex: 0 0 auto;
    max-width: none;
  }
  .tj-app { grid-template-columns: 1fr; row-gap: .9rem; column-gap: 0; }
  .tj-panel {
    position: static;
    border-left: none;
    border-top: 1px solid rgba(0,0,0,.08);
    padding: 12px 4px 0;
    max-height: none;
    min-height: 0;
    font-size: .88rem;
    background: rgba(255,255,255,.72);
    border-radius: 12px;
  }
  .tj-steps {
    overflow: visible;
    padding-right: 0;
  }
  .tj-controls { padding-bottom: .1rem; }
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  body { background: #111; color: #ddd; }
  .tj-header, .tj-topbar { border-bottom-color: rgba(255,255,255,.12); }
  .tj-header-control {
    background: rgba(30,30,30,.9);
    border-color: rgba(255,255,255,.22);
    color: #d1d5db;
  }
  .tj-panel { border-left-color: rgba(255,255,255,.12); color:#ddd; }
  .tj-desc { color:#aaa; }
  .tj-controls { border-top-color: rgba(255,255,255,.08); }
  .tj-steps::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }
  .tj-steps li.tj-done { color: #34d399; }
  .tj-badge {
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.22);
    color: #e5e7eb;
  }
  .tj-done .tj-badge { border-color: rgba(52,211,153,.55); color: #34d399; }
  .tj-btn {
    background: rgba(30,30,30,.9);
    border-color: rgba(255,255,255,.22);
    color: #e5e7eb;
  }
  .tj-btn:hover { background: rgba(96,165,250,.12); color: #fff; border-color: rgba(96,165,250,.22); }
  .tj-btn-ghost { background: transparent; }
  .tj-controls button {
    background: rgba(30,30,30,.9);
    border-color: rgba(255,255,255,.22);
    color: #e5e7eb;
  }
  .tj-controls #tj-prev:hover { background: rgba(96,165,250,.08); color: #fff; border-color: rgba(96,165,250,.18); }
  .tj-card {
    background: rgba(30,30,30,.9);
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    border-color: rgba(255,255,255,.08);
  }
  .tj-progress, .tj-progress-lg { background: rgba(255,255,255,.15); }
  .tj-steppeek { border-top-color: rgba(255,255,255,.12); }
  .tj-steppeek a.tj-step-link { color: #9ec3ff; }
  .tj-steppeek a.tj-step-link.is-current{ background: rgba(255,235,59,.18); color:#fff; }
  .tj-steppeek a.tj-step-link:visited { color: #9ec3ff; }
  .tj-steppeek a.tj-step-link.visited-manual { color: #b7a5ff !important; }

  .tj-filterchip {
    color: #d1d5db;
    border-color: rgba(255,255,255,.12);
  }
  .tj-filterchip.is-active {
    color: #fff;
    border-color: rgba(255,255,255,.22);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  }
  .tj-controls #tj-next {
    background: rgba(96,165,250,.12);
    color: #dbeafe;
    border-color: rgba(96,165,250,.22);
  }
  @media (max-width: 900px) {
    .tj-panel {
      background: rgba(255,255,255,.04);
    }
  }
}

/* ============================================================
   Exploration Trail (log)
============================================================ */

#tj-log {
  margin-top: 24px;
  padding-top: 0;
  border-top: none;
  font-size: 0.8rem;
  color: #444;
}

.tj-log-inner {
  max-width: 960px;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.05);
  background: #fff;
  box-shadow: 0 4px 12px rgba(15,23,42,.04);
  padding: 8px 10px;
  transition: box-shadow .2s ease, transform .2s ease;
}

.tj-log-inner:hover {
  box-shadow: 0 8px 20px rgba(15,23,42,.06);
  transform: translateY(-1px);
}

.tj-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  column-gap: .5rem;
  margin-bottom: .25rem;
}

.tj-log-toggle {
  all: unset;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  color: #111827;
}
.tj-log-toggle::after {
  content: "▾";
  font-size: .7rem;
  opacity: .6;
}
.tj-log-inner.is-collapsed .tj-log-toggle::after { content: "▸"; }

.tj-log-actions { display: inline-flex; gap: .25rem; flex-wrap: wrap; }

#tj-log .tj-log-body {
  max-height: 340px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  transition: max-height .2s ease, opacity .2s ease;
}
#tj-log .tj-log-inner.is-collapsed .tj-log-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
#tj-log .tj-log-inner:not(.is-collapsed) .tj-log-body { opacity: 1; }

.tj-log-empty {
  margin: .1rem 0 .2rem;
  padding: .2rem 0;
  color: #777;
  font-size: .76rem;
}

.tj-log-table-wrap {
  margin-top: .1rem;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,.04);
  overflow-x: auto;
}

.tj-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.tj-log-table thead tr { background: #f9fafb; }

.tj-log-table th,
.tj-log-table td {
  padding: 0.18rem 0.32rem;
  border-bottom: 1px solid rgba(0,0,0,.03);
  vertical-align: middle;
  white-space: nowrap;
}

#tj-log .tj-log-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 5;
}

.tj-log-table th {
  font-weight: 600;
  text-align: left;
  color: #6b7280;
  font-size: 0.68rem;
}
.tj-log-table tbody tr:nth-child(odd) { background: #fcfcfd; }
.tj-log-table tbody tr:hover { background: #f3f4ff; }

.tj-log-table td code {
  display: inline-block;
  max-width: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(15,23,42,.03);
  padding: 0.05rem 0.28rem;
  border-radius: 999px;
  font-size: 0.65rem;
}
.tj-log-table tr:last-child td { border-bottom: none; }

.tj-log-summary { margin-top: 0.35rem; }
.tj-log-table-summary { font-size: 0.72rem; }
.tj-log-table-summary th,
.tj-log-table-summary td { padding: 0.18rem 0.32rem; }

@media (prefers-color-scheme: dark) {
  #tj-log { color: #d1d5db; }

  .tj-log-inner {
    background: #020617;
    border-color: rgba(148,163,184,.35);
    box-shadow: 0 6px 20px rgba(0,0,0,.7);
  }

  .tj-log-table-wrap { border-color: rgba(148,163,184,.35); }
  .tj-log-table thead tr { background: rgba(15,23,42,.9); }
  .tj-log-table tbody tr:nth-child(odd) { background: rgba(15,23,42,.8); }
  .tj-log-table tbody tr:hover { background: rgba(37,99,235,.25); }
  .tj-log-table th { color: #9ca3af; }
  .tj-log-table td { border-bottom-color: rgba(55,65,81,.7); }
  .tj-log-table td code { background: rgba(15,23,42,.9); }
  #tj-log .tj-log-table thead th { background: rgba(30,30,30,0.9); }
}

@media (max-width: 768px) {
  #tj-log .tj-log-body { max-height: 220px; }
}

/* ============================================================
   Enhanced Exploration Graph v2 — card + responsive SVG
============================================================ */

.tj-tooltip {
  position: absolute;
  background: rgba(0,0,0,0.82);
  color: #fff;
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 10000;
}

#tj-graph-section {
  max-width: 960px;
  margin: 18px auto 0;
}

#tj-graph-section .tj-graph-inner {
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.03);
  transition: max-height .35s ease;
  overflow: hidden;
}

#tj-graph-section .tj-graph-inner.is-collapsed { max-height: 0; }
#tj-graph-section .tj-graph-inner:not(.is-collapsed) { max-height: 1600px; }

#tj-graph-section .tj-graph-header {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: #fff;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

#tj-graph-section .tj-graph-header .tj-graph-toggle {
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  color: #0b5cab;
  background: none;
  border: none;
  padding: 0;
}
#tj-graph-section .tj-graph-header .tj-graph-toggle:hover { text-decoration: underline; }

#tj-graph-section .tj-graph-body { padding: 8px 10px 12px; }

#tj-graph {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 8px 4px;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 7;
}

#tj-graph svg {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  user-select: none;
}

#tj-graph .nodes circle:hover {
  stroke: #fff;
  stroke-width: 2.2px;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.35));
}

#tj-graph .links line {
  stroke: #a0aec0;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: opacity .2s ease, stroke-width .2s ease, stroke .2s ease;
}

#tj-graph text {
  fill: #444;
  font-family: "Carlito", sans-serif;
  user-select: none;
  pointer-events: none;
}

#tj-graph-controls {
  margin-top: 16px;
  margin-bottom: 8px;
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
}
#tj-graph-step-label { font-size: .78rem; color: #555; }

#tj-graph-playback {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  justify-content: center;
}
#tj-graph-playback .tj-btn {
  font-size: .62rem;
  padding: .2rem .45rem;
}

#tj-graph-narration {
  margin-top: 6px;
  text-align: center;
  font-size: .8rem;
  color: #666;
  padding-bottom: 4px;
}

@media (prefers-color-scheme: dark) {
  #tj-graph-section .tj-graph-inner {
    background: rgba(20,20,20,.95);
    border-color: rgba(255,255,255,.12);
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
  }
  #tj-graph-section .tj-graph-header {
    background: rgba(30,30,30,.9);
    border-bottom-color: rgba(255,255,255,.12);
  }
  #tj-graph text { color: #ddd; fill: #ddd; }
  #tj-graph .links line { stroke: #7b8794; }
  #tj-graph-narration, #tj-graph-step-label { color: #ccc; }
}

@media (max-width: 768px) {
  #tj-graph { max-width: 100%; aspect-ratio: 16 / 10; }
}

/* ============================================================
   CARDS ONLY: Scaling + header compaction knobs
============================================================ */

:root {
  --tj-card-scale: 1.25;
  --tj-card-base-font: 14px;
}

/* Apply scaling to cards area only */
#tj-list {
  --tj-card-font: calc(var(--tj-card-base-font) * var(--tj-card-scale));
  font-size: var(--tj-card-font);
  line-height: 1.22;
  --tj-card-title-scale: 0.80;
  --tj-card-meta-scale: 0.72;
  --tj-card-title-mb: 0.18em;
  --tj-card-meta-mb: 0.28em;
  --tj-card-title-lines: 2;
  --tj-card-meta-lines: 2;
}

/* IMPORTANT: remove broad heading inflation inside cards */
#tj-list h1,
#tj-list h2,
#tj-list h3 {
  font-size: inherit;
  margin: 0;
  line-height: inherit;
}

/* Card title */
#tj-list .tj-card h3,
#tj-list .tj-card-single h3,
#tj-list .tj-card-compact h3 {
  font-size: calc(1em * var(--tj-card-title-scale));
  line-height: 1.12;
  margin: 0 0 var(--tj-card-title-mb) 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--tj-card-title-lines);
  overflow: hidden;
}

/* Card subtitle/meta line */
#tj-list .tj-card .tj-meta,
#tj-list .tj-card-single .tj-meta,
#tj-list .tj-card-compact .tj-meta {
  font-size: calc(1em * var(--tj-card-meta-scale));
  line-height: 1.18;
  margin: 0 0 var(--tj-card-meta-mb) 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--tj-card-meta-lines);
  overflow: hidden;
}

/* General card text sizing */
#tj-list p,
#tj-list li,
#tj-list a,
#tj-list small {
  font-size: 0.90em;
}

/* Card buttons scale with card font-size */
#tj-list .tj-btn,
#tj-list button,
#tj-list input[type="button"],
#tj-list input[type="submit"] {
  font-size: 0.92em;
  line-height: 1.1;
  padding: 0.35em 0.75em;
  border-radius: 0.55em;
  min-height: 2.05em;
  box-sizing: border-box;
}

/* Keep action rows neat */
#tj-list .tj-actions,
#tj-list .actions,
#tj-list .btn-row {
  display: flex;
  gap: 0.5em;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================================
   Mobile control readability
============================================================ */
@media (max-width: 768px) {
  .tj-header-actions {
    gap: 0.5rem;
  }

  .tj-header .tj-header-control {
    min-height: 36px;
    padding: 0 0.72rem;
    font-size: 0.9rem;
    border-radius: 8px;
  }

  .tj-header .tj-settings-btn {
    width: 36px;
    min-width: 36px;
    padding: 0;
    font-size: 0.95rem;
  }

  .tj-topbar .tj-btn,
  .tj-panel .tj-btn,
  .tj-controls button {
    min-height: 36px;
    font-size: 0.92rem;
    padding: 0.38rem 0.72rem;
    border-radius: 8px;
  }

  .tj-home-btn {
    padding: 0.48rem 0.72rem;
  }
}
