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

:root {
    --bg: #07080d;
    --surface: rgba(22, 24, 32, 0.72);
    --surface2: rgba(32, 35, 46, 0.85);
    --border: rgba(124, 138, 255, 0.16);
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.15);
    --cyan: #22d3ee;
    --cyan-light: #67e8f9;
    --cyan-glow: rgba(34, 211, 238, 0.18);
    --gradient-ai: linear-gradient(135deg, var(--cyan) 0%, var(--accent) 100%);
    --text: #e8eaf2;
    --text-muted: #7b8094;
    --error: #f87171;
    --sidebar-w: 240px;
}

* { scrollbar-width: thin; scrollbar-color: rgba(139, 92, 246, 0.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.35); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, 0.45); }
::-webkit-scrollbar-track { background: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    position: relative;
}

/* ── Futuristic ambient background ── */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(ellipse 900px 500px at 8% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(ellipse 800px 600px at 100% 10%, rgba(34, 211, 238, 0.12), transparent 60%),
        radial-gradient(ellipse 700px 500px at 30% 110%, rgba(34, 211, 238, 0.07), transparent 60%),
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: auto, auto, auto, 42px 42px, 42px 42px;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, rgba(18, 19, 28, 0.92), rgba(13, 14, 20, 0.92));
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--border);
    box-shadow: 1px 0 24px rgba(0, 0, 0, 0.35);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 18px 10px;
    overflow-y: auto;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    padding: 6px 10px 18px;
    flex-shrink: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
.logo:hover { opacity: 0.85; }
.logo-img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.55));
}
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-line1 {
    background: var(--gradient-ai);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.01em;
}
.logo-line2 {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-home {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    margin-bottom: 4px;
}
.nav-home:hover { background: var(--surface2); color: var(--text); }
.nav-home.active {
    background: linear-gradient(90deg, var(--accent-glow), var(--cyan-glow));
    color: var(--cyan-light);
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.25);
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px 8px;
}

/* Section (details/summary) */
.nav-section {
    margin-bottom: 2px;
}

.nav-section > summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: background 0.15s, color 0.15s;
}
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary:hover { background: var(--surface2); color: var(--text); }
.nav-section[open] > summary { color: var(--text); }

.nav-chevron {
    margin-left: auto;
    opacity: 0.4;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.nav-section[open] .nav-chevron { transform: rotate(90deg); }

/* Sub-items */
.nav-sub {
    padding: 3px 0 6px 28px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-sub-item {
    display: block;
    padding: 7px 12px;
    border-radius: 7px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.12s, color 0.12s;
}
.nav-sub-item:hover { background: var(--surface2); color: var(--text); }
.nav-sub-item.active {
    background: linear-gradient(90deg, var(--accent-glow), var(--cyan-glow));
    color: var(--cyan-light);
    font-weight: 500;
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.25);
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Main content ── */
.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 40px 44px;
    max-width: calc(100vw - var(--sidebar-w));
}

/* ── Page header ── */
.page-header { margin-bottom: 28px; }
.page-header h1 {
    font-size: 23px;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(90deg, var(--text) 40%, var(--cyan-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: inline-block;
}
.page-header p { color: var(--text-muted); font-size: 13px; }

/* ── Cards ── */
.card {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px rgba(0,0,0,0.18);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
    border-color: rgba(34, 211, 238, 0.22);
}

.card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
}

/* ── Form ── */
label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

textarea, input[type="text"], input[type="number"], input[type="url"], select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 9px 13px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
textarea:focus, input:focus, select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--cyan-glow);
}
textarea { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { margin-bottom: 14px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--gradient-ai);
    color: #06080f;
    box-shadow: 0 4px 18px rgba(34, 211, 238, 0.22), 0 4px 18px rgba(139, 92, 246, 0.18);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 22px rgba(34, 211, 238, 0.35), 0 4px 22px rgba(139, 92, 246, 0.28); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--cyan); color: var(--cyan-light); }

/* ── Result area ── */
.result-area {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-placeholder { color: var(--text-muted); text-align: center; font-size: 13px; }
.result-placeholder svg { display: block; margin: 0 auto 10px; opacity: 0.25; }

.result-img { max-width: 100%; border-radius: 8px; display: block; }
.result-video { max-width: 100%; border-radius: 8px; }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; width: 100%; }
.img-grid img { width: 100%; border-radius: 8px; display: block; }

/* ── Spinner ── */
.spinner {
    width: 28px; height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 10px;
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.5));
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-muted); font-size: 12px; text-align: center; }

/* ── Error ── */
.error-msg {
    color: var(--error);
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 13px;
}

/* ── Chat ── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 180px); max-height: 700px; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--surface2);
    border-radius: 10px;
    margin-bottom: 14px;
    scroll-behavior: smooth;
}

.chat-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.chat-msg.user {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}
.chat-msg.assistant {
    background: var(--surface);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}
.chat-msg.thinking {
    background: var(--surface);
    border: 1px solid var(--border);
    align-self: flex-start;
    color: var(--text-muted);
    font-style: italic;
    border-bottom-left-radius: 3px;
}

.chat-input-row { display: flex; gap: 9px; align-items: flex-end; }
.chat-input-row textarea { min-height: 44px; max-height: 140px; flex: 1; }

/* ── File upload ── */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
    position: relative;
}
.file-upload:hover { border-color: var(--accent); }
.file-upload.dragover { border-color: var(--accent); background: var(--surface2); }
.file-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-upload p { color: var(--text-muted); font-size: 13px; }
.file-name { color: var(--accent-light); margin-top: 6px; font-size: 13px; }

.preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.preview-remove:hover { background: rgba(220, 50, 50, 0.9); }

.preview-thumb { position: relative; display: inline-block; }
.preview-thumb .preview-remove { width: 18px; height: 18px; font-size: 13px; top: 2px; right: 2px; }

/* ── Transcription result ── */
.transcription-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    min-height: 120px;
    color: var(--text);
}

/* ── Download link ── */
.download-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--accent-light);
    font-size: 12px;
    text-decoration: none;
    margin-top: 10px;
}
.download-link:hover { text-decoration: underline; }

/* ── Dashboard grid ── */
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.dash-card {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    color: var(--text);
    transition: all 0.18s;
    display: block;
}

.dash-card-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent-glow), var(--cyan-glow));
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cyan-light);
    margin-bottom: 12px;
}

.dash-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.dash-card p { color: var(--text-muted); font-size: 12px; line-height: 1.5; }

.dash-card-subs {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dash-sub-tag {
    font-size: 11px;
    padding: 5px 11px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s;
    display: inline-block;
}
.dash-sub-tag:hover {
    border-color: var(--cyan);
    color: var(--cyan-light);
    background: var(--cyan-glow);
}

/* ── Two-column layout ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ── Model toggle ── */
.model-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.model-card {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.15s;
    display: block;
}
.model-card input[type="radio"] { display: none; }
.model-card:hover { border-color: var(--cyan); }
.model-card.active {
    border-color: var(--cyan);
    background: linear-gradient(135deg, var(--accent-glow), var(--cyan-glow));
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.2), 0 0 18px rgba(34, 211, 238, 0.12);
}
.model-card-inner { display: flex; flex-direction: column; gap: 3px; }
.model-name { font-weight: 600; font-size: 14px; }
.model-desc { font-size: 11px; color: var(--text-muted); }
.model-card.active .model-name { color: var(--cyan-light); }

/* ── Aspect ratio grid ── */
.ratio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ratio-btn {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.ratio-btn input[type="radio"] { display: none; }
.ratio-btn:hover { border-color: var(--cyan); }
.ratio-btn.active {
    border-color: var(--cyan);
    background: linear-gradient(135deg, var(--accent-glow), var(--cyan-glow));
}
.ratio-val { font-size: 13px; font-weight: 600; }
.ratio-label { font-size: 10px; color: var(--text-muted); }
.ratio-btn.active .ratio-val { color: var(--cyan-light); }

/* ── Quality toggle ── */
.quality-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.quality-btn {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.quality-btn input[type="radio"] { display: none; }
.quality-btn:hover { border-color: var(--cyan); }
.quality-btn.active {
    border-color: var(--cyan);
    background: linear-gradient(135deg, var(--accent-glow), var(--cyan-glow));
    color: var(--cyan-light);
}
.quality-sub { font-size: 11px; font-weight: 400; color: var(--text-muted); }

/* ── Edit model card ── */
.edit-model-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    transition: border-color 0.15s;
}
.edit-model-card.active {
    border-color: var(--cyan);
    background: linear-gradient(135deg, var(--accent-glow), var(--cyan-glow));
}

.edit-model-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}
.edit-model-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-light);
    background: rgba(124,58,237,0.2);
    padding: 2px 8px;
    border-radius: 20px;
}
.edit-model-desc-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.edit-model-params {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.param-tag {
    font-size: 11px;
    padding: 3px 9px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
}

/* ── Toggle switch ── */
.auto-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 22px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 2px; top: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--gradient-ai); border-color: var(--cyan); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); background: #fff; }

/* ── Auto prompt preview ── */
.auto-prompt-preview {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
    max-height: 90px;
    overflow-y: auto;
}

/* ── Copy button ── */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    margin-top: 10px;
}
.copy-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── Mobile top bar (hidden on desktop) ── */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    padding: 0 14px;
    background: linear-gradient(180deg, rgba(18, 19, 28, 0.95), rgba(13, 14, 20, 0.95));
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    z-index: 30;
}
.mobile-topbar .logo { padding: 0; }
.mobile-topbar .logo-img { width: 28px; height: 28px; }
.mobile-topbar .logo-line1 { font-size: 13px; }
.mobile-topbar .logo-line2 { font-size: 9px; }

.mobile-menu-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.mobile-menu-btn:hover { border-color: var(--cyan); color: var(--cyan-light); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 19;
}
.sidebar-overlay.visible { display: block; }

/* ── Responsive layout ── */
@media (max-width: 860px) {
    .mobile-topbar { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 20;
        padding-top: 70px;
        width: min(82vw, 300px);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar .logo { display: none; }

    .content {
        margin-left: 0;
        max-width: 100vw;
        padding: 70px 16px 32px;
    }

    .two-col { grid-template-columns: 1fr; }
    .dash-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .model-toggle { grid-template-columns: 1fr 1fr; }
    .ratio-grid { grid-template-columns: repeat(3, 1fr); }
    .quality-toggle { grid-template-columns: 1fr 1fr; }

    .page-header h1 { font-size: 19px; }

    .chat-wrap { height: calc(100vh - 220px); }
}

@media (max-width: 480px) {
    .model-toggle { grid-template-columns: 1fr; }
    .ratio-grid { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 70px 12px 28px; }
}

/* ── Site footer ── */
.site-footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.55;
}
