/* ═══════════════════════════════════════
   AI TOOL PAGES — shared UI
   Used by /jd-match, /resume-analyzer, /mock-interview, /multi-agent (with style.css).
   Status colours are tokens so both themes stay readable.
═══════════════════════════════════════ */
:root {
  --ok: #4ADE80;   --ok-bg: rgba(34,197,94,.10);   --ok-bd: rgba(34,197,94,.28);
  --warn: #FBBF24; --warn-bg: rgba(251,191,36,.10); --warn-bd: rgba(251,191,36,.28);
  --bad: #F87171;  --bad-bg: rgba(248,113,113,.10); --bad-bd: rgba(248,113,113,.28);
  --tl-radius: 16px;
}
[data-theme="light"] {
  --ok: #15803D;   --ok-bg: rgba(22,163,74,.08);   --ok-bd: rgba(22,163,74,.28);
  --warn: #B45309; --warn-bg: rgba(217,119,6,.08); --warn-bd: rgba(217,119,6,.30);
  --bad: #B91C1C;  --bad-bg: rgba(220,38,38,.07);  --bad-bd: rgba(220,38,38,.25);
}

body.tl-body { padding-top: 64px; }
.tl-page [hidden] { display: none !important; }   /* component display rules must not override `hidden` */
.tl-page { padding: 40px 0 88px; min-height: 100vh; }
.tl-wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.tl-wrap.narrow { max-width: 860px; }

/* ── Tool switcher ── */
.tl-switch { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.tl-switch a {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text-2); border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-2) 70%, transparent); transition: var(--trans);
}
.tl-switch a:hover { color: var(--text); border-color: var(--border-p); }
.tl-switch a[aria-current="page"] { color: var(--purple-lt); border-color: var(--border-p); background: var(--purple-bg); }
[data-theme="light"] .tl-switch a[aria-current="page"] { color: var(--purple-dk); }

/* ── Hero ── */
.tl-hero { text-align: center; margin-bottom: 30px; }
.tl-hero h1 { font-family: var(--font-head); font-size: clamp(30px, 5vw, 44px); line-height: 1.15; color: var(--text); margin: 10px 0 12px; }
.tl-hero h1 em { color: var(--purple-lt); }
[data-theme="light"] .tl-hero h1 em { color: var(--purple-dk); }
.tl-hero p { color: var(--text-2); font-size: 15.5px; line-height: 1.7; max-width: 620px; margin: 0 auto; }
.tl-points { display: flex; gap: 8px 18px; justify-content: center; flex-wrap: wrap; margin-top: 16px; font-size: 13px; color: var(--text-3); }
.tl-points span::before { content: '✓ '; color: var(--ok); font-weight: 700; }

/* ── Cards & form bits ── */
.tl-card { background: color-mix(in srgb, var(--bg-2) 88%, transparent); border: 1px solid var(--border); border-radius: var(--tl-radius); padding: 22px; }
.tl-card + .tl-card, .tl-stack > * + * { margin-top: 16px; }
.tl-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.tl-count { font-weight: 600; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.tl-count.over { color: var(--bad); }
.tl-textarea {
  width: 100%; min-height: 200px; resize: vertical; box-sizing: border-box; padding: 14px 16px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 14px; line-height: 1.6; transition: border-color .2s, box-shadow .2s;
}
.tl-textarea:focus { outline: none; border-color: var(--border-p); box-shadow: 0 0 0 3px var(--purple-bg); }
.tl-textarea::placeholder { color: var(--text-3); }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.tl-chips > span { font-size: 12px; color: var(--text-3); margin-right: 2px; }
.tl-chip { font-size: 12px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text-2); cursor: pointer; transition: var(--trans); font-family: inherit; }
.tl-chip:hover { border-color: var(--border-p); color: var(--text); }
.tl-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.tl-actions .tl-hint { margin-right: auto; font-size: 12px; color: var(--text-3); }

.tl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 26px;
  border-radius: 11px; border: 1px solid transparent; font: inherit; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: var(--trans); white-space: nowrap;
}
.tl-btn-primary { background: linear-gradient(135deg, #0EA5E9, #38BDF8); color: #04182B; box-shadow: 0 6px 20px rgba(56,189,248,.25); }
.tl-btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(56,189,248,.38); }
.tl-btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.tl-btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-p); }
.tl-btn-sm { padding: 7px 14px; font-size: 12.5px; font-weight: 600; border-radius: 8px; }
.tl-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.tl-btn .tl-spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: tlSpin .7s linear infinite; }
@keyframes tlSpin { to { transform: rotate(360deg); } }

