/* [ÚJ] Text-to-timeline preview modal styling. */

.text-to-timeline-shell {
    width: min(900px, calc(100vw - 48px));
}

.text-to-timeline-body {
    gap: 18px;
}

.text-to-timeline-intro {
    margin: 0;
    line-height: 1.6;
    opacity: 0.86;
}

.text-to-timeline-input {
    min-height: 180px;
    resize: vertical;
}

.text-to-timeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.text-to-timeline-status {
    min-height: 1.4em;
    font-size: 0.92rem;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
    transition: color 0.2s;
}

.text-to-timeline-status.is-success {
    color: color-mix(in srgb, #22c55e 70%, var(--ai-panel-text-color, #1b1b1b));
    font-weight: 600;
}

@keyframes text-to-timeline-just-saved {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, #22c55e 60%, transparent); }
    40%  { box-shadow: 0 0 0 6px color-mix(in srgb, #22c55e 28%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, #22c55e 0%, transparent); }
}

.text-to-timeline-turn.is-just-saved .text-to-timeline-history-bubble.is-ai {
    animation: text-to-timeline-just-saved 1.6s ease-out 1;
    border-color: color-mix(in srgb, #22c55e 50%, var(--ai-panel-section-border, rgba(255,255,255,0.12)));
}

.text-to-timeline-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.text-to-timeline-thread {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    padding-bottom: 4px;
}

.text-to-timeline-turn {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.text-to-timeline-turn.is-history {
    gap: 8px;
    padding: 0;
    border-bottom: none;
}

/* ── history bubbles (chat-style) ────────────────────────────── */

.text-to-timeline-history-bubble {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--ai-panel-section-border, rgba(255, 255, 255, 0.12));
    box-shadow: var(--ai-panel-section-shadow, none);
    max-width: 92%;
}

.text-to-timeline-history-bubble.is-user {
    align-self: flex-end;
    background: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 14%, var(--ai-panel-section-bg, rgba(255,255,255,0.04)));
    border-color: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 32%, transparent);
    border-top-right-radius: 4px;
}

.text-to-timeline-history-bubble.is-ai {
    align-self: flex-start;
    background: var(--ai-panel-section-bg, rgba(255, 255, 255, 0.03));
    border-top-left-radius: 4px;
}

.text-to-timeline-history-bubble-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.text-to-timeline-history-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #fff;
    flex-shrink: 0;
}

.text-to-timeline-history-avatar.is-user {
    background: linear-gradient(135deg, var(--ai-grad-mid, #3b82f6), var(--ai-grad-to, #6366f1));
}

.text-to-timeline-history-avatar.is-ai {
    background: linear-gradient(135deg, var(--ai-grad-from, #06b6d4), var(--ai-grad-mid, #3b82f6));
}

.text-to-timeline-history-bubble-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
    flex: 1;
    min-width: 0;
}

.is-history .text-to-timeline-turn-status {
    font-size: 0.66rem;
    padding: 3px 8px;
    margin-left: auto;
}

.text-to-timeline-history-bubble-text {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    word-break: break-word;
    white-space: pre-wrap;
    max-height: 100px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ai-panel-section-border, rgba(0,0,0,0.18)) transparent;
}

.text-to-timeline-history-bubble-text::-webkit-scrollbar {
    width: 5px;
}

.text-to-timeline-history-bubble-text::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: var(--ai-panel-section-border, rgba(0, 0, 0, 0.22));
}

.text-to-timeline-history-meta {
    margin: 0;
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
}

.text-to-timeline-history-meta.is-empty {
    font-style: italic;
}

.text-to-timeline-history-events-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ai-panel-section-border, rgba(0,0,0,0.18)) transparent;
}

.text-to-timeline-history-events-list::-webkit-scrollbar {
    width: 5px;
}

.text-to-timeline-history-events-list::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: var(--ai-panel-section-border, rgba(0, 0, 0, 0.22));
}

.text-to-timeline-history-event-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 6px 10px 6px 8px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ai-panel-section-bg, rgba(255,255,255,0.03)) 60%, transparent);
}

.text-to-timeline-history-event-row.is-excluded {
    opacity: 0.55;
}

.text-to-timeline-history-event-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    color: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 82%, #1447a6 18%);
    background: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 24%, transparent);
    box-sizing: border-box;
    flex-shrink: 0;
}

.text-to-timeline-history-event-body {
    min-width: 0;
}

.text-to-timeline-history-event-row.is-excluded .text-to-timeline-history-event-icon {
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
    border-color: color-mix(in srgb, var(--ai-panel-section-border, rgba(255,255,255,0.18)) 92%, transparent);
    background: color-mix(in srgb, var(--ai-panel-section-border, rgba(255,255,255,0.18)) 12%, transparent);
}

.text-to-timeline-history-event-title {
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    word-break: break-word;
}

.text-to-timeline-history-event-meta {
    font-size: 0.72rem;
    line-height: 1.4;
    margin-top: 1px;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
}

