/* Review sheet for AI-proposed file changes. */
:root {
  --rv-add: #3fcf8e; --rv-add-bg: rgba(63, 207, 142, .11); --rv-add-ln: rgba(63, 207, 142, .2);
  --rv-del: #ff6b7a; --rv-del-bg: rgba(255, 107, 122, .11); --rv-del-ln: rgba(255, 107, 122, .2);
  --rv-mod: #f5c451; --rv-mod-bg: rgba(245, 196, 81, .13);
  --rv-move: #8fa8ff; --rv-move-bg: rgba(143, 168, 255, .13);
  --rv-ease: cubic-bezier(.22, .9, .24, 1);
  --rv-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}
html.ts-review-lock, html.ts-review-lock body { overflow: hidden; }

/* ---------- chat card ---------- */
.ts-change-card {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 12px 12px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .02));
  animation: rv-card-in .45s var(--rv-ease) both;
}
.ts-change-card-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px; position: relative;
  background: rgba(56, 167, 255, .14); box-shadow: inset 0 0 0 1px rgba(56, 167, 255, .3);
}
.ts-change-card-icon::before, .ts-change-card-icon::after {
  content: ""; position: absolute; left: 9px; right: 9px; height: 2px; border-radius: 2px;
}
.ts-change-card-icon::before { top: 12px; background: var(--rv-add); box-shadow: 0 5px 0 var(--rv-mod); }
.ts-change-card-icon::after { top: 22px; background: var(--rv-del); right: 14px; }
.ts-change-card.is-applied .ts-change-card-icon { background: rgba(63, 207, 142, .15); box-shadow: inset 0 0 0 1px rgba(63, 207, 142, .35); }
.ts-change-card.is-applied .ts-change-card-icon::before { top: 11px; left: 11px; right: auto; width: 6px; height: 10px; border: solid var(--rv-add);
  border-width: 0 2px 2px 0; background: none; box-shadow: none; transform: rotate(45deg); border-radius: 0; }