/* ── Error / notice ── */
.tl-error { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; font-size: 14px; line-height: 1.5;
            background: var(--bad-bg); border: 1px solid var(--bad-bd); color: var(--text); margin-top: 14px; }
.tl-error::before { content: '⚠'; color: var(--bad); font-weight: 700; }
.tl-error[hidden] { display: none; }

/* ── Progress steps while the AI works ── */
.tl-progress { margin-top: 18px; padding: 18px 20px; }
.tl-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tl-steps li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-3); transition: color .3s; }
.tl-steps li::before { content: ''; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--border); box-sizing: border-box; }
.tl-steps li.on { color: var(--text); }
.tl-steps li.on::before { border-color: var(--purple); border-right-color: transparent; animation: tlSpin .8s linear infinite; }
.tl-steps li.ok { color: var(--text-2); }
.tl-steps li.ok::before { content: '✓'; border: none; background: var(--ok-bg); color: var(--ok); font-size: 10px; font-weight: 800; display: grid; place-items: center; }

/* ── Score header ── */
.tl-score { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.tl-ring { position: relative; width: 116px; height: 116px; flex: none; }
.tl-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.tl-ring circle { fill: none; stroke-width: 9; }
.tl-ring .bg { stroke: var(--border); }
.tl-ring .fg { stroke: var(--purple); stroke-linecap: round; transition: stroke-dashoffset 1.1s cubic-bezier(.22,1,.36,1); }
.tl-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 27px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.tl-ring b small { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 1px; color: var(--text-3); margin-top: -2px; }
.tl-score-meta { flex: 1; min-width: 240px; }
.tl-score-meta h2 { font-size: 21px; color: var(--text); margin: 0 0 4px; }
.tl-score-meta .tl-role { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.tl-score-meta p { color: var(--text-2); font-size: 14.5px; line-height: 1.65; margin: 0; }
.tl-tally { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tl-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid; }
.tl-pill.met, .tl-pill.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-bd); }
.tl-pill.partial, .tl-pill.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-bd); }
.tl-pill.missing, .tl-pill.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-bd); }
.tl-pill.muted { color: var(--text-3); background: transparent; border-color: var(--border); font-weight: 600; }

/* ── Section headings inside results ── */
.tl-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tl-sec-head h2, .tl-sec-head h3 { font-size: 15.5px; color: var(--text); margin: 0; display: flex; align-items: center; gap: 8px; }
.tl-sec-head .tl-sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }

/* ── Requirement checklist ── */
.tl-reqs { display: grid; gap: 8px; }
.tl-req { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--border); background: var(--bg); }
.tl-req .tl-pill { grid-row: span 2; align-self: start; min-width: 74px; justify-content: center; }
.tl-req strong { font-size: 14px; color: var(--text); font-weight: 650; }
.tl-req strong .opt { font-size: 11px; font-weight: 600; color: var(--text-3); margin-left: 6px; padding: 1px 7px; border: 1px solid var(--border); border-radius: 999px; }
.tl-req span.ev { font-size: 13px; color: var(--text-2); line-height: 1.55; }
.tl-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.tl-filter button { font: inherit; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: none; color: var(--text-3); cursor: pointer; }
.tl-filter button[aria-pressed="true"] { color: var(--text); border-color: var(--border-p); background: var(--purple-bg); }

/* ── Lists ── */
.tl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.tl-list li { position: relative; padding-left: 22px; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.tl-list li::before { content: '→'; position: absolute; left: 0; color: var(--purple); font-weight: 700; }
.tl-list.ok li::before { content: '✓'; color: var(--ok); }
.tl-list.warn li::before { content: '!'; color: var(--warn); left: 5px; }
.tl-check { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tl-check label { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.6; color: var(--text-2); cursor: pointer; }
.tl-check input { margin-top: 4px; accent-color: var(--purple); width: 15px; height: 15px; flex: none; }
.tl-check input:checked + span { color: var(--text-3); text-decoration: line-through; }
.tl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-tag { font-size: 12.5px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--warn-bd); background: var(--warn-bg); color: var(--warn); font-weight: 600; }

.tl-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .tl-grid2 { grid-template-columns: 1fr; } }