.text-to-timeline-history-event-desc {
    font-size: 0.76rem;
    line-height: 1.45;
    margin-top: 3px;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    opacity: 0.82;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.text-to-timeline-chat-message {
    width: 100%;
    border-radius: 18px;
    padding: 14px 16px;
    border: 1px solid var(--ai-panel-section-border, rgba(255, 255, 255, 0.12));
    box-shadow: var(--ai-panel-section-shadow, none);
}

.text-to-timeline-chat-message-user {
    margin-left: auto;
    max-width: calc(100% - 28px);
    background: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 12%, var(--ai-panel-section-bg, rgba(255, 255, 255, 0.04)));
    border-color: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 28%, var(--ai-panel-section-border, rgba(255, 255, 255, 0.12)));
}

.text-to-timeline-chat-message-assistant {
    background: var(--ai-panel-section-bg, rgba(255, 255, 255, 0.03));
}

.text-to-timeline-turn.is-history .text-to-timeline-chat-message-assistant {
    background: color-mix(in srgb, var(--ai-panel-section-bg, rgba(255, 255, 255, 0.03)) 86%, transparent);
}

.text-to-timeline-chat-role {
    display: inline-flex;
    margin-bottom: 8px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
}

.text-to-timeline-chat-copy {
    margin: 0;
    font-size: 0.96rem;
    line-height: 1.6;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    white-space: pre-wrap;
}

