:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a26;
    --bg-hover: #222233;
    --border: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f0f5;
    --text-secondary: #9898a8;
    --text-muted: #5c5c6e;
    --accent-purple: #a855f7;
    --accent-indigo: #6366f1;
    --accent-cyan: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #6366f1 50%, #06b6d4 100%);
    --accent-glow: rgba(99, 102, 241, 0.3);
    --danger: #ef4444;
    --success: #22c55e;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
    --sidebar-width: 260px;
    --mobile-nav-inner: 56px;
    --nav-shell-bg: #12121a;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-nav-h: calc(var(--mobile-nav-inner) + 8px);
    --mobile-header-h: 56px;
    --layout-bottom: var(--mobile-nav-h);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
    height: auto;
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-x: clip;
    overflow-y: auto;
    max-width: 100%;
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch;
}

/* تجربة تطبيق — منع النسخ والقائمة السياقية (مع استثناء الحقول والأكواد) */
body.app-body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body.app-body input,
body.app-body textarea,
body.app-body select,
body.app-body [contenteditable='true'],
body.app-body .allow-copy,
body.app-body .twofa-secret-row code {
    -webkit-user-select: text;
    user-select: text;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

.app-wrapper,
.main-content {
    max-width: 100%;
    overflow-x: clip;
}

img, video {
    max-width: 100%;
    display: block;
}

.hidden {
    display: none !important;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    transition: transform var(--transition), box-shadow var(--transition);
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 32px var(--accent-glow);
}

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

.btn-primary svg {
    width: 20px;
    height: 20px;
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: background var(--transition);
}

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

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group label svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.form-alert.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.form-alert.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.modal-over-story {
    z-index: 1300;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: background var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
}

.upload-zone {
    display: block;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 20px;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-indigo);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: var(--accent-indigo);
}

.upload-zone p {
    font-weight: 500;
    margin-bottom: 4px;
}

.upload-zone span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.preview-img {
    width: 100%;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    max-height: 300px;
    object-fit: cover;
}

.loading-skeleton .skeleton-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    height: 400px;
    margin-bottom: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

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