.tl-quote { font-size: 14.5px; line-height: 1.8; color: var(--text-2); border-left: 3px solid var(--border-p); padding: 2px 0 2px 16px; margin: 0; white-space: pre-wrap; }

/* ── Before → after rewrite ── */
.tl-rw { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); }
.tl-rw + .tl-rw { margin-top: 10px; }
.tl-rw-head { display: flex; justify-content: space-between; gap: 10px; padding: 8px 13px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.tl-rw-head b { color: var(--text-2); text-transform: uppercase; letter-spacing: .8px; font-size: 11px; }
.tl-rw p { margin: 0; padding: 10px 13px; font-size: 13.5px; line-height: 1.6; }
.tl-rw .before { color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.tl-rw .after { color: var(--text); background: var(--ok-bg); border-top: 1px dashed var(--ok-bd); }

/* ── Markdown output ── */
.tl-md { color: var(--text-2); font-size: 14.5px; line-height: 1.75; overflow-wrap: anywhere; }
.tl-md > :first-child { margin-top: 0; }
.tl-md h1, .tl-md h2, .tl-md h3 { color: var(--text); line-height: 1.3; margin: 18px 0 8px; }
.tl-md h1 { font-size: 22px; } .tl-md h2 { font-size: 17px; } .tl-md h3 { font-size: 15px; }
.tl-md p { margin: 0 0 10px; }
.tl-md ul, .tl-md ol { margin: 0 0 12px; padding-left: 20px; }
.tl-md li { margin-bottom: 4px; }
.tl-md strong { color: var(--text); }
.tl-md code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; padding: 1px 6px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); }
.tl-md pre { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.tl-md pre code { border: none; padding: 0; background: none; }
.tl-md .tl-table-wrap { overflow-x: auto; margin: 0 0 12px; }
.tl-md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tl-md th, .tl-md td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.tl-md th { color: var(--text); background: var(--bg); }
.tl-caret { display: inline-block; width: 2px; height: 1em; background: var(--purple-lt); vertical-align: text-bottom; margin-left: 2px; animation: tlBlink .8s steps(1) infinite; }
@keyframes tlBlink { 50% { opacity: 0; } }

.tl-results[hidden] { display: none; }
.tl-results { margin-top: 22px; }
.tl-fade { animation: tlFade .45s cubic-bezier(.22,1,.36,1) both; }
@keyframes tlFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tl-fade, .tl-steps li.on::before, .tl-btn .tl-spin, .tl-live::before { animation: none; } .tl-break-bar span { transition: none; } }

/* ═══════════════════════════════════════
   DEMO SHELL — app-window frame, stepper, run stats, pipeline explainer
═══════════════════════════════════════ */
.tl-app {
  border: 1px solid var(--border-p); border-radius: 18px; overflow: hidden;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  box-shadow: 0 24px 60px -24px rgba(0,0,0,.55), 0 0 0 1px color-mix(in srgb, var(--purple) 8%, transparent);
}
.tl-app-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 80%, var(--bg-2)); border-bottom: 1px solid var(--border);
}
.tl-dots { display: flex; gap: 6px; flex: none; }
.tl-dots i { width: 11px; height: 11px; border-radius: 50%; background: #F87171; opacity: .85; }
.tl-dots i:nth-child(2) { background: #FBBF24; } .tl-dots i:nth-child(3) { background: #4ADE80; }
.tl-app-title {
  flex: 1; min-width: 0; text-align: center; font-size: 12.5px; color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-app-title b { color: var(--text-2); font-weight: 600; }
.tl-live { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 11.5px; font-weight: 700; color: var(--ok);
           padding: 3px 9px; border-radius: 999px; background: var(--ok-bg); border: 1px solid var(--ok-bd); }
.tl-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: tlPulse 1.8s ease-in-out infinite; }
@keyframes tlPulse { 50% { opacity: .35; } }
.tl-app-body { padding: 20px; background: color-mix(in srgb, var(--bg) 65%, var(--bg-2)); }

.tl-stepper { list-style: none; display: flex; gap: 0; margin: 0 0 18px; padding: 0; counter-reset: st; }
.tl-stepper li {
  flex: 1; display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--text-3);
  counter-increment: st; position: relative; min-width: 0;
}
.tl-stepper li + li { padding-left: 10px; }
.tl-stepper li::before {
  content: counter(st); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; border: 1.5px solid var(--border); color: var(--text-3); background: var(--bg); transition: var(--trans);
}
.tl-stepper li::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: var(--border); margin-right: 4px; min-width: 12px; }
.tl-stepper li:last-child::after { display: none; }
.tl-stepper li.active { color: var(--text); }
.tl-stepper li.active::before { border-color: var(--purple); color: var(--purple-lt); box-shadow: 0 0 0 4px var(--purple-bg); }
.tl-stepper li.done { color: var(--text-2); }
.tl-stepper li.done::before { content: '✓'; border-color: var(--ok-bd); background: var(--ok-bg); color: var(--ok); }
.tl-stepper li.done::after { background: linear-gradient(90deg, var(--ok), var(--purple)); }
.tl-stepper span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tl-toolbar p { margin: 0; font-size: 13px; color: var(--text-3); }
.tl-btn-sample { border-style: dashed; color: var(--purple-lt); border-color: var(--border-p); background: var(--purple-bg); }
[data-theme="light"] .tl-btn-sample { color: var(--purple-dk); }

