/* ====================================================================
   Text to Sign — page-specific layout. Reuses style.css design tokens.
   ==================================================================== */

.t2s-shell { max-width: 1480px; margin: 0 auto; }

.t2s-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(0, 1.65fr) minmax(280px, 0.9fr);
    gap: var(--s-5);
    align-items: stretch;
}

/* ---------- Input column ---------- */
.t2s-input {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    padding: var(--s-5);
}

.t2s-input-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
}
.t2s-input-head h2 {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-size: 1.05rem;
    margin: 0;
}
.t2s-input-head h2 i { width: 18px; height: 18px; color: var(--accent); }

.lang-chip {
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-family: var(--font-mono);
}

.phrase-textarea {
    width: 100%;
    min-height: 130px;
    resize: vertical;
    padding: var(--s-3) var(--s-4);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.55;
    border-radius: var(--r-3);
}

.t2s-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--s-3);
}
.t2s-control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.t2s-control-group label { font-weight: 500; }
.t2s-control-group.toggle-cell {
    align-items: flex-start;
    justify-content: flex-end;
    padding-bottom: 8px;
}

.t2s-actions {
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
}
.t2s-actions .primary-btn,
.t2s-actions .stop-btn { flex: 1 1 auto; }

.t2s-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.word-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
    padding-top: var(--s-1);
}
.word-chip {
    padding: 5px 11px;
    font-size: 0.78rem;
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.18s ease;
}
.word-chip.is-active {
    background: var(--grad-primary);
    color: var(--on-primary);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(124, 92, 255, 0.35);
    transform: translateY(-1px);
}
.word-chip.is-missing {
    color: #ffd2d6;
    border-color: rgba(255, 107, 124, 0.35);
    background: var(--danger-soft);
}
.word-chip.is-done { color: var(--success); border-color: rgba(45, 212, 161, 0.3); }
.word-chip i { width: 12px; height: 12px; }

/* ---------- Stage column ---------- */
.t2s-stage {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}
.t2s-video {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg-deep);
}
.t2s-video video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--bg-deep);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
    transform: none;
}
.t2s-video video.is-active {
    opacity: 1;
    z-index: 2;
}

.t2s-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(7,9,26,0.35), rgba(7,9,26,0.85));
    transition: opacity 0.25s ease;
}
.t2s-overlay.is-hidden { opacity: 0; }
.t2s-empty {
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-3);
}
.t2s-empty i { width: 48px; height: 48px; opacity: 0.6; color: var(--primary); }
.t2s-empty p { margin: 0; font-size: 0.95rem; max-width: 32ch; }
.t2s-empty strong { color: var(--text); }

.t2s-word-label {
    position: absolute;
    bottom: var(--s-5);
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    padding: 10px 22px;
    border-radius: var(--r-full);
    background: rgba(10, 13, 24, 0.78);
    border: 1px solid var(--border-strong);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-2);
}
.t2s-word-label span {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}
.t2s-word-label small {
    font-size: 0.74rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.t2s-err-banner {
    position: absolute;
    top: var(--s-4);
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--r-full);
    background: var(--danger-soft);
    color: #fecaca;
    border: 1px solid rgba(255, 107, 124, 0.35);
    font-size: 0.82rem;
    backdrop-filter: blur(10px);
}
.t2s-err-banner i { width: 14px; height: 14px; }

/* ---------- Companion recorder (collapsible) ---------- */
.t2s-record-shell {
    padding: 0;
    overflow: hidden;
}
.t2s-record-shell summary {
    list-style: none;
    cursor: pointer;
    padding: var(--s-4) var(--s-5);
    display: flex;
    align-items: center;
    gap: var(--s-3);
    user-select: none;
}
.t2s-record-shell summary::-webkit-details-marker { display: none; }
.t2s-record-shell summary::after {
    content: "";
    margin-left: auto;
    width: 9px; height: 9px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}
