/* A picture dropped on TSB (assets/picture-drop.js; Igor 15 Nov «A, B после чтения» → «если реально сделать - делай»).
   The cue: the page soft behind one line of words and its picture. The reading stage: his own picture
   large, what TSB read marked on it, the one next step beside it. A chart filed on Journal lands in its row.
   Built on tokens.css and the kit's buttons (the stage is a .tsb-content-controls root); NEW pieces are marked. */

/* ---- The cue ----------------------------------------------------------------------------------------------------- */
.tsb-drop-cue { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; pointer-events: none; color: var(--ui-ink); font: 400 var(--ui-type-body) var(--ui-font); }
.tsb-drop-cue[hidden] { display: none; }
.tsb-drop-cue::before { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--ui-page) 82%, transparent); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.tsb-drop-cue-copy { position: relative; display: grid; justify-items: center; gap: 12px; max-width: 480px; padding: 32px; text-align: center; }
.tsb-drop-cue-icon { width: 48px; height: 48px; margin-bottom: 12px; color: var(--ui-accent-text); }
.tsb-drop-cue-icon svg { display: block; width: 100%; height: 100%; } /* the picture fills its 48 px, on the title's axis (Igor 19 Nov «мелкая и отвалилась») */
@media (max-width: 559px) { .tsb-drop-cue-icon { width: 32px; height: 32px; } }
.tsb-drop-cue-title { margin: 0; font: 600 var(--ui-type-title-l) var(--ui-font); letter-spacing: -.02em; }
.tsb-drop-cue-text { margin: 0; color: var(--ui-ink-2); }
.tsb-drop-cue-formats { margin: 0; color: var(--ui-ink-3); font: 400 var(--ui-type-caption) var(--ui-font); }

/* Where pictures go, when nothing here takes one: one quiet line at the foot. */
.tsb-picture-hint { position: fixed; left: 50%; bottom: 24px; z-index: 10000; max-width: calc(100vw - 32px); padding: 8px 16px; border-radius: var(--ui-radius-card); background: var(--ui-page); color: var(--ui-ink); box-shadow: var(--ui-shadow-pop); font: 500 var(--ui-type-body) var(--ui-font); transform: translateX(-50%); pointer-events: none; }
.tsb-picture-hint[hidden] { display: none; }

/* ---- The reading stage --------------------------------------------------------------------------------------------- */
html.tsb-read-open { overflow: hidden; }
.tsb-read-stage { position: fixed; inset: 0; z-index: 10000; overflow: auto; overscroll-behavior: contain; color: var(--ui-ink); font: 400 var(--ui-type-body) var(--ui-font); }
.tsb-read-stage[hidden] { display: none; }
.tsb-read-veil { position: fixed; inset: 0; background: color-mix(in srgb, var(--ui-page) 86%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
/* Model A (Igor 19 Nov «смотрится слабо» → «Да, доводи»): the picture and its answer stand in the middle of the screen,
   the status line on top; no empty half under them. */
.tsb-read-sheet { position: relative; box-sizing: border-box; display: flex; flex-direction: column; max-width: 1238px; min-height: 100%; margin: 0 auto; padding: 24px 24px 48px; }
.tsb-read-sheet:focus { outline: none; } /* focus waits here while it reads: no ring on a button nobody touched */
.tsb-read-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; margin: auto 0 24px; } /* the status and the ✕ ride on top of the picture and its answer, centred with them */
.tsb-read-top > .app-action-btn-icon-only { margin-right: -15px; } /* the ✕'s own end on the grid's right edge: 11 px of the button + 4 px inside the icon (Igor 19 Nov «не по сетке»)*/
.tsb-read-status { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ui-ink-2); font: 500 var(--ui-type-body) var(--ui-font); }
.tsb-read-status:empty { visibility: hidden; }
.tsb-read-status::before { content: ''; flex: none; width: 24px; height: 2px; background: var(--ui-accent); }
.tsb-read-layout { align-items: center; margin-bottom: auto; }
.tsb-read-visual { min-width: 0; }

