.guion-layout {
    width: 100%;
    height: calc(100vh - 140px);
    display: flex;
    gap: 24px;
    padding: 20px 30px 30px;
    box-sizing: border-box;
}

/* ===== Columna izquierda: formulario ===== */
.guion-form {
    width: 380px;
    flex-shrink: 0;
    background: #0d1117;
    border: 1px solid rgba(48, 54, 61, 0.9);
    border-radius: 16px;
    padding: 24px;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.guion-form label {
    display: block;
    color: #8b949e;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
    margin-top: 20px;
}

.guion-form label:first-child {
    margin-top: 0;
}

.guion-form textarea {
    width: 100%;
    background: #161b22;
    color: #fff;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.guion-form textarea:focus {
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.guion-form textarea::placeholder {
    color: #64748b;
}

/* ===== Formato: radios estilo toggle ===== */
.formato-group {
    display: flex;
    gap: 10px;
}

.formato-option {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    color: #c9d1d9;
    font-size: 13px;
    transition: all 0.2s;
}

.formato-option input {
    accent-color: #06b6d4;
}

.formato-option.active {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.08);
    color: #fff;
}

/* ===== Botones ===== */
.btn-guion {
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 13px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-guion-primary {
    background: #eab308;
    color: #1c1300;
    margin-top: 24px;
}

.btn-guion-primary:hover {
    background: #facc15;
    transform: translateY(-1px);
}

.btn-guion-link {
    background: transparent;
    color: #06b6d4;
    text-decoration: underline;
    padding: 13px 0;
    text-align: left;
}

.btn-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.btn-row .btn-guion-primary {
    margin-top: 0;
    flex: 1;
}

.btn-guion-secondary {
    width: 100%;
    background: #10b981;
    color: #06281d;
    margin-top: 24px;
}

.btn-guion-secondary:hover {
    background: #34d399;
    transform: translateY(-1px);
}

/* ===== Columna derecha: preview / tomas ===== */
.guion-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    border: 1px solid rgba(48, 54, 61, 0.9);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.toma-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(48, 54, 61, 0.9);
    color: #c9d1d9;
    font-size: 13px;
    letter-spacing: 1px;
    font-weight: 700;
}

.btn-copiar {
    background: #161b22;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-copiar:hover {
    border-color: #06b6d4;
    color: #fff;
}

.toma-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toma-body .chat-msg.user .bubble {
    background: linear-gradient(135deg, #0072ff, #00f2fe);
}

.toma-body .chat-msg.ai .bubble {
    background: transparent;
    border: none;
    color: #c9d1d9;
    white-space: pre-wrap;
    line-height: 1.7;
}

@media (max-width: 900px) {
    .guion-layout {
        flex-direction: column;
        height: auto;
        padding: 15px;
    }
    .guion-form {
        width: 100%;
    }
}

/* ===== Ajustes de espaciado: agrupar cada bloque con su botón ===== */
.guion-form label {
    margin-top: 22px;
}

.guion-form textarea {
    margin-bottom: 2px;
}

.btn-row {
    margin-top: 14px;
}

.btn-guion-link {
    margin-top: 6px;
    padding: 8px 0;
}

.btn-guion-secondary {
    margin-top: 14px;
}

.btn-guion-primary,
.btn-guion-secondary,
.btn-guion-link,
.formato-option,
.btn-copiar {
    outline: none;
}

.btn-guion-primary:focus-visible,
.btn-guion-secondary:focus-visible {
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.35);
}

/* ===== Ocupar todo el espacio disponible del contenedor ===== */
#content {
    height: 100%;
}

.guion-layout {
    height: 100%;
    padding: 0;
    gap: 0;
}

.guion-form {
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    height: 100%;
    box-sizing: border-box;
}

.guion-preview {
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-right: none;
    height: 100%;
}

/* ===== Botón de audio: estado grabando ===== */
.btn-guion-link {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-guion-link.recording {
    color: #f87171;
    animation: pulseRec 1.2s infinite;
}

.btn-guion-link.recording i {
    color: #f87171;
}

.btn-guion-link.recording-error {
    color: #f87171;
}

@keyframes pulseRec {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ===== Reajuste de burbujas del guion ===== */
.toma-body {
    gap: 18px;
    padding: 28px;
}

.toma-body .chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 92%;
}

.toma-body .chat-msg.user {
    max-width: 78%;
}

.toma-body .chat-msg.ai .bubble {
    box-shadow: none;
    border-radius: 0;
    padding: 8px 0;
}

.toma-body .chat-msg.user .bubble {
    border-radius: 16px 4px 16px 16px;
    box-shadow: 0 2px 14px rgba(6, 182, 212, 0.25);
    padding: 14px 20px;
}

/* ===== Avatar tipo robot para respuestas de IA ===== */
.ai-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0072ff, #00f2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0d1117;
    font-size: 16px;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

/* ===== Indicador "escribiendo..." ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 16px 20px !important;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #06b6d4;
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== Rediseño botón "Escribir por Audio" ===== */
.btn-guion-link {
    width: 100%;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 12px 16px;
    text-decoration: none;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #c9d1d9;
    cursor: pointer;
}

.btn-guion-link:hover {
    border-color: rgba(6, 182, 212, 0.5);
    color: #fff;
}

.btn-guion-link #cg-audio-label {
    text-decoration: none;
}

.btn-guion-link.recording {
    background: rgba(248, 113, 113, 0.08);
    border-color: #f87171;
}

.btn-guion-link.recording-error {
    background: rgba(248, 113, 113, 0.08);
    border-color: #f87171;
}

.toma-body .chat-msg.ai .bubble {
  max-width: 95%;
}

.toma-body .chat-msg {
  max-width: 768px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
