﻿
        :root {
            --brand-green: #006633;
            --brand-orange: #cc6633;
            --bubble-w: 20cm;
            --bubble-min-h: 3cm;
            --bubble-max-h: 8cm;
            --bubble-radius: 10px;
            --glow-color: rgba(0, 0, 0, .04);
            --glow-size: 18px;
            --glow-spread: 5px;
            --history-side-pad: 0.6cm;
            --btn-dim: 1cm;
            --toolbar-h: 0.5cm;
            --new-top: 0.96cm;
            --new-height: 1.00cm;
            --new-width: 1.74cm;
            --new-font: 15pt;
            --chat-top-pad: 2.6cm;
            --bubble-vert-gap: 24px;
            --input-w: 100%;
            --input-top-gap: 0.3cm;
            --input-min-h: 1.2cm;
            --input-max-h: 6cm;
            --form-bottom: 5cm;
            --form-height: var(--bubble-min-h);
            --backgraund-color: #faf9f7;
            --primary-sidebar-width: 108px;
            --primary-sidebar-collapsed-width: 64px;
            --secondary-sidebar-width: 244px;
            --secondary-sidebar-collapsed-width: 64px;
            --sidebar-gap: 8px;
            --sidebar-transition: 0.26s cubic-bezier(0.4, 0, 0.2, 1);
            --current-primary-sidebar-width: var(--primary-sidebar-width);
            --current-secondary-sidebar-width: var(--secondary-sidebar-width);
            --current-sidebar-width: calc(var(--current-primary-sidebar-width) + var(--sidebar-gap) + var(--current-secondary-sidebar-width));
            --chat-left-shift: 72px;
            --chat-global-left-offset: 40px;
            --font-whitelist: Roboto, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
        }

        body.sidebar-collapsed {
            --current-primary-sidebar-width: var(--primary-sidebar-collapsed-width);
        }

        body.secondary-sidebar-collapsed {
            --current-secondary-sidebar-width: var(--secondary-sidebar-collapsed-width);
        }

        #chat-wrapper {
            margin-left: var(--current-sidebar-width);
            width: auto;
            max-width: none;
            display: none;
            flex-direction: column;
            align-items: stretch;
            padding: calc(var(--new-top) + var(--new-height) + 0.6cm) 0 calc(var(--form-bottom) + var(--form-height) + 0.5cm);
            transition: margin-left var(--sidebar-transition);
        }

        #contract-workspace,
        #draft-workspace,
        #contract-chat-wrapper,
        #draft-chat-wrapper,
        #contract-chat-form,
        #draft-chat-form {
            display: none;
        }

        #contract-chat-wrapper {
            margin-left: var(--current-sidebar-width);
            width: auto;
            max-width: none;
            display: none;
            flex-direction: column;
            align-items: stretch;
            padding: calc(var(--new-top) + var(--new-height) + 1.5cm) 0 calc(var(--form-bottom) + var(--form-height) + 0.5cm);
            transition: margin-left var(--sidebar-transition);
        }

        #draft-chat-wrapper {
            margin-left: var(--current-sidebar-width);
            width: auto;
            max-width: none;
            display: none;
            flex-direction: column;
            align-items: stretch;
            padding: calc(var(--new-top) + var(--new-height) + 1.5cm) 0 calc(var(--form-bottom) + var(--form-height) + 0.5cm);
            transition: margin-left var(--sidebar-transition);
        }

        #contract-workspace {
            margin-left: var(--current-sidebar-width);
            transition: margin-left var(--sidebar-transition);
            padding: calc(var(--new-top) + var(--new-height) + 0.8cm) 0 18px;
        }

        #draft-workspace {
            margin-left: var(--current-sidebar-width);
            transition: margin-left var(--sidebar-transition);
            padding: calc(var(--new-top) + var(--new-height) + 0.8cm) 0 18px;
        }

        #contract-chat-history {
            width: 90%;
            max-width: var(--bubble-w);
            margin: 0 auto;
            box-sizing: border-box;
            transform: translateX(calc(-1 * var(--chat-left-shift) * 0.35 - var(--chat-global-left-offset)));
        }

        #draft-chat-history {
            width: 90%;
            max-width: var(--bubble-w);
            margin: 0 auto;
            box-sizing: border-box;
            transform: translateX(calc(-1 * var(--chat-left-shift) * 0.35 - var(--chat-global-left-offset)));
        }

        #chat-history {
            width: 90%;
            max-width: var(--bubble-w);
            margin: 0 auto;
            box-sizing: border-box;
            transform: translateX(calc(-1 * var(--chat-left-shift) * 0.35 - var(--chat-global-left-offset)));
        }

        
        .chat-bubble.user {
            background-color: #ffffff;
            color: #111827;
            border: 1px solid rgba(0, 0, 0, 0.08);
            box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
            border-bottom-right-radius: 2px;
        }

        .chat-bubble.bot {
            background-color: #ffffff;
            color: #1f2937;
            border-bottom-left-radius: 2px;
            transform: translateX(-10px);
        }

        
        .chat-spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 2px solid rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            border-top-color: #006633;
            animation: spin 0.8s linear infinite;
            vertical-align: middle;
        }

        html, body {
            height: 100%;
        }

        body {
            background: var(--backgraund-color);
        }

        .chat-container {
            position: relative;
            width: 100%;
            min-height: 100vh;
            overflow: visible;
        }

        #particles-js {
            position: fixed;
            inset: 0;
            z-index: -1;
        }

        .chat-container > h3 {
            display: none;
        }

        .logo {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            font-family: var(--font-whitelist) !important;
            font-weight: 700;
            letter-spacing: 0.02em;
            color: #000;
            white-space: nowrap;
            transition: opacity .4s ease, transform .4s ease, left var(--sidebar-transition);
            user-select: none;
        }

        #hero-logo {
            display: inline-flex;
            gap: 13.3333px;
            align-items: baseline;
            justify-content: center;
            width: min(var(--bubble-w), calc(90vw - var(--current-sidebar-width)));
            max-width: calc(90vw - var(--current-sidebar-width));
            text-align: center;
            line-height: 66.6667px;
            letter-spacing: 1.33333px;
        }

        #hero-logo .brand {
            order: 1;
        }

        #hero-logo .zh {
            order: 2;
        }

        #hero-logo {
            bottom: calc(35vh + 8cm);
            font-size: 66.6667px;
            text-shadow: -7px 4px 13px rgba(0, 0, 0, .14);
            z-index: 5;
        }

        body.engaged #hero-logo {
            opacity: 0;
            pointer-events: none;
        }

        body.feature-contract #hero-logo {
            bottom: calc(35vh + 8cm);
        }

        #hero-logo .em {
            color: #006633;
        }

        #mini-logo {
            position: fixed;
            right: 1.5cm;
            bottom: 1cm;
            left: auto !important;
            transform: none !important;
            font-size: 21.3333px;
            line-height: 32px;
            letter-spacing: 0.426667px;
            opacity: 0;
            pointer-events: none;
            text-shadow: -7px 4px 13px rgba(0, 0, 0, .14);
            z-index: 9999;
        }

        #mini-logo .em {
            color: #006633;
        }

        body.engaged #mini-logo {
            opacity: 1;
            pointer-events: auto;
        }

        @media (max-width: 576px) {
            :root {
                --chat-left-shift: 0px;
            }

            #mini-logo {
                bottom: 2.6cm;
                right: 1.0cm;
            }

            #hero-logo {
                white-space: normal;
                display: inline-flex;
                flex-direction: column;
                align-items: flex-end;
                justify-content: flex-start;
                width: auto;
                max-width: none;
                text-align: right;
                bottom: calc(30vh + 8cm);
                gap: 13.3333px;
                line-height: 66.6667px;
            }

            #hero-logo .zh {
                order: 1;
            }

            #hero-logo .brand {
                order: 2;
            }
        }

        #chat-form {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            bottom: 35vh;
            width: var(--bubble-w);
            max-width: calc(90vw - var(--current-sidebar-width));
            min-height: var(--bubble-min-h);
            max-height: var(--bubble-max-h);
            background: #fff;
            border: 1px solid rgba(0, 0, 0, 0);
            border-radius: 10px;
            box-shadow: 0 0 18px 5px rgba(0, 0, 0, .04);
            padding: 0 0 var(--toolbar-h) 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            color: rgb(33, 37, 41);
            font-family: var(--font-whitelist);
            z-index: 30;
            transition: bottom .45s ease, height .2s, left var(--sidebar-transition), max-width var(--sidebar-transition);
        }

        #contract-chat-form,
        #draft-chat-form {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            bottom: 18vh;
            width: var(--bubble-w);
            max-width: calc(90vw - var(--current-sidebar-width));
            min-height: var(--bubble-min-h);
            max-height: var(--bubble-max-h);
            background: #fff;
            border: 1px solid rgba(0, 0, 0, 0);
            border-radius: 10px;
            box-shadow: 0 0 18px 5px rgba(0, 0, 0, .04);
            padding: 0 0 var(--toolbar-h) 0;
            color: rgb(33, 37, 41);
            font-family: var(--font-whitelist);
            z-index: 30;
            transition: opacity 0.25s ease, bottom .45s ease, left var(--sidebar-transition), max-width var(--sidebar-transition);
        }

        #contract-user-input.form-control,
        #draft-user-input.form-control {
            display: block;
            width: calc(100%) !important;
            min-height: var(--input-min-h) !important;
            max-height: var(--input-max-h) !important;
            padding-right: 6rem;
            border: none !important;
            box-shadow: none !important;
            background: transparent !important;
            outline: none;
            resize: none;
            overflow-y: auto;
            line-height: 1.5;
            white-space: pre-wrap;
            font-size: 1rem;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            bottom: var(--toolbar-h);
        }

        #contract-send-btn,
        #draft-send-btn,
        #contract-stop-btn,
        #draft-stop-btn {
            right: 16px;
        }

        #contract-review-btn {
            right: 16px;
        }

        #contract-send-btn {
            right: calc(16px + var(--btn-dim) + 12px);
        }

        #contract-send-btn::before,
        #draft-send-btn::before {
            content: "➔";
            font-size: 20px;
            line-height: 1;
            color: #fff;
            display: block;
        }

        #contract-review-btn::before {
            content: "✦";
            font-size: 18px;
            line-height: 1;
            color: #fff;
            display: block;
        }

        #contract-send-btn,
        #draft-send-btn,
        #contract-stop-btn,
        #draft-stop-btn {
            border: 1px solid rgba(0, 0, 0, .08);
            box-shadow: 0 0 10px rgba(0, 0, 0, .12);
            background: #006633;
            color: #fff;
        }

        #contract-review-btn {
            border: 1px solid rgba(0, 0, 0, .10);
            box-shadow: 0 0 12px rgba(0, 102, 51, .22);
            background: #00884a;
            color: #fff;
        }

        #contract-send-btn:hover,
        #draft-send-btn:hover,
        #contract-stop-btn:hover,
        #draft-stop-btn:hover {
            background: #005229;
            box-shadow: 0 0 14px rgba(0, 0, 0, .16);
        }

        #contract-review-btn:hover {
            background: #006633;
            box-shadow: 0 0 16px rgba(0, 102, 51, .3);
        }

        #contract-review-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        #contract-stop-btn,
        #draft-stop-btn {
            display: none;
        }

        #contract-stop-btn::before,
        #draft-stop-btn::before {
            content: "";
            width: 14px;
            height: 14px;
            background: #fff;
            border-radius: 3px;
            display: inline-block;
        }

        body.contract-running #contract-send-btn,
        body.contract-running #contract-review-btn {
            display: none !important;
        }

        body.contract-running #contract-stop-btn {
            display: inline-flex !important;
            animation: pulse 1.6s ease-in-out infinite;
        }

        body.draft-running #draft-send-btn {
            display: none !important;
        }

        body.draft-running #draft-stop-btn {
            display: inline-flex !important;
            animation: pulse 1.6s ease-in-out infinite;
        }

        
        .contract-docx-status {
            font-size: 0.875rem;
            color: #374151;
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: 10px;
            padding: 10px 14px;
            margin: 6px 0;
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .contract-docx-download-link {
            display: inline-block;
            padding: 5px 14px;
            background: #006633;
            color: #fff !important;
            border-radius: 6px;
            text-decoration: none !important;
            font-size: 0.85rem;
            font-weight: 500;
            transition: background 0.18s;
            white-space: nowrap;
        }
        .contract-docx-download-link:hover {
            background: #004d26;
        }

        
        #contract-mode-panel,
        #contract-reviewer-panel {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            bottom: 34vh;
            width: min(var(--bubble-w), calc(90vw - var(--current-sidebar-width)));
            max-height: 60vh;
            overflow-y: auto;
            background: rgba(255, 255, 255, 0.97);
            border: 1px solid rgba(0,0,0,0.06);
            border-radius: 16px;
            box-shadow: 0 8px 40px rgba(0,0,0,0.12);
            padding: 24px 28px 28px;
            z-index: 21;
            display: none;
            flex-direction: column;
            gap: 16px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.28s ease, left var(--sidebar-transition);
        }

        .crs-back-btn {
            align-self: flex-start;
            border: none;
            background: none;
            color: #64748b;
            font-size: 0.85rem;
            cursor: pointer;
            padding: 0;
            line-height: 1;
            transition: color 0.15s;
        }
        .crs-back-btn:hover { color: #006633; }

        .crs-panel-title {
            font-size: 1.1rem;
            font-weight: 700;
            color: #111827;
            margin: 0;
        }

        .crs-cards-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 14px;
        }

        .crs-card {
            border: 1.5px solid #bfdbfe;
            border-radius: 12px;
            background: #f0f7ff;
            padding: 18px 16px;
            cursor: pointer;
            transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .crs-card:hover:not(.crs-card-disabled) {
            border-color: #006633;
            background: #f0fdf4;
            box-shadow: 0 4px 18px rgba(0,102,51,0.13);
        }
        .crs-card-disabled {
            opacity: 0.45;
            cursor: not-allowed;
            border-color: #e2e8f0;
            background: #f8fafc;
        }
        .crs-card-icon {
            font-size: 22px;
            line-height: 1;
            color: #006633;
        }
        .crs-card-title {
            font-size: 0.95rem;
            font-weight: 600;
            color: #111827;
        }
        .crs-card-desc {
            font-size: 0.8rem;
            color: #475569;
            line-height: 1.45;
        }
        .crs-card-tag {
            margin-top: 4px;
            display: inline-block;
            font-size: 0.72rem;
            padding: 2px 8px;
            border-radius: 999px;
            background: #dbeafe;
            color: #1e40af;
            font-weight: 500;
            align-self: flex-start;
        }

        
        .crs-selected-mode-badge {
            display: inline-block;
            font-size: 0.82rem;
            padding: 3px 12px;
            border-radius: 999px;
            background: #dcfce7;
            color: #166534;
            font-weight: 600;
            align-self: flex-start;
        }
        .crs-reviewer-form {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .crs-field-label {
            font-size: 0.9rem;
            font-weight: 600;
            color: #374151;
        }
        .crs-required-mark { color: #dc2626; }
        .crs-reviewer-input {
            border: 1.5px solid #d1d5db;
            border-radius: 8px;
            padding: 9px 13px;
            font-size: 0.95rem;
            color: #111827;
            background: #fff;
            outline: none;
            transition: border-color 0.18s;
            width: 100%;
            box-sizing: border-box;
        }
        .crs-reviewer-input:focus { border-color: #006633; box-shadow: 0 0 0 3px rgba(0,102,51,0.1); }
        .crs-field-hint {
            font-size: 0.78rem;
            color: #94a3b8;
            margin: 0;
        }
        .crs-confirm-btn {
            align-self: flex-end;
            background: #006633;
            color: #fff;
            border: none;
            border-radius: 8px;
            padding: 10px 22px;
            font-size: 0.95rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.18s;
        }
        .crs-confirm-btn:hover { background: #004d26; }

        
        .crev-req-wrap {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }
        .crev-req-mode {
            font-size: 0.78rem;
            font-weight: 600;
            color: #006633;
            letter-spacing: 0.02em;
        }
        .crev-req-text {
            font-size: 0.95rem;
            color: #111827;
            white-space: pre-wrap;
            word-break: break-word;
        }
        .crev-req-reviewer {
            font-size: 0.78rem;
            color: #64748b;
        }

        
        .contract-revision-panel {
            width: min(var(--bubble-w), calc(100vw - var(--current-sidebar-width) - 24px));
            align-self: center;
            margin: 0 auto 12px;
        }
        .rev-layout-wrap {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        .rev-top-row {
            display: flex;
            gap: 12px;
            align-items: stretch;
        }
        .rev-req-box,
        .rev-download-box {
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            background: #fff;
            padding: 12px 14px;
            box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
        }
        .rev-req-box {
            flex: 7;
            min-width: 0;
        }
        .rev-download-box {
            flex: 3;
            min-width: 0;
            margin-top: 0;
        }
        .rev-req-title {
            font-size: 0.82rem;
            font-weight: 700;
            color: #166534;
            margin-bottom: 8px;
            letter-spacing: 0.02em;
        }
        .rev-req-content {
            font-size: 0.92rem;
            color: #1f2937;
            line-height: 1.6;
            white-space: pre-wrap;
            word-break: break-word;
        }
        .rev-detail-box {
            width: 100%;
            box-sizing: border-box;
            border: none;
            background: transparent;
            padding: 0;
        }
        .rev-detail-body {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .rev-detail-body > .chat-spinner:only-child {
            align-self: center;
            margin-top: 22px;
            margin-bottom: 4px;
        }
        .rev-plain-text {
            font-size: 0.92rem;
            color: #1f2937;
            line-height: 1.6;
        }
        .rev-output-wrap {
            display: flex;
            flex-direction: column;
            gap: 14px;
        }
        .rev-overall {
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: 10px;
            padding: 14px 16px;
        }
        .rev-overall-label {
            font-size: 0.78rem;
            font-weight: 700;
            color: #166534;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            margin-bottom: 6px;
        }
        .rev-overall-text {
            font-size: 0.92rem;
            color: #1f2937;
            line-height: 1.6;
            white-space: pre-wrap;
            word-break: break-word;
        }
        .rev-overall-author {
            margin-top: 8px;
            font-size: 0.78rem;
            color: #64748b;
            text-align: right;
        }
        .rev-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .rev-item {
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
        }
        .rev-item-fade {
            animation: revItemFadeIn 0.24s ease-out both;
        }
        .rev-item-body-fade {
            animation: revBodyFadeIn 0.2s ease-out both;
        }
        .rev-item-overall {
            background: #fff;
            border-color: #e2e8f0;
            border-left: none;
        }
        .rev-item-overall .rev-item-body {
            padding: 10px 14px;
        }
        .rev-item-clause {
            font-size: 0.75rem;
            font-weight: 600;
            color: #64748b;
            background: #f8fafc;
            padding: 4px 14px;
            border-bottom: 1px solid #e2e8f0;
        }
        .rev-item-body {
            padding: 10px 14px;
            display: flex;
            flex-direction: column;
            gap: 7px;
        }
        .rev-item-row {
            display: flex;
            gap: 10px;
            align-items: flex-start;
        }
        .rev-item-row-overall {
            align-items: stretch;
        }
        .rev-item-row-revised {
            background: transparent;
            border-radius: 0;
            margin: 0;
            border-top: 1px solid #166534;
            padding-top: 8px;
            margin-top: 2px;
        }
        .rev-item-label {
            flex-shrink: 0;
            font-size: 0.72rem;
            font-weight: 700;
            border-radius: 4px;
            padding: 2px 7px;
            margin-top: 1px;
            letter-spacing: 0.03em;
            min-width: 56px;
            text-align: center;
            line-height: 1.25;
        }
        .rev-item-label-orig { background: #f1f5f9; color: #334155; }
        .rev-item-label-rev  { background: #dcfce7; color: #166534; }
        .rev-item-label-note { background: #fef3c7; color: #92400e; }
        .rev-item-label-overall {
            background: #f1f5f9;
            color: #334155;
            min-width: 56px;
            width: 56px;
            padding: 6px 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            writing-mode: vertical-rl;
            text-orientation: upright;
            letter-spacing: 0.08em;
            line-height: 1.05;
        }
        .rev-item-text {
            font-size: 0.88rem;
            color: #1f2937;
            line-height: 1.55;
            white-space: pre-wrap;
            word-break: break-word;
        }
        .rev-item-text-orig { color: #334155; }
        .rev-item-text-rev  { color: #166534; font-weight: 500; }
        .rev-item-text-overall {
            color: #1f2937;
            padding-top: 1px;
        }
        .rev-item-author {
            font-size: 0.75rem;
            color: #94a3b8;
            text-align: right;
            padding-top: 4px;
        }

        @keyframes revItemFadeIn {
            from {
                opacity: 0;
                transform: translateY(6px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes revBodyFadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }

        
        .rev-download-area {
            margin-top: 6px;
            padding: 10px 14px;
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: 10px;
            font-size: 0.875rem;
            color: #374151;
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }
        .rev-download-box.rev-download-area {
            margin-top: 0;
            min-height: 100%;
            box-sizing: border-box;
        }
        @media (max-width: 900px) {
            .rev-top-row {
                flex-direction: column;
            }
            .rev-req-box,
            .rev-download-box {
                flex: 1 1 auto;
            }
        }

        .contract-upload-dropzone {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            bottom: calc(18vh + var(--bubble-min-h) + 30px);
            width: min(var(--bubble-w), calc(90vw - var(--current-sidebar-width)));
            min-height: clamp(140px, 24vh, 180px);
            border: 2px dashed #93c5fd;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.55);
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            gap: 8px;
            color: #334155;
            z-index: 20;
            cursor: pointer;
            transition: opacity 0.25s ease, border-color 0.2s ease, background-color 0.2s ease;
            padding: 20px;
            text-align: center;
        }

        .contract-upload-dropzone.drag-over {
            border-color: #2563eb;
            background: rgba(219, 234, 254, 0.6);
        }

        .contract-upload-title {
            font-size: 16px;
            font-weight: 600;
            color: #1e3a8a;
        }

        .contract-upload-desc {
            font-size: 13px;
            color: #64748b;
        }

        .contract-upload-status {
            margin-top: 10px;
            font-size: 12px;
            color: #475569;
            width: 100%;
            max-width: 560px;
        }

        .contract-upload-status .contract-status-text {
            text-align: center;
            color: #64748b;
        }

        .contract-upload-status .contract-file-pill {
            display: flex;
            align-items: center;
            gap: 10px;
            border-radius: 10px;
            border: 1px solid #bfdbfe;
            background: #eff6ff;
            padding: 10px 12px;
            text-align: left;
        }

        .contract-upload-status .contract-file-icon {
            width: 28px;
            height: 28px;
            border-radius: 8px;
            background: #dbeafe;
            color: #1d4ed8;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            font-size: 16px;
        }

        .contract-upload-status .contract-file-main {
            min-width: 0;
            flex: 1;
        }

        .contract-upload-status .contract-file-name {
            font-size: 13px;
            color: #1e3a8a;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .contract-upload-status .contract-file-meta {
            margin-top: 2px;
            color: #475569;
        }

        .contract-upload-status.is-error .contract-file-pill {
            border-color: #fecaca;
            background: #fef2f2;
        }

        .contract-upload-status.is-error .contract-file-icon {
            background: #fee2e2;
            color: #dc2626;
        }

        .contract-upload-status.is-error .contract-file-name,
        .contract-upload-status.is-error .contract-file-meta,
        .contract-upload-status.is-error .contract-status-text {
            color: #991b1b;
        }

        .contract-upload-status.is-success .contract-status-text {
            display: none;
        }

        .contract-clear-upload-btn {
            margin-top: 10px;
            border: 1px solid #cbd5e1;
            background: #ffffff;
            color: #475569;
            border-radius: 999px;
            font-size: 12px;
            line-height: 1;
            padding: 7px 12px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .contract-clear-upload-btn:hover {
            border-color: #94a3b8;
            color: #334155;
            background: #f8fafc;
        }

        .draft-upload-pill {
            border: 1px solid #bfd4f2;
            border-radius: 12px;
            background: #eef4ff;
            padding: 10px 10px 8px;
        }

        .draft-upload-summary {
            color: #1e3a8a;
            font-size: 12px;
            font-weight: 700;
            line-height: 1.4;
        }

        .draft-upload-hint {
            margin-top: 2px;
            color: #64748b;
            font-size: 11px;
            line-height: 1.35;
        }

        .draft-upload-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
            gap: 8px;
            margin-top: 8px;
            max-height: 190px;
            overflow-y: auto;
            padding-right: 2px;
        }

        .draft-upload-item {
            min-height: 68px;
            height: 68px;
            border: 1px solid #b9cbeb;
            border-radius: 8px;
            background: #ffffff;
            padding: 6px;
            display: flex;
            flex-direction: column;
            gap: 4px;
            font-size: 11px;
            overflow: hidden;
            position: relative;
        }

        .draft-upload-remove-btn {
            position: absolute;
            right: 4px;
            top: 4px;
            width: 18px;
            height: 18px;
            border: 1px solid #cbd5e1;
            border-radius: 999px;
            background: #ffffff;
            color: #64748b;
            font-size: 13px;
            line-height: 1;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            z-index: 2;
        }

        .draft-upload-remove-btn:hover {
            color: #b91c1c;
            border-color: #fca5a5;
            background: #fef2f2;
        }

        .draft-upload-item > span {
            min-width: 0;
        }

        .draft-upload-index {
            font-weight: 700;
            color: #1e3a8a;
            white-space: nowrap;
            word-break: keep-all;
            font-size: 11px;
            padding-right: 22px;
        }

        .draft-upload-name {
            color: #334155;
            display: -webkit-box;
            line-clamp: 2;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
            word-break: break-all;
            line-height: 1.3;
            flex: 1;
        }

        .draft-upload-meta {
            color: #64748b;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 10px;
            white-space: nowrap;
            line-height: 1.2;
        }

        #draft-upload-grid {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            bottom: calc(18vh + var(--bubble-min-h) + 30px);
            width: min(var(--bubble-w), calc(90vw - var(--current-sidebar-width)));
            display: none;
            grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
            gap: 14px;
            z-index: 20;
        }

        #draft-upload-grid .contract-upload-dropzone {
            position: relative;
            left: auto;
            bottom: auto;
            transform: none;
            width: 100%;
            min-height: clamp(132px, 22vh, 172px);
            margin: 0;
            display: flex;
        }

        #draft-upload-dropzone-style .contract-upload-title {
            font-size: 14px;
            line-height: 1.35;
            max-width: 100%;
            word-break: break-word;
        }

        #draft-upload-dropzone-style .contract-upload-desc {
            font-size: 12px;
            line-height: 1.35;
            max-width: 100%;
            word-break: break-word;
        }

        .draft-word-action {
            width: 100%;
            margin-top: 2px;
        }

        .draft-sent-files-bubble {
            margin-top: 6px;
            opacity: 0.95;
        }

        .draft-sent-files-wrap {
            display: flex;
            flex-direction: column;
            gap: 6px;
            width: 100%;
        }

        .draft-sent-files-title {
            font-size: 12px;
            font-weight: 700;
            color: #14532d;
        }

        .draft-sent-files-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .draft-sent-file-item {
            display: grid;
            grid-template-columns: minmax(54px, auto) minmax(0, 1fr);
            gap: 8px;
            align-items: start;
            font-size: 12px;
        }

        .draft-sent-file-tag {
            background: #dcfce7;
            border: 1px solid #86efac;
            color: #166534;
            border-radius: 999px;
            padding: 2px 8px;
            line-height: 1.3;
            font-weight: 700;
            white-space: nowrap;
        }

        .draft-sent-file-name {
            color: #14532d;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            display: block;
        }

        .draft-sent-file-meta {
            color: #166534;
            font-size: 11px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            display: block;
        }

        .draft-word-btn {
            width: 100%;
            border: 1px solid #9dd8b9;
            background: #f0fdf4;
            color: #166534;
            border-radius: 10px;
            padding: 10px 12px;
            font-size: 0.92rem;
            font-weight: 600;
            cursor: pointer;
            text-align: center;
            transition: background-color 0.2s ease, border-color 0.2s ease;
        }

        .draft-word-btn:hover {
            background: #dcfce7;
            border-color: #86efac;
        }

        .contract-word-btn {
            width: 100%;
            border: 1px solid #9dd8b9;
            background: #f0fdf4;
            color: #166534;
            border-radius: 10px;
            padding: 10px 12px;
            font-size: 0.92rem;
            font-weight: 600;
            cursor: pointer;
            text-align: center;
            transition: background-color 0.2s ease, border-color 0.2s ease;
        }

        .contract-word-btn:hover {
            background: #dcfce7;
            border-color: #86efac;
        }

        body.feature-contract #chat-wrapper,
        body.feature-contract #chat-form,
        body.feature-contract #draft-chat-wrapper,
        body.feature-contract #draft-chat-form,
        body.feature-contract #draft-workspace,
        body.feature-contract .ask-mode-wrap,
        body.feature-contract .btn-upload-file,
        body.feature-contract #contract-send-btn,
        body.feature-contract #contract-stop-btn,
        body.feature-contract #contract-review-btn {
            display: none !important;
        }

        body.feature-contract #contract-workspace {
            display: block;
        }

        body.feature-contract .contract-upload-dropzone {
            display: flex;
        }

        
        body.feature-contract #contract-mode-panel,
        body.feature-contract #contract-reviewer-panel {
            display: flex;
        }

        
        body.feature-contract.contract-step-mode #contract-mode-panel,
        body.feature-contract.contract-step-reviewer #contract-reviewer-panel {
            opacity: 1;
            pointer-events: auto;
        }

        body.feature-contract.contract-step-mode .contract-upload-dropzone,
        body.feature-contract.contract-step-reviewer .contract-upload-dropzone,
        body.feature-contract.contract-step-reviewer #contract-mode-panel {
            opacity: 0;
            pointer-events: none;
        }

        
        body.feature-contract.contract-step-mode #hero-logo,
        body.feature-contract.contract-step-reviewer #hero-logo,
        body.feature-contract.contract-step-mode #mini-logo,
        body.feature-contract.contract-step-reviewer #mini-logo {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        body.feature-contract.contract-step-mode #contract-chat-form,
        body.feature-contract.contract-step-reviewer #contract-chat-form {
            opacity: 0;
            pointer-events: none;
        }

        
        body.feature-contract.contract-engaged #hero-logo {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        body.feature-contract.contract-engaged #mini-logo {
            opacity: 1 !important;
            pointer-events: auto !important;
        }

        body.feature-contract.contract-engaged #ai-warning,
        body.feature-contract.contract-running #ai-warning,
        body.feature-contract.contract-running #mini-logo {
            opacity: 1;
            pointer-events: auto;
        }

        body.engaged:not(.contract-step-mode):not(.contract-step-reviewer) #mini-logo,
        body.engaged:not(.contract-step-mode):not(.contract-step-reviewer) #ai-warning {
            opacity: 1 !important;
            pointer-events: auto !important;
        }

        body.feature-contract.contract-engaged #contract-workspace {
            display: none !important;
        }

        body.feature-contract.contract-engaged #contract-chat-form {
            display: none !important;
        }

        
        body.feature-contract.contract-engaged #bottom-mask {
            display: block;
            height: calc((2.05cm + var(--bubble-min-h)) / 2);
        }

        
        body.feature-contract.contract-step-mode #contract-workspace,
        body.feature-contract.contract-step-reviewer #contract-workspace {
            display: none !important;
        }

        body.feature-contract.contract-step-mode #contract-chat-form,
        body.feature-contract.contract-step-reviewer #contract-chat-form {
            display: none !important;
        }

        
        body.feature-contract #contract-chat-history .chat-bubble {
            max-width: 100%;
            width: 100%;
            margin-left: 0 !important;
            margin-right: 0 !important;
            box-sizing: border-box;
        }

        body.feature-contract #contract-chat-history .chat-bubble.user {
            align-self: stretch !important;
            background: #f1f5f9;
            color: #334155;
            border: 1px solid #e2e8f0;
        }

        body.feature-contract #contract-chat-history .chat-bubble.bot {
            align-self: stretch !important;
            transform: none;
            margin-left: 0 !important;
        }

        body.feature-contract #contract-chat-wrapper {
            display: block;
        }

        body.feature-contract #contract-chat-form {
            display: flex !important;
        }

        body.feature-contract #contract-review-btn {
            display: inline-flex !important;
        }

        body.feature-draft #chat-wrapper,
        body.feature-draft #chat-form,
        body.feature-draft #contract-chat-wrapper,
        body.feature-draft #contract-chat-form,
        body.feature-draft #contract-workspace,
        body.feature-draft #contract-mode-panel,
        body.feature-draft #contract-reviewer-panel {
            display: none !important;
        }

        body.feature-draft #draft-chat-wrapper,
        body.feature-draft #draft-workspace {
            display: block;
        }

        body.feature-draft #draft-chat-form {
            display: flex !important;
        }

        body.feature-draft.draft-followup-qa #chat-form {
            display: flex !important;
        }

        body.feature-draft.draft-followup-qa #draft-chat-form {
            display: none !important;
        }

        body.feature-draft.draft-followup-qa #chat-form .btn-upload-file {
            display: none !important;
        }

        body.feature-draft #draft-chat-form {
            bottom: 18vh;
        }

        body.feature-draft.draft-engaged #hero-logo {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        body.feature-draft.draft-logo-shifted:not(.draft-engaged) #hero-logo {
            transform: translateX(-50%) translateY(calc(-1 * var(--draft-logo-shift, 0px)));
        }

        body.feature-draft.draft-engaged #draft-upload-grid {
            display: none !important;
        }

        body.feature-draft.draft-engaged #draft-chat-form {
            bottom: 2.05cm;
        }

        body.feature-draft .contract-upload-dropzone {
            display: none;
        }

        body.feature-draft #draft-upload-grid {
            display: grid;
        }

        @media (max-width: 576px) {
            #chat-form {
                bottom: 30vh;
            }
        }

        body.engaged #chat-form {
            bottom: 2.05cm;
        }

        body.engaged {
            --form-bottom: 2.05cm;
        }

        .input-group {
            width: 100%;
        }

        #user-input.form-control {
            display: block;
            width: calc(100%) !important;
            min-height: var(--input-min-h) !important;
            max-height: var(--input-max-h) !important;
            padding-right: 6rem;
            border: none !important;
            box-shadow: none !important;
            background: transparent !important;
            outline: none;
            resize: none;
            overflow-y: auto;
            line-height: 1.5;
            white-space: pre-wrap;
            font-size: 1rem;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            bottom: var(--toolbar-h);

        }

        #chat-form {
            position: fixed;
        }

        #user-input.form-control {
            position: absolute;
        }

        .chat-action-btn {
            position: absolute;
            bottom: 16px;
            width: var(--btn-dim);
            height: var(--btn-dim);
            border-radius: 50% !important;
            border: 1px solid rgba(0, 0, 0, .08);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            font-size: 0;
            box-shadow: 0 0 10px rgba(0, 0, 0, .12);
            z-index: 31;
            background: #006633;
            color: #fff;
            cursor: pointer;
            transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
        }

        .chat-action-btn:hover {
            transform: scale(1.05);
            background-color: #005229;
            box-shadow: 0 0 14px rgba(0, 0, 0, .16);
        }

        .ask-mode-wrap {
            position: absolute;
            top: 10px;
            right: 14px;
            z-index: 33;
        }

        .ask-mode-select {
            height: 28px;
            border-radius: 999px;
            border: 1px solid #d1d5db;
            background: #fff;
            color: #374151;
            font-size: 12px;
            padding: 0 10px;
            outline: none;
        }

        .ask-mode-select:focus {
            border-color: #2563eb;
        }

        .btn-upload-file {
            width: var(--btn-dim);
            height: var(--btn-dim);
            padding: 0;
            background: transparent !important;
            color: #9ca3af !important;
            border: none !important;
            border-radius: 50% !important;
            box-shadow: none !important;
        }

        .btn-upload-file:hover {
            transform: none;
            background: transparent !important;
            color: #6b7280 !important;
        }

        .btn-upload-file svg {
            width: 20px;
            height: 20px;
            display: block;
        }

        .btn-upload-file .upload-clip-icon {
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
            transform: translate(0.6px, -0.2px);
        }

        #send-btn, #stop-btn {
            right: 16px;
        }

        .btn-upload-file {
            left: auto;
            right: calc(16px + var(--btn-dim) + 12px);
            bottom: 16px;
        }

        #send-btn::before {
            content: "➔";
            font-size: 20px;
            line-height: 1;
            color: #fff;
            display: block;
        }

        body.running #send-btn {
            display: none !important;
        }

        #stop-btn {
            display: none;
        }

        #stop-btn::before {
            content: "";
            width: 14px;
            height: 14px;
            background: #fff;
            border-radius: 3px;
            display: inline-block;
        }

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

            50% {
                transform: scale(1.05);
            }
        }

        body.running #stop-btn {
            display: inline-flex;
            animation: pulse 1.6s ease-in-out infinite;
        }
        
        
        #ocr-loading-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 9999;
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column;
        }

        #ocr-loading-content {
            background: white;
            padding: 24px 40px;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 16px;
        }

        .ocr-spinner {
            width: 32px;
            height: 32px;
            border: 3px solid #f3f3f3;
            border-top: 3px solid var(--brand-green);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

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

        .reset-btn {
            position: fixed;
            top: var(--new-top);
            left: calc((100vw + var(--current-sidebar-width)) / 2 - min((90vw - var(--current-sidebar-width)) / 2, var(--bubble-w) / 2));
            width: var(--new-width);
            height: var(--new-height);
            background: #cccccc !important;
            color: #ffffff !important;
            border: none !important;
            border-radius: 10px !important;
            box-shadow: none !important;
            font-family: var(--font-whitelist);
            font-weight: 700;
            font-size: var(--new-font);
            line-height: 1;
            display: none !important;
            z-index: 40;
            transition: left 0.3s ease;
        }

        body.engaged .reset-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        #ai-warning {
            position: fixed;
            left: calc((100vw + var(--current-sidebar-width)) / 2 - var(--chat-left-shift) - var(--chat-global-left-offset));
            transform: translateX(-50%);
            bottom: 1cm;
            color: #bdbdbd;
            font-size: 15px;
            opacity: 0;
            pointer-events: none;
            transition: opacity .4s ease, transform .4s ease, left 0.3s ease;
            z-index: 9999;
            user-select: none;
        }

        body.engaged #ai-warning {
            opacity: 1;
            pointer-events: auto;
        }

        #top-mask {
            position: fixed;
            left: 0;
            right: 0;
            top: 0;
            height: calc(var(--new-top) + var(--new-height));
            background: var(--backgraund-color);
            z-index: 24;
            pointer-events: none;
            display: none;
        }

        body.engaged #top-mask {
            display: block;
        }

        #bottom-mask {
            position: fixed;
            left: 0;
            right: 0;
            bottom: 0;
            height: calc(var(--form-bottom) + var(--form-height));
            background: var(--backgraund-color);
            z-index: 24;
            pointer-events: none;
            display: none;
        }

        body.engaged #bottom-mask {
            display: block;
        }

        body.engaged #chat-wrapper {
            display: block;
        }

        #chat-history {
            padding: 12px 16px;
            position: static;
            width: 100%;
            background: transparent;
            box-shadow: none;
            display: flex;
            flex-direction: column;
            gap: 0;
        }

        .chat-bubble {
            background: #ffffff;
            border-radius: var(--bubble-radius);
            box-shadow: 0 0 var(--glow-size) var(--glow-spread) var(--glow-color);
            padding: 16px 20px;
            margin: var(--bubble-vert-gap) 0;
            width: fit-content;
            max-width: 95%;
            word-break: break-word;
        }

        .chat-bubble.user {
            white-space: pre-wrap;
            margin-left: auto;
            margin-right: 0;
            max-width: min(88%, calc(var(--bubble-w) - 1.2cm));
        }

        .chat-bubble.bot {
            white-space: normal;
            margin-left: 0;
            margin-right: auto;
            transform: none;
            max-width: min(88%, calc(var(--bubble-w) - 1.2cm));
        }

        .chat-bubble.bot > *:last-child {
            margin-bottom: 5px;
        }

        .chat-bubble.bot p {
            padding: 16px 20px;
        }

        .bot {
            align-self: flex-start;
            font-size: 1rem;
        }

        .user {
            align-self: flex-end;
        }

        .time-info {
            font-size: 0.9em;
            color: #aaa;
            margin: 4px 0;
            width: auto;
        }

        .chat-bubble pre {
            background: #f6f8fa;
            padding: 15px;
            border-radius: 8px;
            overflow: auto;
        }

        .chat-bubble code {
            background: #f6f8fa;
            padding: 4px 6px;
            border-radius: 4px;
        }

        .chat-bubble ul, .chat-bubble ol {
            padding-left: 2em;

        }

        #loading {
            display: none !important;
        }

        
        * {
            scrollbar-width: thin;
            scrollbar-color: transparent transparent;
        }
        *:hover {
            scrollbar-color: rgba(0,0,0,0.22) transparent;
        }
        *::-webkit-scrollbar {
            width: 5px;
            height: 5px;
        }
        *::-webkit-scrollbar-track {
            background: transparent;
        }
        *::-webkit-scrollbar-thumb {
            background: transparent;
            border-radius: 3px;
        }
        *:hover::-webkit-scrollbar-thumb {
            background: rgba(0,0,0,0.22);
        }

        :root {
            --sidebar-bg: #f9fafb;
            --sidebar-border: #e5e7eb;
            --sidebar-text: #374151;
            --sidebar-hover: #e6f3ec;
            --sidebar-active-bg: #d7efe3;
            --sidebar-active-text: #006633;
        }

        #primary-sidebar {
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            width: var(--current-primary-sidebar-width);
            background: #edf7f1;
            border-right: 1px solid #d7e9df;
            display: flex;
            flex-direction: column;
            z-index: 930;
            transition: width var(--sidebar-transition);
            box-shadow: 1px 0 8px rgba(0, 0, 0, 0.04);
        }

        .primary-sidebar-header {
            min-height: 64px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-bottom: 1px solid #d7e9df;
            padding: 8px 8px 8px 10px;
            gap: 6px;
        }

        .top-user-entry {
            position: fixed;
            top: 14px;
            right: 16px;
            z-index: 980;
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            min-width: 128px;
            max-width: 220px;
            border-radius: 999px;
            border: 1px solid #cfe8da;
            background: rgba(255, 255, 255, 0.94);
            box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
            backdrop-filter: blur(6px);
            cursor: pointer;
            transform: none;
            transition: box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
        }

        .top-user-entry:hover {
            transform: none;
            box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
        }

        .top-user-entry .user-avatar {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: #d7efe3;
            color: #006633;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: 600;
            flex-shrink: 0;
        }

        .top-user-entry .user-details {
            min-width: 0;
            display: flex;
            flex-direction: column;
        }

        .top-user-entry .user-name {
            font-size: 12px;
            line-height: 1.15;
            color: #111827;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .top-user-entry .user-status {
            font-size: 10px;
            color: #6b7280;
            line-height: 1.15;
            white-space: nowrap;
        }

        
        .primary-sidebar-logo {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
            width: 34px;
            height: 34px;
            border-radius: 6px;
            transition: transform 0.15s, background 0.15s;
            cursor: pointer;
        }

        .primary-sidebar-logo:hover {
            transform: scale(1.05);
            background: rgba(0, 102, 51, 0.08);
        }

        .primary-sidebar-logo .logo-letter {
            font-size: 18px;
            font-weight: 800;
            color: #006633;
            line-height: 1;
            font-family: 'Inter', sans-serif;
            user-select: none;
        }

        

        .primary-sidebar-content {
            flex: 1;
            padding: 12px 8px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .primary-feature-item {
            border: 1px solid transparent;
            background: transparent;
            color: #374151;
            border-radius: 10px;
            min-height: 42px;
            padding: 8px 10px;
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            width: 100%;
            transition: all 0.2s;
        }

        .primary-feature-item:hover {
            background: #e6f5ed;
        }

        .primary-feature-item.active {
            background: #d7efe3;
            color: #006633;
            border-color: #b7dfca;
            font-weight: 600;
        }

        .primary-feature-icon {
            width: 15px;
            height: 15px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .primary-feature-text {
            font-size: 13px;
            white-space: nowrap;
        }

        body.sidebar-collapsed .primary-feature-item {
            justify-content: center;
            padding: 8px;
        }

        body.sidebar-collapsed .primary-feature-text {
            display: none;
        }

        @media (max-width: 576px) {
            .top-user-entry {
                top: 10px;
                right: 10px;
                min-width: 42px;
                max-width: 42px;
                padding: 6px;
                justify-content: center;
            }

            .top-user-entry .user-details {
                display: none;
            }
        }

        #app-sidebar {
            position: fixed;
            top: 8px;
            left: calc(var(--current-primary-sidebar-width) + var(--sidebar-gap));
            bottom: 8px;
            width: var(--current-secondary-sidebar-width);
            background: var(--sidebar-bg);
            border-right: 1px solid var(--sidebar-border);
            display: flex;
            flex-direction: column;
            z-index: 900;
            transition: left var(--sidebar-transition), width var(--sidebar-transition);
            box-shadow: 4px 0 16px rgba(15, 23, 42, 0.06);
            font-family: var(--font-whitelist);
            border-radius: 12px;
            overflow: hidden;
        }

        .secondary-sidebar-toggle {
            position: absolute;
            top: 14px;
            right: 10px;
            z-index: 12;
        }

        #app-sidebar.collapsed .secondary-sidebar-toggle {
            right: 50%;
            transform: translateX(50%);
        }

        .feature-panel {
            display: none;
            height: 100%;
            width: 100%;
            flex-direction: column;
        }

        .feature-panel.active {
            display: flex;
        }

        .feature-empty-panel {
            margin: 18px;
            border: 1px dashed #cbd5e1;
            border-radius: 12px;
            background: #f8fafc;
            padding: 18px 14px;
            color: #475569;
        }

        .feature-empty-title {
            font-size: 14px;
            font-weight: 600;
            color: #1e293b;
            margin-bottom: 6px;
        }

        .feature-empty-desc {
            font-size: 12px;
            line-height: 1.5;
        }

        #app-sidebar.collapsed {
            width: var(--secondary-sidebar-collapsed-width);
        }

        .sidebar-header {
            height: 64px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            padding: 0 14px;
            border-bottom: 1px solid var(--sidebar-border);
            column-gap: 8px;
        }

        .secondary-title {
            font-size: 13px;
            font-weight: 600;
            color: #334155;
            letter-spacing: 0.01em;
        }

        #app-sidebar.collapsed .secondary-title {
            display: none;
        }

        .user-profile {
            display: flex;
            align-items: center;
            overflow: hidden;
            white-space: nowrap;
            cursor: pointer;
            padding: 6px 10px 6px 4px;
            border-radius: 999px;
            transition: background 0.2s, color 0.2s;
            flex: 1;
            min-width: 0;
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: #d7efe3;
            color: #006633;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            flex-shrink: 0;
            margin-right: 10px;
        }

        .user-details {
            display: flex;
            flex-direction: column;
            transition: opacity 0.2s;
        }

        #app-sidebar.collapsed .user-details,
        #app-sidebar.collapsed .sidebar-title-text,
        #app-sidebar.collapsed .session-title,
        #app-sidebar.collapsed .sidebar-footer-text,
        #app-sidebar.collapsed .new-chat-text {
            display: none;
        }

        #app-sidebar.collapsed .sidebar-header {
            padding: 0;
            justify-content: center;
        }

        #app-sidebar.collapsed .user-profile {
            display: none;
        }

        .user-name {
            font-size: 14px;
            font-weight: 600;
            color: #111827;
        }

        .user-status {
            font-size: 11px;
            color: #6b7280;
        }

        .user-profile:hover {
            background: #e5e7eb;
        }

        .sidebar-toggle-btn {
            background: transparent;
            border: none;
            cursor: pointer;
            color: #6b7280;
            padding: 4px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-left: auto;
        }

        #app-sidebar.collapsed .sidebar-toggle-btn {
            margin-left: 0;
        }

        .sidebar-toggle-btn:hover {
            background: #e5e7eb;
            color: #111827;
        }

        .sidebar-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px 12px;
        }

        #app-sidebar.collapsed .sidebar-content {
            padding: 16px 6px;
        }

        .new-chat-btn {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 10px 12px;
            background: #ffffff;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            color: #374151;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s;
            margin-bottom: 20px;
            white-space: nowrap;
        }
        .new-chat-btn:hover {
            background: #f3f4f6;
            border-color: #d1d5db;
        }

        #app-sidebar.collapsed .new-chat-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            padding: 0;
            margin: 0 auto 20px auto;
        }

        .sidebar-section-title {
            font-size: 12px;
            color: #9ca3af;
            margin-bottom: 8px;
            padding-left: 8px;
            font-weight: 600;
            text-transform: uppercase;
        }

        .sidebar-section-title-spaced {
            margin-top: 20px;
        }

        #app-sidebar.collapsed .sidebar-section-title {
            display: none;
        }

        .session-item {
            display: flex;
            align-items: center;
            padding: 10px 12px;
            border-radius: 8px;
            cursor: pointer;
            color: #4b5563;
            font-size: 13px;
            transition: all 0.2s;
            margin-bottom: 4px;
        }

        .session-item:hover {
            background: var(--sidebar-hover);
            color: #111827;
        }

        .session-item.active {
            background: var(--sidebar-active-bg);
            color: var(--sidebar-active-text);
        }

        .session-icon {
            margin-right: 10px;
            flex-shrink: 0;
        }

        #app-sidebar.collapsed .session-item {
            justify-content: center;
            padding: 8px 0;
        }

        #app-sidebar.collapsed .session-icon {
            margin-right: 0;
        }

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

        .session-delete {
            opacity: 0;
            border: none;
            background: transparent;
            color: #9ca3af;
            font-size: 14px;
            padding: 2px;
            cursor: pointer;
            margin-left: 4px;
        }
        
        .session-edit {
            opacity: 0;
            border: none;
            background: transparent;
            color: #9ca3af;
            font-size: 14px;
            padding: 2px;
            cursor: pointer;
            margin-left: 4px;
        }

        .session-item:hover .session-delete,
        .session-item:hover .session-edit {
            opacity: 1;
        }

        .session-delete:hover {
            color: #ef4444;
        }

        .session-edit:hover {
            color: #006633;
        }

        #app-sidebar.collapsed .session-delete,
        #app-sidebar.collapsed .session-edit {
            display: none;
        }

        
        .session-rename-input {
            flex: 1;
            min-width: 0;
            font-size: 13px;
            padding: 1px 5px;
            border: 1px solid #006633;
            border-radius: 4px;
            background: #fff;
            color: #111827;
            outline: none;
            height: 22px;
            line-height: 1;
        }

        
        .session-rename-confirm {
            opacity: 1;
            border: none;
            background: transparent;
            color: #006633;
            font-size: 14px;
            padding: 2px;
            cursor: pointer;
            margin-left: 4px;
        }

        .session-rename-confirm:hover {
            color: #004d26;
        }

        .sidebar-footer {
            padding: 16px;
            border-top: 1px solid var(--sidebar-border);
        }

        #app-sidebar.collapsed .sidebar-footer {
            padding: 16px 8px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
        }

        .sidebar-footer-btn {
            width: 100%;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 12px;
            border: none;
            background: transparent;
            color: #4b5563;
            font-size: 14px;
            cursor: pointer;
            border-radius: 6px;
            transition: background 0.2s;
        }

        .sidebar-footer-btn:hover {
            background: #fee2e2;
            color: #ef4444;
        }

        #app-sidebar.collapsed .sidebar-footer-btn {
            justify-content: center;
            padding: 8px;
            width: auto;
        }

        .sidebar-version {
            margin-top: 8px;
            font-size: 11px;
            color: #9ca3af;
            text-align: center;
            line-height: 1.6;
            white-space: nowrap;
        }

        #app-sidebar.collapsed .sidebar-version {
            display: none;
        }

        .sidebar-version a {
            color: #006633;
            text-decoration: none;
            margin: 0 4px;
            display: inline-block;
        }

        .sidebar-version a:hover {
            color: #005229;
        }

        @media (min-width: 768px) {
            
            

            .user-info-panel {
                position: fixed;
                top: 0;
                bottom: 0;
                left: var(--current-sidebar-width);
                right: 0;
                display: none;
                overflow-y: auto;
                background: transparent;
                padding: calc(var(--new-top) + var(--new-height) + 0.6cm) 0 calc(var(--form-bottom) + var(--form-height) + 2cm);
                z-index: 10000;
            }
        }

        @media (max-width: 767.98px) {
            .user-info-panel {
                max-width: 100vw;
                margin: 0;
                padding: calc(var(--new-top) + var(--new-height) + 0.6cm) 12px calc(var(--form-bottom) + var(--form-height) + 2cm);
                display: none;
                background: transparent;
                position: fixed;
                inset: 0;
                z-index: 10000;
            }
        }

        .user-info-card {
            background: #ffffff;
            border-radius: 16px;
            box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
            max-width: 680px;
            margin: 0 auto;
            transform: translateX(calc(-1 * var(--chat-left-shift) * 0.35 - var(--chat-global-left-offset)));
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-height: 420px;
            max-height: calc(100vh - 120px);
        }

        
        .uip-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 18px 24px 14px;
            border-bottom: 1px solid #f0f0f0;
            flex-shrink: 0;
        }
        .uip-header-title {
            font-size: 17px;
            font-weight: 600;
            color: #111827;
        }
        .uip-close-btn {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            border-radius: 8px;
            cursor: pointer;
            color: #6b7280;
            transition: background 0.15s, color 0.15s;
        }
        .uip-close-btn:hover {
            background: #f3f4f6;
            color: #111827;
        }

        
        .uip-body {
            display: flex;
            flex: 1;
            min-height: 0;
        }

        
        .uip-tabs {
            width: 148px;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            padding: 12px 0 12px 12px;
            border-right: 1px solid #f0f0f0;
            gap: 2px;
        }
        .uip-tab {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 14px;
            border: none;
            background: transparent;
            border-radius: 10px;
            font-size: 13.5px;
            font-weight: 500;
            color: #6b7280;
            cursor: pointer;
            transition: background 0.15s, color 0.15s;
            text-align: left;
            white-space: nowrap;
        }
        .uip-tab:hover {
            background: #f5f5f5;
            color: #374151;
        }
        .uip-tab.active {
            background: #f0faf5;
            color: #006633;
            font-weight: 600;
        }
        .uip-tab-icon {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
        }

        
        .uip-content {
            flex: 1;
            padding: 20px 24px;
            overflow-y: auto;
            min-height: 0;
        }
        .uip-tab-pane {
            display: none;
        }
        .uip-tab-pane.active {
            display: block;
        }
        .uip-section-title {
            font-size: 15px;
            font-weight: 600;
            color: #111827;
            margin-bottom: 14px;
        }

        #recharge-options-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 12px;
        }

        
        .uip-agreement-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .uip-agreement-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 14px;
            background: #f9fafb;
            border: 1px solid #e5e7eb;
            border-radius: 10px;
            text-decoration: none;
            color: #374151;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s;
        }
        .uip-agreement-item:hover {
            background: #f0faf5;
            border-color: #b7dfca;
            color: #006633;
        }
        .uip-agreement-icon {
            width: 20px;
            height: 20px;
            flex-shrink: 0;
            color: #006633;
        }
        .uip-agreement-text {
            flex: 1;
        }

        
        @media (max-width: 767.98px) {
            .user-info-card {
                border-radius: 0;
                max-width: 100%;
                min-height: 100%;
                max-height: 100%;
                transform: none;
                box-shadow: none;
            }
            .uip-body {
                flex-direction: column;
            }
            .uip-tabs {
                width: 100%;
                flex-direction: row;
                padding: 8px 12px;
                border-right: none;
                border-bottom: 1px solid #f0f0f0;
                gap: 4px;
                overflow-x: auto;
            }
            .uip-tab {
                padding: 8px 12px;
                font-size: 13px;
            }
            .uip-content {
                padding: 16px;
            }
            #recharge-options-container {
                grid-template-columns: 1fr;
            }
        }

        .user-info-field {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 32px;
            margin-bottom: 16px;
            font-size: 14px;
            color: #4b5563;
        }

        .user-info-label {
            color: #6b7280;
        }

        .user-info-value {
            font-weight: 500;
            color: #111827;
        }

        .user-info-recharge-btn {
            width: 100%;
            padding: 14px 16px;
            background: #f9fafb;
            color: #111827;
            border: 1px solid #e5e7eb;
            border-radius: 10px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            text-align: left;
            transition: background 0.2s, border-color 0.2s, transform 0.1s;
        }

        .user-info-recharge-btn:hover {
            background: #f0faf5;
            border-color: #b7dfca;
        }

        .user-info-recharge-btn:active {
            opacity: 0.9;
        }

        .user-info-hint {
            font-size: 12px;
            color: #9ca3af;
            line-height: 1.6;
            margin: -8px 0 4px;
        }

        
        .account-actions {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-top: 8px;
        }

        .account-action-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            width: 100%;
            padding: 11px 14px;
            background: #f9fafb;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            color: #374151;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s;
            text-align: left;
        }
        .account-action-btn:hover {
            background: #f3f4f6;
            border-color: #d1d5db;
        }
        .account-action-icon {
            font-size: 16px;
            width: 22px;
            text-align: center;
            flex-shrink: 0;
        }
        .account-action-text {
            flex: 1;
        }
        .account-action-arrow {
            color: #9ca3af;
            font-size: 18px;
            font-weight: 300;
        }
        .account-action-btn-danger {
            color: #dc2626;
            border-color: #fecaca;
            background: #fef2f2;
        }
        .account-action-btn-danger:hover {
            background: #fee2e2;
            border-color: #fca5a5;
        }

        
        .account-sub-panel {
            margin-top: 16px;
            padding: 18px;
            background: #f9fafb;
            border: 1px solid #e5e7eb;
            border-radius: 12px;
        }
        .account-sub-title {
            font-size: 15px;
            font-weight: 600;
            color: #111827;
            margin-bottom: 6px;
        }
        .account-sub-hint {
            font-size: 12px;
            color: #9ca3af;
            margin-bottom: 14px;
        }
        .account-step-label {
            font-size: 13px;
            font-weight: 600;
            color: #006633;
            margin-bottom: 10px;
            padding-bottom: 6px;
            border-bottom: 1px solid #e5e7eb;
        }
        .account-form-group {
            margin-bottom: 12px;
        }
        .account-form-group label {
            display: block;
            font-size: 13px;
            font-weight: 500;
            color: #4b5563;
            margin-bottom: 5px;
        }
        .account-input {
            width: 100%;
            padding: 9px 12px;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            font-size: 14px;
            color: #111827;
            background: #fff;
            transition: border-color 0.15s, box-shadow 0.15s;
            outline: none;
            font-family: inherit;
        }
        .account-input:focus {
            border-color: #006633;
            box-shadow: 0 0 0 2px rgba(0,102,51,0.12);
        }
        .account-sms-row {
            display: flex;
            gap: 8px;
        }
        .account-sms-row .account-input {
            flex: 1;
        }
        .account-sms-btn {
            padding: 9px 14px;
            background: #e6f5ed;
            color: #006633;
            border: 1px solid #b7dfca;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            white-space: nowrap;
            transition: background 0.15s;
            flex-shrink: 0;
        }
        .account-sms-btn:hover {
            background: #d7efe3;
        }
        .account-sms-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }
        .account-btn-row {
            display: flex;
            gap: 8px;
            margin-top: 14px;
        }
        .account-cancel-btn {
            flex: 1;
            padding: 10px 0;
            background: #fff;
            border: 1px solid #d1d5db;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            color: #374151;
            cursor: pointer;
            transition: background 0.15s;
        }
        .account-cancel-btn:hover {
            background: #f3f4f6;
        }
        .account-submit-btn {
            flex: 1;
            padding: 10px 0;
            background: #006633;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            transition: background 0.15s;
        }
        .account-submit-btn:hover {
            background: #00884a;
        }
        .account-submit-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }
        .account-danger-btn {
            flex: 1;
            padding: 10px 0;
            background: #dc2626;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 600;
            color: #fff;
            cursor: pointer;
            transition: background 0.15s;
        }
        .account-danger-btn:hover {
            background: #b91c1c;
        }
        .account-danger-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        
        .account-warning-box {
            display: flex;
            gap: 10px;
            padding: 12px 14px;
            background: #fffbeb;
            border: 1px solid #fde68a;
            border-radius: 8px;
            margin-bottom: 14px;
        }
        .account-warning-icon {
            font-size: 18px;
            color: #d97706;
            flex-shrink: 0;
            line-height: 1.4;
        }
        .account-warning-text {
            font-size: 13px;
            color: #92400e;
            line-height: 1.6;
        }
        .account-danger-box {
            display: flex;
            gap: 10px;
            padding: 12px 14px;
            background: #fef2f2;
            border: 1px solid #fecaca;
            border-radius: 8px;
            margin-bottom: 14px;
        }
        .account-danger-box .account-warning-text {
            color: #991b1b;
        }

        
        .account-deletion-banner {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 14px;
            background: #fef2f2;
            border: 1px solid #fecaca;
            border-radius: 8px;
            margin-bottom: 12px;
        }
        .deletion-banner-icon {
            font-size: 18px;
            color: #dc2626;
            flex-shrink: 0;
        }
        .deletion-banner-text {
            flex: 1;
            font-size: 13px;
            color: #991b1b;
            line-height: 1.4;
        }
        .deletion-banner-text strong {
            display: block;
            font-size: 14px;
            margin-bottom: 2px;
        }
        .deletion-banner-cancel-btn {
            padding: 6px 14px;
            background: #fff;
            border: 1px solid #fca5a5;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 600;
            color: #dc2626;
            cursor: pointer;
            white-space: nowrap;
            transition: background 0.15s;
            flex-shrink: 0;
        }
        .deletion-banner-cancel-btn:hover {
            background: #fef2f2;
        }

        body.show-user-panel #chat-form {
            display: none !important;
        }

        body.show-user-panel #contract-chat-wrapper,
        body.show-user-panel #contract-chat-form,
        body.show-user-panel #contract-workspace,
        body.show-user-panel #contract-mode-panel,
        body.show-user-panel #contract-reviewer-panel {
            display: none !important;
        }

        body.show-user-panel #draft-chat-wrapper,
        body.show-user-panel #draft-chat-form,
        body.show-user-panel #draft-workspace,
        body.show-user-panel #draft-upload-grid {
            display: none !important;
        }

        body.show-user-panel #user-info-panel {
            display: block;
            background: rgba(250, 249, 247, 0.94);
        }

        body.show-user-panel #hero-logo,
        body.show-user-panel #mini-logo,
        body.show-user-panel #ai-warning,
        body.show-user-panel .reset-btn,
        body.show-user-panel #top-mask,
        body.show-user-panel #bottom-mask,
        body.show-user-panel #loading {
            display: none;
        }

        .mobile-topbar,
        .mobile-sidebar-backdrop {
            display: none;
        }

        @media (max-width: 767.98px) {
            body {
                --current-primary-sidebar-width: 0px;
                --current-secondary-sidebar-width: 0px;
                --current-sidebar-width: 0px;
                --chat-left-shift: 0px;
                --chat-global-left-offset: 0px;
            }

            .top-user-entry {
                display: flex;
                top: 11px;
                right: 12px;
                left: auto;
                transform: none;
                width: 34px;
                min-width: 34px;
                max-width: 34px;
                height: 34px;
                padding: 0;
                border-radius: 50%;
                justify-content: center;
                z-index: 992;
                transition: none;
                box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
            }

            .top-user-entry:hover {
                transform: none;
                box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
            }

            .top-user-entry .user-details {
                display: none;
            }

            .top-user-entry .user-avatar {
                margin-right: 0;
                width: 24px;
                height: 24px;
                font-size: 11px;
            }

            .mobile-topbar-title {
                display: none;
            }

            .mobile-topbar {
                justify-content: flex-start;
                gap: 8px;
            }

            #mobile-secondary-toggle {
                margin-left: 0;
                z-index: 993;
            }

            .mobile-topbar {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                height: 56px;
                display: flex;
                align-items: center;
                justify-content: flex-start;
                gap: 8px;
                padding: 0 12px;
                background: #ffffff;
                border-bottom: 1px solid #e5e7eb;
                box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
                z-index: 990;
            }

            .mobile-topbar-title {
                font-size: 15px;
                font-weight: 600;
                color: #111827;
            }

            .mobile-topbar-btn {
                width: 34px;
                height: 34px;
                border: 1px solid #d1d5db;
                border-radius: 8px;
                background: #ffffff;
                color: #374151;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                font-size: 16px;
                line-height: 1;
                cursor: pointer;
            }

            .mobile-sidebar-backdrop {
                position: fixed;
                inset: 0;
                display: block;
                background: rgba(0, 0, 0, 0.35);
                opacity: 0;
                pointer-events: none;
                transition: opacity 0.2s ease;
                z-index: 945;
            }

            body.mobile-open-primary .mobile-sidebar-backdrop,
            body.mobile-open-secondary .mobile-sidebar-backdrop {
                opacity: 1;
                pointer-events: auto;
            }

            #primary-sidebar,
            #app-sidebar {
                top: 0;
                bottom: 0;
                left: 0;
                border-radius: 0;
                transform: translateX(-110%);
                transition: transform 0.24s ease;
                box-shadow: 6px 0 24px rgba(15, 23, 42, 0.18);
            }

            #primary-sidebar {
                width: min(32vw, 136px);
                max-width: 136px;
                z-index: 960;
            }

            #app-sidebar {
                width: min(46vw, 210px);
                max-width: 210px;
                z-index: 970;
            }

            #app-sidebar.collapsed {
                width: min(46vw, 210px);
                max-width: 210px;
            }

            #app-sidebar.collapsed .user-details,
            #app-sidebar.collapsed .sidebar-title-text,
            #app-sidebar.collapsed .session-title,
            #app-sidebar.collapsed .sidebar-footer-text,
            #app-sidebar.collapsed .new-chat-text,
            #app-sidebar.collapsed .sidebar-section-title {
                display: initial;
            }

            #app-sidebar.collapsed .new-chat-btn {
                width: 100%;
                height: auto;
                border-radius: 8px;
                padding: 10px 12px;
                margin: 0 0 20px 0;
            }

            #app-sidebar.collapsed .session-item {
                justify-content: flex-start;
                padding: 9px 10px;
            }

            body.mobile-open-primary #primary-sidebar {
                transform: translateX(0);
            }

            body.mobile-open-secondary #app-sidebar {
                transform: translateX(0);
            }

            #primary-sidebar .primary-sidebar-header,
            #app-sidebar .sidebar-header {
                min-height: 56px;
            }

            #chat-wrapper,
            #contract-chat-wrapper,
            #draft-chat-wrapper,
            #contract-workspace,
            #draft-workspace {
                margin-left: 0;
                width: 100%;
                padding-top: 66px;
                padding-left: 10px;
                padding-right: 10px;
            }

            #chat-history,
            #contract-chat-history,
            #draft-chat-history {
                width: 100%;
                max-width: 100%;
                transform: none;
                padding-left: 6px;
                padding-right: 6px;
            }

            .chat-bubble {
                max-width: 96%;
                padding: 12px 14px;
                margin: 10px 0;
            }

            .chat-bubble.bot {
                transform: none;
            }

            #chat-form,
            #contract-chat-form,
            #draft-chat-form {
                left: 10px;
                right: 10px;
                transform: none;
                width: auto;
                max-width: none;
                bottom: calc(env(safe-area-inset-bottom, 0px) + 164px);
                border-radius: 14px;
                max-height: 52vh;
                min-height: 92px;
                padding-bottom: 56px;
            }

            body.feature-draft #draft-chat-form {
                bottom: calc(env(safe-area-inset-bottom, 0px) + 164px);
            }

            body.feature-draft.draft-engaged #draft-chat-form {
                bottom: calc(env(safe-area-inset-bottom, 0px) + 150px);
            }

            .contract-upload-dropzone {
                bottom: calc(env(safe-area-inset-bottom, 0px) + 164px + 92px + 24px);
                min-height: clamp(120px, 22vh, 160px);
                transition: bottom .45s ease;
            }

            #draft-upload-grid {
                left: 10px;
                right: 10px;
                width: auto;
                transform: none;
                bottom: calc(env(safe-area-inset-bottom, 0px) + 164px + 92px + 24px);
                gap: 10px;
                transition: bottom .45s ease;
            }

            #draft-upload-grid .contract-upload-dropzone {
                min-height: clamp(112px, 18vh, 150px);
                padding: 14px 10px;
            }

            #draft-upload-dropzone-style .contract-upload-title,
            #draft-upload-dropzone-case .contract-upload-title {
                font-size: 13px;
            }

            #draft-upload-dropzone-style .contract-upload-desc,
            #draft-upload-dropzone-case .contract-upload-desc {
                font-size: 11px;
            }

            body.engaged #chat-form {
                bottom: calc(env(safe-area-inset-bottom, 0px) + 150px);
            }

            #user-input.form-control,
            #contract-user-input.form-control,
            #draft-user-input.form-control {
                left: 12px;
                right: 12px;
                width: auto !important;
                transform: none;
                min-height: 56px !important;
                max-height: 150px !important;
                bottom: 8px;
                font-size: 16px;
                line-height: 1.45;
                padding-right: 5.2rem;
            }

            .chat-action-btn {
                bottom: 10px;
                width: 42px;
                height: 42px;
            }

            #send-btn,
            #stop-btn,
            #contract-send-btn,
            #contract-stop-btn,
            #draft-send-btn,
            #draft-stop-btn {
                right: 10px;
            }

            #contract-review-btn {
                right: calc(10px + 42px + 8px);
            }

            .btn-upload-file {
                right: calc(10px + 42px + 8px);
                width: 42px;
                height: 42px;
                bottom: 10px;
            }

            #hero-logo {
                top: 27vh;
                bottom: auto;
                left: 50%;
                transform: translateX(-50%);
                transform-origin: center top;
                display: inline-flex;
                flex-direction: column;
                align-items: flex-end;
                text-align: right;
                gap: 4px;
                white-space: normal;
                font-size: clamp(66px, 18.8vw, 76px);
                line-height: clamp(66px, 18.8vw, 76px);
                letter-spacing: 1.33333px;
                text-shadow: -9px 5px 16px rgba(0, 0, 0, .22);
            }

            #hero-logo .zh {
                order: 1;
                font-size: 0.92em;
                line-height: 0.92;
                letter-spacing: 0.02em;
                text-shadow: -9px 5px 16px rgba(0, 0, 0, .22);
            }

            #hero-logo .brand {
                order: 2;
                text-shadow: -9px 5px 16px rgba(0, 0, 0, .22);
            }

            body.engaged #hero-logo {
                opacity: 0;
                transform: translateX(-50%) translateY(-10px);
            }

            #ai-warning {
                bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
                z-index: 34;
                pointer-events: auto;
                font-size: 12px;
            }

            #mini-logo {
                right: 12px;
                bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
                font-size: 16px;
                line-height: 20px;
                letter-spacing: 0.2px;
            }

            body.feature-draft.draft-engaged #mini-logo,
            body.feature-contract.contract-engaged #mini-logo {
                opacity: 1 !important;
                pointer-events: auto !important;
            }

            .law-sidebar {
                right: -100%;
                width: 100%;
                max-width: 100%;
                border-left: none;
            }

            .law-sidebar.open {
                right: 0;
            }
        }

        #global-toast {
            position: fixed;
            top: 16px;
            left: 50%;
            transform: translateX(-50%);
            padding: 8px 16px;
            background: rgba(17, 24, 39, 0.9);
            color: #ffffff;
            font-size: 13px;
            border-radius: 999px;
            box-shadow: 0 10px 25px rgba(15, 23, 42, 0.3);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
            z-index: 10100;
            white-space: nowrap;
        }

        #auth-modal-overlay,
        #confirm-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.35);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 10050;
        }

        .auth-modal {
            width: 380px;
            max-width: 92vw;
            background: #ffffff;
            border-radius: 16px;
            box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
            overflow: hidden;
        }

        .auth-modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px;
            border-bottom: 1px solid #f3f4f6;
            background: #ffffff;
        }

        .auth-modal-title {
            font-size: 16px;
            font-weight: 600;
            color: #111827;
            flex: 1;
            text-align: center;
        }

        .auth-header-btn {
            border: none;
            background: transparent;
            cursor: pointer;
            font-size: 18px;
            line-height: 1;
            padding: 2px 6px;
            color: #9ca3af;
        }

        .auth-header-btn:hover {
            color: #4b5563;
        }

        #auth-modal-back {
            visibility: hidden;
        }

        .auth-modal-body {
            font-size: 14px;
            color: #111827;
            padding: 18px 20px 20px;
        }

        .auth-input-group {
            margin-bottom: 10px;
        }

        .auth-label {
            display: block;
            margin-bottom: 6px;
            font-size: 13px;
            color: #4b5563;
            padding: 2px 4px;
        }

        .auth-input {
            width: 100%;
            height: 38px;
            padding: 0 12px;
            border-radius: 999px;
            border: 1px solid #e5e7eb;
            background: #f9fafb;
            font-size: 14px;
            outline: none;
        }

        .auth-input:focus {
            border-color: #006633;
            background: #ffffff;
            box-shadow: 0 0 0 1px rgba(0, 102, 51, 0.14);
        }

        .auth-row {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .auth-row .auth-input {
            flex: 1;
            width: auto;
        }

        .auth-sms-btn {
            height: 38px;
            min-width: 120px;
            white-space: nowrap;
            padding: 0 16px;
            border-radius: 999px;
            border: 1px solid #006633;
            background: #006633;
            color: #ffffff;
            font-size: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .auth-sms-btn:disabled {
            border-color: #d1d5db;
            color: #9ca3af;
            background: #f9fafb;
            cursor: not-allowed;
        }

        .auth-sms-btn:not(:disabled):hover {
            background: #005229;
            color: #ffffff;
        }

        .auth-primary-btn {
            width: 100%;
            padding: 10px;
            border-radius: 999px;
            border: none;
            background: #006633;
            color: #ffffff;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            box-shadow: 0 12px 24px rgba(0, 102, 51, 0.24);
        }

        .auth-primary-btn:disabled {
            background: #9ca3af;
            box-shadow: none;
            cursor: not-allowed;
        }

        .auth-icon-btn {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            border: 1px solid #b7dfca;
            background: #006633;
            color: #ffffff;
            font-size: 16px;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 8px 16px rgba(0, 102, 51, 0.2);
            flex-shrink: 0;
        }

        .auth-icon-btn:not(:disabled):hover {
            background: #005229;
            transform: translateY(-1px);
        }

        .auth-icon-btn:disabled {
            background: #9ca3af;
            box-shadow: none;
            cursor: not-allowed;
        }

        .confirm-modal-footer {
            margin-top: 0;
            padding: 0 20px 20px;
            display: flex;
            justify-content: space-between;
            gap: 10px;
        }

        .confirm-modal-footer .auth-secondary-btn,
        .confirm-modal-footer .auth-primary-btn {
            flex: 1;
            width: auto;
        }

        .auth-secondary-btn {
            padding: 8px 16px;
            border-radius: 999px;
            border: 1px solid #e5e7eb;
            background: #f9fafb;
            color: #4b5563;
            font-size: 13px;
            cursor: pointer;
        }

        .auth-secondary-btn:hover {
            background: #f3f4f6;
        }

        .auth-agreement {
            position: relative;
            margin-top: 12px;
            padding-top: 12px;
            font-size: 12px;
            color: #6b7280;
            text-align: center;
        }

        .auth-agreement::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 1px;
            background-color: #e5e7eb;
        }

        .auth-agreement a {
            color: #006633;
            text-decoration: none;
            margin: 0 2px;
        }

        .auth-agreement a:hover {
            text-decoration: underline;
        }

        .auth-agreement.auth-agreement-compact {
            margin-top: 8px;
            padding-top: 8px;
            font-size: 12px;
        }

        .auth-consent {
            margin-top: 2px;
            margin-bottom: 10px;
            display: flex;
            align-items: flex-start;
            gap: 8px;
            font-size: 13px;
            color: #4b5563;
            line-height: 1.5;
            cursor: pointer;
        }

        .auth-consent input[type="checkbox"] {
            width: 16px;
            height: 16px;
            margin-top: 2px;
            accent-color: #006633;
            cursor: pointer;
            flex: 0 0 auto;
        }

        .auth-consent a {
            color: #006633;
            text-decoration: none;
            margin: 0 2px;
        }

        .auth-consent a:hover {
            text-decoration: underline;
        }

        .auth-agreement.auth-agreement-user-panel {
            display: none; 
        }

        .auth-agreement-link {
            color: #006633;
            text-decoration: none;
        }

        .auth-agreement-link:hover {
            text-decoration: underline;
        }

        .auth-agreement-sep {
            margin: 0 8px;
            color: #d1d5db;
        }

        .auth-secondary-text {
            margin-top: 10px;
            font-size: 12px;
            color: #6b7280;
            text-align: center;
        }

        .auth-link {
            color: #006633;
            cursor: pointer;
        }

        .auth-link:hover {
            color: #005229;
            text-decoration: underline;
        }

        .auth-step {
            display: none;
        }

        .auth-step.active {
            display: block;
        }

        #file-upload,
        #contract-file-upload,
        #draft-file-upload,
        #draft-case-file-upload,
        #draft-style-file-upload {
            display: none;
        }

        #contract-clear-upload-btn,
        #stop-btn,
        #contract-stop-btn,
        #draft-stop-btn,
        #contract-review-btn {
            display: none;
        }

        .spinner {
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 0.8s linear infinite;
            vertical-align: middle;
        }

        .loading-spinner {
            width: 40px;
            height: 40px;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #006633;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

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

        
        .law-sidebar {
            position: fixed;
            top: 0;
            right: -450px;
            width: 450px;
            height: 100%;
            background: white;
            box-shadow: -4px 0 15px rgba(0,0,0,0.1);
            z-index: 10010;
            transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
            border-left: 1px solid #e5e7eb;
        }
        .law-sidebar.open {
            right: 0;
        }
        .law-sidebar-header {
            padding: 16px 20px;
            border-bottom: 1px solid #e5e7eb;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #ffffff;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        }
        .law-sidebar-header h3 {
            margin: 0;
            font-size: 16px;
            font-weight: 600;
            color: #111827;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .law-sidebar-close {
            background: none;
            border: none;
            font-size: 24px;
            line-height: 1;
            cursor: pointer;
            color: #6b7280;
            padding: 4px;
            border-radius: 4px;
            transition: all 0.2s;
        }
        .law-sidebar-close:hover {
            color: #111827;
            background: #f3f4f6;
        }
        .law-sidebar-content {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            background: #f9fafb;
        }
        .law-article {
            margin-bottom: 16px;
            padding: 16px;
            background: white;
            border-radius: 8px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
            border: 1px solid #e5e7eb;
            font-size: 14px;
            line-height: 1.6;
            color: #374151;
            transition: all 0.3s;
        }
        .law-article.highlight {
            background-color: #fffbeb;
            border-color: #fcd34d;
            box-shadow: 0 4px 6px -1px rgba(251, 191, 36, 0.1), 0 2px 4px -1px rgba(251, 191, 36, 0.06);
            transform: scale(1.02);
        }
        .law-link {
            color: #006633;
            cursor: pointer;
            font-weight: 500;
            padding: 0 2px;
            border-radius: 2px;
            transition: all 0.2s;
            text-decoration: underline;
            text-underline-offset: 2px;
        }
        .law-link:hover {
            color: #005229;
            background: #e6f5ed;
        }
        .law-loading {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100px;
            color: #6b7280;
        }
        .law-error {
            text-align: center;
            color: #ef4444;
            padding: 20px;
            background: #fee2e2;
            border-radius: 8px;
            font-size: 14px;
        }

        
        .ref-law-collapse {
            margin-top: 6px;
            margin-bottom: 4px;
            border-radius: var(--bubble-radius, 16px);
            background: #ffffff;
            box-shadow: 0 0 var(--glow-size, 6px) var(--glow-spread, 0px) var(--glow-color, rgba(0,0,0,0.06));
            overflow: hidden;
            width: fit-content;
            max-width: min(88%, calc(var(--bubble-w, 700px) - 1.2cm));
            box-sizing: border-box;
        }
        .ref-law-collapse-header {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            cursor: pointer;
            user-select: none;
            font-size: 0.82rem;
            color: #6b7280;
            font-weight: 500;
            transition: background 0.15s;
        }
        .ref-law-collapse-header:hover {
            background: #f9fafb;
        }
        .ref-law-collapse-arrow {
            display: inline-block;
            width: 14px;
            height: 14px;
            flex-shrink: 0;
            transition: transform 0.25s ease;
            transform: rotate(0deg);
        }
        .ref-law-collapse.open .ref-law-collapse-arrow {
            transform: rotate(90deg);
        }
        .ref-law-collapse-body {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
            padding: 0 16px;
        }
        .ref-law-collapse.open .ref-law-collapse-body {
            max-height: 999999px;
            padding: 0 16px 12px;
        }
        .ref-law-collapse-content {
            color: #9ca3af;
            font-size: 0.82rem;
            line-height: 1.7;
            white-space: pre-wrap;
            word-break: break-word;
        }
        
        .ref-law-collapse-content .law-link {
            text-decoration: none;
            font-weight: 500;
            color: #006633;
        }
        .ref-law-collapse-content .law-link::before {
            content: '';
            display: inline-block;
            width: 12px;
            height: 12px;
            margin-right: 2px;
            vertical-align: -1px;
            background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23006633'%3E%3Cpath d='M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zM7.414 15.414a2 2 0 11-2.828-2.828l3-3a2 2 0 012.828 0 1 1 0 001.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 005.656 5.656l1.5-1.5a1 1 0 00-1.414-1.414l-1.5 1.5z'/%3E%3C/svg%3E") center/contain no-repeat;
        }
        .ref-law-collapse-content .law-link:hover {
            background: #e6f5ed;
            border-radius: 2px;
        }
        
        .ref-law-collapse-content .ref-law-dup-name {
            display: none;
        }
        
        body.feature-contract .ref-law-collapse {
            max-width: 100%;
            margin-left: 0;
            margin-right: 0;
        }
        body.feature-contract #contract-chat-history .ref-law-collapse {
            transform: none;
        }

        #payment-qr-modal.payment-qr-modal {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.35);
            align-items: center;
            justify-content: center;
            z-index: 10001;
        }

        .payment-qr-content {
            background: #fff;
            border-radius: 16px;
            box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
            max-width: 320px;
            text-align: center;
            padding: 30px;
            animation: modalPop 0.3s ease-out;
        }

        .payment-qr-body {
            margin-bottom: 20px;
        }

        .payment-qr-title {
            font-size: 18px;
            color: #333;
            margin-bottom: 10px;
            font-weight: 600;
        }

        .payment-qr-box {
            margin: 20px auto;
            width: 200px;
            height: 200px;
            background: #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .payment-qr-img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        .payment-qr-tip {
            color: #666;
            font-size: 14px;
            margin: 0;
        }

        .payment-qr-actions {
            display: flex;
            gap: 15px;
            justify-content: center;
            margin-top: 25px;
        }

        .payment-qr-close {
            padding: 8px 28px;
            border: none;
            background: #1890ff;
            color: #fff;
            border-radius: 18px;
            cursor: pointer;
            box-shadow: 0 4px 10px rgba(24, 144, 255, 0.3);
            transition: all 0.2s;
            font-size: 14px;
        }

        .payment-qr-close:hover {
            filter: brightness(0.96);
        }

        @keyframes modalPop {
            from {
                transform: scale(0.95);
                opacity: 0.7;
            }

            to {
                transform: scale(1);
                opacity: 1;
            }
        }

        
        .contract-scroll-spacer {
            display: none;
            height: 55vh;
            flex-shrink: 0;
            pointer-events: none;
            user-select: none;
        }

        body.feature-contract.contract-engaged .contract-scroll-spacer,
        body.feature-contract.contract-running .contract-scroll-spacer {
            display: block;
        }
    