.t2s-record-shell[open] summary::after { transform: rotate(-135deg); }
.t2s-record-shell summary i { width: 18px; height: 18px; color: var(--accent); }
.t2s-record-shell summary span { font-weight: 500; }
.t2s-record-shell summary span em {
    font-style: normal;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.88em;
}

.chip-info {
    margin-left: 8px;
    padding: 3px 9px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 0.7rem !important;
    color: var(--text-muted) !important;
    font-weight: 500 !important;
    font-family: var(--font-mono);
}

.t2s-record-body {
    padding: 0 var(--s-5) var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}

.record-stage {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--r-3);
    overflow: hidden;
    background: var(--bg-deep);
    border: 1px solid var(--border);
}
.record-stage video,
.record-stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.record-stage video { z-index: 1; transform: scaleX(-1); }
.record-stage canvas { z-index: 2; transform: scaleX(-1); }

.rec-indicator {
    position: absolute;
    top: 12px; left: 12px;
    z-index: 5;
    padding: 5px 12px;
    border-radius: var(--r-full);
    background: var(--danger-soft);
    color: #ffd2d6;
    font-size: 0.74rem;
    font-weight: 700;
    border: 1px solid rgba(255,107,124,0.45);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
}
.rec-indicator .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #ff5470;
    animation: ping 1s ease-in-out infinite;
}

.rec-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 16px;
    pointer-events: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.45) 0%, transparent 35%, transparent 65%, rgba(0,0,0,0.6) 100%);
}
.rec-overlay-top { font-weight: 600; }
.rec-overlay-bottom { display: flex; justify-content: space-between; gap: 10px; }

.record-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.record-controls > button { flex: 1 1 calc(50% - var(--s-2)); justify-content: center; }

.record-hint {
    margin: 0;
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-3);
    color: var(--text-muted);
    font-size: 0.82rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    line-height: 1.5;
}
.record-hint i { flex-shrink: 0; width: 16px; height: 16px; color: var(--accent); margin-top: 2px; }
.record-hint code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
}

.record-output {
    border-radius: var(--r-3);
    border: 1px solid var(--border);
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}
.record-output .row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}
.record-output .row:last-child { border-bottom: none; }
.record-output .row strong { color: var(--text); font-family: var(--font-mono); }

/* ---------- History column ---------- */
.t2s-history {
    display: flex;
    flex-direction: column;
    padding: var(--s-5);
    min-height: 480px;
}
.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-3);
}
.history-head h3 {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}
.history-head h3 i { width: 16px; height: 16px; color: var(--accent); }

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    max-height: 360px;
    padding-right: 4px;
}
.history-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-3);
    cursor: pointer;
    transition: all 0.15s ease;
}
.history-item:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateX(2px);
}
.history-item p {
    flex: 1;
    margin: 0;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
}
.history-item small {
    display: block;
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 0.72rem;
    font-family: var(--font-mono);
}
.history-item .delete-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-soft);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.15s ease;
}
.history-item:hover .delete-btn { opacity: 1; }
.history-item .delete-btn:hover { color: var(--danger); background: var(--surface-hover); }
.history-item .delete-btn i { width: 14px; height: 14px; }

.t2s-tips { font-size: 0.85rem; color: var(--text-muted); }
.t2s-tips h4 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    margin: 0 0 var(--s-2);
    color: var(--text);
}
.t2s-tips h4 i { width: 14px; height: 14px; color: var(--warning); }
.t2s-tips ul { margin: 0; padding-left: 1.2em; line-height: 1.55; }
.t2s-tips code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
    color: var(--text);
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .t2s-grid { grid-template-columns: 1fr; }
    .t2s-stage { order: -1; }
    .t2s-history { min-height: 320px; }
    .t2s-history .history-list { max-height: 220px; }
}
@media (max-width: 640px) {
    .t2s-controls { grid-template-columns: 1fr 1fr; }
    .t2s-control-group.toggle-cell { grid-column: 1 / -1; padding-bottom: 0; }
    .record-controls > button { flex-basis: 100%; }
    .t2s-word-label span { font-size: 1.2rem; }
}
