/*! Copyright (c) 2026 Christian Anelka. All rights reserved. Proprietary - see LICENSE. */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #686880;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --success: #00cec9;
    --success-glow: rgba(0, 206, 201, 0.2);
    --warning: #fdcb6e;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 20px var(--accent-glow);
}

.sidebar-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.stats-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: auto;
}

.stat-item { text-align: center; }

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
}

.header-info { display: flex; align-items: center; gap: 12px; }
.header-info h1 { font-size: 1.1rem; font-weight: 600; }

.status-badge {
    padding: 4px 10px;
    background: var(--success-glow);
    color: var(--success);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    gap: 16px;
    animation: fadeIn 0.6s ease;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 40px var(--accent-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

.welcome-screen h2 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-screen p {
    color: var(--text-secondary);
    max-width: 500px;
    line-height: 1.6;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.quick-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.quick-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: msgIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.bot { align-self: flex-start; }

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #00cec9, #55efc4);
    color: #0a0a0f;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 0.9rem;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 12px;
}

.result-card .result-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.result-card .result-group {
    color: var(--accent-light);
    font-weight: 600;
    margin-bottom: 4px;
}

.result-card .result-kip {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.result-card .result-hashtag {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--success);
    word-break: break-all;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.result-card .result-hashtag:hover {
    background: rgba(108, 92, 231, 0.1);
    box-shadow: 0 0 15px var(--accent-glow);
}

.result-card .result-hashtag .copy-hint {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.result-card .result-hashtag.copied {
    border-color: var(--success);
    box-shadow: 0 0 15px var(--success-glow);
}

.result-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.result-score {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
}

.score-high { background: rgba(0, 206, 201, 0.2); color: var(--success); }
.score-medium { background: rgba(253, 203, 110, 0.2); color: var(--warning); }
.score-low { background: rgba(255, 118, 117, 0.2); color: #ff7675; }

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Input Area */
.chat-input-area {
    padding: 16px 24px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 18px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    max-height: 120px;
    padding: 8px 0;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder { color: var(--text-muted); }
.input-wrapper textarea:focus { outline: none; }

.send-btn {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--accent-glow);
}

.input-hint {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.app-footer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    letter-spacing: 0.2px;
}

.app-footer strong {
    color: var(--text-secondary);
    font-weight: 600;
}

.footer-heart {
    color: #ff5d6c;
    animation: footerHeartBeat 1.6s ease-in-out infinite;
}

@keyframes footerHeartBeat {
    0%, 60%, 100% { transform: scale(1); }
    30% { transform: scale(1.25); }
}

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--accent-light);
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.08);
}

.ai-toggle-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.ai-toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ai-toggle-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-toggle-subtitle {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.ai-toggle-card.active {
    border-color: var(--success);
    box-shadow: 0 0 16px rgba(0, 206, 201, 0.12);
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #2a2a40;
    border-radius: 22px;
    transition: var(--transition);
}

.switch .slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    top: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.switch input:checked + .slider {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

.switch input:checked + .slider::before {
    transform: translateX(16px);
    background: white;
}

.learning-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    max-height: 320px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-header h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.history-actions {
    display: flex;
    gap: 4px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    padding-right: 2px;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 16px 8px;
    font-style: italic;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.history-item:hover {
    border-color: var(--border-hover);
    background: rgba(108, 92, 231, 0.06);
}

.history-item.active {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.12);
}

.history-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-title {
    font-size: 0.78rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
}

.history-item-time::after {
    content: '·';
    margin-left: 6px;
    color: var(--text-muted);
}

.history-item-count {
    color: var(--text-muted);
}

.history-item-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    flex-shrink: 0;
}

.history-item:hover .history-item-delete,
.history-item.active .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    color: #ff7675;
    background: rgba(255, 118, 117, 0.1);
}

.learning-card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.learning-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.learning-row strong {
    color: var(--success);
    font-size: 1.05rem;
}

.learning-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.btn-mini {
    padding: 6px 8px;
    font-size: 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.btn-mini:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.btn-mini.btn-danger:hover {
    border-color: #ff7675;
    color: #ff7675;
}

.result-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.result-action-btn {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.result-action-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.result-action-btn.btn-correct:hover {
    border-color: var(--warning);
    color: var(--warning);
}

.result-action-btn.btn-confirm:hover {
    border-color: var(--success);
    color: var(--success);
}

.result-action-btn.btn-discuss {
    border-color: rgba(108, 92, 231, 0.4);
    color: var(--accent-light);
}

.result-action-btn.btn-discuss:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(108, 92, 231, 0.12);
    box-shadow: 0 0 12px rgba(108, 92, 231, 0.3);
}

.discussion-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.12), rgba(162, 155, 254, 0.08));
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.82rem;
    animation: bannerIn 0.3s ease;
}

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

