:root {
    --bg-color: #000000;
    --card-bg: #1C1C1E;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --accent-color: #0A84FF; /* Apple Blue/Teal vibe */
    --danger-color: #FF453A;
    --nav-bg: rgba(28, 28, 30, 0.85); /* Glassmorphism */
    --font-main: 'Kanit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Typography & Utilities */
h1, h2, h3 { font-weight: 500; letter-spacing: -0.5px; }
.text-secondary-light { color: #AEAEB2; }
.spacing-2 { letter-spacing: 2px; }

/* Custom Components */
.custom-card {
    background-color: var(--card-bg);
    border-radius: 18px;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}

.custom-modal {
    background-color: #2C2C2E;
    color: var(--text-primary);
    border-radius: 20px;
    border: 1px solid #3A3A3C;
}

/* Bottom Navigation (Apple Style) */
.custom-nav {
    background-color: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid #38383A;
    padding-bottom: env(safe-area-inset-bottom); /* iPhone Home Bar fix */
}

.nav-link-custom {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.75rem;
    padding: 8px 0;
    transition: color 0.3s;
    background: none;
    border: none;
    cursor: pointer;
}

.nav-link-custom i {
    display: block;
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.nav-link-custom.active {
    color: var(--accent-color);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Emergency Charge Button Pulse */
.charge-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-color) 0%, rgba(10,132,255,0.4) 70%);
    border: none;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(10,132,255,0.6);
    animation: pulse 2s infinite;
    margin: 50px auto;
    display: block;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(10,132,255,0.6); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(10,132,255,0.8); }
    100% { transform: scale(1); box-shadow: 0 0 20px rgba(10,132,255,0.6); }
}

/* Black Hole Logic */
.black-hole-input {
    background-color: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid #3A3A3C;
    border-radius: 12px;
    width: 100%;
    min-height: 150px;
    padding: 15px;
    font-size: 1.1rem;
}

.black-hole-input:focus {
    background-color: #2C2C2E;
    outline: none;
    border-color: var(--accent-color);
    color: white;
}

.sucking-anim {
    transition: all 1.5s ease-in;
    transform: scale(0) rotate(720deg);
    opacity: 0;
    filter: blur(10px);
}

/* Music Iframe */
.iframe-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    border-radius: 12px;
    background-color: #000;
}

.iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* แก้ไขสีชื่อผู้แต่ง (Author) ใน Modal ให้เป็นสีขาว */
#result-author {
    color: #FFFFFF !important;
}


/* --- Music Page Gimmicks --- */

/* 1. Fake Audio Visualizer */
.visualizer-container {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 20px;
}

.bar {
    width: 6px;
    background: var(--accent-color);
    border-radius: 99px;
    animation: visualize 1s ease-in-out infinite;
}

/* สร้างจังหวะที่แตกต่างกันให้แต่ละแท่ง */
.bar:nth-child(1) { height: 20px; animation-delay: 0.1s; }
.bar:nth-child(2) { height: 40px; animation-delay: 0.3s; }
.bar:nth-child(3) { height: 50px; animation-delay: 0.0s; }
.bar:nth-child(4) { height: 30px; animation-delay: 0.4s; }
.bar:nth-child(5) { height: 45px; animation-delay: 0.2s; }
.bar:nth-child(6) { height: 25px; animation-delay: 0.1s; }

@keyframes visualize {
    0%, 100% { transform: scaleY(1); opacity: 0.5; }
    50% { transform: scaleY(1.5); opacity: 1; filter: drop-shadow(0 0 5px var(--accent-color)); }
}

