@charset "UTF-8";
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    color-scheme: light;
    --font-base: 'Space Grotesk', 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-family: var(--font-base);
    background-color: var(--page-bg);
    color: #231521;
    --page-bg: #fff9f4;
    --page-bg-secondary: #f3f0ff;
    --page-gradient: radial-gradient(circle at 12% 18%, rgba(255, 173, 213, 0.55), transparent 55%),
        radial-gradient(circle at 78% 0%, rgba(136, 170, 255, 0.42), transparent 58%),
        linear-gradient(180deg, #fff9f4 0%, #fff4ef 58%, #fff9ff 100%);
    --ink-strong: #231521;
    --ink: #2d1f33;
    --ink-soft: rgba(35, 21, 33, 0.74);
    --ink-muted: rgba(35, 21, 33, 0.55);
    --surface: #fffdf9;
    --surface-strong: #ffffff;
    --surface-muted: #fff3ea;
    --border-soft: rgba(35, 21, 33, 0.08);
    --border-strong: rgba(35, 21, 33, 0.18);
    --accent-pink: #ff74c9;
    --accent-apricot: #ffb084;
    --accent-indigo: #6f7cff;
    --accent-gradient: linear-gradient(120deg, #ff74c9 0%, #ff8d6f 48%, #6f7cff 100%);
    --accent-gradient-strong: linear-gradient(120deg, #ff5fbf 0%, #ff7c54 45%, #5d68ff 100%);
    --accent-pill: rgba(255, 116, 201, 0.15);
    --ghost-bg: rgba(255, 255, 255, 0.7);
    --focus-ring: 0 0 0 3px rgba(111, 124, 255, 0.35);
    --shadow-hero: 0 45px 120px rgba(255, 137, 188, 0.24);
    --shadow-card: 0 30px 85px rgba(111, 124, 255, 0.15);
    --shadow-ghost: 0 14px 35px rgba(35, 21, 33, 0.08);
    --success: #2ac4ad;
    --warning: #ffb347;
    --sidebar-width: 280px;
}

::selection {
    background: rgba(255, 116, 201, 0.35);
    color: var(--ink-strong);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-base);
    background-color: var(--page-bg);
    background-image: var(--page-gradient);
    color: var(--ink);
    display: flex;
    position: relative;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

body::before {
    background: radial-gradient(circle at 10% 85%, rgba(255, 226, 198, 0.55), transparent 55%),
        radial-gradient(circle at 90% 20%, rgba(139, 166, 255, 0.35), transparent 52%);
    filter: blur(60px);
}

body::after {
    width: 520px;
    height: 520px;
    top: 18%;
    right: -140px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9), transparent 70%);
    filter: blur(30px);
}

body > * {
    position: relative;
    z-index: 1;
}

button,
textarea {
    font-family: inherit;
    color: inherit;
}

/* App Layout - Sidebar + Main */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease, min-width 0.3s ease;
    z-index: 10;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
}

.sidebar__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar__header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-strong);
}

.sidebar__btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--ghost-bg);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
}

.sidebar__btn:hover {
    background: var(--surface-muted);
    transform: scale(1.05);
}

.sidebar__btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.sidebar__list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar__empty {
    color: var(--ink-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 24px 12px;
    margin: 0;
}

/* Conversation Item */
.conversation-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.conversation-item:hover {
    background: var(--surface-muted);
    border-color: var(--border-soft);
}

.conversation-item.active {
    background: var(--accent-pill);
    border-color: rgba(255, 116, 201, 0.3);
}

.conversation-item__content {
    flex: 1;
    min-width: 0;
}

.conversation-item__title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink-strong);
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item__date {
    font-size: 0.75rem;
    color: var(--ink-muted);
    margin: 0;
}

