:root,
:root[data-tc-theme='ember'] {
    color-scheme: dark;
    --tc-shared-bg: #0a0909;
    --tc-shared-surface: rgba(20, 17, 16, 0.92);
    --tc-shared-surface-2: rgba(36, 29, 26, 0.82);
    --tc-shared-border: rgba(160, 125, 95, 0.28);
    --tc-shared-text: #fff7ed;
    --tc-shared-muted: #d6b18b;
    --tc-shared-accent: #f97316;
    --tc-shared-accent-rgb: 249, 115, 22;
    --tc-shared-glow: rgba(249, 115, 22, 0.14);
}

:root[data-tc-theme='dark'] {
    --tc-shared-bg: #070707;
    --tc-shared-surface: rgba(16, 16, 16, 0.94);
    --tc-shared-surface-2: rgba(27, 27, 27, 0.88);
    --tc-shared-border: rgba(163, 163, 163, 0.22);
    --tc-shared-text: #fafafa;
    --tc-shared-muted: #a3a3a3;
    --tc-shared-accent: #a3a3a3;
    --tc-shared-accent-rgb: 163, 163, 163;
    --tc-shared-glow: rgba(163, 163, 163, 0.045);
}

:root[data-tc-theme='glass'] {
    --tc-shared-bg: #071521;
    --tc-shared-surface: rgba(11, 31, 45, 0.56);
    --tc-shared-surface-2: rgba(25, 48, 64, 0.48);
    --tc-shared-border: rgba(255, 255, 255, 0.17);
    --tc-shared-text: #f8fcff;
    --tc-shared-muted: #96bed3;
    --tc-shared-accent: #38bdf8;
    --tc-shared-accent-rgb: 56, 189, 248;
    --tc-shared-glow: rgba(56, 189, 248, 0.15);
}

:root[data-tc-theme='midnight'] {
    --tc-shared-bg: #080c18;
    --tc-shared-surface: rgba(15, 23, 42, 0.92);
    --tc-shared-surface-2: rgba(30, 41, 59, 0.82);
    --tc-shared-border: rgba(100, 116, 139, 0.28);
    --tc-shared-text: #f8fafc;
    --tc-shared-muted: #94a3b8;
    --tc-shared-accent: #3b82f6;
    --tc-shared-accent-rgb: 59, 130, 246;
    --tc-shared-glow: rgba(59, 130, 246, 0.15);
}

:root[data-tc-theme='royal'] {
    --tc-shared-bg: #0a0712;
    --tc-shared-surface: rgba(20, 14, 34, 0.92);
    --tc-shared-surface-2: rgba(35, 25, 54, 0.82);
    --tc-shared-border: rgba(139, 123, 184, 0.28);
    --tc-shared-text: #faf5ff;
    --tc-shared-muted: #c4b5fd;
    --tc-shared-accent: #a855f7;
    --tc-shared-accent-rgb: 168, 85, 247;
    --tc-shared-glow: rgba(168, 85, 247, 0.15);
}

:root[data-tc-theme='ocean'] {
    --tc-shared-bg: #030e16;
    --tc-shared-surface: rgba(8, 27, 39, 0.92);
    --tc-shared-surface-2: rgba(15, 43, 60, 0.82);
    --tc-shared-border: rgba(56, 150, 188, 0.28);
    --tc-shared-text: #f0f9ff;
    --tc-shared-muted: #7dd3fc;
    --tc-shared-accent: #06b6d4;
    --tc-shared-accent-rgb: 6, 182, 212;
    --tc-shared-glow: rgba(6, 182, 212, 0.15);
}

:root[data-tc-theme='aurora'] {
    --tc-shared-bg: #041213;
    --tc-shared-surface: rgba(9, 30, 30, 0.92);
    --tc-shared-surface-2: rgba(20, 50, 48, 0.82);
    --tc-shared-border: rgba(45, 212, 191, 0.24);
    --tc-shared-text: #f0fdfa;
    --tc-shared-muted: #5eead4;
    --tc-shared-accent: #10b981;
    --tc-shared-accent-rgb: 16, 185, 129;
    --tc-shared-glow: rgba(16, 185, 129, 0.15);
}

:root[data-tc-theme='light'] {
    color-scheme: light;
    --tc-shared-bg: #f4f7fb;
    --tc-shared-surface: rgba(255, 255, 255, 0.94);
    --tc-shared-surface-2: rgba(241, 245, 249, 0.9);
    --tc-shared-border: rgba(100, 116, 139, 0.25);
    --tc-shared-text: #0f172a;
    --tc-shared-muted: #64748b;
    --tc-shared-accent: #8b5cf6;
    --tc-shared-accent-rgb: 139, 92, 246;
    --tc-shared-glow: rgba(139, 92, 246, 0.12);
}

html[data-tc-theme] body {
    color: var(--tc-shared-text);
    background-color: var(--tc-shared-bg) !important;
    transition: color 480ms cubic-bezier(.22, 1, .36, 1), background-color 480ms cubic-bezier(.22, 1, .36, 1);
}