.ts-change-card.is-applied .ts-change-card-icon::after,
.ts-change-card.is-discarded .ts-change-card-icon::after { display: none; }
.ts-change-card.is-discarded { opacity: .62; }
.ts-change-card.is-discarded .ts-change-card-icon { background: rgba(255, 255, 255, .06); box-shadow: inset 0 0 0 1px var(--line); }
.ts-change-card.is-discarded .ts-change-card-icon::before { background: var(--muted); box-shadow: none; top: 16px; }
.ts-change-card-text { display: grid; gap: 6px; min-width: 0; flex: 1; }
.ts-change-card-text strong { font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.ts-change-card-summary { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.ts-change-note { flex-basis: 100%; }
.ts-change-card-open {
  flex: none; border: 0; border-radius: 999px; padding: 9px 16px; font: inherit; font-size: 13px; font-weight: 600;
  color: #04101f; background: var(--accent); cursor: pointer;
  transition: transform .18s var(--rv-ease), box-shadow .18s var(--rv-ease), filter .18s;
}
.ts-change-card-open:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(56, 167, 255, .35); }
.ts-change-card-open:active { transform: translateY(0); filter: brightness(.95); }
@keyframes rv-card-in { from { opacity: 0; transform: translateY(6px); } }

.ts-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.ts-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ts-chip.add { color: var(--rv-add); background: var(--rv-add-bg); }
.ts-chip.mod { color: var(--rv-mod); background: var(--rv-mod-bg); }
.ts-chip.del { color: var(--rv-del); background: var(--rv-del-bg); }
.ts-chip.move { color: var(--rv-move); background: var(--rv-move-bg); }

/* ---------- sheet ---------- */
.ts-review { position: fixed; inset: 0; z-index: 1000; }
.ts-review[hidden] { display: none; }
.ts-review-backdrop {
  position: absolute; inset: 0; background: rgba(2, 4, 12, .55);
  backdrop-filter: blur(6px) saturate(120%); -webkit-backdrop-filter: blur(6px) saturate(120%);
  opacity: 0; transition: opacity .32s ease;
}
.ts-review.open .ts-review-backdrop { opacity: 1; }
.ts-review-sheet {
  position: absolute; left: 50%; bottom: 0; width: min(1180px, 100%); height: min(88dvh, 920px);
  display: grid; grid-template-rows: auto auto 1fr auto; outline: none;
  background: color-mix(in srgb, var(--panel) 92%, #000);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  box-shadow: 0 -24px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  transform: translate(-50%, 104%); transition: transform .42s var(--rv-ease);
  will-change: transform; overflow: hidden;
}
.ts-review.open .ts-review-sheet { transform: translate(-50%, 0); }
.ts-review-grip { display: grid; place-items: center; height: 22px; cursor: grab; touch-action: none; }
.ts-review-grip span { width: 42px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .22); transition: background .2s; }
.ts-review-grip:hover span { background: rgba(255, 255, 255, .4); }

.ts-review-head { display: grid; grid-template-columns: 1fr auto auto; align-items: start; gap: 16px; padding: 4px 24px 16px; border-bottom: 1px solid var(--line); }
.ts-review-eyebrow { margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.ts-review-head h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.ts-review-request { margin: 6px 0 0; color: var(--muted); font-size: 13px; max-width: 60ch;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ts-review-summary { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; justify-content: flex-end; }
.ts-review-x {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
  color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; transition: background .2s, transform .2s var(--rv-ease);
}
.ts-review-x:hover { background: rgba(255, 255, 255, .1); transform: rotate(90deg); }

.ts-review-body { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; min-height: 0; }
.ts-review-files { overflow: auto; padding: 10px; border-right: 1px solid var(--line); display: grid; align-content: start; gap: 2px; }
.ts-review-file {
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; outline: none;
  transition: background .16s ease, opacity .2s;
}
.ts-review-file:hover { background: rgba(255, 255, 255, .045); }
.ts-review-file:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.ts-review-file.active { background: rgba(56, 167, 255, .12); box-shadow: inset 2px 0 0 var(--accent); }
.ts-review-file.excluded { opacity: .45; }
.ts-review-file input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.ts-review-file-name { display: grid; min-width: 0; }
.ts-review-file-name b { font-weight: 550; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-review-file-name small { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.ts-review-file-stat { display: flex; gap: 6px; font: 11px var(--rv-mono); }
.ts-review-file-stat i { font-style: normal; }
.ts-review-file-stat .plus { color: var(--rv-add); }
.ts-review-file-stat .minus { color: var(--rv-del); }

.ts-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 6px;
  font: 600 11px var(--rv-mono); letter-spacing: .02em;
}
.ts-badge.add { color: var(--rv-add); background: var(--rv-add-bg); }
.ts-badge.mod { color: var(--rv-mod); background: var(--rv-mod-bg); }
.ts-badge.del { color: var(--rv-del); background: var(--rv-del-bg); }
.ts-badge.move { color: var(--rv-move); background: var(--rv-move-bg); }

.ts-review-main { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.ts-review-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ts-review-path { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; overflow: hidden; font-size: 13px; }
.ts-review-path .ts-badge { padding: 0 8px; font-family: inherit; }
.ts-review-path code { font-family: var(--rv-mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-arrow { color: var(--muted); }
.ts-review-seg { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); flex: none; }
.ts-review-seg button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 550;
  padding: 5px 12px; border-radius: 7px; cursor: pointer; transition: background .2s, color .2s;
}
.ts-review-seg button.on { background: rgba(255, 255, 255, .1); color: var(--ink); }
.ts-review-seg button:disabled { opacity: .4; cursor: default; }

.ts-review-diff { overflow: auto; min-height: 0; outline: none; background: rgba(0, 0, 0, .18); }
.ts-diff { min-width: max-content; padding: 8px 0 24px; font: 12.5px/1.65 var(--rv-mono); }
.ts-line { display: grid; grid-template-columns: 52px 52px 22px 1fr; }
.ts-line .ln { padding: 0 10px; text-align: right; color: rgba(158, 171, 193, .5); user-select: none; font-size: 11.5px; }
.ts-line .sign { text-align: center; user-select: none; color: var(--muted); }
.ts-line .code { white-space: pre; padding-right: 24px; tab-size: 4; }
.ts-line.add { background: var(--rv-add-bg); }
.ts-line.add .ln { background: var(--rv-add-ln); color: rgba(63, 207, 142, .8); }
.ts-line.add .sign { color: var(--rv-add); }
.ts-line.del { background: var(--rv-del-bg); }
.ts-line.del .ln { background: var(--rv-del-ln); color: rgba(255, 107, 122, .8); }
.ts-line.del .sign { color: var(--rv-del); }
.ts-line.del .code { text-decoration: line-through; text-decoration-color: rgba(255, 107, 122, .35); }
.ts-gap {
  display: block; width: 100%; margin: 6px 0; padding: 6px 0 6px 126px; border: 0; text-align: left; cursor: pointer;
  font: 11.5px var(--rv-mono); color: var(--accent); background: rgba(56, 167, 255, .06);
  border-top: 1px dashed rgba(56, 167, 255, .2); border-bottom: 1px dashed rgba(56, 167, 255, .2);
}
.ts-gap:hover { background: rgba(56, 167, 255, .12); }
div.ts-gap { cursor: default; color: var(--muted); }
.ts-review-empty { display: grid; place-items: center; height: 100%; min-height: 160px; padding: 24px; color: var(--muted); font-size: 14px; text-align: center; }

.ts-review-foot {
  display: flex; align-items: center; gap: 10px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(0, 0, 0, .12);
}
.ts-review-status { flex: 1; font-size: 13px; color: var(--muted); min-width: 0; }
.ts-review-status.error { color: var(--rv-del); }
.ts-review-discard, .ts-review-apply {
  border-radius: 999px; padding: 10px 20px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .18s var(--rv-ease), box-shadow .18s var(--rv-ease), background .18s, opacity .18s;
}
.ts-review-discard { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.ts-review-discard:hover { background: rgba(255, 107, 122, .1); border-color: rgba(255, 107, 122, .4); color: var(--rv-del); }
.ts-review-apply { border: 0; color: #03140c; background: var(--rv-add); box-shadow: 0 6px 22px rgba(63, 207, 142, .28); }
.ts-review-apply:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(63, 207, 142, .38); }
.ts-review-apply:disabled, .ts-review-discard:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.ts-review.busy .ts-review-apply { background-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  background-size: 200% 100%; animation: rv-shimmer 1.1s linear infinite; }
@keyframes rv-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 760px) {
  .ts-review-sheet { height: 94dvh; border-radius: 18px 18px 0 0; }
  .ts-review-head { grid-template-columns: 1fr auto; padding: 2px 16px 12px; }
  .ts-review-summary { grid-column: 1 / -1; justify-content: flex-start; padding: 0; order: 3; }
  .ts-review-head h2 { font-size: 19px; }
  .ts-review-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .ts-review-files { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .ts-review-file { flex: none; grid-template-columns: auto auto auto; max-width: 230px; border: 1px solid var(--line); }
  .ts-review-file-name small, .ts-review-file-stat { display: none; }
  .ts-review-toolbar { padding: 8px 12px; }
  .ts-review-path > .ts-badge { display: none; }
  .ts-review-seg button { padding: 5px 9px; }
  .ts-line { grid-template-columns: 36px 36px 18px 1fr; }
  .ts-line .ln { padding: 0 5px; }
  .ts-gap { padding-left: 90px; }
  .ts-review-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .ts-review-discard, .ts-review-apply { padding: 10px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .ts-review-sheet, .ts-review-backdrop, .ts-change-card { transition: none; animation: none; }
}

/* ---------- read-only (history) mode ---------- */
.ts-review.readonly .ts-review-file input,
.ts-review.readonly .ts-review-apply,
.ts-review.readonly .ts-review-discard { display: none; }
.ts-review.readonly .ts-review-file { grid-template-columns: auto 1fr auto; }

/* ---------- history list (project hub tab + ThinkerStreet_APP sheet) ---------- */
.ts-history-list { display: grid; gap: 8px; }
.ts-history-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; width: 100%;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .025);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s var(--rv-ease);
}
.ts-history-item:hover { border-color: rgba(56, 167, 255, .4); background: rgba(56, 167, 255, .06); transform: translateY(-1px); }
.ts-history-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(56, 167, 255, .16); }
.ts-history-dot.chat, .ts-history-dot.live { background: #a679ff; box-shadow: 0 0 0 4px rgba(166, 121, 255, .18); }
.ts-history-dot.delete { background: var(--rv-del); box-shadow: 0 0 0 4px rgba(255, 107, 122, .16); }
.ts-history-text { display: grid; gap: 5px; min-width: 0; }
.ts-history-text strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-history-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.ts-history-item time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ts-history-empty { padding: 28px 8px; color: var(--muted); font-size: 14px; text-align: center; line-height: 1.6; }

.ts-history { position: fixed; inset: 0; z-index: 950; }
.ts-history[hidden] { display: none; }
.ts-history .ts-review-backdrop { z-index: 0; }
.ts-history-sheet {
  position: absolute; left: 50%; bottom: 0; width: min(760px, 100%); height: min(82dvh, 820px);
  display: grid; grid-template-rows: auto auto 1fr; overflow: hidden; outline: none;
  background: color-mix(in srgb, var(--panel) 92%, #000); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 20px 20px 0 0; box-shadow: 0 -24px 80px rgba(0, 0, 0, .55);
  transform: translate(-50%, 104%); transition: transform .42s var(--rv-ease);
}
.ts-history.open .ts-review-backdrop { opacity: 1; }
.ts-history.open .ts-history-sheet { transform: translate(-50%, 0); }
.ts-history-body { overflow: auto; padding: 16px 20px 32px; }
