
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #ffffff;
    --bg-muted: #f1f5f9;
    --text: #1e293b;
    --text-muted: #5b6b80;
    --primary: #6366f1;
    --primary-rgb: 99, 102, 241;
    --primary-light: #818cf8;
    --primary-fg: #ffffff;
    --error: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --border: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* =========================================================================
   Connection quality indicator
   ========================================================================= */

.conn-indicator {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 50;
    display: flex;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.conn-indicator.visible {
    opacity: 1;
}

.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.conn-dot.green {
    background: var(--success);
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.conn-dot.yellow {
    background: var(--warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.conn-dot.red {
    background: var(--error);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
    animation: conn-pulse 1.5s ease-in-out infinite;
}

@keyframes conn-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* =========================================================================
   Loading Overlay
   ========================================================================= */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.mic-icon {
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
    z-index: 1;
    animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: pulse-ring 2s ease-out infinite;
}

.pulse-ring.delay-1 {
    animation-delay: 0.5s;
}

.pulse-ring.delay-2 {
    animation-delay: 1s;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.loading-text {
    font-size: 18px;
    color: var(--text-muted);
    animation: fade-text 1.5s ease-in-out infinite;
}

@keyframes fade-text {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.start-button {
    margin-top: 8px;
    padding: 14px 40px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    animation: none;
}

.start-button:hover {
    background: var(--primary-light);
}

.start-button:active {
    transform: scale(0.96);
}

/* =========================================================================
   Main App Layout
   ========================================================================= */

.app {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    padding: 2rem 1.5rem;
    overflow: hidden;
}

/* =========================================================================
   Agent Text (above orb)
   ========================================================================= */

.agent-text-container {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    max-width: 32rem;
    /* Leave room for the orb area (absolute-positioned at bottom: 100px) */
    padding-bottom: calc(160px + 100px + 1rem);
    min-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.agent-text-container.preview-active {
    opacity: 0;
    max-height: 0;
    padding-bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.agent-text {
    font-size: 1.25rem;
    font-weight: 500;
    text-align: justify;
    line-height: 1.6;
    color: var(--text);
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 1;
    transform: translateY(0);
    max-height: 100%;
    overflow-y: auto;
}

.agent-text::-webkit-scrollbar {
    width: 4px;
}

.agent-text::-webkit-scrollbar-track {
    background: transparent;
}

.agent-text::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.agent-text.fade-out {
    opacity: 0;
    transform: translateY(8px);
}

/* Markdown inside agent text */
.agent-text p {
    margin: 0.25rem 0;
}

.agent-text p:first-child {
    margin-top: 0;
}

.agent-text p:last-child {
    margin-bottom: 0;
}

.agent-text ul,
.agent-text ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    text-align: left;
}

.agent-text li {
    margin: 0.25rem 0;
}

.agent-text code {
    background: var(--bg-muted);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-size: 0.9em;
}

.agent-text pre {
    background: var(--bg-muted);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    text-align: left;
}

.agent-text pre code {
    background: none;
    padding: 0;
}

.agent-text strong {
    font-weight: 600;
}

.agent-text a {
    color: var(--primary);
    text-decoration: none;
}

.agent-text a:hover {
    text-decoration: underline;
}

.agent-text blockquote {
    border-left: 3px solid var(--border);
    padding-left: 12px;
    margin: 0.5rem 0;
    color: var(--text-muted);
}

@media (min-width: 768px) {
    .agent-text {
        font-size: 1.5rem;
    }
}

/* =========================================================================
   Audio Orb
   ========================================================================= */

.orb-area {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    pointer-events: none;
}

.orb-area > * {
    pointer-events: auto;
}

.orb-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    --audio-level: 0;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    transition: all 0.7s ease;
}

.orb-outer {
    width: 112px;
    height: 112px;
    background: transparent;
}

.orb-middle {
    width: 96px;
    height: 96px;
    background: rgba(var(--primary-rgb), 0.05);
}

.orb-core {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
    box-shadow: 0 4px 24px rgba(var(--primary-rgb), 0.1);
    background: rgba(var(--primary-rgb), 0.6);
}

.orb-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.orb-icon svg {
    width: 32px;
    height: 32px;
}

.orb-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
}

/* Orb states */

/* Connected idle — gentle breathing pulse */
.orb-container.state-idle .orb-core {
    background: rgba(var(--primary-rgb), 0.5);
    animation: orb-pulse-gentle 3s ease-in-out infinite;
    box-shadow: 0 4px 24px rgba(var(--primary-rgb), 0.1);
}

.orb-container.state-idle .orb-middle {
    width: 96px;
    height: 96px;
    background: rgba(var(--primary-rgb), 0.05);
}

.orb-container.state-idle .orb-outer {
    width: 112px;
    height: 112px;
    background: transparent;
}

/* Listening — mic active, responds to ambient sound via --audio-level */
.orb-container.state-listening .orb-core {
    background: rgba(var(--primary-rgb), 0.6);
    animation: none;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), calc(0.15 + var(--audio-level) * 0.2));
    /* Respond to audio: scale grows with sound level */
    transform: scale(calc(1 + var(--audio-level) * 0.2));
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

.orb-container.state-listening .orb-middle {
    width: 100px;
    height: 100px;
    background: rgba(var(--primary-rgb), calc(0.08 + var(--audio-level) * 0.15));
    transform: scale(calc(1 + var(--audio-level) * 0.12));
    transition: transform 0.1s ease-out, background 0.1s ease-out;
    animation: none;
}

.orb-container.state-listening .orb-outer {
    width: 120px;
    height: 120px;
    background: rgba(var(--primary-rgb), calc(0.05 + var(--audio-level) * 0.08));
    transition: background 0.15s ease-out;
    animation: none;
}

/* Agent speaking — strong rhythmic expansion */
.orb-container.state-agent .orb-core {
    background: var(--primary);
    animation: orb-speaking 0.8s ease-in-out infinite;
    box-shadow: 0 8px 32px rgba(var(--primary-rgb), 0.35);
}

.orb-container.state-agent .orb-middle {
    width: 112px;
    height: 112px;
    background: rgba(var(--primary-rgb), 0.15);
    animation: orb-speaking-ring 1.2s ease-in-out infinite;
}

.orb-container.state-agent .orb-outer {
    width: 144px;
    height: 144px;
    background: rgba(var(--primary-rgb), 0.1);
    animation: orb-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* User speaking — responsive to voice level via --audio-level */
.orb-container.state-user .orb-core {
    background: rgba(var(--primary-rgb), 0.85);
    box-shadow: 0 6px 28px rgba(var(--primary-rgb), calc(0.15 + var(--audio-level) * 0.25));
    /* Dynamic scale driven by voice intensity */
    transform: scale(calc(1.02 + var(--audio-level) * 0.2));
    transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
    animation: none;
}

.orb-container.state-user .orb-middle {
    width: 108px;
    height: 108px;
    background: rgba(var(--primary-rgb), calc(0.08 + var(--audio-level) * 0.15));
    transform: scale(calc(1 + var(--audio-level) * 0.15));
    transition: transform 0.08s ease-out, background 0.08s ease-out;
    animation: none;
}

.orb-container.state-user .orb-outer {
    width: 132px;
    height: 132px;
    background: rgba(var(--primary-rgb), calc(0.04 + var(--audio-level) * 0.1));
    transition: background 0.1s ease-out;
}

/* Disconnected — static, muted */
.orb-container.state-disconnected .orb-core {
    background: var(--bg-muted);
    box-shadow: none;
    animation: none;
}

.orb-container.state-disconnected .orb-middle,
.orb-container.state-disconnected .orb-outer {
    width: 80px;
    height: 80px;
    background: transparent;
    animation: none;
}

/* Thinking — agent is processing (tool call in flight, no audio yet).
   Gentle breathing + rotating outer ring to signal "I'm working on it"
   without pretending to speak. */
.orb-container.state-thinking .orb-core {
    background: rgba(var(--primary-rgb), 0.7);
    animation: orb-thinking-core 1.6s ease-in-out infinite;
    box-shadow: 0 4px 24px rgba(var(--primary-rgb), 0.25);
}

.orb-container.state-thinking .orb-middle {
    width: 104px;
    height: 104px;
    background: rgba(var(--primary-rgb), 0.12);
    animation: orb-thinking-ring 1.6s ease-in-out infinite;
}

.orb-container.state-thinking .orb-outer {
    width: 128px;
    height: 128px;
    background: rgba(var(--primary-rgb), 0.08);
    animation: orb-thinking-outer 2.4s linear infinite;
}

@keyframes orb-pulse-gentle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes orb-listening {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes orb-listening-ring {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.05); opacity: 1; }
}

@keyframes orb-speaking {
    0%, 100% { transform: scale(1.05); }
    50% { transform: scale(1.15); }
}

@keyframes orb-speaking-ring {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 1; }
}

@keyframes orb-user-pulse {
    0%, 100% { transform: scale(1.02); }
    50% { transform: scale(1.1); }
}

@keyframes orb-user-ring {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.06); opacity: 1; }
}

@keyframes orb-ping {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    75%, 100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

@keyframes orb-thinking-core {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.06); opacity: 1; }
}

