:root {
    --primary-hue: 250;
    --primary: hsl(var(--primary-hue), 80%, 70%);
    --primary-dark: hsl(var(--primary-hue), 60%, 60%);
    --accent: #00CEC9;
    --bg-dark: #0a0b1e;
    --bg-light: #15172b;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --input-bg: rgba(0, 0, 0, 0.2);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;
}

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

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    /* Fixed height */
    overflow: hidden;
    /* Prevent body scroll */
    display: flex;
    justify-content: center;
    align-items: center;
    /* Center vertically on desktop */
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    /* Fill available height */
    max-height: 100vh;
    position: relative;
    background: var(--bg-light);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Container clips content */
}

/* Dynamic Backgrounds */
.bg-gradient-1,
.bg-gradient-2 {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.4;
}

.bg-gradient-1 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation: float 10s ease-in-out infinite alternate;
}

.bg-gradient-2 {
    width: 250px;
    height: 250px;
    background: var(--accent);
    bottom: 10%;
    left: -80px;
    opacity: 0.2;
    animation: float 15s ease-in-out infinite alternate-reverse;
}

@keyframes float {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(20px, 40px);
    }
}

/* Header */
.header {
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-md);
    position: relative;
    z-index: 2;
}

.status-bar-placeholder {
    height: env(safe-area-inset-top, 20px);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #ccc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Main Content */
.content {
    flex: 1;
    padding: 0 var(--spacing-sm) var(--spacing-lg);
    position: relative;
    z-index: 2;
    overflow-y: auto;
    /* Internal scroll */
    -webkit-overflow-scrolling: touch;
    /* Space for fixed button removed as button is now flex item */
}

/* Glass Panel */
.glass-panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
    padding: var(--spacing-md);
}

/* Input Groups */
.input-group {
    margin-bottom: var(--spacing-lg);
}

.group-title {
    font-size: 14px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: var(--spacing-sm);
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 0.9;
}

.input-wrapper {
    margin-bottom: var(--spacing-sm);
    position: relative;
}

.row {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.half {
    flex: 1;
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-left: 4px;
}

input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    outline: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-family: inherit;
}

input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.2);
}

/* Error State */
.input-wrapper.error input {
    border-color: #ff7675;
    box-shadow: 0 0 0 4px rgba(255, 118, 117, 0.2);
}

.error-msg {
    color: #ff7675;
    font-size: 11px;
    margin-top: 4px;
    margin-left: 4px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Shake Animation */
.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Loading Spinner */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    -webkit-animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@-webkit-keyframes spin {
    to {
        -webkit-transform: rotate(360deg);
    }
}

/* Action Bar - Flex Footer */
.action-bar {
    position: relative;
    width: 100%;
    padding: var(--spacing-md);
    background: linear-gradient(to top, var(--bg-light) 60%, rgba(21, 23, 43, 0));
    z-index: 10;
    display: block;
    margin-top: 0;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.primary-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.4);
    transition: transform 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.primary-btn:active {
    transform: scale(0.98);
}

/* Tabs UI */
.tabs-bar {
    display: flex;
    position: relative;
    padding: 0 16px;
    gap: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 5;
}

.tab-item {
    font-size: 15px;
    color: var(--text-muted);
    padding: 12px 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-item.active {
    color: var(--accent);
    font-weight: 700;
}

.tab-indicator {
    position: absolute;
    bottom: -1px;
    left: 16px;
    height: 3px;
    background: var(--accent);
    border-radius: 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tab Content Visibility */
.tab-pane {
    display: none;
    animation: slideIn 0.4s ease-out;
}

.tab-pane.active {
    display: block;
}

.ai-insight-box {
    background: rgba(108, 92, 231, 0.1);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 24px;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}