.pbtv-root {
    width: 100%;
    direction: rtl;
    font-family: inherit;
    color: #0f172a;
}

.pbtv-root *,
.pbtv-root *::before,
.pbtv-root *::after {
    box-sizing: border-box;
}

.pbtv-toolbar {
    position: relative;
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 7px 9px;
    border: 1px solid #e2e8f0;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: #fff;
}

.pbtv-symbol-picker {
    position: relative;
    flex: 0 1 420px;
    min-width: 280px;
    max-width: 420px;
}

.pbtv-search-icon {
    position: absolute;
    z-index: 2;
    top: 50%;
    right: auto;
    left: 12px;
    width: 19px;
    height: 19px;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
}

.pbtv-search-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.pbtv-search {
    width: 100%;
    min-height: 38px;
    padding: 7px 12px 7px 42px !important;
    direction: rtl;
    text-align: right;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    font: inherit;
}

.pbtv-search:focus {
    border-color: #2563eb;
    outline: 2px solid rgba(37, 99, 235, .14);
}

.pbtv-results {
    position: absolute;
    z-index: 30;
    inset-inline: 0;
    top: calc(100% + 7px);
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
}

.pbtv-result-item {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #eef2f7;
    background: transparent;
    color: #0f172a;
    text-align: right;
    cursor: pointer;
    font: inherit;
}

.pbtv-result-item:hover,
.pbtv-result-item:focus {
    background: #f8fafc;
    outline: none;
}

.pbtv-result-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pbtv-result-symbol {
    direction: ltr;
    color: #64748b;
    font-size: .86em;
}

.pbtv-result-empty {
    padding: 14px;
    color: #64748b;
}

.pbtv-result-error {
    color: #b91c1c;
}

.pbtv-resolution-buttons,
.pbtv-toolbar-actions,
.pbtv-range-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pbtv-resolution-buttons {
    position: relative;
    z-index: 3;
    flex: 0 0 auto;
}

.pbtv-resolution-buttons button,
.pbtv-toolbar-actions button,
.pbtv-range-buttons button {
    min-height: 34px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    white-space: nowrap;
}

.pbtv-resolution-buttons button:hover,
.pbtv-toolbar-actions button:hover,
.pbtv-range-buttons button:hover,
.pbtv-resolution-buttons button.is-active,
.pbtv-range-buttons button.is-active {
    border-color: #dbeafe;
    background: #eff6ff;
    color: #1d4ed8;
}

.pbtv-toolbar-actions {
    margin-inline-start: auto;
}

.pbtv-indicator-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pbtv-indicator-button > span:first-child {
    direction: ltr;
    font-family: Georgia, serif;
    font-size: 16px;
}

.pbtv-fit-button,
.pbtv-theme-button {
    width: 36px;
    padding-inline: 0 !important;
    font-size: 17px !important;
}

.pbtv-indicator-popover {
    position: absolute;
    z-index: 35;
    top: calc(100% + 7px);
    left: 10px;
    width: min(520px, calc(100vw - 32px));
    max-height: min(680px, calc(100vh - 120px));
    overflow-y: auto;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
    line-height: 1.9;
}

.pbtv-indicator-popover strong {
    display: block;
    margin-bottom: 5px;
}

.pbtv-indicator-popover small {
    display: block;
    margin-top: 7px;
    color: #64748b;
}

.pbtv-indicator-popover-content {
    display: grid;
    gap: 9px;
}