@keyframes orb-thinking-ring {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.04); opacity: 0.9; }
}

@keyframes orb-thinking-outer {
    0% { transform: rotate(0deg) scale(1); opacity: 0.5; }
    50% { transform: rotate(180deg) scale(1.05); opacity: 0.75; }
    100% { transform: rotate(360deg) scale(1); opacity: 0.5; }
}

/* =========================================================================
   Loading Ring (waiting for agent response)
   A single arc that chases itself around the orb, YouTube-style.
   ========================================================================= */

.orb-loading-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.orb-loading-ring.visible {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

.orb-loading-track {
    fill: none;
    stroke: rgba(var(--primary-rgb), 0.1);
    stroke-width: 2.5;
}

.orb-loading-arc {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2.5;
    stroke-linecap: round;
    /* Total circumference: 2 * PI * 46 ≈ 289 */
    stroke-dasharray: 289;
    /* Start with a short arc (70 visible, 219 gap) */
    stroke-dashoffset: 219;
    transform-origin: center;
    animation: loading-ring-spin 1.4s linear infinite,
               loading-ring-stretch 1.4s ease-in-out infinite;
}

@keyframes loading-ring-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loading-ring-stretch {
    0%   { stroke-dashoffset: 240; }
    50%  { stroke-dashoffset: 140; }
    100% { stroke-dashoffset: 240; }
}

/* =========================================================================
   Tool Status (below orb)
   ========================================================================= */

.tool-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-muted);
    font-size: 13px;
    color: var(--text-muted);
    animation: fade-in-up 0.3s ease-out;
}

