/* TradingView Advanced Charts in der App (tvchart.js).

   Die Library steht in ihrem eigenen iframe (.tvc-root). Darüber liegt nur
   eine schmale Ebene der App: der Hinweis bei einem Fehler (.tvc-wait,
   oben mittig) und die Karte eines gezogenen SK-Entwurfs (.tvc-card,
   unten mittig über der Zeitachse) -- beide weg vom Rand unten links,
   dort steht das Logo von TradingView, und es bleibt immer sichtbar
   (Lizenz). */

.tvc-host { position: relative; overflow: hidden; }
.tvc-root { position: absolute; inset: 0; }
.tvc-root iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Laden und Fehler: über dem Chart, ohne ihn wegzunehmen. */
.tvc-wait {
  position: absolute; z-index: 6; left: 50%; top: 46px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 140px);
  padding: 8px 14px; border: 1px solid var(--line, #e6e6e8); border-radius: 999px;
  background: var(--surface, #fff); color: var(--ink-soft, #3d3f45);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .12); font-size: 13px; pointer-events: none;
}
.tvc-wait[hidden] { display: none; }
/* Der Hinweis der App bringt seinen eigenen Rahmen mit (.chart-wait). */
.tvc-wait .chart-wait { height: auto; padding: 0; border: 0; background: none; }

/* Die Karten beim Entdecken: ohne Kopfzeile -- die Ebenen rücken hoch. */
.tvc-host[data-readonly] .tvc-wait { top: 8px; }

/* Ein SK-Entwurf ist gezogen: die Frage danach als eigene Karte, im Kleid
   der schwebenden Leisten von TradingView (tvchart.js ``draftCard``). Vor
   dem Zeichnen steht hier nichts. */
.tvc-card {
  position: absolute; z-index: 6; left: 50%; bottom: 44px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 140px);
  padding: 6px 6px 6px 14px; border: 1px solid #e0e3eb; border-radius: 8px;
  background: #fff; color: #131722; font-size: 13px; line-height: 1.3;
  box-shadow: 0 2px 4px rgba(19, 23, 34, .06), 0 10px 28px rgba(19, 23, 34, .14);
  animation: tvc-card-in .16s cubic-bezier(.2, .9, .3, 1);
}
.tvc-card[hidden] { display: none; }
.tvc-card.note { padding: 9px 14px; pointer-events: none; }
@keyframes tvc-card-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translateX(-50%); }
}
.tvc-card-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tvc-card-text b { font-weight: 600; white-space: nowrap; }
.tvc-card-text span { color: #6a6d78; overflow: hidden; text-overflow: ellipsis; }
.tvc-card-text span.err { color: #d93a3a; }
.tvc-card-acts { display: flex; align-items: center; gap: 4px; flex: none; }
.tvc-card button {
  height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: inherit; font: inherit; font-weight: 500;
  white-space: nowrap; cursor: pointer;
}
.tvc-card button:hover:not(:disabled) { background: #f0f3fa; }
.tvc-card button:disabled { opacity: .4; cursor: default; }
.tvc-card button.role { border-color: #d1d4dc; min-width: 88px; }
.tvc-card button.role.sec { border-style: dashed; color: #6a6d78; }
.tvc-card button.go { background: #131722; color: #fff; font-weight: 600; }
.tvc-card button.go:hover:not(:disabled) { background: #2a2e39; }
.tvc-card button.del { color: #d93a3a; }
.tvc-card button.del:hover:not(:disabled) { background: #fdecec; }

:root[data-theme="dark"] .tvc-card {
  border-color: #2e2e2e; background: #1f1f1f; color: #dbdbdb;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
}
:root[data-theme="dark"] .tvc-card-text span { color: #8c8f99; }
:root[data-theme="dark"] .tvc-card-text span.err { color: #f26d6d; }
:root[data-theme="dark"] .tvc-card button:hover:not(:disabled) { background: #2e2e2e; }
:root[data-theme="dark"] .tvc-card button.role { border-color: #434651; }
:root[data-theme="dark"] .tvc-card button.role.sec { color: #8c8f99; }
:root[data-theme="dark"] .tvc-card button.go { background: #dbdbdb; color: #131722; }
:root[data-theme="dark"] .tvc-card button.go:hover:not(:disabled) { background: #fff; }
:root[data-theme="dark"] .tvc-card button.del { color: #f26d6d; }
:root[data-theme="dark"] .tvc-card button.del:hover:not(:disabled) { background: #3a2323; }

@media (max-width: 640px) {
  .tvc-wait { max-width: calc(100% - 24px); }
  .tvc-card { max-width: calc(100% - 24px); flex-wrap: wrap; justify-content: center; gap: 8px; }
  .tvc-card-text { flex: 1 1 100%; text-align: center; }
}

/* Die Leiste über dem Chart (Zeiteinheiten, Knöpfe, "Trade") steht im
   Chart selbst -- außen nichts doppelt. */
body .app.tv .tv-bar { display: none; }

/* Oben rechts vor der Glocke: der Hinweis auf TradingView mit Link
   (Lizenz 3.2). Die Suche bleibt, wo sie ist. */
.tv-attrib {
  font-size: 12px; color: var(--grey, #787b86); text-decoration: none; white-space: nowrap;
}
.tv-attrib:hover { color: var(--ink, #131722); text-decoration: underline; }
.topbar .tv-credit { flex: none; margin: 0 12px 0 auto; font-size: 11.5px; }
.topbar .tv-credit[hidden] { display: none; }
.topbar .tv-credit:not([hidden]) ~ .inbox,
.topbar .tv-credit:not([hidden]) ~ .guest-cta { margin-left: 0; }

/* "Indikatoren, Messwerte und Strategien" (tvchart.js, ``openInd``): wie
   der Dialog auf TradingView -- Suche oben, links Gruppen, rechts die
   Liste. Bewegt werden nur transform/opacity. */
.tvi-back {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: rgba(19, 23, 34, .36);
  animation: tvi-fade .12s ease-out;
}
.tvi-back[hidden] { display: none; }
.tvi {
  width: min(880px, 100%); height: min(660px, calc(100vh - 48px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg, #fff); color: var(--ink, #131722);
  border: 1px solid var(--line, #e0e3eb); border-radius: 8px;
  box-shadow: 0 20px 56px rgba(19, 23, 34, .24); font-size: 14px;
  animation: tvi-pop .16s cubic-bezier(.2, .9, .3, 1);
}
@keyframes tvi-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tvi-pop {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.tvi svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
           stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.tvi-head { display: flex; align-items: center; justify-content: space-between;
            padding: 16px 12px 12px 20px; }
.tvi-head h3 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.tvi-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink, #131722); cursor: pointer;
}
.tvi-close:hover { background: var(--bg-sunken, #f0f3fa); }
.tvi-close svg { width: 22px; height: 22px; }

.tvi-search {
  display: flex; align-items: center; gap: 10px; margin: 0 20px 12px; padding: 0 12px;
  height: 42px; border: 1px solid var(--line-strong, #d1d4dc); border-radius: 8px; cursor: text;
}
.tvi-search:focus-within { border-color: var(--accent, #2962ff); box-shadow: 0 0 0 1px var(--accent, #2962ff); }
.tvi-search svg { color: var(--grey, #787b86); }
.tvi-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent;
  color: var(--ink, #131722); font: inherit; font-size: 16px;
}
.tvi-search input::placeholder { color: var(--grey, #787b86); }

.tvi-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr);
            border-top: 1px solid var(--line, #e0e3eb); }
.tvi-nav { overflow-y: auto; padding: 4px 8px 12px; border-right: 1px solid var(--line, #e0e3eb);
           scrollbar-width: thin; }
.tvi-nav h4 { margin: 12px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
              text-transform: uppercase; color: var(--grey, #787b86); }
.tvi-cat {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 36px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink, #131722);
  font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.tvi-cat:hover { background: var(--bg-sunken, #f0f3fa); }
.tvi-cat.on { background: var(--bg-sunken, #f0f3fa); font-weight: 600; }
.tvi-cat span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tvi-cat em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--grey, #787b86); }

.tvi-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tvi-cols { display: flex; justify-content: space-between; padding: 12px 24px 6px 56px;
            font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
            color: var(--grey, #787b86); }
.tvi-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 10px; scrollbar-width: thin;
            overscroll-behavior: contain; }
.tvi-row {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px;
  padding: 2px 14px 2px 8px; border-radius: 6px; cursor: pointer; user-select: none;
}
.tvi-row:hover, .tvi-row.at { background: var(--bg-sunken, #f0f3fa); }
.tvi-row::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: var(--accent, #2962ff); opacity: 0;
}
.tvi-row.added::after { animation: tvi-added .7s ease-out; }
@keyframes tvi-added { from { opacity: .16; } to { opacity: 0; } }
.tvi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tvi-name mark { background: none; color: var(--accent, #2962ff); font-weight: 600; }
.tvi-name small { display: block; margin-top: 1px; font-size: 12px; color: var(--grey, #787b86);
                  overflow: hidden; text-overflow: ellipsis; }
.tvi-name small.warn { color: #e8710a; }
.tvi-row.konf, .tvi-row.live { padding-left: 12px; }
.tvi-row.konf { min-height: 46px; }
.tvi-ico { display: inline-flex; width: 28px; justify-content: center; color: var(--grey, #787b86); }
.tvi-meta { flex: none; font-size: 12px; color: var(--grey, #787b86); }
.tvi-star {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border: 0; border-radius: 4px; background: transparent;
  color: var(--grey, #787b86); cursor: pointer; opacity: 0; transition: opacity .1s ease;
}
.tvi-row:hover .tvi-star, .tvi-row.at .tvi-star, .tvi-star.on, .tvi-star:focus-visible { opacity: 1; }
.tvi-star:hover { color: var(--ink, #131722); }
.tvi-star.on { color: var(--ink, #131722); }
.tvi-star.on svg { fill: currentColor; }
.tvi-count {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent, #2962ff); color: #fff; font-size: 11.5px; font-weight: 600;
}
.tvi-switch {
  position: relative; flex: none; width: 32px; height: 18px; border-radius: 9px;
  background: var(--line-strong, #d1d4dc); transition: background-color .15s ease;
}
.tvi-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s ease;
}
.tvi-switch.on { background: var(--accent, #2962ff); }
.tvi-switch.on::after { transform: translateX(14px); }
.tvi-del {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border: 0; border-radius: 4px; background: transparent;
  color: var(--grey, #787b86); cursor: pointer;
}
.tvi-del:hover { background: rgba(242, 54, 69, .1); color: #f23645; }
.tvi-del svg { width: 18px; height: 18px; }
.tvi-note { padding: 40px 24px; text-align: center; color: var(--grey, #787b86); }

.tvi-foot { display: flex; align-items: center; gap: 16px; padding: 9px 20px;
            border-top: 1px solid var(--line, #e0e3eb); font-size: 12px; color: var(--grey, #787b86); }
.tvi-foot kbd { margin-right: 3px; }
.tvi-lib {
  margin-left: auto; padding: 4px 6px; border: 0; border-radius: 4px; background: transparent;
  color: var(--grey, #787b86); font: inherit; font-size: 12px; cursor: pointer;
}
.tvi-lib:hover { color: var(--ink, #131722); text-decoration: underline; }

@media (hover: none) { .tvi-star { opacity: 1; } }
@media (max-width: 640px) {
  .tvi-back { padding: 0; align-items: stretch; }
  .tvi { width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .tvi-head { padding: 10px 8px 8px 16px; }
  .tvi-head h3 { font-size: 17px; }
  .tvi-search { margin: 0 16px 10px; }
  .tvi-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .tvi-nav { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 10px 16px;
             border-right: 0; border-bottom: 1px solid var(--line, #e0e3eb); scrollbar-width: none; }
  .tvi-nav::-webkit-scrollbar { display: none; }
  .tvi-nav h4, .tvi-cat svg, .tvi-cols, .tvi-foot { display: none; }
  .tvi-cat { flex: none; width: auto; height: 34px; padding: 0 14px; gap: 6px; font-size: 14px;
             border: 1px solid var(--line-strong, #d1d4dc); border-radius: 99px; }
  .tvi-cat.on { background: var(--ink, #131722); border-color: var(--ink, #131722);
                color: var(--on-ink, #fff); }
  .tvi-cat.on em { color: inherit; }
  .tvi-list { padding: 6px 8px 16px; }
  .tvi-row { min-height: 48px; }
}