.conversation-item__delete {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.conversation-item:hover .conversation-item__delete {
    opacity: 1;
}

.conversation-item__delete:hover {
    background: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-y: auto;
}

.app-main > .app-shell {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: clamp(32px, 6vw, 80px) 20px;
}

.app-shell {
    width: min(1180px, 100%);
    display: flex;
    flex-direction: column;
    gap: clamp(24px, 3vw, 48px);
}

h1,
h2,
h3 {
    color: var(--ink-strong);
    margin-top: 0;
}

p {
    color: var(--ink-soft);
    line-height: 1.6;
    margin-top: 0;
}

.hero {
    text-align: center;
    padding: clamp(32px, 5vw, 64px);
    border-radius: 40px;
    background: linear-gradient(140deg, rgba(255, 233, 243, 0.95), rgba(255, 245, 230, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-hero);
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0.08;
    mix-blend-mode: multiply;
}

.hero h1 {
    font-size: clamp(2.8rem, 5vw, 3.8rem);
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}

.hero__badge {
    position: absolute;
    top: 18px;
    right: 24px;
    background: var(--accent-pill);
    color: var(--ink-strong);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.25em;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
}

.hero__subtitle {
    max-width: 640px;
    margin: 0 auto;
    font-size: 1.15rem;
    color: var(--ink-soft);
}

/* User Menu */
.user-menu {
    position: absolute;
    top: 18px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    z-index: 5;
}

.user-menu[hidden] {
    display: none;
}

.user-menu__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-muted);
}

.user-menu__name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-strong);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu__settings {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
    opacity: 0.5;
    transition: opacity 0.2s ease;
    padding: 4px;
    text-decoration: none;
}

.user-menu__settings:hover {
    opacity: 1;
    color: var(--accent-indigo);
}

.auth-block {
    padding: clamp(22px, 3vw, 32px);
    border-radius: 32px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card);
}

.auth-block__content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
}

.auth-block__column {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.auth-block__status p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 500;
}

.gbutton-placeholder {
    min-width: 220px;
    min-height: 44px;
}

.workspace {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: clamp(20px, 2vw, 32px);
    padding: clamp(24px, 3vw, 36px);
    border-radius: 40px;
    background: var(--surface-strong);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card);
}

.workspace[data-disabled] {
    opacity: 0.6;
    filter: grayscale(0.25);
}

.workspace__pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.workspace__pane h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

textarea {
    width: 100%;
    min-height: 280px;
    padding: 18px 20px;
    border-radius: 28px;
    border: 1px solid var(--border-soft);
    background: var(--surface-muted);
    font-size: 1rem;
    resize: vertical;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

textarea:focus {
    outline: none;
    border-color: rgba(255, 116, 201, 0.6);
    box-shadow: var(--focus-ring);
    background: var(--surface-strong);
}

textarea:disabled {
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-muted);
}

textarea::placeholder {
    color: var(--ink-muted);
}

/* Example dropdown */
.example-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: var(--surface-muted);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23231521' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    transition: border-color 180ms ease, box-shadow 180ms ease;
    margin-bottom: 12px;
}

.example-select:hover {
    border-color: var(--border-strong);
}

.example-select:focus {
    outline: none;
    border-color: rgba(255, 116, 201, 0.6);
    box-shadow: var(--focus-ring);
}

/* Example mode - greyed out content (still editable to allow clearing) */
textarea.example-mode {
    color: var(--ink-muted);
    background: var(--surface-muted);
}

.result-card__content.example-mode {
    opacity: 0.75;
}

.result-card__content.example-mode h4::after {
    content: " (Example)";
    font-weight: 400;
    color: var(--ink-muted);
    font-size: 0.85em;
}

.result-card__content.example-mode pre {
    color: var(--ink-muted);
}

.workspace__hint {
    font-size: 0.9rem;
    color: var(--ink-muted);
}

.result-card {
    min-height: 280px;
    border-radius: 32px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid rgba(111, 124, 255, 0.15);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card__placeholder {
    margin: 0;
    color: var(--ink-muted);
}

.result-card__content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card pre,
.chunk-card pre {
    margin: 0;
    font-family: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.result-card__chunks {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chunk-card {
    border-radius: 18px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(35, 21, 33, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chunk-card h5 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--ink);
}

.auth-user {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-user p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 500;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 14px 26px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--ghost-bg);
    color: var(--ink);
    box-shadow: var(--shadow-ghost);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn--primary {
    background-image: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 25px 40px rgba(255, 116, 201, 0.25);
}

.btn--primary:hover:not(:disabled) {
    transform: translateY(-1px);
    background-image: var(--accent-gradient-strong);
}

.btn--ghost {
    background: rgba(255, 255, 255, 0.65);
    color: var(--ink);
    border: 1px solid var(--border-soft);
}

.btn--ghost:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-ghost);
}

.btn--small {
    font-size: 0.85rem;
    padding: 8px 16px;
}

.badge {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    background: var(--accent-pill);
    color: var(--ink-strong);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.progress {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(111, 124, 255, 0.2);
    border-top-color: var(--accent-indigo);
    animation: spin 1s linear infinite;
}

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

.auth-error {
    color: #d32f2f;
    background: #fdedea;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #fadbd8;
    font-size: 0.9rem;
}

.auth-error p {
    color: #c62828;
    margin-bottom: 4px;
}

.auth-error ul {
    margin: 4px 0 0;
    padding-left: 20px;
    color: #c62828;
}

.auth-error li {
    margin-bottom: 2px;
}

.small {
    font-size: 0.85rem;
}

/* Mobile sidebar toggle button (visible when sidebar collapsed) */
.sidebar-toggle-mobile {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 20;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--surface-strong);
    box-shadow: var(--shadow-ghost);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--ink);
}