/* His picture, as it is; every mark is placed in fractions of it. Framed as Journal frames a chart screenshot: one
   line, radius 12, no shadow (Igor 19 Nov «Да, замени»: only what floats over the page casts one, DESIGN-SYSTEM 2.5). */
.tsb-read-figure { position: relative; display: inline-block; max-width: 100%; margin: 0; vertical-align: top; border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-card); background: var(--ui-page); }
.tsb-read-figure > img { display: block; width: auto; height: auto; max-width: 100%; max-height: min(72vh, 720px); border-radius: calc(var(--ui-radius-card) - 1px); }
/* NEW: the scanner (Igor 15 Nov «чтение выглядит уныло»). His picture stays as it is (19 Nov: no veil over it, it read
   as faded); one line with a soft accent wake goes over it while the model reads. Nothing claims to know more. One
   layer three pictures tall moves by transform (the compositor's work, no repaint of the picture on every frame). */
.tsb-read-scan { position: absolute; inset: 0; z-index: 1; display: none; overflow: hidden; border-radius: calc(var(--ui-radius-card) - 1px); pointer-events: none; }
.tsb-read-figure[data-reading] .tsb-read-scan { display: block; }
.tsb-read-scan::before { content: ''; position: absolute; left: 0; right: 0; top: -100%; height: 300%; will-change: transform;
    --wake: color-mix(in srgb, var(--ui-accent) 10%, transparent);
    background: linear-gradient(to bottom, transparent 0 45%, var(--wake) calc(50% - 1px), var(--ui-accent) calc(50% - 1px) calc(50% + 1px), var(--wake) calc(50% + 1px), transparent 55% 100%);
    animation: tsb-read-band 2.4s var(--ui-ease-in-out, ease-in-out) infinite alternate; }
@keyframes tsb-read-band { from { transform: translateY(-16.667%); } to { transform: translateY(16.667%); } }
/* NEW: what TSB looks for, then what it found, as model A's one row of steps under a hairline (a step is ticked only
   once the answer is in). */
.tsb-read-found { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 24px 0 0; padding: 16px 0 0; list-style: none; border-top: 1px solid var(--ui-line); font: 400 var(--ui-type-caption) var(--ui-font); }
.tsb-read-found li { display: flex; align-items: center; gap: 6px; color: var(--ui-ink-3); transition: color var(--ui-motion-base, .2s) ease; }
.tsb-read-found li:not([data-state]) { animation: tsb-read-wait 1.8s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 300ms); }
@keyframes tsb-read-wait { 50% { color: var(--ui-ink-2); } }
.tsb-read-found svg { flex: none; width: 14px; height: 14px; transition: transform var(--ui-motion-base, .2s) ease; }
.tsb-read-found li[data-state="found"] { color: var(--ui-accent-text); font-weight: 500; }
.tsb-read-found li[data-state="found"] svg { transform: scale(1.15); }
.tsb-read-marks { position: absolute; inset: 0; pointer-events: none; }

/* NEW: the marks (what was read, where it was read). */
.tsb-read-mark { position: absolute; opacity: 0; transition: opacity var(--ui-motion-base, .2s) ease; transition-delay: calc(var(--i, 0) * 120ms); }
.tsb-read-marks.is-shown .tsb-read-mark { opacity: 1; }
.tsb-read-tag { display: flex; align-items: center; gap: 4px; max-width: 46%; padding: 4px 8px; border-radius: var(--ui-radius-control); background: var(--ui-page); color: var(--ui-ink); box-shadow: var(--ui-shadow-pop); font: 500 var(--ui-type-caption) var(--ui-font); white-space: nowrap; }
.tsb-read-tag > span { overflow: hidden; text-overflow: ellipsis; }
.tsb-read-tag svg { flex: none; width: 14px; height: 14px; color: var(--ui-accent-text); }
.tsb-read-tag:not(.is-axis) { left: 0; top: 0; transform: translateY(calc(-100% - 8px)); } /* model A's pin, moved just above the picture: it covers none of the chart's legend */
.tsb-read-figure:has(.tsb-read-tag:not(.is-axis)) { margin-top: 40px; }
.tsb-read-tag.is-axis { left: var(--x); top: var(--y); transform: translate(-50%, -100%); border-bottom: 2px solid var(--ui-accent); }
/* Model A: a level runs over the part of the picture where the trade is drawn and ends in a dot before the price
   axis, so the chart's own price tags stay readable. */
