* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --gold: #d9a441;
    --gold-dim: #a87b28;
    --gold-bright: #f0c060;
    --bg: #080808;
    --bg2: #111111;
    --bg3: #1a1a1a;
    --border: rgba(217, 164, 65, 0.25);
    --border-strong: rgba(217, 164, 65, 0.6);
    --text: #e8d5a0;
    --text-dim: #8a7550;
    --scan-color: rgba(217, 164, 65, 0.03);
}

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    overflow: hidden;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        var(--scan-color) 2px,
        var(--scan-color) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* ─── AUTH ─── */

#auth-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 100;
}

.auth-box {
    width: 440px;
    background: var(--bg2);
    border: 1px solid var(--border-strong);
    padding: 40px;
    position: relative;
}

.auth-box::before {
    content: '';
    position: absolute;
    top: -1px; left: 20px;
    width: 60px; height: 3px;
    background: var(--gold);
}

.auth-logo {
    font-family: 'Rajdhani', sans-serif;
    font-size: 40px; font-weight: 700;
    letter-spacing: 12px; color: var(--gold);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 3px;
    color: var(--text-dim);
    margin-bottom: 24px;
}

.auth-line { height: 1px; background: var(--border); margin-bottom: 24px; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; }

.auth-tab {
    flex: 1;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 9px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px; letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    background: rgba(217, 164, 65, 0.1);
    border-color: var(--gold);
    color: var(--gold);
}

.auth-fields { margin-bottom: 20px; }

.auth-field { margin-bottom: 16px; }

.auth-field label {
    display: block;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 2px;
    color: var(--text-dim); margin-bottom: 8px;
}

.auth-field input {
    width: 100%;
    background: var(--bg3);
    color: var(--gold);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px; outline: none;
    transition: border-color 0.2s;
}

.auth-field input:focus { border-color: var(--gold); }

.auth-submit {
    width: 100%;
    background: var(--gold); color: #000;
    border: none; padding: 13px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 15px; font-weight: 700;
    letter-spacing: 4px; cursor: pointer;
    transition: opacity 0.2s;
}

.auth-submit:hover { opacity: 0.88; }

.auth-divider {
    text-align: center; margin: 18px 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute; top: 50%; left: 0; right: 0;
    height: 1px; background: var(--border);
}

.auth-divider span {
    position: relative;
    background: var(--bg2);
    padding: 0 12px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 2px;
    color: var(--text-dim);
}

.auth-google {
    width: 100%;
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 11px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px; letter-spacing: 1px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: border-color 0.2s;
}

.auth-google:hover { border-color: var(--gold); }

.auth-error {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px; color: #e05555;
    margin-top: 14px; text-align: center; min-height: 16px;
}

/* ─── MAIN SCREEN ─── */

#main-screen {
    height: 100vh;
    display: flex; flex-direction: column;
}

/* Header */
.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}

.header-left {
    display: flex; align-items: center; gap: 12px;
}

.logo-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 20px; font-weight: 700;
    letter-spacing: 8px; color: var(--gold);
}

.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 6px #4caf5088;
    animation: pulse 2s infinite;
}

.status-dot.loading {
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold);
    animation: pulse-fast 0.8s infinite;
}

.status-dot.error {
    background: #e05555;
    box-shadow: 0 0 6px #e0555588;
    animation: none;
}

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

.status-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 2px; color: var(--text-dim);
}

.online-count {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 2px;
    color: #4caf50; opacity: 0.8;
}

.header-right {
    display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
}

/* Usage bar */
.usage-wrap {
    display: flex; align-items: center; gap: 7px;
}

.usage-bar {
    width: 80px; height: 4px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: #4caf50;
    border-radius: 2px;
    transition: width 0.4s ease, background 0.4s ease;
}

.usage-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 1px;
    color: var(--text-dim); white-space: nowrap;
}

/* Plan badge */
.plan-badge {
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px; letter-spacing: 2px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.plan-badge.pro {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(217, 164, 65, 0.1);
}

.user-email {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 1px;
    color: var(--text-dim);
    max-width: 140px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 34px; height: 34px;
    cursor: pointer; font-size: 15px;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.icon-btn:hover { border-color: var(--gold); color: var(--gold); }

.upgrade-btn {
    border-color: var(--gold-dim);
    color: var(--gold-dim);
}

.upgrade-btn:hover {
    background: rgba(217, 164, 65, 0.1);
    border-color: var(--gold);
    color: var(--gold);
}

/* Chat */
#chat {
    flex: 1;
    overflow-y: auto;
    padding: 28px 0;
    scroll-behavior: smooth;
}

#chat::-webkit-scrollbar { width: 4px; }
#chat::-webkit-scrollbar-track { background: transparent; }
#chat::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.message-wrap {
    max-width: 780px;
    margin: 0 auto 20px;
    padding: 0 32px;
    display: flex; gap: 14px;
    animation: fadeUp 0.25s ease;
}

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