.discussion-banner-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.discussion-banner-info svg {
    color: var(--accent-light);
    flex-shrink: 0;
}

.discussion-banner-info strong {
    display: block;
    font-size: 0.78rem;
    color: var(--accent-light);
    margin-bottom: 2px;
}

.discussion-banner-info span {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-discuss-cancel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-discuss-cancel:hover {
    border-color: #ff7675;
    color: #ff7675;
}

.revised-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--success));
    color: var(--bg-primary);
    margin-left: 6px;
    letter-spacing: 0.4px;
}

.discussion-footer {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(108, 92, 231, 0.06);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
}

.discussion-footer-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.discussion-footer-hint strong {
    color: var(--accent-light);
}

.unsaved-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(253, 203, 110, 0.1);
    border-bottom: 1px solid rgba(253, 203, 110, 0.4);
    color: var(--text-primary);
    font-size: 0.82rem;
    animation: bannerIn 0.3s ease;
}

.unsaved-banner svg:first-child {
    color: var(--warning);
    flex-shrink: 0;
}

.unsaved-banner span {
    flex: 1;
    color: var(--text-secondary);
    line-height: 1.4;
}

.unsaved-banner span strong {
    color: var(--text-primary);
}

.unsaved-banner-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.unsaved-action-btn {
    background: rgba(253, 203, 110, 0.15);
    border: 1px solid rgba(253, 203, 110, 0.4);
    color: var(--warning);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.unsaved-action-btn:hover {
    background: rgba(253, 203, 110, 0.25);
    border-color: var(--warning);
}

.unsaved-dismiss {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.unsaved-dismiss:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.ai-reasoning {
    margin-top: 10px;
    padding: 10px 12px;
    border-left: 3px solid var(--accent);
    background: rgba(108, 92, 231, 0.06);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.ai-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    margin-left: 6px;
    letter-spacing: 0.5px;
}

.key-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(0, 206, 201, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 206, 201, 0.3);
    margin-left: 6px;
    letter-spacing: 0.3px;
    font-family: 'Courier New', monospace;
}

.key-badge.rotated {
    background: rgba(253, 203, 110, 0.15);
    color: var(--warning);
    border-color: rgba(253, 203, 110, 0.4);
    animation: rotatePulse 1.5s ease-in-out 2;
}

@keyframes rotatePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); box-shadow: 0 0 8px rgba(253, 203, 110, 0.4); }
}