.tool-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================================
   Migration Progress (top bar, matches preview container design)
   ========================================================================= */

.migration-progress {
    width: 100%;
    max-width: 24rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-bottom: 8px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.migration-progress.visible {
    opacity: 1;
    transform: translateY(0);
}

.migration-progress-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.migration-progress-track {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.migration-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--primary);
    transition: width 0.5s ease-out;
    width: 0%;
}

/* =========================================================================
   User Transcript (below orb)
   ========================================================================= */

.user-transcript {
    margin-top: 16px;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
    max-width: 24rem;
    transition: opacity 0.5s ease;
    opacity: 0;
    min-height: 1.5em;
}

.user-transcript.visible {
    opacity: 0.7;
}

/* =========================================================================
   Error Area (above bottom bar)
   ========================================================================= */

.error-area {
    width: 100%;
    max-width: 28rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 1rem;
}

.error-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--error);
    border-radius: 10px;
    font-size: 13px;
    color: white;
    animation: fade-in-up 0.3s ease-out;
}

.error-toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.error-toast.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Fatal error */
.fatal-error {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--error);
    border-radius: 10px;
    font-size: 13px;
    color: white;
    animation: fade-in-up 0.3s ease-out;
}

.fatal-error svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.fatal-error .error-content {
    flex: 1;
}

.fatal-error .error-ref {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
    font-family: monospace;
}

.error-report-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.error-report-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =========================================================================
   Limit Reached (overlay version — replaces loading content)
   ========================================================================= */

.limit-reached-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    padding: 0 24px;
    animation: fade-in-up 0.3s ease-out;
}

.limit-reached-notice svg {
    color: var(--warning);
}

.limit-reached-notice h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.limit-reached-notice p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 300px;
}

.limit-reached-notice .limit-upgrade-hint {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

/* Limit Reached (banner version — mid-session) */

.limit-reached-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--warning);
    border-radius: 10px;
    font-size: 13px;
    color: white;
    animation: fade-in-up 0.3s ease-out;
}

.limit-reached-banner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.limit-reached-banner .limit-reached-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.limit-reached-banner .limit-reached-text span {
    font-size: 12px;
    opacity: 0.9;
}

/* =========================================================================
   Bottom Bar
   ========================================================================= */

.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding-top: 1.5rem;
    flex-shrink: 0;
    margin-top: auto;
}

.report-button {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    padding: 8px 10px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
}

.report-button:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.end-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.end-button:hover {
    background: #dc2626;
}

.end-button:active {
    transform: scale(0.98);
}

.end-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.end-button svg {
    opacity: 0.9;
}

.restart-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.restart-button:hover {
    background: var(--primary-light);
}

.restart-button:active {
    transform: scale(0.98);
}

.restart-button svg {
    opacity: 0.9;
}

