:root {
    --primary-blue: #0066FF;
    --primary-gradient: linear-gradient(135deg, #0066FF 0%, #00B2FF 100%);
    --bg-gradient: linear-gradient(180deg, #F0F7FF 0%, #FFFFFF 100%);
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.8);
    --soft-shadow: 0 12px 40px -12px rgba(0, 102, 255, 0.15);
    --text-main: #1A202C;
    --text-secondary: #718096;
    --radius-super: 32px;
    --radius-large: 24px;
    --radius-medium: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: transparent;
    position: relative;
    /* Removed default container shadow for cleaner look */
}

/* Header Style */
.app-header {
    height: 64px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    position: relative;
    flex-shrink: 0;
    z-index: 100;
}

#page-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.back-btn {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    color: var(--primary-blue);
    font-size: 20px;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:active {
    background: rgba(0, 102, 255, 0.1);
}

.user-avatar {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2);
    border: 2px solid #fff;
}

/* Content Area */
.app-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 20px;
    scrollbar-width: none; /* Firefox */
}

.app-content::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.content-section {
    display: none;
    min-height: 100%;
    height: auto;
    flex-direction: column;
}

.content-section.active {
    display: flex;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* AI Portal Styles */
.ai-portal-section {
    align-items: center;
    padding: 40px 24px;
}

.brand-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    margin-top: 20px;
}

