/* ---------- CHOICES PANEL ---------- */
.tl-choices {
    padding: 10px 20px 12px;
    background: transparent;
    border: none;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.tl-choices-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--reader-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.tl-choices-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    margin: 0 auto;
    max-width: 1200px;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top;
}
/* Hide choices list when typing a custom action */
#tl-choices-body:has(.tl-custom-choice:focus-within) .tl-choices-list {
    opacity: 0;
    max-height: 0 !important;
    margin: 0 auto;
    transform: scaleY(0.9);
    pointer-events: none;
}

.tl-choice-btn {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex: 1 1 calc(33.33% - 6px);
    min-width: 180px;
    padding: 8px 10px;
    border-radius: 12px;
    color: var(--reader-text);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s, background 0.2s, box-shadow 0.2s;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(8px);
    animation: tl-choice-stagger .3s ease-out forwards;
    position: relative;
    overflow: hidden;
    background: rgba(var(--reader-paper-soft-rgb), 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(var(--reader-accent-rgb), 0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.tl-choice-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -10%; width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(var(--reader-text-rgb), 0.1), transparent);
    transform: skewX(-20deg);
}
.tl-choice-btn:nth-child(1) { animation-delay: 0s; }
.tl-choice-btn:nth-child(2) { animation-delay: 0.08s; }
.tl-choice-btn:nth-child(3) { animation-delay: 0.16s; }
@keyframes tl-choice-stagger {
    to { opacity: 1; transform: translateY(0); }
}

/* ── Smooth reveal when auto-opened on scroll ── */
#tl-choices-body {
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
#tl-choices-body.tl-choices-revealing {
    opacity: 0;
    max-height: 0 !important;
}
#tl-choices-body.tl-choices-revealed {
    opacity: 1;
    max-height: 500px; /* Reduced from 1500px to avoid animation hang when closing */
}
/* Tap guard — prevent accidental clicks during reveal animation */
#tl-choices-body.tl-choices-guard .tl-choice-btn,
#tl-choices-body.tl-choices-guard .tl-custom-choice {
    pointer-events: none;
}
.tl-choice-btn:hover {
    border-color: var(--reader-accent-strong) !important;
    color: var(--reader-accent-strong);
    background: rgba(var(--reader-paper-soft-rgb), 0.85);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 20px var(--reader-shadow), 0 0 15px rgba(var(--reader-accent-strong-rgb), 0.4);
}
.tl-choice-btn:hover::after {
    left: 20%;
    transition: left 0.6s ease;
}
.tl-choice-num {
    width: 20px; height: 20px;
    min-width: 20px;
    border-radius: 6px;
    background: rgba(var(--reader-accent-rgb), 0.2);
    color: var(--reader-accent);
    font-size: 11px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    margin-top: 1px;
}
.tl-choice-tag {
    font-size: 14px;
    line-height: 1;
    margin-top: 1px;
    flex-shrink: 0;
}
.tl-custom-choice {
    display: flex;
    gap: 0;
    margin-top: 6px;
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;

    border-radius: 12px;
    border: 1px solid var(--reader-line);
    background: var(--reader-paper);
    overflow: hidden;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: stretch; /* Default stretch to fill height */
}
.tl-custom-choice:focus-within {
    border-color: var(--reader-accent-strong);
    box-shadow: 0 0 0 3px rgba(var(--reader-accent-strong-rgb), 0.2);
    background: var(--reader-paper-soft);
    align-items: flex-end; /* Keep buttons at bottom when expanded */
}
.tl-custom-choice .tl-input-sm {
    flex: 1;
    min-width: 0;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-height: 44px;
    padding-top: 12px;
    padding-bottom: 12px;
    line-height: 20px;
    transition: min-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tl-custom-choice:focus-within .tl-input-sm {
    min-height: 160px; /* Expand to cover the suggested choices space */
}
#tl-choices-close-btn {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(var(--reader-accent-rgb), 0.2) !important;
    color: var(--reader-accent) !important;
    font-weight: 700;
    transition: all .2s;
    border: none;
    cursor: pointer;
    margin: 0 0 0 12px;
    align-self: center;
    white-space: nowrap;
    flex: 0 0 auto;
    height: 24px;
    display: flex;
    align-items: center;
}
.tl-custom-choice:focus-within #tl-choices-close-btn {
    align-self: flex-end;
    margin-bottom: 10px;
}
.tl-custom-choice .tl-btn-sm {
    width: 44px;
    min-width: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    margin: 0 !important;
}
#tl-custom-submit {
    height: auto; 
    background: transparent !important;
    border: none !important;
    border-left: 1px solid var(--reader-line) !important;
    transition: all 0.2s;
    cursor: pointer;
}
.tl-custom-choice:focus-within #tl-custom-submit {
    height: 44px;
}
#tl-custom-submit:hover {
    background: rgba(var(--reader-accent-rgb), 0.1) !important;
}


