/* ==========================================================
   在线提词器
   编辑区使用 .tp-tool 作用域，提词态使用独立 .tp-stage 遮罩
   ========================================================== */

.tp-tool {
    width: 100%;
}

.tp-check-row label {
     margin-bottom: 0px !important;
}

.tp-tool [hidden],
.tp-stage[hidden],
.tp-stage [hidden],
.tp-modal[hidden] {
    display: none !important;
}

.tp-banner {
    margin-bottom: 12px;
    padding: 9px 12px;
    font-size: 12.5px;
    line-height: 1.7;
    border-radius: 6px;
}

.tp-banner-warn {
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.tp-banner-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #0f766e;
    background: #f0fcf9;
    border: 1px solid #d5eee8;
}

.tp-link-btn {
    flex: 0 0 auto;
    padding: 0;
    font-size: 12.5px;
    color: var(--dd-brand, #16a34a);
    background: none;
    border: 0;
    cursor: pointer;
    text-decoration: underline;
}

.tp-card {
    margin-bottom: 14px;
    background: #fff;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 8px;
}

.tp-card h2 {
    margin: 0;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--dd-ink, #1f2937);
    background: #f8fafc;
    border-bottom: 1px solid var(--dd-line, #e5e7eb);
}

.tp-count {
    float: right;
    font-size: 12px;
    font-weight: 400;
    color: var(--dd-ink-3, #9ca3af);
}

.tp-body {
    padding: 14px;
}

.tp-editor {
    display: block;
    width: 100%;
    min-height: 220px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--dd-ink, #1f2937);
    background: #fff;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 6px;
    outline: none !important;
    box-sizing: border-box;
    resize: vertical;
}

.tp-editor:focus {
    border-color: var(--dd-brand, #16a34a);
}

.tp-meta {
    margin-top: 10px;
    font-size: 12.5px;
    line-height: 30px;
    color: var(--dd-ink-2, #4b5563);
}

.tp-stat {
    display: inline-block;
    margin-right: 14px;
    font-weight: 700;
    color: var(--dd-brand, #16a34a);
}

.tp-inline-label {
    display: inline-block;
    margin: 0 5px;
    font-size: 12.5px;
    color: var(--dd-ink-2, #4b5563);
    vertical-align: middle;
}

.tp-select {
    height: 32px;
    padding: 0 8px;
    font-size: 12.5px;
    color: var(--dd-ink, #1f2937);
    background: #fff;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 4px;
    outline: none !important;
    vertical-align: middle;
}

.tp-select-sm {
    height: 28px;
    padding: 0 6px;
}

.tp-muted {
    margin-left: 6px;
    font-size: 12px;
    color: var(--dd-ink-3, #9ca3af);
}

.tp-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--dd-line, #e5e7eb);
}

.tp-btn {
    display: inline-block;
    height: 36px;
    margin-right: 8px;
    padding: 0 15px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 34px;
    color: var(--dd-ink-2, #4b5563);
    text-align: center;
    background: #f6f8f9;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 6px;
    cursor: pointer;
    outline: none !important;
    vertical-align: middle;
}

.tp-btn:hover {
    color: var(--dd-brand, #16a34a);
    border-color: var(--dd-brand, #16a34a);
}

.tp-btn-primary {
    color: #fff;
    background: var(--dd-brand, #16a34a);
    border-color: var(--dd-brand, #16a34a);
}

.tp-btn-primary:hover {
    color: #fff;
    background: var(--dd-brand-dark, #15803d);
    border-color: var(--dd-brand-dark, #15803d);
}

.tp-btn-ghost {
    background: #fff;
}

.tp-message {
    margin-top: 12px;
    padding: 8px 11px;
    font-size: 12.5px;
    line-height: 1.7;
    color: #0f766e;
    background: #f0fcf9;
    border: 1px solid #d5eee8;
    border-radius: 6px;
}

.tp-message.is-error {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.tp-settings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 18px;
}

.tp-field {
    min-width: 0;
}

.tp-field > label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--dd-ink-2, #4b5563);
}

.tp-value {
    margin-left: 4px;
    font-weight: 400;
    color: var(--dd-brand, #16a34a);
}

.tp-field input[type="range"] {
    display: block;
    width: 100%;
    height: 6px;
    margin: 4px 0;
    accent-color: var(--dd-brand, #16a34a);
    cursor: pointer;
}

.tp-field .tp-select {
    width: 100%;
}

.tp-field .tp-muted {
    display: block;
    margin: 5px 0 0;
}

.tp-font-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tp-font-row .tp-select {
    flex: 1 1 auto;
    min-width: 0;
}

.tp-font-load {
    flex: 0 0 auto;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
}

.tp-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tp-color-row .tp-select {
    flex: 1 1 auto;
    min-width: 0;
}

.tp-color-pick {
    flex: 0 0 auto;
    width: 38px;
    height: 32px;
    padding: 2px;
    background: #fff;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 6px;
    cursor: pointer;
}

.tp-check-row {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--dd-line, #e5e7eb);
    font-size: 12.5px;
    line-height: 28px;
    color: var(--dd-ink-2, #4b5563);
}

.tp-check-row label {
    display: inline-block;
    margin-right: 22px;
    cursor: pointer;
}

.tp-check-row input {
    margin-right: 5px;
    vertical-align: middle;
    margin-bottom: 4px;
}

.tp-doc-list {
    margin-bottom: 12px;
}

.tp-doc-empty {
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--dd-ink-3, #9ca3af);
    background: #f8fafc;
    border: 1px dashed var(--dd-line, #e5e7eb);
    border-radius: 6px;
}

.tp-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 6px;
}

.tp-doc-item + .tp-doc-item {
    margin-top: 8px;
}

.tp-doc-main {
    min-width: 0;
}

.tp-doc-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--dd-ink, #1f2937);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-doc-meta {
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--dd-ink-3, #9ca3af);
}

.tp-doc-actions {
    flex: 0 0 auto;
    white-space: nowrap;
}

.tp-doc-actions button {
    margin-left: 4px;
    padding: 2px 6px;
    font-size: 12px;
    color: var(--dd-brand, #16a34a);
    background: none;
    border: 0;
    cursor: pointer;
}

.tp-doc-actions button:hover {
    text-decoration: underline;
}

.tp-doc-actions .is-danger {
    color: #b91c1c;
}

.tp-privacy {
    margin-bottom: 14px;
    padding: 9px 11px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--dd-ink-3, #6b7280);
    background: #f8fafc;
    border: 1px solid var(--dd-line, #e5e7eb);
    border-radius: 6px;
}

/* 快捷键弹窗 */
.tp-modal {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, .55);
}

.tp-modal-dialog {
    width: min(520px, 100%);
    max-height: 85vh;
    padding: 18px;
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    box-sizing: border-box;
}

.tp-modal-dialog h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--dd-ink, #1f2937);
}

.tp-modal-dialog .tp-btn {
    margin-top: 14px;
}

.tp-shortcuts {
    font-size: 12.5px;
    line-height: 1.9;
    color: var(--dd-ink-2, #4b5563);
}

.tp-shortcuts > div {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tp-shortcuts span {
    margin-left: 6px;
}

.tp-shortcuts kbd {
    display: inline-block;
    min-width: 18px;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 11.5px;
    text-align: center;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-bottom-width: 2px;
    border-radius: 4px;
}

/* ==========================================================
   提词态
   ========================================================== */
body.tp-lock {
    overflow: hidden !important;
}

.tp-stage {
    --tp-margin: 15vw;
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: block;
    overflow: hidden;
    color: #fff;
    background: #000;
}

.tp-stage.is-light {
    color: #111;
    background: #fff;
}

.tp-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    /* 提词视口只用于接管键盘事件，不显示焦点框（不是可交互控件） */
    outline: none;
}

.tp-viewport.is-dragging {
    cursor: grabbing;
}

.tp-scroll,
.tp-mirror {
    will-change: transform;
}

.tp-mirror {
    transform-origin: center center;
}

.tp-content {
    padding-left: calc(var(--tp-margin) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--tp-margin) + env(safe-area-inset-right, 0px));
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", sans-serif;
    text-align: left;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

.tp-content p {
    margin: 0 0 .55em;
    white-space: pre-wrap;
}

/* 空行也保留行号：压缩高度但不省略编号 */
.tp-content p.tp-line.is-empty {
    align-items: center;
    min-height: .72em;
    margin-bottom: .22em;
}

.tp-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: rgba(255, 255, 255, .18);
    z-index: 2;
    pointer-events: none;
}

.tp-stage.is-light .tp-progress {
    background: rgba(0, 0, 0, .12);
}

.tp-progress-bar {
    width: 0;
    height: 100%;
    background: var(--dd-brand, #16a34a);
    transition: width .1s linear;
}

.tp-countdown {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(72px, 18vw, 220px);
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, .45);
}

.tp-stage.is-light .tp-countdown {
    color: #111;
    background: rgba(255, 255, 255, .5);
}

.tp-end-hint {
    position: absolute;
    left: 50%;
    bottom: 88px;
    z-index: 4;
    padding: 8px 14px;
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
    background: rgba(0, 0, 0, .72);
    border-radius: 6px;
    transform: translateX(-50%);
}

.tp-stage-status {
    position: absolute;
    top: max(14px, env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 6;
    max-width: min(92vw, 720px);
    padding: 8px 13px;
    font-size: 12.5px;
    line-height: 1.6;
    color: #fff;
    text-align: center;
    background: rgba(185, 28, 28, .9);
    border-radius: 6px;
    transform: translateX(-50%);
}

.tp-controls {
    position: absolute;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100vw - 20px);
    padding: 7px 10px;
    overflow-x: auto;
    color: #fff;
    background: rgba(18, 18, 18, .86);
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 8px;
    box-sizing: border-box;
    transform: translateX(-50%);
    transition: opacity .25s ease, visibility .25s ease;
}

.tp-controls.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tp-stage.is-light .tp-controls {
    color: #111;
    background: rgba(255, 255, 255, .94);
    border-color: #d1d5db;
}

.tp-ctrl {
    flex: 0 0 auto;
    height: 30px;
    padding: 0 9px;
    font-size: 12px;
    line-height: 28px;
    color: inherit;
    white-space: nowrap;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 4px;
    cursor: pointer;
    outline: none !important;
}

.tp-ctrl:hover,
.tp-ctrl:focus-visible {
    border-color: var(--dd-brand, #16a34a);
    color: var(--dd-brand, #16a34a);
}

.tp-ctrl.is-active {
    color: #fff;
    background: var(--dd-brand, #16a34a);
    border-color: var(--dd-brand, #16a34a);
}

.tp-ctrl.is-active:hover,
.tp-ctrl.is-active:focus-visible {
    color: #fff;
}

.tp-stage.is-light .tp-ctrl {
    border-color: #d1d5db;
}

.tp-ctrl-exit {
    color: #fca5a5;
}

.tp-speed {
    flex: 0 0 auto;
    min-width: 58px;
    font-size: 12px;
    text-align: center;
}

.tp-remaining {
    flex: 0 0 auto;
    font-size: 12px;
    white-space: nowrap;
    opacity: .85;
}

.tp-help-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 7;
    width: min(460px, calc(100vw - 28px));
    max-height: 80vh;
    padding: 16px;
    overflow: auto;
    color: #111;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .35);
    box-sizing: border-box;
    transform: translate(-50%, -50%);
}

.tp-help-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.tp-help-head .tp-ctrl {
    color: #111;
    border-color: #d1d5db;
}

.tp-stage.is-fallback::after {
    content: "网页全屏模式";
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 3;
    padding: 4px 8px;
    font-size: 11px;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    border-radius: 4px;
    pointer-events: none;
}

@media (max-width: 767.98px) {
    .tp-settings {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tp-doc-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .tp-doc-actions {
        white-space: normal;
    }
}

@media (max-width: 575.98px) {
    .tp-settings {
        grid-template-columns: minmax(0, 1fr);
    }

    .tp-meta .tp-muted {
        display: block;
        margin-left: 0;
    }

    .tp-controls {
        gap: 4px;
        padding: 6px 8px;
    }

    .tp-ctrl {
        padding: 0 7px;
    }

    .tp-end-hint {
        bottom: 80px;
        font-size: 12px;
        white-space: normal;
        width: max-content;
        max-width: 90vw;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tp-controls,
    .tp-progress-bar {
        transition: none !important;
    }
}

/* ==========================================================
   提词行号
   ========================================================== */

.tp-content p.tp-line {
    display: flex;
    align-items: baseline;
    gap: .34em;
}

.tp-line-no {
    flex: 0 0 auto;
    min-width: 1.15em;
    font-size: .34em;
    font-weight: 500;
    line-height: 1.5;
    text-align: right;
    opacity: .4;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

.tp-line-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: pre-wrap;
}

.tp-content.hide-line-no .tp-line-no {
    display: none;
}

/* 镜像时行号反向翻转，保证数字本身仍然可读 */
.tp-mirror.is-mirror-h .tp-line-no {
    transform: scaleX(-1);
}

.tp-mirror.is-mirror-v .tp-line-no {
    transform: scaleY(-1);
}

.tp-mirror.is-mirror-h.is-mirror-v .tp-line-no {
    transform: scale(-1, -1);
}

/* ==========================================================
   全屏设置：左侧配置 / 右侧即时预览
   ========================================================== */

.tp-stage.is-config .tp-viewport {
    left: 384px;
}

/* 配置模式保留播放控制与进度条，整体右移到预览区上 */
.tp-stage.is-config .tp-progress {
    left: 384px;
}

.tp-stage.is-config .tp-controls,
.tp-stage.is-config .tp-help-panel {
    left: calc(50% + 192px);
}

.tp-stage.is-config .tp-end-hint {
    left: calc(50% + 192px);
}

.tp-stage.is-config .tp-countdown {
    display: none !important;
}

.tp-config {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    width: 384px;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
    overscroll-behavior: contain;
    background: #0f1115;
    border-right: 1px solid rgba(255, 255, 255, .12);
}

.tp-config-card {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    padding: 14px 16px 16px;
    background: #fff;
    border-radius: 10px;
    color: #111827;
}

.tp-config-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    overscroll-behavior: contain;
}

.tp-config-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.tp-config-head strong {
    font-size: 15px;
    font-weight: 700;
}

.tp-config-hint {
    font-size: 11.5px;
    color: #6b7280;
}

.tp-config-doc {
    margin-bottom: 14px;
}

.tp-config-doc > label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: #4b5563;
}

.tp-config-textarea {
    display: block;
    width: 100%;
    height: 148px;
    padding: 10px 12px;
    box-sizing: border-box;
    font-size: 13px;
    line-height: 1.7;
    color: #111827;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    outline: none;
    resize: vertical;
}

.tp-config-textarea:focus {
    background: #fff;
    border-color: var(--dd-brand, #16a34a);
}

.tp-config-body .tp-settings {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.tp-config-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.tp-config-actions .tp-btn {
    flex: 1 1 auto;
    padding-left: 8px;
    padding-right: 8px;
}

.tp-config-tip {
    margin: 10px 0 0;
    font-size: 11.5px;
    color: #9ca3af;
}

@media (max-width: 900px) {
    .tp-stage.is-config .tp-viewport {
        display: none;
    }

    .tp-config {
        width: 100%;
        border-right: 0;
    }

    .tp-stage.is-config .tp-controls,
    .tp-stage.is-config .tp-progress,
    .tp-stage.is-config .tp-end-hint,
    .tp-stage.is-config .tp-help-panel {
        display: none;
    }
}
