.sm-tv-launcher {
    background: #66ccff;
    color: #000000;
    border: 2px solid #66ccff;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    font-size: 12px;
    padding: 8px 14px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 0 16px rgba(102, 204, 255, 0.45);
}

.sm-tv-launcher:hover {
    background: #ffffff;
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.6);
}

.sm-tv-launcher--hidden {
    display: none;
}

.sm-tv-launcher--standalone {
    position: fixed;
    left: 140px;
    bottom: 20px;
    z-index: 9998;
}

.sm-tv-window {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9995;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
}

.sm-tv-window--hidden {
    display: none;
}

.sm-tv-window--dragging,
.sm-tv-window--resizing {
    user-select: none;
}

.sm-tv-set {
    position: relative;
    width: 100%;
    cursor: move;
}

.sm-tv-screen {
    position: absolute;
    z-index: 1;
    overflow: hidden;
    background: #000000;
    border-radius: 2px;
}

.sm-tv-frame {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    pointer-events: none;
}

.sm-tv-frame--missing {
    min-height: 360px;
    background:
        linear-gradient(180deg, #2a2a2a 0%, #111 100%);
    border: 8px solid #333;
    border-radius: 18px;
    box-sizing: border-box;
}

.sm-tv-video {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    display: block;
    background: #000000;
}

.sm-tv-static {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    pointer-events: none;
    opacity: 0.95;
}

.sm-tv-static.is-active {
    display: block;
}

.sm-tv-no-signal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(14px, 3vw, 28px);
    letter-spacing: 0.2em;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    background: repeating-linear-gradient(
        0deg,
        #111 0px,
        #111 2px,
        #222 2px,
        #222 4px
    );
}

.sm-tv-no-signal.is-visible {
    display: flex;
}

.sm-tv-buttons {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.sm-tv-channel-btn {
    position: absolute;
    pointer-events: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
}

.sm-tv-channel-btn:focus-visible {
    outline: 2px solid #66ccff;
    outline-offset: 2px;
}

.sm-tv-close {
    position: absolute;
    z-index: 6;
    pointer-events: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    border-radius: 1px;
    transition: background 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}

/* Slightly larger hit target without shifting visual center */
.sm-tv-close::before {
    content: '';
    position: absolute;
    top: -6px;
    right: -8px;
    bottom: -6px;
    left: -8px;
}

.sm-tv-close:hover {
    background: rgba(255, 30, 30, 0.35);
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.65);
}

.sm-tv-close:active,
.sm-tv-close.is-pressed {
    background: rgba(255, 0, 0, 0.92);
    filter: brightness(1.35) saturate(1.4);
    box-shadow:
        0 0 4px rgba(255, 0, 0, 1),
        0 0 14px rgba(255, 40, 40, 1),
        0 0 24px rgba(255, 0, 0, 0.7);
}

.sm-tv-close:focus-visible {
    outline: 2px solid rgba(255, 80, 80, 0.75);
    outline-offset: 2px;
}

.sm-tv-close--calibrating {
    background: rgba(255, 0, 0, 0.35) !important;
    border: 2px dashed #ff3333;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
    cursor: move;
    z-index: 20;
}

.sm-tv-close--calibrating::before {
    display: none;
}

.sm-tv-close-calibrate-resize {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff3333;
    border: 2px solid #ffffff;
    box-shadow: 0 0 6px rgba(255, 0, 0, 0.9);
    cursor: nwse-resize;
    pointer-events: auto;
}

.sm-tv-calibrate-panel {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    width: min(520px, calc(100vw - 24px));
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.92);
    border: 2px solid #ff3333;
    color: #ffffff;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.5;
    box-shadow: 0 0 24px rgba(255, 0, 0, 0.35);
}

.sm-tv-calibrate-panel strong {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #ff6666;
}

.sm-tv-calibrate-panel p {
    margin: 0 0 10px;
}

.sm-tv-calibrate-highlight {
    color: #ff6666;
    font-weight: bold;
}

.sm-tv-calibrate-panel code {
    display: block;
    margin-bottom: 10px;
    padding: 8px;
    background: #111111;
    border: 1px solid #444444;
    color: #66ff66;
    word-break: break-all;
}

.sm-tv-calibrate-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sm-tv-calibrate-actions button {
    background: #222222;
    color: #ffffff;
    border: 1px solid #666666;
    font-family: inherit;
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
}

.sm-tv-calibrate-actions button:hover {
    border-color: #ff6666;
    color: #ffcccc;
}

#smTvCalibrateSave {
    border-color: #ff3333;
    color: #ff9999;
}

.sm-tv-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 5;
    width: 24px;
    height: 24px;
    cursor: nwse-resize;
    border-bottom-right-radius: 4px;
    background: linear-gradient(
        135deg,
        transparent 0 40%,
        rgba(0, 0, 0, 0.18) 40% 100%
    );
}

.sm-tv-resize-handle::before {
    content: '';
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 14px;
    height: 14px;
    opacity: 0.55;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 3px,
            rgba(255, 51, 51, 0.85) 3px,
            rgba(255, 51, 51, 0.85) 4px
        );
}

.sm-tv-resize-handle:hover::before,
.sm-tv-window--resizing .sm-tv-resize-handle::before {
    opacity: 0.9;
}
