/* ==============================
   Apex MnK Aim Optimizer — Style
   ============================== */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --accent-blue: #4a9eff;
    --accent-red: #ff4655;
    --accent-green: #22c55e;
    --accent-orange: #f59e0b;
    --accent-purple: #a855f7;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --glass-bg: rgba(26, 26, 36, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

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

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(74, 158, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255, 70, 85, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- HEADER ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

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

.logo-icon {
    font-size: 28px;
    color: var(--accent-red);
    filter: drop-shadow(0 0 8px rgba(255, 70, 85, 0.5));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(255, 70, 85, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 16px rgba(255, 70, 85, 0.8));
    }
}

.header-logo h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-red);
    border: 1px solid rgba(255, 70, 85, 0.3);
    border-radius: 20px;
    padding: 4px 12px;
    background: rgba(255, 70, 85, 0.08);
    letter-spacing: 0.05em;
}

/* ---------- MAIN CONTAINER ---------- */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---------- SECTIONS ---------- */
.section {
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    transition: border-color var(--transition);
}

.section:hover {
    border-color: var(--border-hover);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-icon {
    font-size: 20px;
}

.collapse-icon {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform var(--transition);
}

.section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.section.collapsed .section-body {
    display: none;
}

.section-body {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
    color: var(--text-primary);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #3a7ad9);
    border-color: var(--accent-blue);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5aabff, var(--accent-blue));
    box-shadow: 0 4px 16px rgba(74, 158, 255, 0.3);
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-red), #d93a47);
    border-color: var(--accent-red);
    color: #fff;
}

