/* Premium Design Variables */
:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(139, 92, 246, 0.3);
    
    --primary-grad: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    --secondary-grad: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    --emerald-grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --font-outfit: 'Outfit', sans-serif;
    --font-inter: 'Inter', sans-serif;
    
    --glow-primary: 0 0 20px rgba(139, 92, 246, 0.25);
    --glow-emerald: 0 0 20px rgba(16, 185, 129, 0.25);
}

/* Reset & Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-inter);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
}

/* Background Ambient Glows */
.glow-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, rgba(59, 130, 246, 0.05) 50%, transparent 100%);
    z-index: -1;
    pointer-events: none;
}

/* Layout Containers */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.85rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 3rem;
    height: 3rem;
}

.brand h1 {
    font-family: var(--font-outfit);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 40%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.api-status {
    display: flex;
    align-items: center;
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.badge.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
    color: #34d399;
}

.badge.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
}

/* Glassmorphism Panel base */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header-with-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.btn-icon-refresh {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-icon-refresh:hover:not(:disabled) {
    color: #fff;
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.35);
}

.btn-icon-refresh:disabled {
    opacity: 0.55;
    cursor: wait;
}

.btn-icon-refresh .fa {
    font-size: 1.125rem;
    line-height: 1;
}

.panel-header h2 {
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}