.pbtv-indicator-option {
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.pbtv-indicator-option.is-enabled {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.pbtv-indicator-toggle {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.pbtv-indicator-toggle input {
    flex: 0 0 auto;
    margin-top: 5px;
}

.pbtv-indicator-toggle > span {
    display: grid;
    gap: 1px;
}

.pbtv-indicator-toggle b {
    color: #0f172a;
    font-size: 13px;
}

.pbtv-indicator-toggle small {
    margin: 0;
    color: #64748b;
    font-size: 11px;
    line-height: 1.55;
}

.pbtv-indicator-params {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
    padding-right: 25px;
}

.pbtv-indicator-params label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-size: 11px;
}

.pbtv-indicator-params input {
    width: 66px;
    min-height: 29px;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #0f172a;
    direction: ltr;
    text-align: center;
}

.pbtv-indicator-reset {
    min-height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
}

.pbtv-indicator-reset:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}


.pbtv-chart-type-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pbtv-chart-type-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: currentColor;
}

.pbtv-chart-type-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.pbtv-chart-type-popover {
    position: absolute;
    z-index: 35;
    top: calc(100% + 7px);
    left: 10px;
    width: min(360px, calc(100vw - 32px));
    max-height: min(620px, calc(100vh - 120px));
    overflow-y: auto;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
    line-height: 1.7;
}

.pbtv-chart-type-popover strong {
    display: block;
    margin-bottom: 8px;
}

.pbtv-chart-type-popover small {
    display: block;
    margin-top: 10px;
    color: #64748b;
    font-size: 11px;
    line-height: 1.55;
}

.pbtv-chart-type-popover-content {
    display: grid;
    gap: 4px;
}

.pbtv-chart-type-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #0f172a;
    text-align: right;
    cursor: pointer;
    font: inherit;
}

.pbtv-chart-type-option:hover,
.pbtv-chart-type-option:focus {
    border-color: #dbeafe;
    background: #eff6ff;
    outline: none;
}

.pbtv-chart-type-option.is-active {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.pbtv-chart-type-option-icon {
    display: inline-flex;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    color: #475569;
}

.pbtv-chart-type-option-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.pbtv-chart-type-option.is-active .pbtv-chart-type-option-icon {
    color: #1d4ed8;
}

.pbtv-chart-type-option-text {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.pbtv-chart-type-option-text b {
    font-size: 13px;
    font-weight: 600;
}

.pbtv-chart-type-option-text small {
    margin: 0;
    color: #64748b;
    font-size: 11px;
    line-height: 1.45;
}

.pbtv-selected {
    min-height: 30px;
    padding: 5px 10px;
    border-inline: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-size: 12px;
}

.pbtv-chart-stage {
    display: flex;
    width: 100%;
    min-width: 0;
    direction: rtl;
    align-items: stretch;
}

.pbtv-latest-values {
    position: relative;
    z-index: 7;
    flex: 0 0 126px;
    min-width: 126px;
    height: var(--pbtv-chart-height, 820px);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-left: 0;
    background: #f8fafc;
}

.pbtv-latest-values-canvas {
    position: relative;
    width: 100%;
    height: 100%;
}

.pbtv-latest-value {
    position: absolute;
    right: 7px;
    left: 7px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
    min-height: 22px;
    padding: 2px 6px 2px 5px;
    border: 1px solid #cbd5e1;
    border-color: color-mix(in srgb, var(--pbtv-label-color) 48%, transparent);
    border-right: 4px solid var(--pbtv-label-color);
    border-radius: 5px;
    background: #fff;
    color: #334155;
    direction: ltr;
    font-size: 10px;
    line-height: 1.35;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .08);
    white-space: nowrap;
}

.pbtv-latest-value span {
    overflow: hidden;
    color: #64748b;
    text-overflow: ellipsis;
}

.pbtv-latest-value b {
    color: #0f172a;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.pbtv-chart-container {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: var(--pbtv-chart-height, 820px);
    height: var(--pbtv-chart-height, 820px);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.pbtv-chart {
    width: 100%;
    height: 100%;
}

.pbtv-loading,
.pbtv-error {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(255, 255, 255, .94);
    color: #475569;
    text-align: center;
}

.pbtv-error {
    color: #b91c1c;
}

.pbtv-pane-legend {
    position: absolute;
    z-index: 8;
    left: 10px;
    max-width: calc(100% - 100px);
    direction: ltr;
    pointer-events: none;
    color: #334155;
    font-size: 12px;
    line-height: 1.55;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .85);
}

.pbtv-price-legend {
    top: 8px;
}

.pbtv-symbol-line {
    direction: rtl;
    margin-bottom: 2px;
    font-weight: 700;
    font-size: 13px;
    text-align: left;
}

.pbtv-ohlc-line,
.pbtv-ma-line,
.pbtv-oscillator-legend,
.pbtv-macd-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 9px;
}

