:root {
    --bg: #f4efe4;
    --card: #fffaf1;
    --gold: #b39359;
    --text: #1c1914;
    --muted: #6b6458;
    --border: #e4d9c6;
    --header-bg: rgba(244, 239, 228, 0.92);
}

:root.light-mode {
    --bg: #f4efe4;
    --card: #fffaf1;
    --text: #1c1914;
    --border: #e4d9c6;
    --header-bg: rgba(244, 239, 228, 0.92);
}

html[data-theme="dark"] {
    --bg: #1c1814;
    --card: #2a241c;
    --text: #f4efe4;
    --muted: #b3a48d;
    --border: #3d3428;
    --header-bg: rgba(28, 24, 20, 0.92);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: 'Tajawal', 'IBM Plex Sans Arabic', sans-serif;
    color: var(--text);
    background:
        radial-gradient(ellipse 80% 50% at 100% -10%, rgba(179, 147, 89, 0.1), transparent 55%),
        radial-gradient(ellipse 60% 40% at -5% 100%, rgba(56, 184, 181, 0.05), transparent 50%),
        var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

:root.light-mode body {
    background:
        radial-gradient(ellipse 80% 50% at 100% -10%, rgba(179, 147, 89, 0.08), transparent 55%),
        var(--bg);
}

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    top: -100px;
    right: 1rem;
    z-index: 10000;
    background: var(--gold);
    color: #1a140c;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
}
.skip-link:focus { top: 1rem; }

header {
    padding: 25px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-group {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 700;
    transition: 0.3s;
}

.nav-link:hover, .nav-link.active {
    color: var(--gold);
}

/* Dropdown for calculators */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    /* Inherits from .nav-link */
    cursor: pointer;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dropdown-content {
    display: block;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    position: absolute;
    background-color: var(--card);
    border: 1px solid var(--border);
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 8px;
    padding: 8px 0;
    margin-top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.dropdown-content a {
    color: var(--muted);
    padding: 10px 20px;
    text-decoration: none;
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    transition: 0.2s;
    white-space: nowrap;
}

.dropdown-content a:hover {
    background-color: rgba(179, 147, 89, 0.1);
    color: var(--gold);
}

.dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
}

.lbl {
    font-size: 0.6rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 15px;
    display: block;
}

.title {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
}

/* دائرة التحميل (Spinner) لرسوم TradingView */
.tv-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid rgba(179, 147, 89, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 0;
}
@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Utilities extracted from inline styles */
#logo {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    font-family: "Noto Naskh Arabic", "Amiri", serif;
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}
#logo::before {
    content: "";
    width: 2.15rem;
    height: 2.15rem;
    flex: 0 0 2.15rem;
    border-radius: 0.55rem;
    background: var(--text) url("/favicon.svg") center / contain no-repeat;
    box-shadow: 0 0 0 1px rgba(179, 147, 89, 0.35);
}
.logo-highlight { color: var(--gold); }
.text-gold { color: var(--gold); }
.text-blue { color: #38bdf8; }
.text-green { color: #34d399; }
.text-red { color: #ef4444; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Extracted inline styles for links */
#nav-builder {
    color: var(--gold);
}
.advisor-back-btn {
    text-decoration: none;
    border-color: #38bdf8;
    color: #38bdf8;
}
.builder-back-btn {
    text-decoration: none;
}