@media (max-width: 860px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(0);
        z-index: 100;
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }

    .sidebar-toggle-mobile {
        display: flex;
    }

    .sidebar.collapsed ~ .app-main .sidebar-toggle-mobile {
        display: flex;
    }

    .app-main {
        padding: 32px 14px;
        padding-top: 70px;
    }

    .hero {
        padding: 32px 18px;
    }

    .user-menu {
        position: relative;
        top: auto;
        left: auto;
        margin-bottom: 16px;
        justify-content: center;
    }

    .auth-block__content {
        flex-direction: column;
        align-items: stretch;
    }

    .workspace {
        padding: 20px;
        border-radius: 28px;
    }

    .workspace__pane textarea {
        min-height: 220px;
    }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 90;
}

.sidebar-overlay.visible {
    display: block;
}

/* ===================================
   Payment UI (Stripe-like)
   =================================== */

.payment-container {
    max-width: 380px;
    width: 100%;
    margin: 0 auto;
    padding: 32px;
    background: var(--surface-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    box-sizing: border-box;
}

.payment-header {
    text-align: center;
    margin-bottom: 28px;
}

.payment-stripe-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.payment-mock-badge {
    background: #6c757d;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.payment-sandbox-badge {
    background: #f59e0b;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stripe Elements container */
.stripe-element-container {
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stripe-element-container:focus-within {
    border-color: #635bff;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.1);
}

.payment-error {
    color: #fa755a;
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

.payment-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink-strong);
    margin: 0 0 10px 0;
}

.payment-amount {
    font-size: 36px;
    font-weight: 700;
    color: var(--ink-strong);
    margin: 0;
    letter-spacing: -1px;
}

.payment-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

.payment-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.payment-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
}

.payment-field input {
    width: 100%;
    padding: 14px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    font-size: 16px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    background: var(--surface);
    color: var(--ink-strong);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.payment-field input::placeholder {
    color: var(--ink-muted);
}

.payment-field input:focus {
    outline: none;
    border-color: #635bff;
    box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.15);
}

.payment-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 14px;
    width: 100%;
}

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

.payment-submit {
    margin-top: 10px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    background: #635bff;
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.payment-submit:hover {
    background: #5851db;
}

.payment-submit:active {
    transform: scale(0.98);
}

.payment-submit:disabled {
    background: #a5a2ff;
    cursor: not-allowed;
    transform: none;
}

.payment-hint {
    margin-top: 20px;
    font-size: 12px;
    color: var(--ink-muted);
    text-align: center;
    line-height: 1.5;
}

.payment-legal {
    margin-top: 12px;
    font-size: 11px;
    color: var(--ink-muted);
    text-align: center;
    line-height: 1.5;
}

.payment-legal a {
    color: var(--ink-soft);
    text-decoration: underline;
}

.payment-legal a:hover {
    color: var(--ink-strong);
}

.payment-cancel {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.payment-cancel:hover {
    background: var(--surface-muted);
    border-color: var(--border-strong);
}

/* Sign-in Invitation (for unauthenticated users after analysis) */
.signin-invitation {
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface-muted);
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    text-align: center;
}

.signin-invitation__title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    color: var(--ink-strong);
}

.signin-invitation__note {
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.signin-invitation__actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.signin-invitation__actions .gbutton-placeholder {
    min-height: auto;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-soft);
}

.app-footer__links {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.app-footer__links a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.app-footer__links a:hover {
    color: var(--accent-indigo);
    text-decoration: underline;
}

.app-footer__separator {
    color: var(--ink-muted);
    font-size: 0.85rem;
}

.app-footer__copy {
    margin: 0;
    font-size: 0.75rem;
    color: var(--ink-muted);
}