.pbtv-ma-line span::before {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 4px;
    border-radius: 50%;
    background: var(--pbtv-series-color);
    content: "";
}

.pbtv-oscillator-legend,
.pbtv-macd-legend {
    right: auto;
    left: 10px;
}

.pbtv-oscillator-legend > span:first-child,
.pbtv-macd-legend > span:first-child {
    color: #475569;
}

.is-positive {
    color: #089981 !important;
}

.is-negative {
    color: #f23645 !important;
}

.pbtv-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-top: 0;
    background: #fff;
}

.pbtv-range-buttons {
    direction: ltr;
    overflow-x: auto;
}

.pbtv-status {
    min-width: 150px;
    color: #64748b;
    font-size: 12px;
    text-align: left;
}

.pbtv-attribution {
    padding: 6px 10px;
    color: #64748b;
    font-size: 11px;
    text-align: left;
}

.pbtv-attribution a {
    color: inherit;
    text-decoration: underline;
}

.pbtv-loading[hidden],
.pbtv-error[hidden],
.pbtv-results[hidden],
.pbtv-indicator-popover[hidden],
.pbtv-chart-type-popover[hidden],
.pbtv-compare-popover[hidden],
.pbtv-pane-legend[hidden],
.pbtv-latest-values[hidden] {
    display: none !important;
}

.pbtv-root[data-theme="dark"] {
    color: #e5e7eb;
}

.pbtv-root[data-theme="dark"] .pbtv-toolbar,
.pbtv-root[data-theme="dark"] .pbtv-selected,
.pbtv-root[data-theme="dark"] .pbtv-bottom-bar,
.pbtv-root[data-theme="dark"] .pbtv-indicator-popover,
.pbtv-root[data-theme="dark"] .pbtv-chart-type-popover,
.pbtv-root[data-theme="dark"] .pbtv-results {
    border-color: #334155;
    background: #111827;
    color: #e5e7eb;
}

.pbtv-root[data-theme="dark"] .pbtv-search {
    border-color: #475569;
    background: #0f172a;
    color: #f8fafc;
}

.pbtv-root[data-theme="dark"] .pbtv-result-item {
    border-color: #1f2937;
    color: #e5e7eb;
}

.pbtv-root[data-theme="dark"] .pbtv-result-item:hover,
.pbtv-root[data-theme="dark"] .pbtv-result-item:focus {
    background: #1f2937;
}

.pbtv-root[data-theme="dark"] .pbtv-resolution-buttons button,
.pbtv-root[data-theme="dark"] .pbtv-toolbar-actions button,
.pbtv-root[data-theme="dark"] .pbtv-range-buttons button {
    color: #cbd5e1;
}

.pbtv-root[data-theme="dark"] .pbtv-resolution-buttons button:hover,
.pbtv-root[data-theme="dark"] .pbtv-toolbar-actions button:hover,
.pbtv-root[data-theme="dark"] .pbtv-range-buttons button:hover,
.pbtv-root[data-theme="dark"] .pbtv-resolution-buttons button.is-active,
.pbtv-root[data-theme="dark"] .pbtv-range-buttons button.is-active {
    border-color: #1e3a8a;
    background: #172554;
    color: #bfdbfe;
}

.pbtv-root[data-theme="dark"] .pbtv-chart-container {
    border-color: #334155;
    background: #111827;
}