.matched-tokens {
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.matched-token {
    display: inline-block;
    padding: 1px 6px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
    border-radius: 4px;
    margin-right: 4px;
    font-family: 'Courier New', monospace;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-backdrop[hidden] {
    display: none;
}

.toast[hidden] {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

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

.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row select {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition);
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-row select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

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

.form-row-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.test-result {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.5;
    word-break: break-all;
}

.test-result.success {
    background: rgba(0, 206, 201, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.test-result.error {
    background: rgba(255, 118, 117, 0.1);
    border: 1px solid #ff7675;
    color: #ff7675;
}

.api-keys-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.api-keys-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.api-keys-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.api-keys-list:empty::before {
    content: 'Belum ada key. Klik "Tambah Key" untuk mulai.';
    display: block;
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.api-keys-empty-note {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-style: italic;
}

.api-key-row {
    display: grid;
    grid-template-columns: auto 1fr 2fr auto;
    gap: 8px;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}

.api-key-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-muted);
    transition: var(--transition);
}

.api-key-status.ready { background: var(--success); box-shadow: 0 0 6px var(--success-glow); }
.api-key-status.cooldown { background: var(--warning); }
.api-key-status.error { background: #ff7675; }

.api-key-row input[type="text"],
.api-key-row input[type="password"] {
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    transition: var(--transition);
    min-width: 0;
}

.api-key-row input[type="text"]:focus,
.api-key-row input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.api-key-row input.api-key-label {
    font-size: 0.78rem;
}

.api-key-row input.api-key-value {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.btn-remove-key {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-remove-key:hover {
    border-color: #ff7675;
    color: #ff7675;
    background: rgba(255, 118, 117, 0.08);
}

.btn-add-key {
    margin-top: 4px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-add-key:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.06);
}

.btn-add-key:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.test-result-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.test-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.78rem;
    line-height: 1.4;
}

.test-result-item.ok {
    border-color: rgba(0, 206, 201, 0.4);
    background: rgba(0, 206, 201, 0.06);
}

.test-result-item.fail {
    border-color: rgba(255, 118, 117, 0.4);
    background: rgba(255, 118, 117, 0.06);
}

.test-result-item .tr-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.test-result-item.ok .tr-icon { background: var(--success); color: var(--bg-primary); }
.test-result-item.fail .tr-icon { background: #ff7675; color: white; }
.test-result-item.testing .tr-icon { background: var(--text-muted); color: var(--bg-primary); }

.test-result-item .tr-label {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    flex-shrink: 0;
}

.test-result-item .tr-msg {
    color: var(--text-secondary);
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.correction-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: var(--bg-primary);
}

.correction-option {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.correction-option:hover {
    background: var(--bg-tertiary);
}

.correction-option.selected {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.1);
}

.correction-option .opt-group {
    color: var(--accent-light);
    font-weight: 600;
    font-size: 0.85rem;
}

.correction-option .opt-kip {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-top: 2px;
}

.correction-option .opt-hashtag {
    color: var(--success);
    font-size: 0.7rem;
    margin-top: 4px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

.correction-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 24px 12px;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: #ff7675; }

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.status-badge.ai-on {
    background: rgba(108, 92, 231, 0.18);
    color: var(--accent-light);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.guide-modal {
    max-width: 640px;
}

.guide-body {
    gap: 18px;
}

.guide-intro {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.guide-intro strong {
    color: var(--text-primary);
}

.guide-section-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-top: 4px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.guide-paragraph {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.6;
}

.guide-paragraph strong {
    color: var(--text-primary);
}

.guide-callout {
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.85rem;
    line-height: 1.55;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.guide-callout strong {
    color: var(--text-primary);
}

.guide-callout.info {
    border-color: rgba(108, 92, 231, 0.4);
    background: rgba(108, 92, 231, 0.08);
}

.guide-callout.warn {
    border-color: rgba(253, 203, 110, 0.5);
    background: rgba(253, 203, 110, 0.08);
}

.guide-callout.danger {
    border-color: rgba(255, 118, 117, 0.5);
    background: rgba(255, 118, 117, 0.08);
}

.guide-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.guide-steps > li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.guide-steps > li > div {
    flex: 1;
    min-width: 0;
}

.guide-steps strong {
    color: var(--text-primary);
}

.guide-step-num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7c6cf0);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.guide-step-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin-top: 4px;
}

.guide-step-hint.inline {
    display: inline;
    margin-top: 0;
}

.guide-step-hint em,
.guide-intro em {
    color: var(--accent-light);
    font-style: normal;
}

.guide-buttons-demo {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.demo-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.demo-btn-confirm {
    background: rgba(0, 206, 201, 0.15);
    color: var(--success);
    border-color: rgba(0, 206, 201, 0.4);
}

.demo-btn-correct {
    background: rgba(253, 203, 110, 0.15);
    color: #fdcb6e;
    border-color: rgba(253, 203, 110, 0.4);
}

.demo-btn-discuss {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-light);
    border-color: rgba(108, 92, 231, 0.4);
}

.demo-btn-export {
    background: var(--bg-tertiary);
    color: var(--accent-light);
    border-color: var(--border);
}

.guide-arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.guide-sub-list {
    margin: 6px 0 0 18px;
    padding: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.guide-sub-list li {
    margin-bottom: 3px;
}

.guide-sub-list code {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--accent-light);
    font-family: 'Courier New', monospace;
}

.guide-export-box {
    background: rgba(0, 206, 201, 0.06);
    border: 1px solid rgba(0, 206, 201, 0.3);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.guide-export-box strong {
    color: var(--success);
    display: block;
    margin-bottom: 6px;
}

kbd {
    display: inline-block;
    padding: 2px 7px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    margin: 0 2px;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        height: 100vh;
        z-index: 100;
        box-shadow: var(--shadow);
    }
    .sidebar.open { left: 0; }
    .menu-toggle { display: block; }
    .message { max-width: 95%; }
    .modal { max-width: 100%; }
    .guide-modal { max-width: 100%; }
    .guide-buttons-demo { flex-direction: column; align-items: flex-start; gap: 4px; }
    .guide-arrow { display: none; }
}