.text-to-timeline-turn-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.text-to-timeline-turn-heading {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.text-to-timeline-turn-heading strong {
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    font-size: 1rem;
}

.text-to-timeline-turn-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    background: color-mix(in srgb, var(--ai-panel-muted-text, #666666) 14%, transparent);
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-turn-status.is-active {
    background: color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 18%, transparent);
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-turn-status.is-saved {
    background: color-mix(in srgb, #22c55e 16%, transparent);
    color: color-mix(in srgb, #14532d 86%, var(--ai-panel-text-color, #1b1b1b));
}

.text-to-timeline-turn-status.is-unsaved {
    background: color-mix(in srgb, #f59e0b 18%, transparent);
    color: color-mix(in srgb, #7c2d12 76%, var(--ai-panel-text-color, #1b1b1b));
}

.text-to-timeline-turn-summary {
    margin: 0 0 14px;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
    line-height: 1.5;
}

.text-to-timeline-turn-note {
    margin: 4px 0 0;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
    line-height: 1.5;
}

.text-to-timeline-messages {
    border: 1px solid var(--ai-panel-section-border, rgba(255, 255, 255, 0.12));
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--ai-panel-section-bg, rgba(255, 255, 255, 0.03));
    box-shadow: var(--ai-panel-section-shadow, none);
}

.text-to-timeline-message-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-message-list {
    margin: 0;
    padding-left: 18px;
    line-height: 1.55;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
}

.text-to-timeline-events {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.text-to-timeline-event-card {
    border: 1px solid var(--ai-panel-section-border, rgba(255, 255, 255, 0.14));
    border-radius: 18px;
    padding: 16px;
    background: var(--ai-panel-section-bg, rgba(255, 255, 255, 0.035));
    box-shadow: var(--ai-panel-section-shadow, none);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.text-to-timeline-event-card.is-readonly {
    opacity: 0.9;
}

.text-to-timeline-event-card:not(.is-readonly):hover,
.text-to-timeline-event-card:not(.is-readonly):focus-within {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--ai-grad-mid) 34%, var(--ai-panel-section-border, rgba(255, 255, 255, 0.14)));
    box-shadow: 0 20px 36px color-mix(in srgb, var(--ai-grad-mid) 12%, transparent);
}

.text-to-timeline-event-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.text-to-timeline-event-header strong {
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-item-header-meta {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.text-to-timeline-type-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid var(--ai-panel-input-border, var(--border-soft, #dddddd));
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    background: color-mix(in srgb, var(--ai-panel-input-bg, #f7f7f7) 82%, transparent);
}

.text-to-timeline-type-chip.is-review {
    color: color-mix(in srgb, #92400e 82%, var(--ai-panel-text-color, #1b1b1b));
    border-color: color-mix(in srgb, #f59e0b 45%, var(--ai-panel-input-border, #dddddd));
    background: color-mix(in srgb, #f59e0b 14%, var(--ai-panel-input-bg, #f7f7f7));
}

.text-to-timeline-reviewed-toggle {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ai-panel-input-text, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-review-note {
    margin: 0;
    border: 1px solid color-mix(in srgb, #f59e0b 42%, var(--ai-panel-section-border, rgba(255,255,255,0.12)));
    border-radius: 12px;
    padding: 10px 12px;
    color: color-mix(in srgb, #92400e 78%, var(--ai-panel-text-color, #1b1b1b));
    background: color-mix(in srgb, #f59e0b 12%, var(--ai-panel-section-bg, rgba(255,255,255,0.03)));
    line-height: 1.45;
    word-break: break-word;
}

.text-to-timeline-include {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
}

.text-to-timeline-include.is-interactive {
    position: relative;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.text-to-timeline-include.is-interactive:hover {
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-include.is-readonly {
    padding: 0;
    border: none;
    background: transparent;
}

.text-to-timeline-include input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    appearance: none;
    -webkit-appearance: none;
    pointer-events: none;
}

.text-to-timeline-checkbox-ui {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--ai-panel-input-border, #dddddd) 88%, #64748b);
    background: color-mix(in srgb, var(--ai-panel-input-bg, #f7f7f7) 88%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
    transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.text-to-timeline-checkbox-ui::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border-right: 2px solid transparent;
    border-bottom: 2px solid transparent;
    opacity: 0;
    transform: rotate(45deg) scale(0.8);
    transition: opacity 0.15s, transform 0.15s, border-color 0.15s;
}

.text-to-timeline-include input[type="checkbox"]:checked + .text-to-timeline-checkbox-ui {
    border-color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    background: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-panel-text-color, #1b1b1b) 14%, transparent);
}

.text-to-timeline-include input[type="checkbox"]:checked + .text-to-timeline-checkbox-ui::after {
    border-color: var(--ai-panel-input-bg, var(--app-background, #ffffff));
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

.text-to-timeline-include input[type="checkbox"]:focus-visible + .text-to-timeline-checkbox-ui {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-panel-text-color, #1b1b1b) 18%, transparent);
}

.text-to-timeline-include-text {
    font-weight: 600;
    line-height: 1.2;
}

.text-to-timeline-event-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.text-to-timeline-event-grid .lifeos-form-group {
    margin: 0;
}

.text-to-timeline-span-2 {
    grid-column: 1 / -1;
}

.text-to-timeline-source {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--ai-panel-muted-text, var(--text-muted, #666666));
}

.text-to-timeline-save-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.text-to-timeline-save-actions button {
    min-width: 180px;
}

.ai-panel-workspace-body .text-to-timeline-message-list {
    margin-bottom: 0;
}

.text-to-timeline-chat-message-assistant > .lifeos-form-group {
    margin: 0 0 14px;
}

.text-to-timeline-preview-panel .lifeos-form-group input,
.text-to-timeline-preview-panel .lifeos-form-group textarea,
.text-to-timeline-preview-panel .lifeos-form-group select {
    background-color: var(--ai-panel-input-bg, var(--surface-muted, #f7f7f7));
    background-image: none;
    color: var(--ai-panel-input-text, var(--app-text-color, #1b1b1b));
    border: 1px solid var(--ai-panel-input-border, var(--border-soft, #dddddd));
    border-radius: 12px;
    box-shadow: none;
}

.text-to-timeline-preview-panel .lifeos-form-group input:focus,
.text-to-timeline-preview-panel .lifeos-form-group textarea:focus,
.text-to-timeline-preview-panel .lifeos-form-group select:focus {
    border-color: var(--ai-grad-mid, #3b82f6);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 18%, transparent);
    outline: none;
}

.text-to-timeline-preview-panel .lifeos-form-group label,
.text-to-timeline-preview-panel .timeline-field-label {
    color: var(--ai-panel-text-color, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-static-value {
    min-height: 44px;
    display: flex;
    align-items: center;
    border: 1px solid var(--ai-panel-input-border, var(--border-soft, #dddddd));
    border-radius: 12px;
    padding: 10px 14px;
    background-color: color-mix(in srgb, var(--ai-panel-input-bg, #f7f7f7) 82%, transparent);
    color: var(--ai-panel-input-text, var(--app-text-color, #1b1b1b));
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.text-to-timeline-preview-panel .cat-select-trigger,
.text-to-timeline-preview-panel .cat-select-dropdown {
    background-color: var(--ai-panel-input-bg, var(--surface-muted, #f7f7f7));
    color: var(--ai-panel-input-text, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-preview-panel .cat-select-trigger {
    border: 1px solid var(--ai-panel-input-border, var(--border-soft, #dddddd));
    border-radius: 12px;
    box-shadow: none;
    min-height: 44px;
    padding: 10px 14px;
}

.text-to-timeline-preview-panel .cat-select-trigger:hover:not(.cat-select-disabled),
.text-to-timeline-preview-panel .cat-select-active .cat-select-trigger:not(.cat-select-disabled) {
    border-color: var(--ai-grad-mid, #3b82f6);
}

.text-to-timeline-preview-panel .cat-select-active .cat-select-trigger:not(.cat-select-disabled) {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-grad-mid, #3b82f6) 18%, transparent);
}

.text-to-timeline-preview-panel .cat-select-dropdown {
    border-color: var(--ai-panel-input-border, var(--border-soft, #dddddd));
}

.text-to-timeline-preview-panel .cat-select-item {
    color: var(--ai-panel-input-text, var(--app-text-color, #1b1b1b));
}

.text-to-timeline-field-readonly {
    cursor: default;
}

@media (max-width: 720px) {
    .text-to-timeline-shell {
        width: calc(100vw - 24px);
    }

    .text-to-timeline-chat-message-user {
        max-width: 100%;
    }

    .text-to-timeline-toolbar,
    .text-to-timeline-save-actions,
    .text-to-timeline-event-header,
    .text-to-timeline-turn-header {
        flex-direction: column;
        align-items: stretch;
    }

    .text-to-timeline-history-bubble {
        max-width: 100%;
    }

    .text-to-timeline-event-grid {
        grid-template-columns: 1fr;
    }
}