.pbtv-root[data-theme="dark"] .pbtv-loading,
.pbtv-root[data-theme="dark"] .pbtv-error {
    background: rgba(17, 24, 39, .95);
}

.pbtv-root[data-theme="dark"] .pbtv-pane-legend {
    color: #d1d5db;
    text-shadow: 0 1px 0 rgba(0, 0, 0, .8);
}

.pbtv-root[data-theme="dark"] .pbtv-oscillator-legend > span:first-child,
.pbtv-root[data-theme="dark"] .pbtv-macd-legend > span:first-child {
    color: #cbd5e1;
}

.pbtv-root[data-theme="dark"] .pbtv-latest-values {
    border-color: #334155;
    background: #0f172a;
}

.pbtv-root[data-theme="dark"] .pbtv-latest-value {
    border-color: #475569;
    border-color: color-mix(in srgb, var(--pbtv-label-color) 50%, transparent);
    background: #111827;
    color: #e5e7eb;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
}

.pbtv-root[data-theme="dark"] .pbtv-latest-value span {
    color: #94a3b8;
}

.pbtv-root[data-theme="dark"] .pbtv-latest-value b,
.pbtv-root[data-theme="dark"] .pbtv-indicator-toggle b {
    color: #f8fafc;
}

.pbtv-root[data-theme="dark"] .pbtv-indicator-option {
    border-color: #334155;
    background: #0f172a;
}

.pbtv-root[data-theme="dark"] .pbtv-indicator-option.is-enabled {
    border-color: #1e40af;
    background: #172554;
}

.pbtv-root[data-theme="dark"] .pbtv-indicator-params input,
.pbtv-root[data-theme="dark"] .pbtv-indicator-reset {
    border-color: #475569;
    background: #111827;
    color: #f8fafc;
}


.pbtv-root[data-theme="dark"] .pbtv-chart-type-option {
    color: #e5e7eb;
}

.pbtv-root[data-theme="dark"] .pbtv-chart-type-option:hover,
.pbtv-root[data-theme="dark"] .pbtv-chart-type-option:focus,
.pbtv-root[data-theme="dark"] .pbtv-chart-type-option.is-active {
    border-color: #1e3a8a;
    background: #172554;
}

.pbtv-root[data-theme="dark"] .pbtv-chart-type-option-icon {
    color: #cbd5e1;
}

.pbtv-root[data-theme="dark"] .pbtv-chart-type-option.is-active .pbtv-chart-type-option-icon {
    color: #bfdbfe;
}

.pbtv-root[data-theme="dark"] .pbtv-chart-type-option-text small,
.pbtv-root[data-theme="dark"] .pbtv-chart-type-popover small {
    color: #94a3b8;
}

@media (max-width: 900px) {
    .pbtv-toolbar {
        flex-wrap: wrap;
    }

    .pbtv-symbol-picker {
        flex: 1 1 100%;
        min-width: 0;
        max-width: none;
    }

    .pbtv-toolbar-actions {
        margin-inline-start: auto;
    }
}

@media (max-width: 640px) {
    .pbtv-root {
        --pbtv-chart-height: 650px !important;
    }

    .pbtv-resolution-buttons button,
    .pbtv-toolbar-actions button,
    .pbtv-range-buttons button {
        padding-inline: 7px;
        font-size: 12px;
    }

    .pbtv-indicator-button > span:last-child {
        display: none;
    }
    .pbtv-chart-type-button .pbtv-chart-type-label {
        display: none;
    }


    .pbtv-bottom-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .pbtv-status {
        min-width: 0;
        text-align: right;
    }

    .pbtv-pane-legend {
        max-width: calc(100% - 78px);
        font-size: 10px;
    }

    .pbtv-latest-values {
        flex-basis: 94px;
        min-width: 94px;
    }

    .pbtv-latest-value {
        right: 4px;
        left: 4px;
        grid-template-columns: 1fr;
        gap: 0;
        padding-inline: 5px;
    }

    .pbtv-latest-value span {
        display: none;
    }
}

