 :root,
        [data-theme="light"] {
            --bg: #ffffff;
            --petroleo: #0a3147;
            --ouro-velho: #b8860b;
            --gold-soft: rgba(184, 134, 11, 0.15);
            --gold-ghost: rgba(184, 134, 11, 0.06);
            --gold-border: rgba(184, 134, 11, 0.25);
            --transition: 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
            --white-soft: #f8f6f2;
            --text-muted: #40515e;
            --navy-card: rgba(10, 49, 71, 0.03);
            --shadow-copper: 0 8px 32px rgba(184, 134, 11, 0.08);
            --shadow-elevated: 0 4px 20px rgba(0, 0, 0, 0.05);
            --border-subtle: rgba(184, 134, 11, 0.12);
            --border-medium: rgba(184, 134, 11, 0.25);
            --success: #4caf50;
            --danger: #b54a4a;
            --compliance-color: #40515e;
            --legal-bg: rgba(10, 49, 71, 0.02);
            --input-bg: rgba(255, 255, 255, 0.6);
            --modal-bg: rgba(255, 255, 255, 0.9);
            --overlay-bg: rgba(10, 49, 71, 0.7);
            --login-bg: rgba(255, 255, 255, 0.85);
            --login-box-bg: rgba(255, 255, 255, 0.7);
            --tag-bg: rgba(255, 255, 255, 0.6);
            --font-heading: 'Cinzel', serif;
            --font-subtitle: 'Marcellus', serif;
            --theme-toggle-border: #b8860b;
            --theme-toggle-bg: transparent;
            --storage-bar-bg: rgba(184, 134, 11, 0.08);
            --storage-bar-fill: #b8860b;
            --tag-border-alpha: rgba(184, 134, 11, 0.08);
            --tag-border-hover-alpha: rgba(184, 134, 11, 0.22);
            --editor-bg: #fefdfa;
            --editor-toolbar-bg: #faf8f3;
            --editor-border: rgba(184, 134, 11, 0.18);
        }

        [data-theme="dark"] {
            --bg: #0B1A2F;
            --petroleo: #EAE4D9;
            --ouro-velho: #C87A4F;
            --gold-soft: rgba(200, 122, 79, 0.15);
            --gold-ghost: rgba(200, 122, 79, 0.08);
            --gold-border: rgba(200, 122, 79, 0.3);
            --transition: 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
            --white-soft: #EAE4D9;
            --text-muted: #a0b2c0;
            --navy-card: #102A43;
            --shadow-copper: 0 8px 32px rgba(200, 122, 79, 0.08);
            --shadow-elevated: 0 4px 20px rgba(0, 0, 0, 0.15);
            --border-subtle: rgba(200, 122, 79, 0.12);
            --border-medium: rgba(200, 122, 79, 0.3);
            --success: #4caf50;
            --danger: #b54a4a;
            --compliance-color: #8a9fb0;
            --legal-bg: #0A1625;
            --input-bg: rgba(10, 26, 47, 0.6);
            --modal-bg: rgba(16, 42, 67, 0.95);
            --overlay-bg: rgba(0, 0, 0, 0.7);
            --login-bg: rgba(11, 26, 47, 0.9);
            --login-box-bg: rgba(16, 42, 67, 0.8);
            --tag-bg: rgba(16, 42, 67, 0.6);
            --font-heading: 'Playfair Display', serif;
            --font-subtitle: 'Inter', sans-serif;
            --theme-toggle-border: #C87A4F;
            --theme-toggle-bg: rgba(200, 122, 79, 0.1);
            --storage-bar-bg: rgba(200, 122, 79, 0.1);
            --storage-bar-fill: #C87A4F;
            --tag-border-alpha: rgba(200, 122, 79, 0.07);
            --tag-border-hover-alpha: rgba(200, 122, 79, 0.2);
            --editor-bg: #0D1F35;
            --editor-toolbar-bg: #0F2238;
            --editor-border: rgba(200, 122, 79, 0.2);
        }

        *,
        *::before,
        *::after {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html {
            font-size: 16px;
            -webkit-font-smoothing: antialiased;
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: 'Inter', sans-serif;
            background-color: var(--bg);
            color: var(--petroleo);
            height: 100vh;
            height: 100dvh;
            width: 100vw;
            overflow: hidden;
            font-weight: 300;
            line-height: 1.6;
            position: relative;
            user-select: none;
            letter-spacing: -0.01em;
            transition: background-color 0.5s ease, color 0.5s ease;
        }

        body::after {
            content: "";
            position: fixed;
            top: -10%;
            left: 0;
            width: 100%;
            height: 120%;
            background: linear-gradient(to bottom,
                    transparent 0%,
                    var(--gold-soft) 45%,
                    rgba(184, 134, 11, 0.04) 50%,
                    var(--gold-soft) 55%,
                    transparent 100%);
            z-index: 0;
            pointer-events: none;
            animation: descerBrilho 8s linear infinite;
        }

        @keyframes descerBrilho {
            0% { transform: translateY(-10%); }
            100% { transform: translateY(10%); }
        }

        .app-shell {
            position: relative;
            z-index: 1;
            width: 100%;
            height: 100%;
            max-width: 1680px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: 280px 1fr;
            grid-template-rows: 1fr auto auto;
            gap: 12px;
            padding: 16px 20px;
            grid-template-areas:
                "sidebar main"
                "sidebar input-area"
                "sidebar .";
        }

        .sidebar { grid-area: sidebar; display: flex; flex-direction: column; gap: 12px; min-height: 0; z-index: 3; }
        .sidebar-panel {
            background: var(--navy-card);
            border: 1px solid var(--border-subtle);
            padding: 18px 16px;
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
            transition: all var(--transition), background-color 0.5s ease, border-color 0.5s ease;
            position: relative;
            overflow: hidden;
            flex: 1;
            display: flex;
            flex-direction: column;
            min-height: 0;
            border-top: 1px solid var(--ouro-velho);
        }
        .sidebar-panel:hover { border-color: var(--border-medium); box-shadow: var(--shadow-copper); transform: translateY(-2px); }
        .sidebar-panel-title {
            font-family: var(--font-heading);
            font-size: 0.7rem;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: var(--ouro-velho);
            margin-bottom: 14px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: color 0.5s ease;
        }
        .sidebar-panel-title::after { content: ''; flex: 1; height: 1px; background: var(--border-subtle); opacity: 0.6; }
        .sidebar-list {
            list-style: none;
            display: flex;
            flex-direction: column;
            gap: 4px;
            flex: 1;
            overflow-y: auto;
            padding-right: 2px;
            scrollbar-width: thin;
            scrollbar-color: rgba(184, 134, 11, 0.15) transparent;
        }
        .sidebar-list::-webkit-scrollbar { width: 3px; }
        .sidebar-list::-webkit-scrollbar-track { background: transparent; }
        .sidebar-list::-webkit-scrollbar-thumb { background: rgba(184, 134, 11, 0.15); border-radius: 10px; }
        .sidebar-item {
            padding: 9px 12px;
            font-size: 0.75rem;
            font-weight: 300;
            color: var(--text-muted);
            transition: all var(--transition), background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
            cursor: pointer;
            letter-spacing: 0.02em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            border: 1px solid transparent;
            background: transparent;
            position: relative;
        }
        .sidebar-item:hover { background: var(--gold-ghost); color: var(--petroleo); border-color: var(--border-subtle); }
        .sidebar-item.active {
            color: var(--ouro-velho);
            font-weight: 500;
            background: var(--gold-ghost);
            border-color: var(--border-medium);
            box-shadow: 0 0 14px rgba(184, 134, 11, 0.06);
        }
        .sidebar-item.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 5px;
            bottom: 5px;
            width: 2px;
            background: var(--ouro-velho);
            border-radius: 0 2px 2px 0;
        }

        .sidebar-item-footer {
            font-size: 0.5rem;
            color: var(--text-muted);
            opacity: 0.55;
            letter-spacing: 0.04em;
            padding: 2px 12px 4px;
            text-align: right;
            transition: opacity 0.3s ease;
            font-style: italic;
        }
        .sidebar-item:hover+.sidebar-item-footer,
        .sidebar-item-footer:hover { opacity: 0.85; }

        .tabs-container {
            border-top: 1px solid var(--border-subtle);
            border-bottom: 1px solid var(--border-subtle);
            padding: 12px 0;
            margin: 12px 0;
            display: flex;
            justify-content: center;
            gap: 0;
        }
        .tab-list { display: flex; list-style: none; gap: 0; width: 100%; justify-content: space-around; }
        .tab-list li { flex: 1; text-align: center; position: relative; }
        .tab-list a {
            text-decoration: none;
            font-size: 0.65rem;
            font-weight: 400;
            letter-spacing: 0.04em;
            color: var(--text-muted);
            padding: 8px 4px;
            display: block;
            transition: all 0.25s ease, color 0.5s ease;
            border-bottom: 1px solid transparent;
            white-space: nowrap;
            cursor: pointer;
        }
        .tab-list a:hover { color: var(--ouro-velho); border-bottom-color: var(--ouro-velho); }
        .tab-list a.active { color: var(--ouro-velho); border-bottom-color: var(--ouro-velho); font-weight: 500; }
        .tab-list li:not(:last-child)::after {
            content: '';
            position: absolute;
            right: 0;
            top: 20%;
            height: 60%;
            width: 1px;
            background: var(--border-subtle);
        }

        .storage-indicator {
            padding: 8px 12px;
            margin-top: 6px;
            background: var(--gold-ghost);
            border: 1px solid var(--border-subtle);
            font-size: 0.55rem;
            color: var(--text-muted);
            letter-spacing: 0.03em;
            transition: all 0.5s ease;
            flex-shrink: 0;
        }
        .storage-indicator .storage-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
        .storage-indicator .storage-icon { font-size: 0.7rem; opacity: 0.75; }
        .storage-bar-outer { height: 3px; background: var(--storage-bar-bg); border-radius: 10px; overflow: hidden; position: relative; }
        .storage-bar-inner { height: 100%; background: var(--storage-bar-fill); border-radius: 10px; transition: width 0.6s cubic-bezier(0.22, 0.61, 0.36, 1); opacity: 0.75; }
        .storage-bar-inner.near-limit { opacity: 1; animation: storagePulse 2s infinite; }
        @keyframes storagePulse { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }
        .storage-count { font-size: 0.5rem; text-align: right; margin-top: 2px; opacity: 0.65; }

        .main-area {
            grid-area: main;
            background: var(--navy-card);
            border: 1px solid var(--border-subtle);
            display: flex;
            flex-direction: column;
            position: relative;
            overflow: hidden;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
            min-height: 0;
            z-index: 1;
            border-top: 1px solid var(--ouro-velho);
            transition: background-color 0.5s ease, border-color 0.5s ease;
        }
        .chat-header {
            flex-shrink: 0;
            padding: 16px 22px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid var(--border-subtle);
            gap: 12px;
            flex-wrap: wrap;
            z-index: 2;
            background: var(--navy-card);
            transition: background-color 0.5s ease, border-color 0.5s ease;
        }
        .chat-header-title { font-family: var(--font-heading); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ouro-velho); font-weight: 400; transition: color 0.5s ease; }
        .chat-header-indicators { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
        .indicator { font-size: 0.65rem; letter-spacing: 0.04em; color: var(--text-muted); display: flex; align-items: center; gap: 6px; transition: color 0.5s ease; }
        .indicator .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ouro-velho); box-shadow: 0 0 8px var(--gold-soft); animation: dotPulse 2.8s ease-in-out infinite; }
        @keyframes dotPulse { 0%, 100% { box-shadow: 0 0 6px var(--gold-soft); } 50% { box-shadow: 0 0 16px var(--gold-soft), 0 0 28px rgba(184, 134, 11, 0.15); } }
        .indicator .val { font-weight: 500; color: var(--petroleo); transition: color 0.5s ease; }
        .indicator .val.highlight { color: var(--ouro-velho); font-weight: 500; }
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 20px 22px;
            display: flex;
            flex-direction: column;
            gap: 22px;
            scrollbar-width: thin;
            scrollbar-color: rgba(184, 134, 11, 0.1) transparent;
            mask-image: linear-gradient(to bottom, transparent 0%, black 3%, black 97%, transparent 100%);
            -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 3%, black 97%, transparent 100%);
            position: relative;
            z-index: 1;
            min-height: 0;
        }
        .chat-messages::-webkit-scrollbar { width: 3px; }
        .chat-messages::-webkit-scrollbar-track { background: transparent; }
        .chat-messages::-webkit-scrollbar-thumb { background: rgba(184, 134, 11, 0.1); border-radius: 10px; }
        .msg { display: flex; flex-direction: column; gap: 3px; animation: msgIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1); position: relative; }
        @keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        .msg.user { align-items: flex-end; padding-left: 15%; }
        .msg.ai { align-items: flex-start; padding-right: 12%; border-left: 1px solid var(--border-medium); padding-left: 14px; }
        .msg-label { font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; opacity: 0.65; transition: color 0.5s ease; }
        .msg.user .msg-label { color: var(--text-muted); }
        .msg.ai .msg-label { color: var(--ouro-velho); }
        .msg-content { font-size: 0.85rem; line-height: 1.7; color: var(--petroleo); letter-spacing: 0.01em; transition: color 0.5s ease; font-weight: 350; }
        .msg.user .msg-content { color: #1a4055; }
        [data-theme="dark"] .msg.user .msg-content { color: #d5d0c5; }
        .msg-time { font-size: 0.55rem; color: var(--text-muted); letter-spacing: 0.05em; margin-top: 1px; }
        .msg-meta-footer { font-size: 0.48rem; color: var(--text-muted); opacity: 0.55; letter-spacing: 0.04em; margin-top: 1px; font-style: italic; transition: opacity 0.4s ease; }
        .msg:hover .msg-meta-footer { opacity: 0.8; }

        .input-area {
            grid-area: input-area;
            z-index: 3;
            display: flex;
            flex-direction: column;
            gap: 6px;
            background: var(--navy-card);
            border-top: 1px solid var(--border-subtle);
            padding: 12px;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            transition: all 0.35s ease, background-color 0.5s ease, border-color 0.5s ease;
        }

        body.no-ai .input-area { background: transparent; border-top-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
        body.no-ai .input-wrapper { background: rgba(255, 255, 255, 0.2); border-color: var(--border-subtle); }
        body.no-ai #userInput { color: rgba(10, 49, 71, 0.5); }
        body.no-ai #userInput::placeholder { color: rgba(64, 81, 94, 0.35); }
        body.no-ai .send-btn,
        body.no-ai .mic-btn,
        body.no-ai .editor-shortcut-btn { opacity: 0.35; border-color: var(--border-subtle); }

        .tags-grid-container {
            padding: 8px 12px;
            background: var(--input-bg);
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            border: 1px solid var(--border-subtle);
            max-height: 42px;
            overflow-x: auto;
            overflow-y: hidden;
            white-space: nowrap;
            scrollbar-width: thin;
            scrollbar-color: rgba(184, 134, 11, 0.1) transparent;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.35s ease, transform 0.35s ease, background-color 0.5s ease;
            transform: translateY(5px);
            display: flex;
            align-items: center;
        }
        .tags-grid-container.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
        .tags-grid { display: flex; gap: 8px; flex-wrap: nowrap; }
        .grid-tag {
            font-size: 0.65rem;
            font-weight: 350;
            letter-spacing: 0.03em;
            color: var(--text-muted);
            background: var(--tag-bg);
            border: 1px solid var(--tag-border-alpha);
            padding: 4px 12px;
            white-space: nowrap;
            cursor: pointer;
            transition: all var(--transition), background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            animation: tagFadeIn 0.4s ease forwards;
            animation-delay: var(--tag-delay, 0s);
            opacity: 0;
            flex-shrink: 0;
        }
        @keyframes tagFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
        .grid-tag:hover { color: var(--petroleo); background: var(--gold-ghost); border-color: var(--tag-border-hover-alpha); transform: translateY(-2px); box-shadow: 0 4px 18px rgba(184, 134, 11, 0.08); }
        .grid-tag.size-sm { font-size: 0.6rem; padding: 3px 10px; }
        .grid-tag.size-md { font-size: 0.7rem; padding: 5px 13px; }
        .grid-tag.size-lg { font-size: 0.78rem; padding: 7px 16px; font-weight: 400; border-color: var(--tag-border-hover-alpha); background: var(--gold-ghost); }
        .grid-tag.highlight-tag { color: var(--ouro-velho); border-color: var(--tag-border-hover-alpha); background: var(--gold-ghost); font-weight: 500; }
        .grid-tag.tag-known { color: var(--ouro-velho); background: var(--gold-ghost); border-color: var(--tag-border-hover-alpha); font-weight: 700; }
        .grid-tag.tag-unknown { color: var(--text-muted); background: var(--input-bg); border-color: var(--tag-border-alpha); }

        .input-wrapper {
            display: flex;
            align-items: center;
            background: var(--input-bg);
            border: 1px solid var(--border-subtle);
            padding: 5px 8px 5px 18px;
            transition: all var(--transition), background-color 0.5s ease, border-color 0.5s ease;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
            position: relative;
        }
        .input-wrapper:focus-within { border-color: var(--border-medium); box-shadow: var(--shadow-copper); }
        #userInput {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            color: var(--petroleo);
            font-family: 'Inter', sans-serif;
            font-size: 0.85rem;
            padding: 10px 4px;
            letter-spacing: 0.01em;
            resize: none;
            min-height: 22px;
            max-height: 110px;
            line-height: 1.5;
            caret-color: var(--ouro-velho);
            transition: color 0.5s ease;
        }
        #userInput::placeholder { color: var(--text-muted); letter-spacing: 0.03em; font-style: italic; opacity: 0.7; }
        .send-btn {
            flex-shrink: 0;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 1px solid var(--border-medium);
            background: var(--gold-ghost);
            color: var(--ouro-velho);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition), background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease;
            position: relative;
            overflow: hidden;
            font-family: 'Inter', sans-serif;
            font-weight: 500;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            backdrop-filter: blur(4px);
        }
        .send-btn:hover { background: rgba(184, 134, 11, 0.15); border-color: var(--ouro-velho); box-shadow: 0 8px 24px rgba(184, 134, 11, 0.25); transform: scale(1.05); }
        .send-btn:active { transform: scale(0.93); transition: transform 0.1s ease; }
        .send-btn svg { width: 17px; height: 17px; }

        .mic-btn,
        .editor-shortcut-btn {
            flex-shrink: 0;
            width: 42px;
            height: 42px;
            border-radius: 50%;
            border: 1px solid var(--border-medium);
            background: var(--gold-ghost);
            color: var(--text-muted);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition), background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease;
            margin-left: 8px;
            font-size: 1rem;
        }
        .mic-btn:hover,
        .editor-shortcut-btn:hover { background: rgba(184, 134, 11, 0.15); border-color: var(--ouro-velho); color: var(--ouro-velho); }
        .mic-btn.recording { background: rgba(184, 134, 11, 0.15); border-color: var(--ouro-velho); color: var(--ouro-velho); animation: pulse-rec 1.2s infinite; }
        @keyframes pulse-rec { 0%, 100% { box-shadow: 0 0 0 0 rgba(184, 134, 11, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(184, 134, 11, 0); } }

        .compliance-footer {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 14px;
            font-size: 0.55rem;
            color: var(--text-muted);
            letter-spacing: 0.03em;
            opacity: 0.82;
            transition: opacity 0.2s, color 0.5s ease;
            padding: 4px 0;
            align-items: center;
        }
        .compliance-footer span { cursor: pointer; transition: color 0.2s, color 0.5s ease; }
        .compliance-footer span:hover { color: var(--ouro-velho); }
        .daily-counter { color: var(--ouro-velho); font-weight: 500; cursor: default !important; }
        .footer-explanation-box { display: none; width: 100%; margin-top: 8px; padding: 12px 14px; background: var(--gold-ghost); border: 1px solid var(--border-subtle); font-size: 0.7rem; color: var(--petroleo); text-align: left; line-height: 1.7; border-left: 2px solid var(--ouro-velho); }

        #loginOverlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: var(--login-bg);
            backdrop-filter: blur(10px);
            z-index: 200;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.5s ease;
        }
        #loginOverlay .login-box {
            background: var(--login-box-bg);
            border: 1px solid var(--ouro-velho);
            box-shadow: var(--shadow-copper);
            padding: 2.5rem;
            width: 90%;
            max-width: 400px;
            max-height: 90vh;
            overflow-y: auto;
            backdrop-filter: blur(18px);
            transition: background-color 0.5s ease, border-color 0.5s ease;
        }
        #loginOverlay .login-box h2 { font-family: var(--font-heading); font-weight: 400; font-size: 2rem; color: var(--petroleo); margin-bottom: 0.3rem; letter-spacing: 0.04em; transition: color 0.5s ease; }
        #loginOverlay .login-box .subtle { font-family: var(--font-subtitle); color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
        .login-tabs { display: none; }
        .login-panel { display: block; }
        .form-group { margin-bottom: 1.2rem; }
        .form-group label { display: block; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; font-weight: 500; transition: color 0.5s ease; }
        .form-group input {
            width: 100%;
            padding: 0.7rem 0.8rem;
            background: var(--input-bg);
            border: 1px solid var(--border-subtle);
            color: var(--petroleo);
            font-family: 'Inter', sans-serif;
            font-size: 0.85rem;
            transition: border-color 0.25s ease, background 0.25s ease, background-color 0.5s ease, color 0.5s ease;
        }
        .form-group input:focus { outline: none; border-color: var(--ouro-velho); background: var(--input-bg); box-shadow: 0 0 0 1px var(--gold-soft); }
        .btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.65rem 1.4rem; font-family: var(--font-heading); font-size: 0.82rem; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; transition: all var(--transition), background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease; border: 1px solid transparent; text-decoration: none; }
        .btn-primary { background: var(--ouro-velho); color: white; border-color: var(--ouro-velho); }
        .btn-primary:hover { background: var(--petroleo); border-color: var(--petroleo); box-shadow: 0 4px 20px rgba(184, 134, 11, 0.3); }
        .btn-outline { background: transparent; color: var(--ouro-velho); border-color: var(--border-medium); }
        .btn-outline:hover { background: var(--gold-ghost); border-color: var(--ouro-velho); }
        .btn-sm { padding: 0.4rem 0.8rem; font-size: 0.7rem; }
        .login-error { color: var(--danger); font-size: 0.75rem; margin-top: 0.5rem; min-height: 1.2em; }
        .tiny { font-family: var(--font-subtitle); font-size: 0.6rem; color: var(--text-muted); margin-top: 1rem; opacity: 0.75; }

        .modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--overlay-bg); backdrop-filter: blur(4px); z-index: 150; align-items: center; justify-content: center; transition: background-color 0.5s ease; }
        .modal-overlay.open { display: flex; }
        .modal-content { background: var(--modal-bg); border: 1px solid var(--ouro-velho); width: 90%; max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; backdrop-filter: blur(20px); transition: background-color 0.5s ease, border-color 0.5s ease; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border-subtle); font-family: var(--font-heading); font-size: 0.85rem; color: var(--petroleo); transition: color 0.5s ease, border-color 0.5s ease; }
        .modal-header button { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-muted); cursor: pointer; padding: 4px 10px; font-size: 0.9rem; transition: all 0.2s ease, color 0.5s ease, border-color 0.5s ease; }
        .modal-header button:hover { color: var(--ouro-velho); border-color: var(--ouro-velho); }
        .modal-body { padding: 1.2rem; overflow-y: auto; color: var(--text-muted); font-size: 0.8rem; transition: color 0.5s ease; }
        .info-row { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border-subtle); }
        .info-row .label { color: var(--text-muted); }
        .info-row .value { color: var(--petroleo); font-weight: 500; transition: color 0.5s ease; }

        .historico-list { display: flex; flex-direction: column; gap: 6px; }
        .historico-item { background: var(--navy-card); border: 1px solid var(--border-subtle); padding: 8px 10px; font-size: 0.7rem; transition: background-color 0.5s ease, border-color 0.5s ease; position: relative; }
        .historico-item .h-footer { font-size: 0.48rem; color: var(--text-muted); opacity: 0.55; letter-spacing: 0.04em; margin-top: 3px; text-align: right; font-style: italic; }
        .h-data { font-size: 0.58rem; color: var(--text-muted); margin-bottom: 2px; }
        .h-prompt { color: var(--ouro-velho); margin-bottom: 2px; font-weight: 450; }
        .h-resposta { color: var(--petroleo); transition: color 0.5s ease; }
        .historico-actions { padding: 0.8rem 1rem; border-top: 1px solid var(--border-subtle); display: flex; gap: 8px; flex-wrap: wrap; }
        .historico-actions button { background: transparent; border: 1px solid var(--border-medium); color: var(--ouro-velho); padding: 6px 14px; font-size: 0.7rem; cursor: pointer; transition: all 0.2s ease, background-color 0.5s ease, border-color 0.5s ease; font-family: var(--font-heading); }
        .historico-actions button:hover { background: var(--gold-ghost); }

        #robotPlaceholder { display: none; position: absolute; top: 50%; right: 5%; transform: translateY(-50%); max-width: 280px; width: 70%; opacity: 0.18; pointer-events: none; z-index: 0; filter: grayscale(0.3) blur(0.5px); transition: opacity 0.6s ease; }

        .compliance-tooltip { display: none; position: fixed; background: var(--modal-bg); border: 1px solid var(--ouro-velho); color: var(--petroleo); font-family: var(--font-subtitle); font-size: 0.62rem; padding: 10px 14px; box-shadow: var(--shadow-copper); max-width: 240px; z-index: 200; pointer-events: none; backdrop-filter: blur(10px); transition: background-color 0.5s ease, color 0.5s ease; }

        .editor-modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--overlay-bg); backdrop-filter: blur(6px); z-index: 160; align-items: center; justify-content: center; transition: background-color 0.5s ease; }
        .editor-modal-overlay.open { display: flex; animation: editorFadeIn 0.4s ease; }
        @keyframes editorFadeIn { from { opacity: 0; } to { opacity: 1; } }
        .editor-container { background: var(--editor-bg); border: 1px solid var(--editor-border); width: 92%; max-width: 900px; height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); transition: background-color 0.5s ease, border-color 0.5s ease; animation: editorSlideUp 0.45s cubic-bezier(0.22, 0.61, 0.36, 1); }
        @keyframes editorSlideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
        .editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 14px; background: var(--editor-toolbar-bg); border-bottom: 1px solid var(--editor-border); align-items: center; flex-shrink: 0; transition: background-color 0.5s ease, border-color 0.5s ease; }
        .editor-toolbar .tool-group { display: flex; gap: 2px; padding: 0 6px; border-right: 1px solid var(--border-subtle); }
        .editor-toolbar .tool-group:last-child { border-right: none; }
        .editor-toolbar button { width: 32px; height: 30px; border: 1px solid transparent; background: transparent; color: var(--petroleo); cursor: pointer; font-size: 0.8rem; border-radius: 3px; transition: all 0.2s ease, color 0.5s ease, background-color 0.5s ease; display: flex; align-items: center; justify-content: center; font-family: 'Inter', sans-serif; }
        .editor-toolbar button:hover { background: var(--gold-ghost); border-color: var(--border-subtle); }
        .editor-toolbar button.active { background: var(--gold-soft); border-color: var(--border-medium); color: var(--ouro-velho); }
        .editor-toolbar select { background: transparent; border: 1px solid var(--border-subtle); color: var(--petroleo); padding: 4px 8px; font-size: 0.7rem; font-family: 'Inter', sans-serif; cursor: pointer; border-radius: 3px; transition: all 0.2s ease, color 0.5s ease, border-color 0.5s ease; }
        .editor-toolbar select:hover { border-color: var(--border-medium); }
        .editor-body { flex: 1; padding: 20px 24px; overflow-y: auto; outline: none; font-family: 'Inter', sans-serif; font-size: 0.9rem; line-height: 1.8; color: var(--petroleo); background: var(--editor-bg); transition: background-color 0.5s ease, color 0.5s ease; min-height: 0; }
        .editor-body:focus { outline: none; }
        .editor-body h1 { font-family: var(--font-heading); font-size: 1.6rem; margin-bottom: 0.6rem; color: var(--ouro-velho); }
        .editor-body h2 { font-family: var(--font-heading); font-size: 1.2rem; margin-bottom: 0.4rem; color: var(--petroleo); }
        .editor-body h3 { font-family: var(--font-heading); font-size: 1rem; margin-bottom: 0.3rem; }
        .editor-body b, .editor-body strong { font-weight: 600; }
        .editor-body i, .editor-body em { font-style: italic; }
        .editor-body u { text-decoration: underline; text-decoration-color: var(--ouro-velho); text-underline-offset: 3px; }
        .editor-body ul, .editor-body ol { padding-left: 1.5rem; margin: 0.5rem 0; }
        .editor-body blockquote { border-left: 2px solid var(--ouro-velho); padding-left: 1rem; margin: 0.8rem 0; color: var(--text-muted); font-style: italic; }
        .editor-footer { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--editor-border); font-size: 0.55rem; color: var(--text-muted); flex-shrink: 0; transition: border-color 0.5s ease, color 0.5s ease; gap: 10px; flex-wrap: wrap; }
        .editor-footer .footer-left { display: flex; align-items: center; gap: 6px; opacity: 0.65; }
        .editor-footer .footer-actions { display: flex; gap: 8px; }
        .editor-footer button { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-muted); padding: 5px 12px; font-size: 0.65rem; cursor: pointer; font-family: var(--font-heading); letter-spacing: 0.04em; transition: all 0.2s ease, color 0.5s ease, border-color 0.5s ease; border-radius: 2px; }
        .editor-footer button:hover { color: var(--ouro-velho); border-color: var(--border-medium); background: var(--gold-ghost); }
        .editor-footer .word-count { font-size: 0.5rem; opacity: 0.55; }

        .theme-toggle {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            width: 36px;
            height: 36px;
            background: var(--theme-toggle-bg);
            border: 1px solid var(--theme-toggle-border);
            border-radius: 2px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 99999;
            pointer-events: auto;
            transition: all 0.3s ease, background-color 0.5s ease, border-color 0.5s ease;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            opacity: 0.65;
            padding: 0;
            touch-action: manipulation;
        }
        .theme-toggle:hover { opacity: 1; border-color: var(--ouro-velho); box-shadow: 0 0 16px var(--gold-soft); }
        .theme-toggle svg { width: 16px; height: 16px; stroke: var(--ouro-velho); fill: none; stroke-width: 1.5; transition: transform 0.5s ease, stroke 0.5s ease; }
        .theme-toggle:hover svg { transform: rotate(30deg); }

        .pdf-export-container {
            position: absolute;
            left: -9999px;
            top: 0;
            width: 800px;
            background: #ffffff;
            color: #1a1a1a;
            font-family: 'Inter', 'Georgia', serif;
            padding: 40px 50px;
            line-height: 1.8;
            z-index: -1;
        }
        .pdf-export-container h1 { font-family: 'Cinzel', serif; font-size: 1.8rem; color: #b8860b; border-bottom: 1px solid #b8860b; padding-bottom: 8px; margin-bottom: 24px; }
        .pdf-export-container .pdf-entry { margin-bottom: 28px; border-left: 2px solid #b8860b; padding-left: 14px; }
        .pdf-export-container .pdf-data { font-size: 0.7rem; color: #666; margin-bottom: 4px; }
        .pdf-export-container .pdf-prompt { font-weight: 600; color: #b8860b; margin-bottom: 6px; }
        .pdf-export-container .pdf-resposta { color: #1a1a1a; }

        @media (max-width: 1100px) {
            .app-shell { grid-template-columns: 240px 1fr; gap: 8px; padding: 10px 12px; }
            .sidebar-panel { padding: 12px 10px; }
            .sidebar-item { font-size: 0.7rem; padding: 7px 10px; }
            .compliance-footer { gap: 10px; font-size: 0.5rem; }
            .editor-container { width: 96%; height: 90vh; }
            .editor-body { padding: 14px 16px; font-size: 0.8rem; }
        }
        @media (max-width: 768px) {
            .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "sidebar" "main" "input-area"; gap: 6px; padding: 6px 8px; }
            .sidebar { flex-direction: row; gap: 6px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; max-height: 130px; }
            .sidebar::-webkit-scrollbar { display: none; }
            .sidebar-panel { flex: 1 1 auto; min-width: 160px; max-height: 120px; padding: 10px 10px; }
            .sidebar-panel-title { font-size: 0.55rem; margin-bottom: 6px; }
            .sidebar-item { font-size: 0.65rem; padding: 6px 8px; }
            .storage-indicator { display: none; }
            .chat-messages { padding: 12px 10px; gap: 14px; }
            .msg.user { padding-left: 8%; }
            .msg.ai { padding-right: 5%; padding-left: 10px; }
            .msg-content { font-size: 0.78rem; }
            .chat-header { padding: 10px 12px; gap: 6px; }
            .indicator { font-size: 0.55rem; gap: 4px; }
            .tabs-container { padding: 8px 0; margin: 8px 0; }
            .tags-grid-container { max-height: 36px; padding: 6px 10px; }
            .compliance-footer { justify-content: flex-start; gap: 8px; font-size: 0.5rem; }
            #robotPlaceholder { max-width: 200px; right: 2%; }
            .editor-toolbar { gap: 2px; padding: 6px 8px; }
            .editor-toolbar button { width: 26px; height: 26px; font-size: 0.7rem; }
            .editor-body { padding: 12px 14px; font-size: 0.78rem; }
            .editor-footer { font-size: 0.48rem; padding: 6px 10px; }
        }
        @media (max-width: 480px) {
            .app-shell { gap: 4px; padding: 4px 4px; }
            .sidebar { max-height: 100px; }
            .sidebar-panel { min-width: 130px; padding: 8px 6px; }
            .sidebar-item { font-size: 0.6rem; padding: 5px 6px; }
            .chat-header { padding: 8px 10px; gap: 4px; }
            .chat-header-title { font-size: 0.6rem; }
            .indicator { font-size: 0.48rem; gap: 3px; }
            .msg-content { font-size: 0.72rem; }
            .editor-container { width: 100%; height: 95vh; border-radius: 0; }
            .editor-toolbar { padding: 4px 6px; gap: 1px; }
            .editor-toolbar button { width: 24px; height: 24px; font-size: 0.65rem; }
            .theme-toggle { bottom: 1rem; right: 1rem; width: 30px; height: 30px; }
        }