* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: "Inter", sans-serif; 
    background: #fff;
    color: #111;
}
.script-text { font-family: "Playfair Display", serif; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

nav { 
    border-bottom: 1px solid #e5e5e5; 
    height: 55px; 
    display: flex; 
    align-items: center;
    padding: 0 40px;
}
nav .logo { 
    display: flex; 
    align-items: center; 
    gap: 8px;
    font-weight: 500;
}
nav .nav-right { 
    margin-left: auto; 
    display: flex; 
    gap: 16px; 
    align-items: center;
}
nav a { 
    text-decoration: none; 
    color: #666; 
    font-size: 13px;
    transition: color 0.2s;
}
nav a:hover { color: #111; }

.auth-page { 
    min-height: calc(100vh - 55px); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    padding: 40px 20px;
}
.auth-box { 
    border: 1px solid #e5e5e5; 
    padding: 40px; 
    max-width: 400px; 
    width: 100%;
}
.auth-box h2 { 
    font-size: 24px; 
    margin-bottom: 24px;
    font-weight: 500;
}
.auth-box .notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 12px;
    margin-bottom: 20px;
    font-size: 12px;
    color: #856404;
    line-height: 1.5;
}
.form-group { 
    margin-bottom: 16px; 
}
.form-group label { 
    display: block; 
    font-size: 13px; 
    margin-bottom: 6px;
    color: #666;
}
.form-group input { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid #d0d0d0; 
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus { 
    outline: none; 
    border-color: #111; 
}
.btn { 
    background: #111; 
    color: #fff; 
    border: none; 
    padding: 10px 20px; 
    font-size: 13px; 
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    transition: background 0.2s;
}
.btn:hover { background: #000; }
.btn:disabled { background: #ccc; cursor: not-allowed; }
.btn-secondary { 
    background: #f5f5f5; 
    color: #111; 
    border: 1px solid #d0d0d0;
}
.btn-secondary:hover { background: #e5e5e5; }
.link-text { 
    text-align: center; 
    margin-top: 20px; 
    font-size: 13px; 
    color: #666;
}
.link-text a { 
    color: #111; 
    text-decoration: underline;
    cursor: pointer;
}

.dashboard { padding: 40px 0; }
.dash-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}
.dash-header h1 { 
    font-size: 28px; 
    font-weight: 500; 
}
.dash-nav { 
    display: flex; 
    gap: 8px; 
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 32px;
}
.dash-nav button { 
    background: none; 
    border: none; 
    padding: 12px 16px; 
    font-size: 13px; 
    cursor: pointer;
    color: #666;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}
.dash-nav button.active { 
    color: #111; 
    border-bottom-color: #111;
}
.dash-nav button:hover { color: #111; }

.card { 
    border: 1px solid #e5e5e5; 
    padding: 24px;
    margin-bottom: 24px;
}
.card h3 { 
    font-size: 16px; 
    font-weight: 500; 
    margin-bottom: 16px;
}
.card p { 
    font-size: 13px; 
    color: #666; 
    line-height: 1.6;
    margin-bottom: 16px;
}

.stats { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 1px; 
    background: #e5e5e5;
    border: 1px solid #e5e5e5;
    margin-bottom: 32px;
}
.stat { 
    background: #fff; 
    padding: 24px;
}
.stat-value { 
    font-size: 32px; 
    font-weight: 500; 
    margin-bottom: 4px;
}
.stat-label { 
    font-size: 12px; 
    color: #666;
}

.key-item { 
    border-bottom: 1px solid #f0f0f0; 
    padding: 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.key-item:last-child { border-bottom: none; }
.key-info { flex: 1; }
.key-name { 
    font-size: 14px; 
    font-weight: 500; 
    margin-bottom: 4px;
}
.key-value { 
    font-size: 12px; 
    color: #666; 
    font-family: monospace;
    word-break: break-all;
}
.key-date { 
    font-size: 11px; 
    color: #999; 
    margin-top: 4px;
}
.btn-small { 
    padding: 6px 12px; 
    font-size: 12px;
    white-space: nowrap;
    width: auto;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 13px;
}
table th { 
    text-align: left; 
    padding: 12px 8px; 
    border-bottom: 1px solid #e5e5e5;
    font-weight: 500;
    color: #666;
    font-size: 12px;
}
table td { 
    padding: 12px 8px; 
    border-bottom: 1px solid #f5f5f5;
}
table tr:last-child td { border-bottom: none; }

.playground-container { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 24px;
}
@media (max-width: 768px) {
    .playground-container { grid-template-columns: 1fr; }
}
textarea { 
    width: 100%; 
    min-height: 300px; 
    padding: 12px; 
    border: 1px solid #d0d0d0;
    font-size: 13px;
    font-family: monospace;
    resize: vertical;
}
textarea:focus { 
    outline: none; 
    border-color: #111; 
}
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    font-size: 13px;
    font-family: inherit;
    background: white;
}
select:focus {
    outline: none;
    border-color: #111;
}

.hidden { display: none !important; }

#navUser:not(.hidden) { display: flex; }

.error { 
    background: #fee; 
    border: 1px solid #fcc; 
    padding: 12px; 
    margin-bottom: 16px;
    font-size: 13px;
    color: #c00;
}

.cf-turnstile { margin-bottom: 16px; }

/* Loading Spinners */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e5e5;
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-large {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Smooth Transitions */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
}

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

.dash-nav button {
    transition: all 0.2s ease;
}

input, textarea, select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.05);
}

/* Fade In Animation */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-card {
    height: 200px;
}

/* Provider Icons */
.provider-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Chat bubbles */
.chat-msg {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}
.chat-avatar.user { background: #111; color: #fff; }
.chat-avatar.assistant { background: #f0f0f0; color: #111; border: 1px solid #e0e0e0; }
.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-bubble.user { background: #111; color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble.assistant { background: #f5f5f5; color: #111; border: 1px solid #e5e5e5; border-bottom-left-radius: 3px; }

/* Blinking cursor */
.blink-cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background: #111;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s step-start infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}

/* System model modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}
.modal-box {
    background: #fff;
    border: 1px solid #e5e5e5;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    animation: fadeIn 0.3s ease;
}
.system-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #111;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.system-badge:hover { transform: scale(1.1); }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #111;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10001;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Docs code blocks */
.docs-block {
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 14px;
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre;
    position: relative;
}
.docs-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}
.docs-copy:hover { background: #f0f0f0; }