.message-wrap.user { flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 1px;
    margin-top: 2px;
}

.msg-avatar.user-av { border: 1px solid var(--border-strong); color: var(--gold); }
.msg-avatar.bot-av  { border: 1px solid var(--border); color: var(--text-dim); font-size: 8px; }

.message {
    max-width: 72%;
    padding: 14px 18px;
    line-height: 1.65; font-size: 15px;
    white-space: pre-wrap; word-break: break-word;
}

.message.user {
    background: rgba(217, 164, 65, 0.1);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.message.bot {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text); position: relative;
}

.message.bot::before {
    content: '';
    position: absolute;
    top: 0; left: -1px;
    width: 3px; height: 100%;
    background: var(--gold-dim);
}

.message.error-msg { border-color: rgba(224, 85, 85, 0.4); color: #e08080; }

/* Typing */
.typing-dots { display: flex; gap: 5px; padding: 4px 0; }
.typing-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--gold-dim);
    animation: dot 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.9); }
    30%           { opacity: 1;   transform: scale(1.1); }
}

/* Upgrade inline button */
.upgrade-inline-btn {
    display: inline-block;
    margin-top: 8px;
    background: var(--gold); color: #000;
    border: none; padding: 8px 18px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px; font-weight: 700;
    letter-spacing: 2px; cursor: pointer;
    transition: opacity 0.2s;
}

.upgrade-inline-btn:hover { opacity: 0.85; }

/* Input panel */
#panel {
    padding: 14px 24px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#input-wrapper {
    max-width: 780px; margin: 0 auto;
    display: flex; gap: 10px; align-items: flex-end;
}

#input {
    flex: 1;
    background: var(--bg2); color: var(--text);
    border: 1px solid var(--border);
    padding: 12px 16px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 15px; outline: none; resize: none;
    min-height: 46px; max-height: 200px;
    overflow-y: auto; line-height: 1.5;
    transition: border-color 0.2s;
}

#input:focus { border-color: var(--gold-dim); }
#input::placeholder { color: var(--text-dim); font-size: 14px; }
#input::-webkit-scrollbar { width: 3px; }
#input::-webkit-scrollbar-thumb { background: var(--border-strong); }

#send-btn {
    width: 46px; height: 46px;
    background: var(--gold); color: #000;
    border: none; cursor: pointer;
    font-size: 20px; font-weight: bold;
    transition: opacity 0.2s, transform 0.1s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

#send-btn:hover { opacity: 0.85; }
#send-btn:active { transform: scale(0.95); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.panel-hint {
    max-width: 780px; margin: 7px auto 0;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; color: var(--text-dim); letter-spacing: 1px;
}

/* Empty state */
.empty-state {
    max-width: 780px; margin: 60px auto;
    padding: 0 32px; text-align: center;
}

.empty-logo {
    font-family: 'Rajdhani', sans-serif;
    font-size: 56px; font-weight: 700;
    letter-spacing: 16px; color: var(--gold);
    opacity: 0.15; margin-bottom: 16px;
}

.empty-hint {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px; letter-spacing: 2px;
    color: var(--text-dim); margin-bottom: 24px;
}

.empty-upgrade {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 24px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.empty-upgrade:hover { border-color: var(--gold); color: var(--gold); }

/* ─── MODAL BASE ─── */

.modal-overlay, .history-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 200;
}

.modal-close {
    position: absolute; top: 18px; right: 18px;
    background: none; border: 1px solid var(--border);
    color: var(--text-dim); width: 32px; height: 32px;
    cursor: pointer; font-size: 14px;
    transition: all 0.2s;
}

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

/* ─── PRICING MODAL ─── */

#pricing-modal {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 300;
}

.modal-box {
    position: relative;
    background: var(--bg2);
    border: 1px solid var(--border-strong);
    padding: 48px 48px 40px;
    width: 640px; max-width: 95vw;
    z-index: 301;
}

.modal-box::before {
    content: '';
    position: absolute; top: -1px; left: 20px;
    width: 80px; height: 3px;
    background: var(--gold);
}

.modal-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 28px; font-weight: 700;
    letter-spacing: 6px; color: var(--text);
    margin-bottom: 4px;
}

.modal-subtitle {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 3px;
    color: var(--text-dim); margin-bottom: 36px;
}

.plans-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.plan-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    padding: 28px 24px;
    position: relative;
}