.tsb-read-level { left: 36%; right: 4.5%; height: 0; border-top: 1px solid currentColor; color: var(--ui-accent-text); }
.tsb-read-level::after { content: ''; position: absolute; right: 0; top: -4px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tsb-read-level.is-target { color: var(--ui-gain); }
.tsb-read-level.is-stop { color: var(--ui-loss); }
.tsb-read-level > span { position: absolute; right: 8%; top: var(--shift, 0px); display: flex; align-items: baseline; gap: 8px; padding: 4px 8px; border-left: 2px solid currentColor; border-radius: var(--ui-radius-control); background: var(--ui-page); box-shadow: var(--ui-shadow-pop); transform: translateY(-50%); white-space: nowrap; }
.tsb-read-level small { color: var(--ui-ink-2); font: 400 var(--ui-type-caption) var(--ui-font); }
.tsb-read-level b { font: 600 var(--ui-type-body) var(--ui-font); font-variant-numeric: tabular-nums; }
/* Model A's band: the row that was read, tinted; its tick sits outside the picture, so every cell stays readable. */
.tsb-read-row { left: .5%; right: .5%; border-left: 3px solid var(--ui-accent); background: color-mix(in srgb, var(--ui-accent) 12%, transparent); transform: translateY(-50%); }
.tsb-read-row svg { position: absolute; left: -24px; top: 50%; width: 14px; height: 14px; color: var(--ui-accent-text); transform: translateY(-50%); }
.tsb-read-cell { border: 2px solid var(--ui-accent); border-radius: var(--ui-radius-control); transform: translate(-50%, -50%); }

/* The answer beside the picture: what it is, in his numbers, and the one next step. */
.tsb-read-answer { min-width: 0; }
/* The kit's .ui-page-title: the stage fills the screen and is read as a page, so its title takes the page title role
   (model A's 32 px; Igor 19 Nov «Да, доводи»), not the 24 px of a dialog box. Focused for a screen reader, not a control. */
.tsb-read-title { letter-spacing: -.04em; text-wrap: balance; }
.tsb-read-title:focus { outline: none; }
.tsb-read-copy { margin: 12px 0 0; color: var(--ui-ink-2); text-wrap: pretty; }
.tsb-read-figures { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 24px 0 0; }
.tsb-read-figures div { margin: 0; }
.tsb-read-figures dt { color: var(--ui-ink-2); font: 400 var(--ui-type-caption) var(--ui-font); }
.tsb-read-figures dd { margin: 4px 0 0; font: 600 var(--ui-type-title-s) var(--ui-font); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tsb-read-answer .ui-notice { margin-top: 24px; }
.tsb-read-trades { margin: 24px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--ui-line); }
.tsb-read-trade { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px 16px; padding: 16px 0; border-bottom: 1px solid var(--ui-line); } /* the tick and the money on the name's line (Igor 19 Nov) */
.tsb-read-trade.is-choice { grid-template-columns: auto minmax(0, 1fr) auto; cursor: pointer; }
.tsb-read-trade input { width: 16px; height: 16px; margin: 4px 0 0; accent-color: var(--ui-accent); } /* centred on the name's 24 px line */
.tsb-read-trade strong { display: block; font: 600 var(--ui-type-lead) var(--ui-font); letter-spacing: -.01em; }
.tsb-read-trade small { display: block; margin-top: 4px; color: var(--ui-ink-2); font: 400 var(--ui-type-caption) var(--ui-font); }
.tsb-read-money { font: 600 var(--ui-type-lead) var(--ui-font); letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tsb-read-money.is-gain { color: var(--ui-gain); }
.tsb-read-money.is-loss { color: var(--ui-loss); }
.tsb-read-actions { display: grid; gap: 12px; margin-top: 24px; }
.tsb-read-actions > .app-action-btn { width: 100%; justify-content: center; } /* model A's stack: the main step, then each other place for it */
.tsb-read-quiet { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-left: -10px; } /* the quiet button's own 10px: its words on the title's edge */
.tsb-read-quiet .ui-link { min-height: 40px; margin-left: 10px; font-size: var(--ui-type-body-size, 14px); }
.tsb-read-foot { margin: 16px 0 0; color: var(--ui-ink-3); font: 400 var(--ui-type-caption) var(--ui-font); }

@container ui-grid (max-width: 899px) {
    .tsb-read-figure > img { max-height: 56vh; }
    /* The dates go under the picture (model A's phone), clear of the levels drawn on it. */
    .tsb-read-figure:has(.is-axis) { margin-bottom: 40px; }
    .tsb-read-tag.is-axis { left: 50%; top: 100%; transform: translate(-50%, 8px); }
}
@media (max-width: 559px) {
    .tsb-read-sheet { padding: 16px 16px 32px; }
    .tsb-read-top { margin-bottom: 16px; }
    .tsb-read-level > span { right: 4px; gap: 4px; padding: 2px 6px; }
    .tsb-read-level small { display: none; }
    .tsb-read-tag { max-width: 70%; }
    .tsb-read-level { left: 5%; }
    .tsb-read-row svg { display: none; }
    .tsb-read-actions .app-action-btn { min-height: 44px; }
}

/* ---- B: a chart filed on Journal lands in its own trade's card (model B; Igor 19 Nov «ок») ------------------------------
   Inside the card, under its pictures: the chart at their size and frame (journal-workspace.css .j-list-preview img),
   what was read in the accent on top, the one confirmation, Open · Undo, the correction as a question. No bar, no box. */
.j-record-main > .tsb-landed { grid-column: 1 / -1; order: 99; } /* last in the card, also where the phone reorders it (journal-workspace.css orders the result 1, the pictures 4) */
.tsb-landed { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; margin: 0; color: var(--ui-ink); font: 400 var(--ui-type-body) var(--ui-font); cursor: auto; }
.tsb-landed-thumb { display: block; width: auto; height: auto; max-width: 180px; max-height: 90px; border: 1px solid var(--ui-line-strong); border-radius: var(--ui-radius-card); }
.tsb-landed:focus { outline: none; } /* focus lands on the receipt (read out), Tab goes on to Open */
.tsb-landed-copy { min-width: 0; }
.tsb-landed-source { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; color: var(--ui-accent-text); font: 500 var(--ui-type-caption) var(--ui-font); }
.tsb-landed-source svg { flex: none; width: 14px; height: 14px; }
.tsb-landed-source span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsb-landed-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; margin: 0; }
.tsb-landed-title strong { font: 600 var(--ui-type-body) var(--ui-font); }
.tsb-landed .tsb-landed-wrong { min-height: 0; }
.tsb-landed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.tsb-landed-done { margin: 0; color: var(--ui-ink-2); }
.tsb-landed.is-done { grid-template-columns: minmax(0, 1fr); }
.tsb-landed-flight { position: fixed; z-index: 10001; margin: 0; border-radius: var(--ui-radius-card); pointer-events: none; transform-origin: 0 0; transition: transform 420ms var(--ui-ease-out, ease-out), opacity 420ms ease; }
@media (max-width: 559px) {
    .tsb-landed { gap: 12px; }
    .tsb-landed-thumb { max-width: 120px; max-height: 72px; }
}
@media (prefers-reduced-motion: reduce) {
    .tsb-read-figure[data-reading] .tsb-read-scan { display: none; }
    .tsb-read-found li { animation: none; transition: none; }
    .tsb-read-found svg { transition: none; }
    .tsb-read-mark { transition: none; }
    .tsb-landed-flight { display: none; }
}