/* ========== Phase 1.3: App shell + left vertical toolbar ========== */
.pbtv-app {
    display: flex;
    width: 100%;
    min-width: 0;
    direction: rtl;
    align-items: stretch;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.pbtv-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pbtv-left-toolbar {
    flex: 0 0 44px;
    width: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-left: 1px solid #e2e8f0;
    background: #f8fafc;
    z-index: 15;
}

.pbtv-tool-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.pbtv-tool-group-bottom {
    margin-top: auto;
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
}

.pbtv-tool {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    padding: 0;
}

.pbtv-tool svg {
    width: 18px;
    height: 18px;
    display: block;
}

.pbtv-tool:hover,
.pbtv-tool:focus {
    background: #e2e8f0;
    color: #0f172a;
    outline: none;
}

.pbtv-tool.is-active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.pbtv-tool[aria-pressed="true"] {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.pbtv-tool-danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.pbtv-root .pbtv-toolbar {
    border-radius: 0;
    border-top: 0;
    border-inline: 0;
}

.pbtv-root .pbtv-selected,
.pbtv-root .pbtv-bottom-bar,
.pbtv-root .pbtv-attribution {
    border-inline: 0;
}

.pbtv-root .pbtv-chart-stage {
    border-inline: 0;
}

.pbtv-root .pbtv-chart-container {
    border-radius: 0;
    border-inline-end: 0;
}

.pbtv-root .pbtv-latest-values {
    border-radius: 0;
}

.pbtv-compare-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.pbtv-compare-popover {
    position: absolute;
    z-index: 35;
    top: calc(100% + 7px);
    left: 10px;
    width: min(360px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 120px));
    overflow-y: auto;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
    line-height: 1.7;
}

.pbtv-compare-popover strong {
    display: block;
    margin-bottom: 8px;
}

.pbtv-compare-popover small {
    display: block;
    margin-top: 10px;
    color: #64748b;
    font-size: 11px;
}

.pbtv-compare-search {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    font: inherit;
    direction: rtl;
    text-align: right;
}

.pbtv-compare-results {
    margin-top: 6px;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
}

.pbtv-compare-list {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}

.pbtv-compare-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #f8fafc;
    font-size: 12px;
}

.pbtv-compare-item-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.pbtv-compare-item button {
    border: 0;
    background: transparent;
    color: #b91c1c;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
}

.pbtv-compare-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 2px;
    font-size: 11px;
}

.pbtv-compare-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pbtv-compare-legend i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.pbtv-draw-canvas {
    touch-action: none;
}

.pbtv-root[data-theme="dark"] .pbtv-app {
    border-color: #334155;
    background: #111827;
}

.pbtv-root[data-theme="dark"] .pbtv-left-toolbar {
    border-color: #334155;
    background: #0f172a;
}

.pbtv-root[data-theme="dark"] .pbtv-tool-group {
    border-color: #1f2937;
}

.pbtv-root[data-theme="dark"] .pbtv-tool {
    color: #cbd5e1;
}

.pbtv-root[data-theme="dark"] .pbtv-tool:hover,
.pbtv-root[data-theme="dark"] .pbtv-tool:focus {
    background: #1f2937;
    color: #f8fafc;
}

.pbtv-root[data-theme="dark"] .pbtv-tool.is-active,
.pbtv-root[data-theme="dark"] .pbtv-tool[aria-pressed="true"] {
    background: #172554;
    border-color: #1e3a8a;
    color: #bfdbfe;
}

.pbtv-root[data-theme="dark"] .pbtv-compare-popover {
    border-color: #334155;
    background: #111827;
    color: #e5e7eb;
}

.pbtv-root[data-theme="dark"] .pbtv-compare-search {
    border-color: #475569;
    background: #0f172a;
    color: #f8fafc;
}