.brand-logo-anim {
    width: 100px;
    height: 100px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.logo-core {
    font-size: 48px;
    z-index: 2;
    position: relative;
    filter: drop-shadow(0 10px 20px rgba(0, 102, 255, 0.2));
}

.logo-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(0, 102, 255, 0.15);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ring-1 {
    width: 100%;
    height: 100%;
    animation: pulse 3s infinite ease-in-out;
}

.ring-2 {
    width: 70%;
    height: 70%;
    animation: pulse 3s infinite ease-in-out 0.5s;
    border-color: rgba(0, 102, 255, 0.25);
}

.brand-title {
    font-size: 32px;
    font-weight: 800;
    color: #1a1a1a;
    margin-bottom: 8px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.brand-slogan {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.portal-actions {
    width: 100%;
    max-width: 400px;
    margin-bottom: 40px;
}

.fake-search-box {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: var(--glass-border);
    border-radius: var(--radius-super);
    padding: 18px 24px;
    text-decoration: none;
    box-shadow: var(--soft-shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.fake-search-box:active {
    transform: scale(0.98);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.search-icon {
    font-size: 20px;
    margin-right: 16px;
    color: var(--primary-blue);
}

.search-placeholder {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
}

.suggested-questions {
    width: 100%;
    max-width: 400px;
}

.suggestions-title {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-left: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggestion-item {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 16px 20px;
    border-radius: var(--radius-large);
    font-size: 15px;
    color: var(--text-main);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.4);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.suggestion-item::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-gradient);
    margin-right: 12px;
}

.suggestion-item:active {
    background: #fff;
    transform: scale(0.99);
}

/* Chat Section */
.chat-container {
    flex: 1;
    padding: 20px 24px 100px; /* Added extra bottom padding */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: none;
}

.chat-container::-webkit-scrollbar {
    display: none;
}

.message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: var(--radius-large);
    font-size: 16px;
    line-height: 1.6;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.system-message {
    align-self: flex-start;
    background-color: #fff;
    color: var(--text-main);
    border-top-left-radius: 4px;
    border: 1px solid rgba(0,0,0,0.03);
}

.user-message {
    align-self: flex-end;
    background: var(--primary-gradient);
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 8px 20px -4px rgba(0, 102, 255, 0.3);
}

.ai-input-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px 24px 24px;
    border-top: 1px solid rgba(255,255,255,0.5);
    z-index: 20;
}

.mode-switch {
    display: flex;
    margin-bottom: 16px;
    gap: 8px;
    background: rgba(0,0,0,0.04);
    padding: 4px;
    border-radius: 16px;
    width: fit-content;
}

.mode-btn {
    border: none;
    background: none;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 16px;
    cursor: pointer;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #fff;
    color: var(--primary-blue);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.mode-btn.active::after { display: none; }

.input-area {
    display: flex;
    align-items: center;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: var(--radius-super);
    padding: 6px 6px 6px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.input-area input {
    flex: 1;
    border: none;
    background: none;
    font-size: 16px;
    outline: none;
    padding: 10px 0;
    color: var(--text-main);
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    transition: transform 0.1s;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Content Area */
.app-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 90px; /* Space for the absolute nav bar */
    scrollbar-width: none; /* Firefox */
}

/* Learning Section */
.learning-section {
    padding: 12px 12px calc(90px + env(safe-area-inset-bottom)); /* Consistent 12px margins, plus nav space */
    background: transparent;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.learning-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.flash-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--glass-border);
    border-radius: var(--radius-super);
    box-shadow: var(--soft-shadow);
    padding: 24px 24px 120px; /* Extra bottom padding for buttons */
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    position: relative; /* For absolute buttons */
}

.card-type {
    font-size: 13px;
    color: var(--primary-blue);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 32px;
    background: rgba(0, 102, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    align-self: flex-start;
}

#question-text {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
    letter-spacing: -0.5px;
    flex: 1;
    display: flex;
    align-items: center;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 24px; /* Match card padding */
    position: absolute;
    bottom: 24px;
    left: 0;
    right: 0;
}

.action-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    font-size: 32px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-wrong {
    background-color: #FFF5F5;
    color: #FF3B30;
    border: 1px solid #FFE5E5;
    box-shadow: 0 8px 24px -6px rgba(255, 59, 48, 0.2);
}

.btn-correct {
    background-color: #F0FFF4;
    color: #34C759;
    border: 1px solid #D6FFDE;
    box-shadow: 0 8px 24px -6px rgba(52, 199, 89, 0.2);
}

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

.learning-progress {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    background: rgba(255,255,255,0.5);
    padding: 8px 16px;
    border-radius: 20px;
}

/* Review Popup */
.review-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 24px;
}

.review-popup-overlay.active {
    opacity: 1;
}

.review-popup-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: var(--glass-border);
    border-radius: var(--radius-super);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.review-popup-overlay.active .review-popup-content {
    transform: scale(1);
}

.review-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.review-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.close-popup {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.review-list {
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.review-item {
    background: white;
    padding: 16px;
    border-radius: var(--radius-large);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.03);
    cursor: pointer;
    transition: all 0.2s;
}

.review-item:active {
    transform: scale(0.98);
    background: #f8faff;
    border-color: var(--primary-blue);
}

.review-question {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.review-meta {
    display: flex;
    font-size: 13px;
    color: var(--text-secondary);
    gap: 12px;
}

.review-hint {
    font-size: 12px;
    color: var(--primary-blue);
    margin-top: 8px;
    text-align: right;
    font-weight: 500;
    opacity: 0.8;
}

/* News Section */
.news-section {
    background: transparent;
    padding-top: 10px;
}

.market-indices {
    padding: 20px 24px;
    gap: 12px;
    border-bottom: none;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.index-item {
    background: white;
    flex: 1;
    min-width: 100px;
    padding: 16px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.03);
}

.index-name {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.index-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
}

.index-item.up .index-value,
.index-item.up .index-change {
    color: #34C759;
}

.index-item.down .index-value,
.index-item.down .index-change {
    color: #FF3B30;
}

.news-categories-wrapper {
    background: transparent;
    border-bottom: none;
    padding: 0 24px 10px;
}

.news-categories {
    gap: 12px;
    padding: 8px 0;
}

.category-btn {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.5);
    border: 1px solid transparent;
}

.category-btn.active {
    background: #fff;
    color: var(--primary-blue);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.news-list {
    padding: 10px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.news-item {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: var(--radius-large);
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer; /* Added cursor pointer */
    transition: transform 0.2s, background 0.2s;
}

.news-item:active {
    transform: scale(0.98);
    background: #fff;
}

.news-time {
    font-size: 12px;
    color: var(--primary-blue);
    font-weight: 600;
    background: rgba(0, 102, 255, 0.08);
    width: fit-content;
    padding: 4px 8px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.news-content h4 {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
}

.news-content p {
    color: var(--text-secondary);
}

/* News Detail Page */
.news-detail-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.news-detail-page.active {
    transform: translateX(0);
}

.news-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 100px;
}

.news-actions {
    padding: 16px 24px calc(20px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: row;
    gap: 12px;
    background: white;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.news-action-btn {
    border-radius: var(--radius-large);
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.05);
    flex: 1;
    cursor: pointer;
}

.btn-ai-analyze {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 8px 20px -4px rgba(0, 102, 255, 0.3);
}

/* Navigation Bar */
.app-nav {
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.nav-item {
    opacity: 0.5;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-secondary);
}

.nav-item.active {
    color: var(--primary-blue);
    opacity: 1;
}

.nav-item .icon {
    font-size: 24px;
    /* Removed drop-shadow for pure color look */
}

.nav-item.active .icon {
    transform: translateY(-2px);
    /* Removed drop-shadow */
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.nav-item .label {
    font-size: 10px;
    font-weight: 500;
}

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

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

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.4; }
    100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.8; }
}