html[data-tc-theme] :where(header, nav, aside, footer) {
    border-color: var(--tc-shared-border) !important;
    transition: color 480ms cubic-bezier(.22, 1, .36, 1), background-color 480ms cubic-bezier(.22, 1, .36, 1), border-color 480ms cubic-bezier(.22, 1, .36, 1), box-shadow 480ms cubic-bezier(.22, 1, .36, 1);
}

html[data-tc-theme='glass'] body {
    background-image: radial-gradient(circle at 12% 10%, rgba(56, 189, 248, .16), transparent 32rem), radial-gradient(circle at 88% 86%, rgba(129, 140, 248, .14), transparent 38rem) !important;
    background-attachment: fixed !important;
}

html[data-tc-theme='glass'] :where(header, nav, aside, footer) {
    background-color: var(--tc-shared-surface) !important;
    box-shadow: inset 0 1px rgba(255,255,255,.15), 0 18px 55px rgba(0,7,14,.22) !important;
    backdrop-filter: blur(22px) saturate(150%) !important;
}

html[data-tc-theme] .position-card {
    border-color: var(--tc-shared-border) !important;
    background-color: var(--tc-shared-surface) !important;
    background-image: linear-gradient(145deg, rgba(var(--tc-shared-accent-rgb), .075), transparent 54%) !important;
    box-shadow: 0 14px 42px rgba(0, 0, 0, .14), inset 0 1px rgba(255,255,255,.035) !important;
    transition: transform .24s cubic-bezier(.22,1,.36,1), border-color .24s ease, box-shadow .24s ease, background-color .48s ease !important;
}

html[data-tc-theme] .position-card:hover,
html[data-tc-theme] .position-card.selected {
    border-color: rgba(var(--tc-shared-accent-rgb), .48) !important;
    box-shadow: 0 20px 52px rgba(0,0,0,.2), 0 0 30px rgba(var(--tc-shared-accent-rgb), .08) !important;
    transform: translateY(-3px);
}

html[data-tc-theme='glass'] .position-card {
    background-color: rgba(11,31,45,.54) !important;
    background-image: linear-gradient(135deg, rgba(255,255,255,.095), rgba(255,255,255,.018) 58%, rgba(56,189,248,.055)) !important;
    box-shadow: inset 0 1px rgba(255,255,255,.14), 0 18px 48px rgba(0,7,14,.22) !important;
    backdrop-filter: blur(20px) saturate(145%);
}

/* Legacy theme controls are replaced by the shared TokenCraft picker. */
.theme-console,
.themes-panel {
    display: none !important;
}

html.tc-shared-theme-changing::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    pointer-events: none;
    background: radial-gradient(circle at 88% 8%, var(--tc-shared-glow), transparent 42rem);
    animation: tc-shared-flash .62s ease both;
}

.tc-shared-theme {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 2147483645;
    font: 600 13px/1.2 Inter, 'Segoe UI', sans-serif;
}

.tc-shared-theme-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 2.45rem;
    padding: 0 .85rem;
    color: var(--tc-shared-text);
    border: 1px solid var(--tc-shared-border);
    border-radius: .72rem;
    background: var(--tc-shared-surface);
    box-shadow: 0 14px 42px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.06);
    backdrop-filter: blur(18px) saturate(140%);
    cursor: pointer;
}

.tc-shared-current-dot {
    width: .46rem;
    height: .46rem;
    border-radius: 999px;
    background: var(--tc-shared-accent);
    box-shadow: 0 0 10px var(--tc-shared-accent);
}

.tc-shared-theme-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + .55rem);
    width: 13.5rem;
    padding: .38rem;
    border: 1px solid var(--tc-shared-border);
    border-radius: .72rem;
    background: var(--tc-shared-surface);
    box-shadow: 0 20px 60px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.055);
    backdrop-filter: blur(22px) saturate(145%);
    animation: tc-shared-menu-in .24s cubic-bezier(.22, 1, .36, 1) both;
}

.tc-shared-theme-menu[hidden] { display: none !important; }

.tc-shared-theme-menu button {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    min-height: 2.35rem;
    padding: .5rem .65rem;
    color: var(--tc-shared-muted);
    border: 0;
    border-radius: .48rem;
    background: transparent;
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease, transform .18s ease;
}

.tc-shared-theme-menu button:hover,
.tc-shared-theme-menu button[aria-checked='true'] {
    color: var(--tc-shared-text);
    background: rgba(var(--tc-shared-accent-rgb), .16);
    transform: translateX(2px);
}

.tc-shared-theme-menu button i {
    width: 1rem;
    color: var(--tc-shared-accent);
    font-style: normal;
    text-align: center;
}

.tc-shared-theme-menu button span { flex: 1; text-align: left; }
.tc-shared-theme-menu button b {
    width: .46rem;
    height: .46rem;
    border-radius: 999px;
    background: var(--tc-shared-accent);
    box-shadow: 0 0 9px var(--tc-shared-accent);
}

@keyframes tc-shared-menu-in {
    from { opacity: 0; transform: translateY(.5rem) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tc-shared-flash {
    0%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

@media (max-width: 680px) {
    .tc-shared-theme { right: .75rem; bottom: .75rem; }
    .tc-shared-theme-menu { width: min(13.5rem, calc(100vw - 1.5rem)); }
}

@media (prefers-reduced-motion: reduce) {
    .tc-shared-theme *, html.tc-shared-theme-changing::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