.pbtv-root[data-theme="dark"] .pbtv-compare-results {
    border-color: #334155;
}

.pbtv-root[data-theme="dark"] .pbtv-compare-item {
    border-color: #334155;
    background: #0f172a;
    color: #e5e7eb;
}

.pbtv-root[data-theme="dark"] .pbtv-compare-popover small {
    color: #94a3b8;
}

@media (max-width: 720px) {
    .pbtv-left-toolbar {
        flex-basis: 38px;
        width: 38px;
        padding-inline: 2px;
    }
    .pbtv-tool {
        width: 30px;
        height: 30px;
    }
    .pbtv-tool svg {
        width: 16px;
        height: 16px;
    }
    .pbtv-compare-button span:last-child {
        display: none;
    }
}

/* Hide old outer border since app shell owns it */
.pbtv-root > .pbtv-app .pbtv-toolbar {
    border-top: 0;
}

/* ========== v2.4 Rahavard-style left toolbar ========== */
.pbtv-left-toolbar {
    flex: 0 0 46px;
    width: 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 10px;
    border-left: 1px solid #1f2937;
    background: #0b1220;
    z-index: 20;
}

.pbtv-tool-group,
.pbtv-tool-flyout-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.pbtv-tool-spacer {
    flex: 1 1 auto;
    min-height: 12px;
}