/* =========================================================================
   Report Modal (light theme)
   ========================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fade-in 0.2s ease-out;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-description {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 12px;
}

.report-textarea {
    width: 100%;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}

.report-textarea:focus {
    border-color: var(--primary);
}

.report-feedback {
    font-size: 13px;
    color: var(--success);
    margin: 8px 0 0;
}

.report-feedback.error {
    color: var(--error);
}

.modal-footer {
    padding: 12px 20px 16px;
    display: flex;
    justify-content: flex-end;
}

.report-submit {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.report-submit:hover {
    background: var(--primary-light);
}

.report-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================================================
   Preview Container (planning timeline + task cards)
   ========================================================================= */

.preview-container {
    width: 100%;
    max-width: 24rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
}

.preview-container.visible {
    transform: translateY(0);
    opacity: 1;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.preview-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
}

.preview-dismiss-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.preview-dismiss-btn:hover {
    color: var(--text);
}

.preview-content {
    padding: 10px 14px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.preview-content::-webkit-scrollbar {
    width: 4px;
}

.preview-content::-webkit-scrollbar-track {
    background: transparent;
}

.preview-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.preview-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

/* --- Hierarchy Preview Tree --- */

.hierarchy-tree,
.hnode-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.hnode-children {
    padding-left: 14px;
    border-left: 1px dashed var(--border);
    margin-left: 6px;
    margin-top: 2px;
}

.hnode {
    margin: 2px 0;
}

.hnode-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.3;
    background: transparent;
}