.btn-accent:hover {
    background: linear-gradient(135deg, #ff5a68, var(--accent-red));
    box-shadow: 0 4px 16px rgba(255, 70, 85, 0.3);
}

.btn-danger {
    background: rgba(255, 70, 85, 0.1);
    border-color: rgba(255, 70, 85, 0.3);
    color: var(--accent-red);
}

.btn-danger:hover {
    background: rgba(255, 70, 85, 0.2);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-icon-left {
    font-size: 16px;
}

.btn-analyze {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    margin-top: 8px;
}

/* ---------- INPUTS ---------- */
input[type="text"],
input[type="password"],
input[type="number"],
select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    padding: 10px 14px;
    transition: all var(--transition);
    width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    display: block;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.help-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.help-text a {
    color: var(--accent-blue);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

/* ---------- API SETTINGS ---------- */
.api-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: end;
}

.api-key-group {
    min-width: 0;
}

.api-key-wrapper {
    display: flex;
    gap: 4px;
}

.api-key-wrapper input {
    flex: 1;
    min-width: 0;
}

.api-row .input-group:last-child {
    min-width: 200px;
}

/* ---------- VIDEO ---------- */
.video-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.video-preview-area {
    margin-top: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

.video-preview-area video {
    width: 100%;
    max-height: 360px;
    display: block;
}

.video-info {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

/* ---------- STATUS BAR ---------- */
.status-bar {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.status-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.step {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.step.active {
    color: var(--accent-blue);
    background: rgba(74, 158, 255, 0.1);
    border-color: rgba(74, 158, 255, 0.3);
    animation: step-pulse 1.5s ease-in-out infinite;
}

.step.done {
    color: var(--accent-green);
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.step.error {
    color: var(--accent-red);
    background: rgba(255, 70, 85, 0.1);
    border-color: rgba(255, 70, 85, 0.3);
}

@keyframes step-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(74, 158, 255, 0.2);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(74, 158, 255, 0.1);
    }
}

.step-arrow {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.4;
}

.status-message {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-bar {
    height: 3px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ---------- RESULT ---------- */
.result-content {
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.result-content::-webkit-scrollbar {
    width: 6px;
}

.result-content::-webkit-scrollbar-track {
    background: transparent;
}

.result-content::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

.pattern-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn-pattern {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition);
    position: relative;
}

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

.btn-pattern.pattern-a {
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--accent-green);
}

.btn-pattern.pattern-a:hover {
    background: rgba(34, 197, 94, 0.1);
}

.btn-pattern.pattern-b {
    border-color: rgba(74, 158, 255, 0.4);
    color: var(--accent-blue);
}

.btn-pattern.pattern-b:hover {
    background: rgba(74, 158, 255, 0.1);
}

.btn-pattern.pattern-c {
    border-color: rgba(245, 158, 11, 0.4);
    color: var(--accent-orange);
}

.btn-pattern.pattern-c:hover {
    background: rgba(245, 158, 11, 0.1);
}

.btn-pattern.pattern-restore {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.btn-pattern.recommended::after {
    content: '★推奨';
    font-size: 9px;
    position: absolute;
    top: -8px;
    right: -4px;
    background: var(--accent-red);
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
}

/* ---------- PRACTICE ROUTINE ---------- */
.practice-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.practice-options {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.practice-options select {
    width: auto;
    min-width: 160px;
}

.practice-content {
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ---------- CHAT ---------- */
.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    min-height: 100px;
}

.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;
}

.chat-msg {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.7;
    max-width: 85%;
    animation: msg-in 0.3s ease;
    white-space: pre-wrap;
    word-break: break-word;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.user {
    background: rgba(74, 158, 255, 0.12);
    border: 1px solid rgba(74, 158, 255, 0.2);
    align-self: flex-end;
}

.chat-msg.model {
    background: var(--bg-card);
    border: 1px solid var(--border);
    align-self: flex-start;
}

.chat-input-area {
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
}

.btn-chat-send {
    min-width: 72px;
}

/* ---------- SETTINGS PANEL ---------- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.setting-item label {
    margin-bottom: 10px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    outline: none;
    border: 1px solid var(--border);
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), #3a7ad9);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
    transition: all var(--transition);
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(74, 158, 255, 0.5);
}

.slider-value {
    min-width: 48px;
    text-align: right;
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-blue);
    font-variant-numeric: tabular-nums;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin-bottom: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 24px;
    transition: all var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: rgba(74, 158, 255, 0.2);
    border-color: var(--accent-blue);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background: var(--accent-blue);
}

.toggle-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.setting-hint {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

/* Per-Optic ADS */
.per-optic-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.per-optic-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.per-optic-toggle {
    font-size: 10px;
    transition: transform var(--transition);
}

.per-optic-toggle.open {
    transform: rotate(90deg);
}

.per-optic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- cm/360° GAUGE ---------- */
.cm360-display {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.cm360-header {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 16px;
}

.cm360-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cm360-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.cm360-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-blue);
    font-variant-numeric: tabular-nums;
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.3);
}

.gauge-container {
    max-width: 500px;
    margin: 0 auto;
}

.gauge-zones {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.zone {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
}

.zone-high {
    color: var(--accent-red);
}

.zone-mid {
    color: var(--accent-orange);
}

.zone-low {
    color: var(--accent-green);
}

.gauge-bar {
    position: relative;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg,
            rgba(255, 70, 85, 0.3) 0%,
            rgba(245, 158, 11, 0.3) 33%,
            rgba(34, 197, 94, 0.3) 66%,
            rgba(34, 197, 94, 0.3) 100%);
    margin-top: 4px;
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--accent-red), var(--accent-orange), var(--accent-green));
    transition: width 0.4s ease;
    opacity: 0.6;
}

.gauge-marker {
    position: absolute;
    top: -6px;
    width: 3px;
    height: 22px;
    border-radius: 2px;
    transition: left 0.4s ease;
}

.gauge-pro-avg {
    background: rgba(168, 85, 247, 0.8);
}

.marker-label {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-purple);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.gauge-current {
    background: var(--accent-blue);
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.5);
}

/* ---------- PROFILES ---------- */
.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-save-row,
.profile-load-row,
.profile-io-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.profile-save-row input {
    flex: 1;
    min-width: 200px;
}

.profile-load-row select {
    flex: 1;
    min-width: 200px;
}

.profile-list {
    margin-top: 12px;
}

/* ---------- HISTORY ---------- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.history-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-date {
    font-size: 13px;
    font-weight: 600;
}

.history-model {
    font-size: 11px;
    color: var(--text-secondary);
}

.history-score {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-orange);
}

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

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 24px;
    opacity: 0.7;
}

/* ---------- FOOTER ---------- */
.app-footer {
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid var(--border);
    margin-top: 20px;
    position: relative;
    z-index: 1;
}

.footer-donate {
    margin-bottom: 16px;
}

.donate-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.btn-donate-kofi {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    background: rgba(255, 94, 91, 0.12);
    border: 1px solid rgba(255, 94, 91, 0.35);
    color: #ff5e5b;
    transition: all var(--transition);
}

.btn-donate-kofi:hover {
    transform: translateY(-2px);
    background: rgba(255, 94, 91, 0.22);
    box-shadow: 0 4px 20px rgba(255, 94, 91, 0.25);
}

.footer-credit {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ---------- HEADER RIGHT ---------- */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-help {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-help:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: scale(1.1);
    box-shadow: 0 2px 12px rgba(74, 158, 255, 0.2);
}

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

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: rgba(255, 70, 85, 0.15);
    color: var(--accent-red);
}

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

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 3px;
}

/* Help sections */
.help-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.help-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.help-section h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.help-section p {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.help-steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
    margin: 8px 0;
}

.help-steps li {
    counter-increment: step;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-primary);
    padding: 8px 8px 8px 40px;
    position: relative;
    border-left: 2px solid var(--border);
    margin-left: 12px;
}

.help-steps li::before {
    content: counter(step);
    position: absolute;
    left: -14px;
    top: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-steps li:last-child {
    border-left-color: transparent;
}

.help-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.help-list li {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-primary);
    padding: 4px 0 4px 20px;
    position: relative;
}

.help-list li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--accent-blue);
    font-weight: 700;
}

.help-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
    word-break: break-all;
}

.help-link:hover {
    text-decoration: underline;
}

.help-note {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(74, 158, 255, 0.06);
    border: 1px solid rgba(74, 158, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 10px;
}

.help-faq {
    margin: 0;
}

.help-faq dt {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 10px;
}

.help-faq dt:first-child {
    margin-top: 0;
}

.help-faq dd {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 0;
    margin-top: 2px;
}

.help-section code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    color: var(--accent-orange);
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .header-inner {
        padding: 0 12px;
    }

    .main-container {
        padding: 12px;
    }

    .section-body {
        padding: 0 16px 16px;
    }

    .api-row {
        grid-template-columns: 1fr;
    }

    .api-row .input-group:last-child {
        min-width: 0;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .video-controls {
        flex-direction: column;
    }

    .video-controls .btn {
        width: 100%;
    }

    .header-badge {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-logo h1 {
        font-size: 16px;
    }

    .subtitle {
        font-size: 10px;
    }

    .cm360-value {
        font-size: 28px;
    }
}