/* Fetch a JD from a link */
.tl-urlrow { display: flex; gap: 8px; margin-bottom: 10px; }
.tl-input {
  flex: 1; min-width: 0; box-sizing: border-box; padding: 9px 13px; font: inherit; font-size: 13.5px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
}
.tl-input:focus { outline: none; border-color: var(--border-p); box-shadow: 0 0 0 3px var(--purple-bg); }
.tl-input::placeholder { color: var(--text-3); }
.tl-or { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-3); letter-spacing: 1px; text-transform: uppercase; margin: 2px 0 10px; }
.tl-or::before, .tl-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.tl-note { font-size: 12.5px; color: var(--ok); margin: -2px 0 8px; }

/* Score breakdown bar */
.tl-break { margin-top: 14px; }
.tl-break-bar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--border); gap: 2px; }
.tl-break-bar span { display: block; height: 100%; transition: flex-grow .9s cubic-bezier(.22,1,.36,1); flex-grow: 0; flex-basis: 0; }
.tl-break-bar .met { background: var(--ok); } .tl-break-bar .partial { background: var(--warn); } .tl-break-bar .missing { background: var(--bad); }
.tl-break-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.tl-break-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* Run stats */
.tl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tl-stat { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); }
.tl-stat b { display: block; font-size: 19px; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.tl-stat span { font-size: 11.5px; color: var(--text-3); letter-spacing: .3px; }

/* Before → after score */
.tl-delta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 12px;
            border: 1px solid var(--ok-bd); background: var(--ok-bg); margin-bottom: 14px; font-size: 14px; color: var(--text-2); }
.tl-delta b { font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }
.tl-delta .arrow { color: var(--ok); font-weight: 800; }
.tl-delta .up { color: var(--ok); font-weight: 800; }
.tl-delta.flat { border-color: var(--border); background: var(--bg); }

/* "How it works" pipeline */
.tl-how { margin-top: 34px; }
.tl-how h2 { text-align: center; font-size: 13px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-3); margin: 0 0 14px; font-weight: 700; }
.tl-pipe { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tl-pipe li { position: relative; padding: 16px; border: 1px dashed var(--border); border-radius: 14px; background: color-mix(in srgb, var(--bg-2) 60%, transparent); }
.tl-pipe li b { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin-bottom: 5px; }
.tl-pipe li b em { font-style: normal; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
                   font-size: 11.5px; background: var(--purple-bg); color: var(--purple-lt); }
[data-theme="light"] .tl-pipe li b em { color: var(--purple-dk); }
.tl-pipe li p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text-3); }
.tl-pipe li code { font-size: 11.5px; padding: 1px 5px; border-radius: 5px; background: var(--bg); border: 1px solid var(--border); color: var(--text-2); }

.learn-strip { margin-top: 28px; }
@media (max-width: 600px) {
  .tl-card { padding: 18px 16px; }
  .tl-ring { width: 96px; height: 96px; }
  .tl-ring b { font-size: 22px; }
  .tl-actions { justify-content: stretch; }
  .tl-actions .tl-btn { flex: 1; }
  .tl-actions .tl-hint { width: 100%; }
  .tl-app-body { padding: 14px; }
  .tl-app-title { text-align: left; }
  .tl-stepper li span { display: none; }
  .tl-stepper li.active span { display: inline; }
  .tl-urlrow .tl-btn { padding: 9px 12px; }
}