.plan-card.plan-pro {
    border-color: var(--gold-dim);
    background: rgba(217, 164, 65, 0.04);
}

.plan-badge-label {
    position: absolute; top: -1px; right: 16px;
    background: var(--gold); color: #000;
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px; letter-spacing: 2px;
    padding: 3px 10px;
}

.plan-name {
    font-family: 'Rajdhani', sans-serif;
    font-size: 22px; font-weight: 700;
    letter-spacing: 4px; color: var(--text);
    margin-bottom: 8px;
}

.plan-price {
    font-family: 'Rajdhani', sans-serif;
    font-size: 36px; font-weight: 700;
    color: var(--gold); margin-bottom: 20px;
    line-height: 1;
}

.plan-price span {
    font-size: 14px; color: var(--text-dim);
    font-weight: 400; letter-spacing: 1px;
}

.plan-divider {
    height: 1px; background: var(--border);
    margin-bottom: 20px;
}

.plan-features {
    list-style: none;
    margin-bottom: 24px;
}

.plan-features li {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px; letter-spacing: 1px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    line-height: 1.4;
}

.feat-yes { color: var(--text); }
.feat-no  { color: var(--text-dim); }

.plan-current-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; letter-spacing: 2px;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 10px; text-align: center;
}

.plan-btn {
    width: 100%;
    background: var(--gold); color: #000;
    border: none; padding: 13px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px; font-weight: 700;
    letter-spacing: 4px; cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.plan-btn:hover { opacity: 0.88; }
.plan-btn:active { transform: scale(0.98); }
.plan-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── HISTORY PANEL ─── */

#history-panel {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 300;
}

.history-box {
    position: relative;
    background: var(--bg2);
    border: 1px solid var(--border-strong);
    width: 480px; max-width: 95vw;
    max-height: 80vh;
    display: flex; flex-direction: column;
    z-index: 301;
}

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

.history-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px; font-weight: 700;
    letter-spacing: 4px; color: var(--text);
}

.history-header .modal-close {
    position: static;
}

.history-list {
    overflow-y: auto; flex: 1;
    padding: 12px 0;
}

.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-strong); }

.history-item {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.history-item:hover { background: rgba(217, 164, 65, 0.05); }

.history-item-title {
    font-size: 14px; color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.history-item-date {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px; color: var(--text-dim); letter-spacing: 1px;
}

.history-loading, .history-empty {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px; color: var(--text-dim);
    letter-spacing: 2px; text-align: center;
    padding: 32px;
}

/* ─── TOAST ─── */

.toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px; letter-spacing: 1px;
    padding: 12px 24px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 500;
    white-space: nowrap;
}

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

/* ─── RESPONSIVE ─── */

@media (max-width: 600px) {
    .header { padding: 10px 14px; }
    .usage-wrap { display: none; }
    .user-email { display: none; }
    .plans-grid { grid-template-columns: 1fr; }
    .modal-box { padding: 32px 24px; }
}
.support-bar {
    max-width: 780px;
    margin: 10px auto 0;
    text-align: center;
}

.support-btn {
    display: inline-block;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    color: #000;
    background: var(--gold);
    padding: 8px 28px;
    text-decoration: none;
    transition: opacity 0.2s;
}

.support-btn:hover {
    opacity: 0.85;
}

.legal-links {
    max-width: 780px;
    margin: 8px auto 0;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-dim);
    display: flex;
    gap: 10px;
    justify-content: center;
}
.legal-links a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s;
}
.legal-links a:hover { color: var(--gold); }

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}
.auth-checkbox input {
    width: 14px;
    height: 14px;
    margin-top: 2px;
    accent-color: var(--gold);
    flex-shrink: 0;
    cursor: pointer;
}
.auth-checkbox label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-dim);
    line-height: 1.6;
    cursor: pointer;
}
.auth-checkbox label a {
    color: var(--gold-dim);
    text-decoration: none;
}
.auth-checkbox label a:hover {
    color: var(--gold);
}
.msg-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.msg-action-btn {
    background: transparent;
    border: 1px solid rgba(217,164,65,0.3);
    color: #8a7550;
    padding: 4px 12px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-action-btn:hover {
    border-color: #d9a441;
    color: #d9a441;
}

.btn-continue {
    border-color: rgba(76,175,80,0.4);
    color: #4caf50;
}

.btn-continue:hover {
    border-color: #4caf50;
    color: #4caf50;
    background: rgba(76,175,80,0.08);
}

.btn-end {
    border-color: rgba(224,85,85,0.4);
    color: #e05555;
}

.btn-end:hover {
    border-color: #e05555;
    color: #e05555;
    background: rgba(224,85,85,0.08);
}