.hnode-new > .hnode-row {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.hnode-edited > .hnode-row {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.hnode-deleted > .hnode-row {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    text-decoration: line-through;
}

.hnode-icon {
    display: inline-flex;
    color: var(--text-muted);
}

.hnode-pillar > .hnode-row > .hnode-label,
.hnode-inbox > .hnode-row > .hnode-label {
    font-weight: 600;
    color: var(--text-primary);
}

.hnode-goal > .hnode-row > .hnode-label {
    font-weight: 500;
}

.hnode-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hnode-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.hnode-badge-new {
    background: #6366f1;
    color: white;
}

.hnode-badge-edited {
    background: #eab308;
    color: #1f2937;
}

.hnode-badge-deleted {
    background: #ef4444;
    color: white;
}

/* --- Morning Plan Event Timeline (legacy, used by showMorningPlanPreview) --- */

.event-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.event-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.event-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

.event-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 3px solid transparent;
}

.event-new .event-bar {
    background: rgba(var(--primary-rgb), 0.1);
    border-left-color: var(--primary);
}

.event-existing .event-bar {
    background: var(--bg-muted);
    border-left-color: var(--border);
}

.event-conflict .event-bar {
    border-left-color: var(--error);
    background: rgba(239, 68, 68, 0.08);
}

.event-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-existing .event-title {
    color: var(--text-muted);
    font-weight: 400;
}

.event-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: 3px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.event-badge-new {
    background: var(--primary);
    color: var(--primary-fg);
}

.event-badge-cal {
    background: var(--bg-muted);
    color: var(--text-muted);
    font-weight: 500;
}

.event-badge-conflict {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
}

.task-priority {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.task-priority.priority-high {
    color: #ef4444;
}

.task-priority.priority-medium {
    color: #ffe296;
}

.task-priority.priority-low {
    color: #96b0ff;
}

/* --- Preview Timeline (matches CalendarDayTimeline.tsx) --- */

.ptl-allday {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.ptl-allday-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 9999px;
}

.ptl-pill-local {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
}

.ptl-pill-ext {
    background: rgba(234, 179, 8, 0.15);
    color: #d97706;
}

.ptl-container {
    position: relative;
    width: 100%;
    user-select: none;
    margin-top: 4px;
}

/* Hour row — matches: absolute left-0 right-0 flex items-start */
.ptl-hour-row {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
}

/* Hour label — matches: w-12 -mt-2 text-[10px] font-medium text-muted-foreground pr-2 text-right */
.ptl-hour-label {
    width: 48px;
    margin-top: -8px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    padding-right: 8px;
    text-align: right;
    flex-shrink: 0;
    user-select: none;
}

/* Hour line — matches: flex-1 h-px bg-border/60 */
.ptl-hour-line {
    flex: 1;
    height: 1px;
    background: var(--border);
    opacity: 0.6;
}

/* Block area — matches: absolute left-12 right-1 top-0 bottom-0 */
.ptl-blocks {
    position: absolute;
    left: 48px;
    right: 4px;
    top: 0;
    bottom: 0;
}

/* Event block — matches: absolute rounded-md border px-1.5 py-1 overflow-hidden shadow-sm */
.ptl-block {
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 4px 6px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Skedul block — matches: bg-primary/85 border-primary text-primary-foreground */
.ptl-block-skedul {
    background: rgba(var(--primary-rgb), 0.85);
    border-color: var(--primary);
    color: var(--primary-fg);
}

/* Done block — matches: bg-primary/40 border-primary/50 text-primary-foreground/70 */
.ptl-block-done {
    background: rgba(var(--primary-rgb), 0.4);
    border-color: rgba(var(--primary-rgb), 0.5);
    color: rgba(255, 255, 255, 0.7);
}

/* External block — matches: bg-amber-500/20 border-amber-500/50 text-foreground */
.ptl-block-ext {
    background: rgba(234, 179, 8, 0.2);
    border-color: rgba(234, 179, 8, 0.5);
    color: var(--text);
}

/* Block inner — matches: flex items-start gap-1 */
.ptl-block-inner {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
    min-height: 0;
    pointer-events: none;
}

/* Block icon — matches: w-3 h-3 shrink-0 mt-0.5 */
.ptl-block-icon {
    flex-shrink: 0;
    margin-top: 2px;
    opacity: 0.9;
}

.ptl-icon-lock {
    opacity: 0.7;
}

/* Block text — matches: min-w-0 flex-1 */
.ptl-block-text {
    min-width: 0;
    flex: 1;
}

/* Block title — matches: font-medium leading-tight truncate text-xs */
.ptl-block-title {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ptl-title-short {
    font-size: 11px;
}

.ptl-title-done {
    text-decoration: line-through;
    opacity: 0.7;
}

/* Block time — matches: text-[10px] opacity-80 mt-0.5 */
.ptl-block-time {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ptl-badge {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    align-self: flex-start;
    margin-top: 2px;
}

.ptl-badge-new {
    background: rgba(var(--primary-rgb), 0.9);
    color: #fff;
}

/* --- Preview Task List (matches TaskItem.tsx) --- */

.ptask-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Task row — matches: group flex items-center gap-2 p-1.5 rounded-lg border border-transparent bg-card */
.ptask {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--bg);
    transition: background 0.15s, border-color 0.15s;
}

.ptask:hover {
    background: rgba(var(--primary-rgb), 0.04);
    border-color: rgba(var(--primary-rgb), 0.2);
}

.ptask-done {
    opacity: 0.6;
}

.ptask-deleted {
    opacity: 0.5;
}

/* Checkbox — matches: w-4 h-4 rounded-full border-2 */
.ptask-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid;
    border-color: var(--text-muted);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    padding: 0;
    cursor: default;
}

.ptask-check-done {
    background: var(--primary);
    border-color: var(--primary);
    opacity: 1;
    color: var(--primary-fg);
}

/* Priority flag — matches: h-2.5 w-2.5 flex-shrink-0 */
.ptask-flag {
    flex-shrink: 0;
}

@keyframes pulse-flag {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.ptask-flag-pulse {
    animation: pulse-flag 2s ease-in-out infinite;
}

/* Content wrapper — matches: flex-1 min-w-0 overflow-hidden */
.ptask-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.ptask-title-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

/* Title — matches: text-xs font-medium truncate flex-1 min-w-0 */
.ptask-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ptask-title-done {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Meta row — matches: flex items-center gap-1 */
.ptask-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

/* List badge — matches: flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded */
.ptask-list-badge {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 4px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Due date — matches: text-[9px] text-muted-foreground */
.ptask-due {
    font-size: 9px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.ptask-due-overdue {
    color: #ef4444;
}

/* Status badges */
.ptask-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.ptask-badge-new {
    background: var(--primary);
    color: var(--primary-fg);
}

.ptask-badge-done {
    background: #22c55e;
    color: #fff;
}

.ptask-badge-del {
    background: #ef4444;
    color: #fff;
}

.ptask-badge-edit {
    background: #eab308;
    color: #1f2937;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 768px) {
    .app {
        padding: 1.5rem 1rem;
    }

    .agent-text-container {
        padding-bottom: calc(160px + 80px + 1rem);
    }

    .orb-area {
        bottom: 80px;
    }

    .preview-container {
        max-width: 100%;
        border-radius: 8px;
    }

    .migration-progress {
        max-width: 100%;
        border-radius: 8px;
    }
}

/* =========================================================================
   Toast Notifications
   ========================================================================= */

.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}

.toast-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.toast-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #22c55e;
}

.toast-info {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #6366f1;
}