.panel-sub {
    font-size: 0.825rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Grid Layout */
.workspace-grid {
    display: grid;
    grid-template-columns: minmax(260px, 300px) 1fr;
    gap: 1rem;
    align-items: start;
}

/* Integrations List */
.integrations-list {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.integration-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 0.65rem;
    padding: 0.65rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.integration-card:hover {
    border-color: var(--border-highlight);
    background: rgba(255, 255, 255, 0.03);
}

.integration-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

.integration-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.integration-icon.outlook {
    background: rgba(3, 100, 196, 0.15);
    border: 1px solid rgba(3, 100, 196, 0.3);
    color: #0078d4;
}

.integration-icon.teams {
    background: rgba(98, 100, 167, 0.15);
    border: 1px solid rgba(98, 100, 167, 0.3);
    color: #6264a7;
}

.integration-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.integration-meta {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.integration-info h3 {
    font-size: 0.875rem;
    font-weight: 500;
}

.integration-info .status-text {
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.account-linked {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.35rem;
    font-size: 0.7rem;
    color: #c4b5fd;
    width: 100%;
    max-width: 100%;
    line-height: 1.3;
}

.account-linked.hidden {
    display: none !important;
}

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

.account-linked-label.hidden {
    display: none;
}

.account-info-btn {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: none;
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    cursor: help;
    border-radius: 50%;
    transition: color 0.2s ease, background 0.2s ease;
}

.account-info-icon {
    width: 0.875rem;
    height: 0.875rem;
    display: block;
}

.account-info-btn:hover,
.account-info-btn:focus-visible {
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.12);
    outline: none;
}

.account-info-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.45rem);
    transform: translateX(-50%);
    z-index: 20;
    width: max-content;
    max-width: 14rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.4rem;
    background: #111827;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.65rem;
    line-height: 1.45;
    white-space: pre-line;
    text-align: left;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.account-info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #111827;
}

.account-info-btn:hover .account-info-tooltip,
.account-info-btn:focus-visible .account-info-tooltip {
    opacity: 1;
    visibility: visible;
}

.integration-info .status-text.connecting {
    color: #fbbf24;
}

.integration-info .status-text.connected {
    color: #10b981;
}

/* Buttons */
.btn {
    font-family: var(--font-inter);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-connect {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-connect:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-disconnect {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.btn-disconnect:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-primary {
    background: var(--primary-grad);
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.btn-glow:hover {
    box-shadow: var(--glow-primary);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* Chat workspace (WhatsApp / ChatGPT style) */
.main-panel.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: min(72vh, 640px);
    max-height: min(78vh, 720px);
    padding: 0;
    overflow: hidden;
}

.chat-panel-header {
    flex-shrink: 0;
    padding: 0.85rem 1rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

.chat-panel-header .panel-sub {
    margin-bottom: 0;
}

.chat-panel-header h2 {
    margin-bottom: 0.1rem;
}

#new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.chat-thread-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(11, 15, 25, 0.4) 0%, rgba(11, 15, 25, 0.15) 100%);
}

.chat-thread {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    max-width: 92%;
}

.chat-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
}

.chat-msg--assistant {
    align-self: flex-start;
    margin-right: auto;
}

.chat-msg--cancelled .chat-bubble {
    opacity: 0.65;
    border-color: rgba(148, 163, 184, 0.35);
}

.chat-cancelled-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    padding: 0.2rem 0.5rem;
    border-radius: 0.35rem;
    background: rgba(148, 163, 184, 0.15);
}

.chat-text--muted {
    color: var(--text-secondary);
}

.chat-avatar {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chat-msg--user .chat-avatar {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

.chat-msg--assistant .chat-avatar {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
}

.chat-bubble {
    padding: 0.65rem 0.85rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.45;
    word-break: break-word;
}

.chat-msg--user .chat-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.chat-msg--assistant .chat-bubble {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.chat-text {
    margin: 0;
    white-space: pre-wrap;
}

/* Assistant Markdown output */
.chat-markdown {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.chat-markdown > *:first-child {
    margin-top: 0;
}

.chat-markdown > *:last-child {
    margin-bottom: 0;
}

.chat-markdown p {
    margin: 0 0 0.5rem;
    white-space: normal;
}

.chat-markdown ul,
.chat-markdown ol {
    margin: 0.35rem 0 0.6rem;
    padding-left: 1.25rem;
}

.chat-markdown li {
    margin: 0.2rem 0;
}

.chat-markdown li > p {
    margin: 0;
}

.chat-markdown strong {
    font-weight: 600;
    color: #e2e8f0;
}

.chat-markdown em {
    color: var(--text-secondary);
}

.chat-markdown a {
    color: #93c5fd;
    text-decoration: underline;
}

.chat-markdown a:hover {
    color: #bfdbfe;
}

.chat-markdown code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82em;
    background: rgba(0, 0, 0, 0.28);
    padding: 0.12em 0.35em;
    border-radius: 4px;
}

.chat-markdown pre {
    margin: 0.5rem 0;
    padding: 0.55rem 0.7rem;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.5rem;
    overflow-x: auto;
}

.chat-markdown pre code {
    background: none;
    padding: 0;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3 {
    font-family: var(--font-outfit);
    font-weight: 600;
    margin: 0.65rem 0 0.35rem;
    line-height: 1.3;
}

.chat-markdown h1 { font-size: 1.05rem; }
.chat-markdown h2 { font-size: 0.98rem; }
.chat-markdown h3 { font-size: 0.92rem; }

.chat-markdown blockquote {
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    border-left: 3px solid rgba(139, 92, 246, 0.5);
    color: var(--text-secondary);
}

.chat-msg--error .chat-markdown,
.chat-msg--error .chat-markdown strong {
    color: #fca5a5;
}

.chat-msg--error .chat-markdown a {
    color: #fecaca;
}

.chat-text--error {
    color: #fca5a5;
}

.chat-bubble-title {
    font-family: var(--font-outfit);
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0 0 0.4rem;
}

.chat-bubble-title--success {
    color: #6ee7b7;
}

.chat-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0 0 0.35rem;
}

.chat-bubble-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}

.chat-bubble-image {
    max-width: 140px;
    max-height: 100px;
    border-radius: 0.5rem;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-loading {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-loading-dot {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #a78bfa;
    animation: chat-bounce 1.2s ease-in-out infinite;
}

.chat-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.chat-loading-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

.chat-bubble-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.65rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-msg--user .chat-bubble-actions {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.chat-conflict-list {
    margin: 0.35rem 0 0.5rem;
    padding-left: 1.1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.chat-conflict-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.chat-conflict-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-conflict-label input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 0.4rem;
    padding: 0.4rem 0.5rem;
    color: #fff;
    font-size: 0.8rem;
}

.chat-outcome {
    margin: 0;
    font-family: var(--font-inter);
    font-size: 0.8rem;
    white-space: pre-wrap;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 0.4rem;
    max-height: 8rem;
    overflow-y: auto;
}

.chat-meeting-link {
    display: inline-flex;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.chat-composer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: rgba(11, 15, 25, 0.92);
    padding: 0.5rem 0.65rem 0.65rem;
}

.chat-composer.dragover {
    background: rgba(139, 92, 246, 0.06);
}

.chat-composer-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 0.25rem 0.4rem;
}

.chat-composer-attachments.hidden {
    display: none;
}

.chat-attach-chip {
    position: relative;
    width: 3rem;
    height: 3rem;
    border-radius: 0.4rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-attach-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-attach-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 1.1rem;
    height: 1.1rem;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
}

.chat-composer-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 0.35rem 0.45rem 0.35rem 0.35rem;
}

.chat-composer-icon-btn {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-composer-icon-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.chat-composer-input {
    flex: 1 1 auto;
    min-height: 2.25rem;
    max-height: 120px;
    resize: none;
    border: none;
    background: transparent;
    color: #fff;
    font-family: var(--font-inter);
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0.45rem 0.25rem;
    outline: none;
}

.chat-composer-input::placeholder {
    color: var(--text-muted);
}

.chat-composer-send {
    flex-shrink: 0;
    width: 2.35rem;
    height: 2.35rem;
    border: none;
    border-radius: 50%;
    background: var(--primary-grad);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-composer-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.chat-composer-send:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: var(--glow-primary);
}

.chat-plan-fields {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.chat-panel .plan-compact-summary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
}

.chat-panel .plan-compact-row {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    gap: 0.4rem;
}

.chat-panel .plan-compact-row dt {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
}

.chat-panel .plan-compact-row dd {
    margin: 0;
    color: inherit;
}

@media (max-width: 640px) {
    .main-panel.chat-panel {
        min-height: min(65vh, 520px);
        max-height: none;
    }

    .chat-msg {
        max-width: 96%;
    }

    .chat-conflict-times {
        grid-template-columns: 1fr;
    }
}

/* Stage Systems */
.stage-container {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
}

.stage-container.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Stage 1: Task input card */
.task-input-card {
    margin: 0.75rem;
    padding: 1rem 1.1rem 1.15rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-input-header h3 {
    font-family: var(--font-outfit);
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
}

.task-input-images {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: 0.65rem;
    padding: 0.75rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.task-input-images.dragover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.04);
}

.task-images-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.65rem;
}

.task-images-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.task-images-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    min-height: 2.5rem;
}

.task-image-thumb {
    position: relative;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 0.45rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.task-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.task-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 1.25rem;
    height: 1.25rem;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}

.task-input-text-group textarea {
    min-height: 5rem;
    resize: vertical;
}

.task-input-actions {
    display: flex;
    justify-content: flex-end;
}

/* Legacy drop zone (unused) */
.drop-zone {
    min-height: 200px;
    height: auto;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: all 0.3s ease;
    margin: 0.75rem;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.03);
    box-shadow: inset 0 0 20px rgba(139, 92, 246, 0.05);
}

.drop-zone-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.drop-zone:hover .upload-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}

.upload-icon svg {
    width: 2rem;
    height: 2rem;
}

.drop-zone-content h3 {
    font-family: var(--font-outfit);
    font-size: 1.25rem;
    font-weight: 500;
}

.drop-zone-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Stage 2: Scanning / Processing */
.loader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 2rem;
    text-align: center;
}

.image-preview-container {
    position: relative;
    max-width: 250px;
    max-height: 250px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-bar {
    position: absolute;
    width: 100%;
    height: 4px;
    background: #8b5cf6;
    box-shadow: 0 0 12px #8b5cf6;
    top: 0;
    left: 0;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

.loader-status h3 {
    font-family: var(--font-outfit);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.loader-status p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

.glowing-spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 4px solid rgba(255, 255, 255, 0.05);
    border-top-color: #8b5cf6;
    border-bottom-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    box-shadow: var(--glow-primary);
}

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

/* Compact proposed plan */
.plan-compact-card {
    margin: 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-height: min(70vh, 520px);
    overflow-y: auto;
}

.plan-compact-header h3 {
    font-family: var(--font-outfit);
    font-size: 1.1rem;
}

.plan-compact-summary {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.8rem;
}

.plan-compact-row {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 0.5rem;
    align-items: start;
}

.plan-compact-row dt {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
}

.plan-compact-row dd {
    color: var(--text-primary);
    line-height: 1.35;
    word-break: break-word;
}

.plan-edit-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.plan-edit-details summary {
    cursor: pointer;
    color: #a78bfa;
    margin-bottom: 0.5rem;
}

.plan-form--compact {
    padding: 0.5rem 0 0;
    gap: 0.65rem;
}

.reasoning-box--compact {
    max-height: 5rem;
    overflow-y: auto;
    font-size: 0.8rem;
}

.plan-compact-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-color);
}

.conflict-card {
    margin: 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(251, 191, 36, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.conflict-card h3 {
    font-family: var(--font-outfit);
    font-size: 1.1rem;
    color: #fbbf24;
}

.conflict-message {
    font-size: 0.9rem;
    line-height: 1.45;
}

.conflict-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Stage 3: Verification Form */
.plan-form {
    padding: 0.85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.plan-cache-banner {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 0.5rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.15rem;
}

.plan-cache-banner.hidden {
    display: none;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: #fff;
    font-family: var(--font-inter);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
    background: rgba(0, 0, 0, 0.3);
}

.form-hint {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.form-group select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.type-conditional {
    display: none;
}

.type-conditional.active {
    display: flex;
}

.reasoning-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
}

.action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
}

/* Stage 5: Outcome Results Card */
.result-success-card {
    text-align: center;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.success-icon {
    width: 4.5rem;
    height: 4.5rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10b981;
    box-shadow: var(--glow-emerald);
}

.success-icon svg {
    width: 2.25rem;
    height: 2.25rem;
}

.result-success-card h2 {
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    font-weight: 700;
}

.outcome-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.6;
    text-align: left;
    max-width: 500px;
    width: 100%;
    min-height: 3rem;
    white-space: pre-line;
}

.outcome-box:empty {
    display: none;
}

.outcome-box--muted {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.result-actions {
    margin-top: 0.5rem;
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: center;
}

.btn-action-link {
    width: 100%;
    background: var(--emerald-grad);
    box-shadow: var(--glow-emerald);
    color: white;
    font-weight: 600;
    padding: 0.75rem;
}

.btn-action-link:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

/* Auth gate (Supabase) */
.hidden {
    display: none !important;
}

.auth-loading {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(11, 15, 25, 0.94);
    backdrop-filter: blur(10px);
}

.auth-loading-card {
    text-align: center;
    padding: 2.5rem 2rem;
    max-width: 360px;
    width: 100%;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.auth-loading-spinner {
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto 1.25rem;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: auth-spin 0.85s linear infinite;
}

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

.auth-loading-title {
    font-family: var(--font-outfit);
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.auth-loading-sub {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(11, 15, 25, 0.92);
    backdrop-filter: blur(8px);
}

.page-login .auth-gate {
    background: transparent;
    backdrop-filter: none;
}

.page-dashboard .app-container {
    display: flex;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.auth-brand h1 {
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    margin-bottom: 0.35rem;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-hint {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

.auth-unauthorized {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(10px);
}

.auth-unauthorized-card {
    text-align: center;
    max-width: 400px;
    width: 100%;
    padding: 2rem 1.5rem;
}

.auth-unauthorized-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    font-size: 1.35rem;
}

.auth-unauthorized-card h2 {
    font-family: var(--font-outfit);
    font-size: 1.35rem;
    margin-bottom: 0.5rem;
}

.auth-unauthorized-message {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-oauth-section {
    margin-bottom: 0.25rem;
}

.auth-oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.btn-oauth {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
}

.btn-oauth:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: lowercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent-primary, #818cf8);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-link-btn:hover {
    color: #a5b4fc;
}

.auth-error-banner {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(248, 113, 113, 0.35);
    background: rgba(127, 29, 29, 0.25);
}

.auth-error-banner__icon {
    color: #f87171;
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.auth-error-banner__title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #fecaca;
    margin-bottom: 0.25rem;
}

.auth-error-banner__text {
    font-size: 0.85rem;
    color: #fca5a5;
    line-height: 1.45;
}

.auth-message {
    min-height: 1.25rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.auth-message--error {
    color: #f87171;
}

.auth-message--success {
    color: #34d399;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.auth-user-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Mobile & compact dashboard --- */
@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .integrations-panel {
        order: 2;
    }

    .main-panel {
        order: 1;
    }
}

@media (max-width: 640px) {
    .app-container {
        padding: 0.65rem 0.5rem 1rem;
        gap: 0.65rem;
    }

    .glow-bg {
        width: 100vw;
        height: 100vw;
    }

    .brand {
        gap: 0.6rem;
    }

    .logo-icon {
        width: 2.25rem;
        height: 2.25rem;
    }

    .brand h1 {
        font-size: 1.05rem;
        line-height: 1.2;
    }

    .brand .subtitle {
        font-size: 0.7rem;
        display: none;
    }

    .app-header {
        padding-bottom: 0.6rem;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        gap: 0.4rem;
    }

    .auth-user-email {
        max-width: 42vw;
        font-size: 0.75rem;
    }

    .badge {
        padding: 0.35rem 0.6rem;
        font-size: 0.62rem;
    }

    .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.72rem;
    }

    .panel-header {
        padding: 0.65rem 0.75rem;
    }

    .panel-header h2 {
        font-size: 0.95rem;
    }

    .panel-sub {
        font-size: 0.72rem;
    }

    .integrations-list {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .integration-card {
        flex-direction: column;
        align-items: stretch;
    }

    .integration-card .btn {
        width: 100%;
        margin-top: 0.35rem;
    }

    .integration-info h3 {
        font-size: 0.8rem;
    }

    .drop-zone {
        min-height: 160px;
        margin: 0.5rem;
    }

    .drop-zone-content {
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .drop-zone-content h3 {
        font-size: 1rem;
    }

    .drop-zone-content p {
        font-size: 0.75rem;
    }

    .upload-icon {
        width: 2.75rem;
        height: 2.75rem;
    }

    .loader-wrapper {
        padding: 1.25rem 0.75rem;
        gap: 1rem;
    }

    .loader-status h3 {
        font-size: 1rem;
    }

    .loader-status p {
        font-size: 0.75rem;
    }

    .plan-form {
        padding: 0.65rem 0.75rem 0.85rem;
        gap: 0.65rem;
    }

    .form-group label {
        font-size: 0.68rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 0.875rem;
        padding: 0.5rem 0.6rem;
    }

    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .reasoning-box {
        font-size: 0.8rem;
        max-height: 120px;
    }

    .result-success-card {
        padding: 1rem 0.75rem;
    }

    .result-success-card h2 {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

