:root {
    --primary-color: #ff6b6b;
    --primary-gradient: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
    --secondary-color: #fca311;
    --bg-color: #12141d;
    --card-bg: #1e202e;
    --card-hover: #26293a;
    --text-main: #f1f3f5;
    --text-muted: #94a3b8;
    --nav-bg: rgba(18, 20, 29, 0.9);
    --search-bg: #1e202e;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --safe-top: env(safe-area-inset-top, 0px);
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-hover: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --search-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    padding-top: calc(60px + var(--safe-top));
    padding-bottom: 40px;
    user-select: none;
    -webkit-user-select: none;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Bar Header */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(60px + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.app-bar-container {
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-color);
    cursor: pointer;
}

.logo-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.icon-btn:active {
    transform: scale(0.92);
}

/* Hero Search */
.hero-search-wrapper {
    max-width: 800px;
    margin: 12px auto 0;
    padding: 0 16px;
}

.search-box {
    background: var(--search-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-main);
}

.clear-search-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
}

/* Main Content */
.app-content {
    max-width: 800px;
    margin: 16px auto 0;
}

/* Categories Bar (Horizontal Scrollable Chips) */
.categories-bar-wrapper {
    padding: 0 16px;
    margin-bottom: 16px;
}

.categories-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}

.categories-bar::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 8px 18px;
    border-radius: 50px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chip.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(255, 107, 107, 0.4);
}

/* Recipe Grid */
.recipe-grid {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Recipe Card (App Style) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Carousel inside Card */
.card-carousel-wrapper {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
    background: #0f111a;
}

.card-carousel {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.card-carousel::-webkit-scrollbar {
    display: none;
}

.carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    position: relative;
}

.carousel-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 5;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 20px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
}

.dot.active {
    background: white;
    width: 14px;
    border-radius: 10px;
}

.category-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(18, 20, 29, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: var(--secondary-color);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    border-radius: 20px;
    z-index: 5;
}

.share-btn-overlay {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(18, 20, 29, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: transform 0.2s ease;
}

.share-btn-overlay:active {
    transform: scale(0.9);
}

.card-body {
    padding: 18px 20px;
    cursor: pointer;
}

.card-title {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 10px;
    color: var(--text-main);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

.meta-chip {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Fullscreen Recipe Modal View */
.recipe-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.recipe-modal.active {
    transform: translateY(0);
}

.modal-nav {
    height: calc(56px + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 12px;
    padding-right: 12px;
    z-index: 10;
}

.modal-nav-title {
    font-weight: 800;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.modal-scroll-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 40px;
}

.detail-carousel-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
    background: #000;
}

.detail-body {
    padding: 24px 20px;
    max-width: 700px;
    margin: 0 auto;
}

.detail-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.25;
}

.detail-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 28px;
    padding: 14px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 107, 107, 0.15);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-text-val {
    font-weight: 800;
    font-size: 15px;
}

.stat-text-lbl {
    font-size: 12px;
    color: var(--text-muted);
}

.section-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ingredients-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 28px;
}

.ingredient-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 15px;
}

.ingredient-row:last-child {
    border-bottom: none;
}

.ingredient-name {
    font-weight: 600;
}

.ingredient-amt {
    font-weight: 800;
    color: var(--primary-color);
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.step-card {
    display: flex;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-md);
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-text {
    font-size: 15px;
    line-height: 1.5;
    padding-top: 4px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(18, 20, 29, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-md);
    z-index: 3000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}