.pbtv-tool {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.pbtv-tool svg {
    width: 20px;
    height: 20px;
    display: block;
}

.pbtv-tool:hover,
.pbtv-tool:focus {
    background: rgba(148, 163, 184, 0.12);
    color: #e2e8f0;
    outline: none;
}

.pbtv-tool.is-active {
    background: rgba(41, 98, 255, 0.18);
    border-color: rgba(41, 98, 255, 0.35);
    color: #93c5fd;
}

/* Magnet active = solid blue tile like Rahavard */
.pbtv-tool[data-tool-action="magnet"][aria-pressed="true"] {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

.pbtv-tool[aria-pressed="true"]:not([data-tool-action="magnet"]) {
    background: rgba(41, 98, 255, 0.18);
    border-color: rgba(41, 98, 255, 0.35);
    color: #93c5fd;
}

.pbtv-tool-danger:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}

/* Flyout menus */
.pbtv-tool-flyout {
    position: absolute;
    top: 0;
    right: calc(100% + 6px);
    min-width: 170px;
    padding: 6px;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #111827;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    z-index: 40;
    display: grid;
    gap: 2px;
}

.pbtv-tool-flyout[hidden] {
    display: none !important;
}

.pbtv-tool-flyout button {
    display: block;
    width: 100%;
    text-align: right;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #e2e8f0;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.pbtv-tool-flyout button:hover,
.pbtv-tool-flyout button.is-active {
    background: rgba(37, 99, 235, 0.22);
    color: #bfdbfe;
}

/* Style panel */
.pbtv-style-panel {
    position: absolute;
    z-index: 25;
    top: 48px;
    left: 12px;
    width: 200px;
    padding: 12px;
    border: 1px solid #334155;
    border-radius: 10px;
    background: rgba(17, 24, 39, 0.96);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    color: #e2e8f0;
    direction: rtl;
    font-size: 12px;
}

.pbtv-style-panel[hidden] {
    display: none !important;
}

.pbtv-style-panel-title {
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 13px;
}

.pbtv-style-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: #94a3b8;
}

.pbtv-style-row input[type="color"] {
    width: 36px;
    height: 28px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.pbtv-style-row input[type="range"] {
    width: 90px;
}

.pbtv-style-row select {
    min-width: 90px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 3px 6px;
    font: inherit;
}

.pbtv-style-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.pbtv-style-actions button {
    flex: 1;
    min-height: 30px;
    border: 1px solid #475569;
    border-radius: 7px;
    background: #0f172a;
    color: #e2e8f0;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
}

.pbtv-style-actions button:hover {
    border-color: #64748b;
    background: #1e293b;
}

.pbtv-style-delete:hover {
    border-color: #ef4444;
    color: #fca5a5;
}

/* Light theme overrides for left toolbar */
.pbtv-root[data-theme="light"] .pbtv-left-toolbar {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.pbtv-root[data-theme="light"] .pbtv-tool {
    color: #475569;
}

.pbtv-root[data-theme="light"] .pbtv-tool:hover,
.pbtv-root[data-theme="light"] .pbtv-tool:focus {
    background: #e2e8f0;
    color: #0f172a;
}

.pbtv-root[data-theme="light"] .pbtv-tool.is-active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.pbtv-root[data-theme="light"] .pbtv-tool[data-tool-action="magnet"][aria-pressed="true"] {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.pbtv-root[data-theme="light"] .pbtv-tool-flyout {
    border-color: #cbd5e1;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.pbtv-root[data-theme="light"] .pbtv-tool-flyout button {
    color: #0f172a;
}

.pbtv-root[data-theme="light"] .pbtv-tool-flyout button:hover,
.pbtv-root[data-theme="light"] .pbtv-tool-flyout button.is-active {
    background: #eff6ff;
    color: #1d4ed8;
}

.pbtv-root[data-theme="light"] .pbtv-style-panel {
    border-color: #cbd5e1;
    background: rgba(255, 255, 255, 0.98);
    color: #0f172a;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.pbtv-root[data-theme="light"] .pbtv-style-row {
    color: #64748b;
}

.pbtv-root[data-theme="light"] .pbtv-style-row select,
.pbtv-root[data-theme="light"] .pbtv-style-actions button {
    border-color: #cbd5e1;
    background: #fff;
    color: #0f172a;
}

@media (max-width: 720px) {
    .pbtv-left-toolbar {
        flex-basis: 40px;
        width: 40px;
        padding-inline: 2px;
    }
    .pbtv-tool {
        width: 32px;
        height: 32px;
    }
    .pbtv-tool svg {
        width: 17px;
        height: 17px;
    }
    .pbtv-style-panel {
        width: 170px;
        left: 6px;
        top: 40px;
    }
}

/* Emoji picker */
.pbtv-emoji-picker {
    position: absolute;
    z-index: 50;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    width: min(320px, calc(100% - 24px));
    padding: 12px;
    border: 1px solid #334155;
    border-radius: 12px;
    background: rgba(17, 24, 39, 0.98);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
    color: #e2e8f0;
    direction: rtl;
}
.pbtv-emoji-picker-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}
.pbtv-emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}
.pbtv-emoji-picker-grid button {
    height: 40px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0f172a;
    font-size: 20px;
    cursor: pointer;
}
.pbtv-emoji-picker-grid button:hover {
    border-color: #60a5fa;
    background: #1e293b;
}
.pbtv-emoji-cancel {
    margin-top: 10px;
    width: 100%;
    min-height: 34px;
    border: 1px solid #475569;
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    font: inherit;
}
.pbtv-root[data-theme="light"] .pbtv-emoji-picker {
    border-color: #cbd5e1;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
}
.pbtv-root[data-theme="light"] .pbtv-emoji-picker-grid button {
    border-color: #e2e8f0;
    background: #f8fafc;
}

/* v2.5 indicator search + favorites + layout */
.pbtv-indicator-search {
    width: 100%;
    min-height: 34px;
    margin-bottom: 10px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    font: inherit;
    direction: rtl;
}
.pbtv-root[data-theme="dark"] .pbtv-indicator-search {
    border-color: #475569;
    background: #0f172a;
    color: #f8fafc;
}
.pbtv-indicator-option {
    position: relative;
}
.pbtv-fav-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
}
.pbtv-fav-btn.is-fav { color: #f59e0b; }
.pbtv-layout-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.pbtv-layout-popover {
    position: absolute;
    z-index: 35;
    top: calc(100% + 7px);
    left: 10px;
    width: min(380px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 120px));
    overflow-y: auto;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
    line-height: 1.7;
}
.pbtv-layout-popover strong { display: block; margin-bottom: 8px; }
.pbtv-layout-popover small { display: block; margin-top: 10px; color: #64748b; font-size: 11px; }
.pbtv-layout-save-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.pbtv-layout-name {
    flex: 1;
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font: inherit;
    direction: rtl;
}
.pbtv-layout-save {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid #2563eb;
    border-radius: 7px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font: inherit;
}
.pbtv-layout-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 6px;
    background: #f8fafc;
    font-size: 12px;
}
.pbtv-layout-item small { display: block; color: #64748b; }
.pbtv-layout-item-actions { display: flex; gap: 4px; }
.pbtv-layout-item-actions button {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    padding: 4px 8px;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
}
.pbtv-layout-io {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.pbtv-layout-export, .pbtv-layout-import-label {
    flex: 1;
    min-height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    text-align: center;
    padding: 6px;
}
.pbtv-layout-empty { color: #64748b; font-size: 12px; padding: 8px 0; }
.pbtv-layout-popover[hidden] { display: none !important; }

.pbtv-root[data-theme="dark"] .pbtv-layout-popover {
    border-color: #334155;
    background: #111827;
    color: #e5e7eb;
}
.pbtv-root[data-theme="dark"] .pbtv-layout-name,
.pbtv-root[data-theme="dark"] .pbtv-layout-item,
.pbtv-root[data-theme="dark"] .pbtv-layout-export,
.pbtv-root[data-theme="dark"] .pbtv-layout-import-label,
.pbtv-root[data-theme="dark"] .pbtv-layout-item-actions button {
    border-color: #475569;
    background: #0f172a;
    color: #e5e7eb;
}
.pbtv-root[data-theme="dark"] .pbtv-layout-popover small,
.pbtv-root[data-theme="dark"] .pbtv-layout-empty { color: #94a3b8; }

@media (max-width: 720px) {
    .pbtv-layout-button span:last-child { display: none; }
}

/* v2.6 export + watchlist + undo */
.pbtv-export-button,
.pbtv-watchlist-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.pbtv-watchlist-popover {
    position: absolute;
    z-index: 35;
    top: calc(100% + 7px);
    left: 10px;
    width: min(320px, calc(100vw - 32px));
    max-height: min(480px, calc(100vh - 120px));
    overflow-y: auto;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .18);
    line-height: 1.7;
}
.pbtv-watchlist-popover[hidden] { display: none !important; }
.pbtv-watchlist-popover strong { display: block; margin-bottom: 8px; }
.pbtv-watchlist-popover small { display: block; margin-top: 10px; color: #64748b; font-size: 11px; }
.pbtv-watchlist-add-row { margin-bottom: 10px; }
.pbtv-watchlist-add-current {
    width: 100%;
    min-height: 34px;
    border: 1px solid #2563eb;
    border-radius: 7px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font: inherit;
}
.pbtv-watchlist-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.pbtv-watchlist-open {
    flex: 1;
    text-align: right;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px 10px;
    cursor: pointer;
    font: inherit;
}
.pbtv-watchlist-open small { display: block; color: #64748b; }
.pbtv-watchlist-item > button[data-watch-remove] {
    width: 28px;
    height: 28px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.pbtv-root[data-theme="dark"] .pbtv-watchlist-popover {
    border-color: #334155;
    background: #111827;
    color: #e5e7eb;
}
.pbtv-root[data-theme="dark"] .pbtv-watchlist-open,
.pbtv-root[data-theme="dark"] .pbtv-watchlist-item > button[data-watch-remove] {
    border-color: #475569;
    background: #0f172a;
    color: #e5e7eb;
}
@media (max-width: 720px) {
    .pbtv-export-button span:last-child,
    .pbtv-watchlist-button span:last-child { display: none; }
}