/* 2. Horizontal Scroll Filters */
.filter-scroll {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 5px;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.filter-scroll::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.filter-chip {
    white-space: nowrap;
    background-color: var(--card-bg);
    border: 1px solid #3A3A3C;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.filter-chip.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(10,132,255,0.4);
}

.filter-chip:hover {
    border-color: var(--accent-color);
}

/* Surprise Me Button */
.surprise-btn {
    background: linear-gradient(45deg, #FF9500, #FF3B30);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(255, 59, 48, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.surprise-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4);
}

.surprise-btn i {
    font-size: 1.1rem;
}

/* --- Search Bar --- */
.search-container {
    position: relative;
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    background-color: #2C2C2E; /* สีเทาเข้มแบบ Apple Input */
    border: none;
    border-radius: 12px;
    padding: 12px 15px 12px 45px; /* เว้นที่ด้านซ้ายให้ไอคอน */
    color: var(--text-primary);
    font-size: 1rem;
    transition: background-color 0.2s;
}

.search-input:focus {
    outline: none;
    background-color: #3A3A3C; /* สว่างขึ้นนิดนึงตอนกด */
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.1rem;
    pointer-events: none; /* กดทะลุไอคอนได้ */
}

/* --- Gimmick 1: Battery Charging Effect (Home) --- */
.battery-container {
    width: 200px;
    height: 100px;
    border: 4px solid var(--text-secondary);
    border-radius: 15px;
    position: relative;
    margin: 50px auto;
    padding: 5px;
    display: none; /* ซ่อนไว้ก่อน */
}

.battery-container::after {
    content: '';
    position: absolute;
    right: -12px;
    top: 25px;
    width: 8px;
    height: 40px;
    background: var(--text-secondary);
    border-radius: 0 4px 4px 0;
}

.battery-level {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FF9500, #34C759);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(52, 199, 89, 0.5);
    transition: width 0.1s linear;
}

.charging-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    white-space: nowrap;
    z-index: 10;
}

/* --- Gimmick 2: Space Atmosphere (Vent) --- */
.space-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
    z-index: -1;
    overflow: hidden;
}

.stars {
    width: 2px; height: 2px;
    background: transparent;
    box-shadow: 100px 200px #FFF, 300px 500px #FFF, 500px 100px #FFF, 
                600px 300px #FFF, 800px 50px #FFF, 200px 600px #FFF, 
                400px 400px #FFF, 700px 700px #FFF; /* สร้างดาวปลอมด้วย Shadow */
    animation: animStar 50s linear infinite;
}

.stars::after {
    content: " ";
    position: absolute;
    top: 2000px; width: 2px; height: 2px;
    background: transparent;
    box-shadow: 100px 200px #FFF, 300px 500px #FFF, 500px 100px #FFF, 
                600px 300px #FFF, 800px 50px #FFF, 200px 600px #FFF, 
                400px 400px #FFF, 700px 700px #FFF;
}

@keyframes animStar {
    from { transform: translateY(0px); }
    to { transform: translateY(-2000px); }
}

/* Black Hole Warp Animation */
.warp-speed {
    animation: warpOut 0.8s ease-in forwards;
    transform-origin: center;
}

@keyframes warpOut {
    0% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(0.1) rotate(180deg); opacity: 0.5; filter: blur(5px); }
    100% { transform: scale(0) rotate(720deg); opacity: 0; }
}


/* --- Developer Profile Page --- */
.dev-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--card-bg);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}

.social-link {
    color: var(--text-secondary);
    font-size: 1.5rem;
    margin: 0 10px;
    transition: all 0.3s;
}

.social-link:hover {
    color: var(--accent-color);
    transform: translateY(-3px);
}

/* How-to Modal List */
.howto-icon {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 10px;
}

/* --- Search & Sort Layout --- */
.search-sort-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.search-container {
    flex-grow: 1; /* ให้ช่องค้นหายืดเต็มพื้นที่ที่เหลือ */
    margin-bottom: 0 !important; /* ลบ margin เดิมออก */
}

.sort-btn {
    background-color: #2C2C2E;
    color: var(--text-secondary);
    border: none;
    border-radius: 12px;
    padding: 0 15px;
    height: 48px; /* ความสูงเท่าช่องค้นหา */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.sort-btn:active {
    transform: scale(0.95);
    background-color: #3A3A3C;
}

.sort-btn.active {
    color: var(--accent-color);
    background-color: rgba(10, 132, 255, 0.1);
}