:root {
    /* ============================================
       DARK THEME - Apple HIG Optimized
       Base → Elevated → Secondary Elevated
       ============================================ */
    
    /* Background layers (darker = further back) */
    --bg-app: #000000;              /* Pure black - great for OLED */
    --bg-card: #1c1c1e;             /* Elevated surface - cards */
    --bg-secondary: #2c2c2e;        /* Secondary elevated - inputs, controls */
    --bg-tertiary: #3a3a3c;         /* Tertiary - hover states */
    
    /* Text hierarchy */
    --text-main: #ffffff;           /* Primary text */
    --text-secondary: #ebebf5;      /* Secondary text - 60% opacity feel */
    --text-muted: #8e8e93;          /* Tertiary/placeholder text */
    --text-quaternary: #636366;     /* Disabled text */
    
    /* Semantic colors - vibrant for dark mode */
    --accent: #0a84ff;              /* iOS blue - links, primary actions */
    --green: #30d158;               /* Success, positive values */
    --red: #ff453a;                 /* Error, negative values */
    --orange: #ff9f0a;              /* Warning, alerts */
    --yellow: #ffd60a;              /* Favorites, highlights */
    
    /* Borders & separators */
    --border: rgba(84, 84, 88, 0.65);           /* Opaque separator */
    --border-light: rgba(84, 84, 88, 0.35);     /* Non-opaque separator */
    
    /* Fills for controls */
    --fill-primary: rgba(120, 120, 128, 0.36);  /* Toggle off, slider track */
    --fill-secondary: rgba(120, 120, 128, 0.24);
    --fill-tertiary: rgba(120, 120, 128, 0.18);
    
    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    
    /* Shadows - subtle glow effect in dark mode */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --glow-accent: 0 0 20px rgba(10, 132, 255, 0.3);
    --glow-green: 0 0 12px rgba(48, 209, 88, 0.4);
    
    /* Safe Area Insets (set by JS for Telegram Mini App) */
    --safe-area-top: 0px;
    --safe-area-bottom: 0px;
    --safe-area-left: 0px;
    --safe-area-right: 0px;
    --content-safe-area-top: 0px;
    --content-safe-area-bottom: 0px;
    --content-safe-area-left: 0px;
    --content-safe-area-right: 0px;
}

/* Light Theme */
[data-theme="light"] {
    /* Background layers */
    --bg-app: #f2f2f7;
    --bg-card: #ffffff;
    --bg-secondary: #e5e5ea;
    --bg-tertiary: #d1d1d6;
    
    /* Text hierarchy */
    --text-main: #000000;
    --text-secondary: #3c3c43;
    --text-muted: #6e6e73;
    --text-quaternary: #aeaeb2;
    
    /* Semantic colors - slightly less saturated for light mode */
    --accent: #007aff;
    --green: #34c759;
    --red: #ff3b30;
    --orange: #ff9500;
    --yellow: #ffcc00;
    
    /* Borders & separators */
    --border: rgba(60, 60, 67, 0.29);
    --border-light: rgba(60, 60, 67, 0.12);
    
    /* Fills for controls */
    --fill-primary: rgba(120, 120, 128, 0.2);
    --fill-secondary: rgba(120, 120, 128, 0.16);
    --fill-tertiary: rgba(120, 120, 128, 0.12);
    
    /* Shadows */
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    --glow-accent: none;
    --glow-green: none;
}

/* ============================================
   DARK THEME - Enhanced Styling
   Following iOS/Apple Human Interface Guidelines
   ============================================ */

/* --- Dark Theme: Cards with subtle elevation glow --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.card:active {
    background: var(--bg-secondary);
    border-color: var(--border);
}

/* Glass hover effect for cards */
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 100%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: inherit;
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .card::before {
    background: linear-gradient(
        135deg,
        rgba(0, 0, 0, 0.02) 0%,
        rgba(0, 0, 0, 0.04) 50%,
        rgba(0, 0, 0, 0.02) 100%
    );
}

[data-theme="light"] .card:hover {
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* --- Dark Theme: Status Bar with vibrancy --- */
.status-bar {
    background: rgba(0, 0, 0, 0.72);
    border-bottom: 1px solid var(--border-light);
}

/* --- Dark Theme: Tabs Navigation --- */
.tabs-nav {
    background: rgba(0, 0, 0, 0.72);
    border-bottom: 1px solid var(--border-light);
}

/* --- Dark Theme: Bottom Sheet --- */
.sheet-content {
    background: rgba(28, 28, 30, 0.97);
    border-top: 1px solid var(--border-light);
}

/* --- Dark Theme: Toggle Slider --- */
.slider {
    background-color: var(--fill-primary);
}

.slider:before {
    background-color: #ffffff;
    box-shadow: 
        0 3px 8px rgba(0, 0, 0, 0.4),
        0 1px 1px rgba(0, 0, 0, 0.3);
}

/* --- Dark Theme: Settings Sections --- */
.settings-section {
    border-bottom: 1px solid var(--border-light);
}

.switch {
    border-bottom: 1px solid var(--border-light);
}

.switches-group .switch {
    border-bottom: 1px solid var(--border-light);
}

/* --- Dark Theme: Exchange Buttons with glow --- */
.ex-btn {
    background: var(--fill-tertiary);
    color: var(--text-muted);
    border: 1px solid transparent;
}

.ex-btn:hover {
    background: var(--fill-secondary);
    color: var(--text-secondary);
}

.ex-btn.active {
    background: linear-gradient(135deg, rgba(48, 209, 88, 0.2), rgba(10, 132, 255, 0.15));
    color: #ffffff;
    border-color: rgba(48, 209, 88, 0.4);
    box-shadow: 
        0 0 12px rgba(48, 209, 88, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.ex-btn.active:hover {
    background: linear-gradient(135deg, rgba(48, 209, 88, 0.28), rgba(10, 132, 255, 0.22));
    box-shadow: 
        0 0 16px rgba(48, 209, 88, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* --- Dark Theme: Input Fields --- */
input[type="number"] {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    color: var(--text-main);
}

input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

/* --- Dark Theme: Adjust Buttons --- */
.adjust-btn {
    background: var(--fill-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-light);
}

.adjust-btn:hover {
    background: var(--fill-primary);
}

.adjust-btn:active {
    background: var(--bg-tertiary);
}

/* --- Dark Theme: Primary Button with glow --- */
.primary-btn {
    background: var(--accent);
    box-shadow: 0 0 20px rgba(10, 132, 255, 0.25);
}

.primary-btn:hover {
    box-shadow: 0 0 24px rgba(10, 132, 255, 0.35);
}

.primary-btn:active {
    transform: scale(0.98);
    box-shadow: 0 0 16px rgba(10, 132, 255, 0.2);
}

/* --- Dark Theme: Details View --- */
.details-view {
    background: var(--bg-app);
}

.details-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

/* --- Dark Theme: Orderbook with subtle depth --- */
.books-section {
    background: var(--bg-app);
}

.book-panel {
    background: var(--bg-card);
    border-right: 1px solid var(--border-light);
}

/* --- Dark Theme: Alerts section --- */
.alerts-section {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

/* --- Dark Theme: Alert inputs --- */
.alert-group input {
    background: var(--bg-app);
    border: 1px solid var(--border-light);
}

.alert-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

/* --- Dark Theme: Chart section --- */
.chart-section {
    border-bottom-color: var(--border-light);
}

/* --- Dark Theme: Liquidity section --- */
.liq-section {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

.slider-container input[type=range]::-webkit-slider-runnable-track {
    background: var(--fill-primary);
}

.slider-container input[type=range]::-webkit-slider-thumb {
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* --- Dark Theme: Status table --- */
#exchange-status-table td {
    border-bottom: 1px solid var(--border-light);
}

.ex-status-dot {
    background: var(--fill-primary);
}

/* --- Dark Theme: Meta row separator --- */
.meta-row {
    border-top: 1px solid var(--border-light);
}

/* --- Dark Theme: Inactive card --- */
.card.inactive {
    background: rgba(28, 28, 30, 0.5);
    border: 1px dashed var(--border);
}

/* --- Dark Theme: Icon button active state --- */
.icon-btn:active {
    background: var(--fill-secondary);
}

/* --- Dark Theme: Lang/Theme buttons --- */
.lang-btn,
.theme-btn {
    background: var(--fill-tertiary);
    border: 2px solid transparent;
    color: var(--text-muted);
}

.lang-btn:hover,
.theme-btn:hover {
    background: var(--fill-secondary);
}

.lang-btn.active,
.theme-btn.active {
    border-color: var(--accent);
    color: var(--text-main);
    background: rgba(10, 132, 255, 0.12);
}

/* --- Dark Theme: Chart frame --- */
#chart-frame {
    background: var(--bg-app);
}

/* ============================================
   LIGHT THEME - Complete Styling
   Following iOS/Apple Human Interface Guidelines
   ============================================ */

/* Favorite button - no background, clean look */
.fav-btn {
    background: transparent !important;
}

/* Favorite icon default color (dark theme) */
.fav-btn .fav-icon {
    color: rgba(255, 255, 255, 0.5);
}

/* --- Light Theme: Favorite Button --- */
[data-theme="light"] .fav-btn .fav-icon {
    color: rgba(60, 60, 67, 0.3);
}

[data-theme="light"] .details-fav-btn:not(.active) .details-fav-icon {
    color: rgba(60, 60, 67, 0.3);
}

/* --- Light Theme: Status Bar & Navigation --- */
[data-theme="light"] .status-bar {
    background: rgba(249, 249, 249, 0.94);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] #status-text {
    color: #1c1c1e;
}

[data-theme="light"] .tab-logo {
    color: #1c1c1e;
}

[data-theme="light"] .tabs-nav {
    background: rgba(249, 249, 249, 0.94);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* --- Light Theme: Cards --- */
[data-theme="light"] .card {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .card:active {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .card.inactive {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.15);
}

/* --- Light Theme: Bottom Sheet --- */
[data-theme="light"] .sheet-backdrop {
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .sheet-content {
    background: rgba(255, 255, 255, 0.98);
}

/* --- Light Theme: Settings Sections --- */
[data-theme="light"] .settings-section {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .switch {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .switches-group .switch {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* --- Light Theme: Toggle Slider --- */
[data-theme="light"] .slider {
    background-color: rgba(120, 120, 128, 0.16);
}

[data-theme="light"] .slider:before {
    background-color: #ffffff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
}

[data-theme="light"] .disabled-feature .slider {
    background-color: rgba(120, 120, 128, 0.08) !important;
}

/* --- Light Theme: Exchange Buttons --- */
[data-theme="light"] .ex-btn {
    background: rgba(0, 0, 0, 0.04);
    color: rgba(60, 60, 67, 0.6);
}

[data-theme="light"] .ex-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(60, 60, 67, 0.8);
}

[data-theme="light"] .ex-btn.active {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.15), rgba(0, 122, 255, 0.12));
    color: var(--text-main);
    box-shadow: 
        0 0 0 1px rgba(52, 199, 89, 0.3),
        0 2px 6px rgba(52, 199, 89, 0.1);
    text-shadow: none;
}

[data-theme="light"] .ex-btn.active:hover {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.22), rgba(0, 122, 255, 0.18));
    box-shadow: 
        0 0 0 1px rgba(52, 199, 89, 0.4),
        0 3px 8px rgba(52, 199, 89, 0.15);
}

/* --- Light Theme: Exchange Status Table --- */
[data-theme="light"] #exchange-status-table td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ex-status-dot {
    background: rgba(60, 60, 67, 0.18);
}

/* --- Light Theme: Input Fields --- */
[data-theme="light"] input[type="number"] {
    background: rgba(118, 118, 128, 0.12);
    border-color: transparent;
    color: var(--text-main);
}

[data-theme="light"] input[type="number"]:focus {
    border-color: var(--accent);
    background: #ffffff;
}

[data-theme="light"] .alert-group input {
    background: rgba(118, 118, 128, 0.12);
    border-color: transparent;
}

[data-theme="light"] .alert-group input:focus {
    background: #ffffff;
    border-color: var(--accent);
}

/* --- Light Theme: Adjust Buttons (+/-) --- */
[data-theme="light"] .adjust-btn {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-main);
}

[data-theme="light"] .adjust-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .adjust-btn:active {
    background: rgba(0, 0, 0, 0.15);
}

/* --- Light Theme: Details View --- */
[data-theme="light"] .details-view {
    background: rgba(242, 242, 247, 0.98);
}

[data-theme="light"] .details-header {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .icon-btn:active {
    background: rgba(0, 0, 0, 0.08);
}

/* --- Light Theme: Liquidity Section --- */
[data-theme="light"] .liq-section {
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] #liq-amount {
    color: var(--text-main);
}

[data-theme="light"] .slider-container input[type=range]::-webkit-slider-thumb {
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .slider-container input[type=range]::-webkit-slider-runnable-track {
    background: rgba(120, 120, 128, 0.16);
}

/* --- Light Theme: Alerts Section --- */
[data-theme="light"] .alerts-section {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* --- Light Theme: Orderbook --- */
[data-theme="light"] .books-section {
    background: #ffffff;
}

[data-theme="light"] .book-panel {
    background: #ffffff;
    border-right-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chart-section {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] #chart-frame {
    background: #ffffff;
}

/* --- Light Theme: Scrollbars --- */
[data-theme="light"] body.split-view #feed::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(52, 199, 89, 0.3) 0%, rgba(0, 122, 255, 0.3) 100%);
}

[data-theme="light"] body.split-view #feed::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(52, 199, 89, 0.5) 0%, rgba(0, 122, 255, 0.5) 100%);
}

[data-theme="light"] body.split-view #fav-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(255, 179, 0, 0.35) 0%, rgba(255, 149, 0, 0.35) 100%);
}

[data-theme="light"] body.split-view #fav-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(255, 179, 0, 0.55) 0%, rgba(255, 149, 0, 0.55) 100%);
}

/* Firefox scrollbar light theme */
[data-theme="light"] body.split-view #feed {
    scrollbar-color: rgba(52, 199, 89, 0.3) transparent;
}

[data-theme="light"] body.split-view #fav-panel {
    scrollbar-color: rgba(255, 179, 0, 0.35) transparent;
}

/* --- Light Theme: Misc Elements --- */
[data-theme="light"] .fav-container {
    border-left-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .meta-row {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .header-beta {
    background: linear-gradient(135deg, #34c759, #007aff);
    color: #ffffff;
}


/* SF Distant Galaxy font for logo (second font in the file) */
@font-face {
    font-family: 'SF Distant Galaxy';
    src: url('../fonts/SF.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body {
    background-color: transparent;
    /* Allow splash screen to show through */
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

/* Status Bar - Base layout (colors in theme blocks) */
.status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    box-sizing: border-box;
    transition: background 0.2s ease;
}

/* On mobile with safe area, extend header to top of screen */
body.has-safe-area .status-bar {
    height: calc(44px + var(--safe-area-top) + var(--content-safe-area-top));
    align-items: flex-end;
    padding-bottom: 10px;
}

.status-left,
.status-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-left {
    justify-content: flex-start;
}

.status-right {
    justify-content: flex-end;
}

.status-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}

/* On mobile with safe area, lift logo up into safe area zone (between Telegram buttons) */
body.has-safe-area .status-center {
    position: absolute;
    top: calc(var(--safe-area-bottom));
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Logo text style in status bar */
#status-text {
    font-family: 'SF Distant Galaxy', monospace;
    font-weight: normal;
    letter-spacing: 0.05em;
}

/* Beta badge in header */
.header-beta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    background: linear-gradient(135deg, #30d158, #0a84ff);
    border-radius: 4px;
    font-family: 'SF Distant Galaxy', monospace;
    font-size: 10px;
    font-weight: normal;
    letter-spacing: 0.08em;
    color: #000;
    text-transform: uppercase;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
    position: relative;
}

.dot.ok {
    background: var(--green);
    box-shadow: 0 0 8px rgba(48, 209, 88, 0.5);
}

.dot.err {
    background: var(--red);
}


.text-btn,
.icon-btn-small {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.text-btn:hover,
.icon-btn-small:hover {
    background: var(--fill-tertiary);
}

.text-btn:active,
.icon-btn-small:active {
    background: var(--fill-secondary);
}

.icon-btn-small {
    padding: 6px;
    font-size: 18px;
    /* for material icon */
}

/* Flip button for favorites */
.flip-btn {
    background: transparent;
    border: none;
    outline: none;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    margin-left: auto;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.flip-btn:hover {
    background: var(--fill-tertiary);
}

.flip-btn:active {
    background: var(--fill-secondary);
}

/* Tabs Navigation - Base layout (colors in theme blocks) */
.tabs-nav {
    position: fixed;
    top: calc(44px + var(--safe-area-top) + var(--content-safe-area-top));
    left: var(--safe-area-left);
    right: var(--safe-area-right);
    height: 40px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    z-index: 90;
    transition: background 0.2s ease;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-btn.active {
    color: var(--text-main);
    border-bottom-color: var(--accent);
}

/* Logo text inside tab button */
.tab-logo {
    font-family: 'SF Distant Galaxy', monospace;
    font-weight: normal;
    font-size: 13px;
    letter-spacing: 0.05em;
}

/* Live indicator dot with blinking animation */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    margin-left: 6px;
    box-shadow: 0 0 8px rgba(48, 209, 88, 0.6);
    animation: liveDotBlink 1s ease-in-out infinite;
}

@keyframes liveDotBlink {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(48, 209, 88, 0.8);
    }
    50% {
        opacity: 0.4;
        box-shadow: 0 0 4px rgba(48, 209, 88, 0.3);
    }
}

/* Feed */
.feed-container {
    padding: 12px;
    padding-bottom: calc(20px + var(--safe-area-bottom));
    padding-left: calc(12px + var(--safe-area-left));
    padding-right: calc(12px + var(--safe-area-right));
    min-height: calc(100vh - 84px - var(--safe-area-top) - var(--content-safe-area-top));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* In split-view, cards should stretch full width */
body.split-view .feed-container {
    align-items: stretch;
}

.feed-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Push below fixed header: status-bar 44px + tabs-nav 40px + 1px border = 85px */
    padding-top: calc(85px + var(--safe-area-top) + var(--content-safe-area-top));
}

#fav-panel {
    display: none;
}

.fav-container {
    border-left: 1px solid var(--border);
    background: transparent;
    min-height: 100vh;
}

.fav-headline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px;
    /* Reduced top padding from 95px */
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.fav-title {
    margin: 0;
    font-size: 12px;
    color: var(--text-main);
}

.fav-sub {
    margin: 4px 0 0;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.fav-note {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.fav-list {
    padding: 0 12px 20px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

body.split-view .fav-list {
    align-items: stretch;
    padding: 0;
}

.fav-list .empty-placeholder {
    margin-top: 0;
}

body.split-view .tabs-nav {
    display: none;
}

body.split-view .feed-layout {
    flex-direction: row;
    align-items: stretch;
    gap: 18px;
    padding-left: 16px;
    padding-right: 16px;
    /* Only status-bar in split view: 44px + 1px border = 45px */
    padding-top: calc(45px + var(--safe-area-top) + var(--content-safe-area-top));
    height: calc(100vh - 45px - var(--safe-area-top) - var(--content-safe-area-top));
    overflow: hidden;
}

body.split-view #feed,
body.split-view #fav-panel {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    flex: 1;
    min-width: 0;
    /* Prevent flex overflow */
    padding: 12px 16px 20px 16px !important;
    /* Remove individual container padding in split view */
    min-height: auto;
    max-height: calc(100vh - 60px - var(--safe-area-top) - var(--content-safe-area-top));
    overflow-y: auto;
    overflow-x: hidden;
    gap: 10px;
}

/* Remove border between panels in split view */
body.split-view .fav-container {
    border-left: none;
}

/* Cards should take full width in split view */
body.split-view #feed .card,
body.split-view #fav-panel .card,
body.split-view .fav-list .card {
    width: 100% !important;
    max-width: none !important;
    flex-shrink: 0;
}

/* Custom Scrollbars for Split View */
body.split-view #feed::-webkit-scrollbar,
body.split-view #fav-panel::-webkit-scrollbar {
    width: 4px;
}

body.split-view #feed::-webkit-scrollbar-track,
body.split-view #fav-panel::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
    margin: 8px 0;
}

body.split-view #feed::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(48, 209, 88, 0.4) 0%, rgba(10, 132, 255, 0.4) 100%);
    border-radius: 4px;
    transition: background 0.2s;
}

body.split-view #feed::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(48, 209, 88, 0.7) 0%, rgba(10, 132, 255, 0.7) 100%);
}

body.split-view #fav-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.4) 0%, rgba(255, 159, 10, 0.4) 100%);
    border-radius: 4px;
    transition: background 0.2s;
}

body.split-view #fav-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.7) 0%, rgba(255, 159, 10, 0.7) 100%);
}

/* Firefox scrollbar */
body.split-view #feed {
    scrollbar-width: thin;
    scrollbar-color: rgba(48, 209, 88, 0.4) transparent;
}

body.split-view #fav-panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 215, 0, 0.4) transparent;
}

.empty-placeholder {
    text-align: center;
    margin-top: 100px;
    color: var(--text-muted);
}

/* Card Style - Base layout (colors in theme blocks above) */
.card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 14px;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.15s ease, border-color 0.15s ease;
}

/* Animation only for newly created cards */
.card.new-card {
    animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card.hidden {
    display: none !important;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-row:last-child {
    margin-bottom: 0;
}

.symbol {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.spread-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    transition: color 0.3s ease, opacity 0.15s ease;
}

.price {
    transition: opacity 0.15s ease;
}

.ex-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.dir-arrow {
    font-size: 16px;
    line-height: 1;
    color: var(--text-main);
    transition: color 0.3s ease, filter 0.15s ease, transform 0.15s ease;
}

/* Removed default green/red colors - arrows are white by default
   They flash green/red only on spread changes via JS animation */

.ex-name {
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Volume text in card */
.volume-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 6px;
}

/* Reverse spread text in card */
.reverse-spread {
    font-size: 12px;
    color: var(--text-muted);
}

.price {
    font-family: monospace;
    font-weight: 500;
    margin-left: auto;
}

/* Meta row - Base layout (colors in theme blocks) */
.meta-row {
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.volume-info {
    font-size: 11px;
    color: var(--text-muted);
}

.card-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Bottom Sheet */
.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    visibility: visible;
    transition: visibility 0.3s;
}

.bottom-sheet.hidden {
    visibility: hidden;
    pointer-events: none;
}

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 1;
    transition: opacity 0.3s;
}

.bottom-sheet.hidden .sheet-backdrop {
    opacity: 0;
}

.sheet-content {
    position: relative;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px 20px 0 0;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease;
    z-index: 2;
    box-sizing: border-box;
}

.bottom-sheet.hidden .sheet-content {
    transform: translateY(100%);
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sheet-header h3 {
    font-size: 16px;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 24px;
    padding: 8px;
}

.filter-row,
.settings-row {
    margin-bottom: 12px;
}

.filter-row label,
.settings-row h3 {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 0;
}

/* Settings Sections - Base layout (borders in theme blocks) */
.settings-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
}

.settings-section.compact {
    margin-bottom: 12px;
    padding-bottom: 12px;
}

.settings-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 10px 0;
    padding: 0;
}

/* Filters Grid - two columns */
.filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.filter-item label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.filter-item input {
    width: 100%;
}

/* Language & Theme Selector */
.language-selector,
.theme-selector {
    display: flex;
    gap: 8px;
}

/* Lang/Theme buttons - Base layout (colors in theme blocks) */
.lang-btn,
.theme-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .lang-btn.active,
[data-theme="light"] .theme-btn.active {
    background: rgba(0, 122, 255, 0.1);
}

/* Switches Group */
.switches-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.switches-group .switch {
    padding: 10px 0;
}

.switches-group .switch:last-child {
    border-bottom: none;
}

/* Compact table */
.compact-table {
    font-size: 12px;
}

.compact-table th,
.compact-table td {
    padding: 6px 8px;
}

/* Compact button */
.primary-btn.compact {
    padding: 10px 16px;
    font-size: 12px;
}

.input-group {
    display: flex;
    gap: 4px;
}

/* Input and adjust buttons - Base layout (colors in theme blocks) */
input[type="number"] {
    flex: 1;
    padding: 8px 10px;
    font-size: 16px;
    border-radius: 8px;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.adjust-btn {
    width: 32px;
    min-width: 32px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.adjust-btn:hover {
    background: var(--border);
}

.adjust-btn:active {
    background: var(--border);
    opacity: 0.8;
}

/* Primary button - Base layout (effects in theme blocks) */
.primary-btn {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 10px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.1s ease;
}

/* Switch Toggle - Base layout (colors in theme blocks) */
.switch {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 0;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Slider - Base layout (colors in theme blocks) */
.slider {
    position: relative;
    width: 50px;
    height: 28px;
    border-radius: 34px;
    transition: background-color 0.3s ease;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    border-radius: 50%;
    transition: transform 0.3s ease, box-shadow 0.2s ease;
}

input:checked+.slider {
    background-color: var(--green);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.label-text {
    font-size: 15px;
    font-weight: 500;
}

/* Disabled Feature Style */
.disabled-feature {
    opacity: 0.5;
    cursor: not-allowed;
}

.disabled-feature .switch {
    cursor: not-allowed;
    pointer-events: none;
}

.disabled-feature .slider {
    background-color: var(--fill-tertiary) !important;
    cursor: not-allowed;
}

.disabled-feature .label-text {
    color: var(--text-muted);
}

/* Exchange Filter Grid */
.exchanges-filter > label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.filter-hint {
    font-size: 11px;
    opacity: 0.7;
}

.exchanges-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}

/* Exchange Button - Base layout (colors in theme blocks) */
.ex-btn {
    padding: 8px 6px;
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.ex-btn:active {
    transform: scale(0.96);
}

/* Exchange Status Table */
#exchange-status-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13px;
}

#exchange-status-table th {
    text-align: left;
    color: var(--text-muted);
    padding-bottom: 8px;
    font-weight: 500;
}

#exchange-status-table td {
    padding: 8px 0;
}

/* Status dot - Base layout (colors in theme blocks) */
.ex-status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
}

.ex-status-dot.ok {
    background: var(--green);
}

.ex-status-dot.bad {
    background: var(--red);
}

.ex-status-dot.pending {
    background: var(--text-muted);
}

.status-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.diag-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

/* Details View - Base layout (colors in theme blocks) */
.details-view {
    position: fixed;
    top: calc(var(--safe-area-top) + var(--content-safe-area-top));
    left: var(--safe-area-left);
    right: var(--safe-area-right);
    bottom: var(--safe-area-bottom);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 150;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.details-view.hidden {
    transform: translateX(100%);
}

/* Details header - Base layout (colors in theme blocks) */
.details-header {
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    flex-shrink: 0;
}

/* Icon button - Base layout (colors in theme blocks) */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.header-title {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-right: 40px;
    /* balance back btn */
}

.header-title h2 {
    font-size: 16px;
    margin: 0;
}

/* Details header layout - card-like format */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.det-symbol {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.header-subs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
}

.sep {
    color: var(--text-muted);
    opacity: 0.4;
    font-size: 10px;
    padding: 0 1px;
}

.spread-tag {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.spread-tag-rev {
    font-size: 12px;
    color: var(--text-muted);
}

.details-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-section {
    height: 40%;
    /* Reduced for slider */
    border-bottom: 1px solid var(--border);
    position: relative;
}

/* Chart frame - Base layout (colors in theme blocks) */
#chart-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Alert Levels Section - Base layout (colors in theme blocks) */
.alerts-section {
    padding: 12px;
}

.alert-input-row {
    display: flex;
    gap: 12px;
}

.alert-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-group label {
    font-size: 11px;
    color: var(--text-muted);
}

.alert-group input {
    background: var(--bg-app);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}

.alert-group input:focus {
    border-color: var(--accent);
    outline: none;
}

.input-with-clear {
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-with-clear input {
    flex: 1;
    min-width: 0;  /* Allow flex shrinking */
    width: auto;   /* Override width: 100% from .alert-group input */
}

.clear-input-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;  /* Don't shrink the button */
}

.clear-input-btn .material-icons {
    font-size: 18px;
}

.clear-input-btn:hover {
    color: #ff453a;
    background: rgba(255, 69, 58, 0.1);
}

.clear-input-btn:active {
    transform: scale(0.95);
}

.alert-hint {
    font-size: 10px;
    color: var(--accent);
    margin-left: 4px;
    cursor: help;
}

.alerts-description {
    font-size: 10px;
    color: var(--text-muted);
    margin: 8px 0 0 0;
    text-align: center;
    opacity: 0.7;
}

/* Inactive Favorite Card */
.card.inactive {
    opacity: 0.6;
    filter: grayscale(0.8);
    border: 1px dashed var(--border);
}

.card.inactive .fav-btn {
    background: rgba(255, 69, 58, 0.15) !important;
    color: var(--red) !important;
}

/* Liquidity Slider Section - Base layout (colors in theme blocks) */
.liq-section {
    padding: 12px;
}

.liq-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.liq-label {
    color: var(--text-muted);
}

#liq-amount {
    font-weight: 700;
    color: var(--text-main);
}

.slider-container {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.slider-container input[type=range] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    padding: 0;
    margin: 0;
}

.slider-container input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -8px;
}

.slider-container input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    border-radius: 2px;
}

.liq-stats {
    display: flex;
    gap: 16px;
    font-size: 11px;
    font-family: monospace;
}

.stat-box {
    display: flex;
    gap: 4px;
    color: var(--text-muted);
}

.stat-box .val {
    color: var(--text-main);
    font-weight: 600;
}

/* Books - Base layout (colors in theme blocks) */
.books-section {
    flex: 1;
    display: flex;
    min-height: 0;
}

.book-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
}

.book-panel:last-child {
    border-right: none;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.ex-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.side-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 4px;
}

.side-badge.long {
    background: rgba(48, 209, 88, 0.15);
    color: var(--green);
}

.side-badge.short {
    background: rgba(255, 69, 58, 0.15);
    color: var(--red);
}

.price-display {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    font-family: monospace;
    text-align: center;
}

.price-display.long {
    color: var(--green);
}

.price-display.short {
    color: var(--red);
}

.orderbook-list {
    flex: 1;
    overflow-y: auto;
    font-family: monospace;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ob-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 4px;
    position: relative;
}

.ob-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    opacity: 0.15;
    z-index: 0;
    transition: width 0.1s;
}

.ob-fill.bid {
    right: 0;
    background: var(--green);
}

.ob-fill.ask {
    right: 0;
    background: var(--red);
}

.ob-price,
.ob-amount {
    position: relative;
    z-index: 1;
}

/* Alert Banner Notifications */
.alert-banner {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Details View Favorite Button */
.details-fav-btn {
    padding: 8px;
    background: transparent;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.details-fav-btn:active {
    transform: scale(0.95);
}

.details-fav-btn .details-fav-icon {
    font-size: 19px;
    transition: color 0.2s ease;
}

.details-fav-btn.active .details-fav-icon {
    color: #ffd700;
}

.details-fav-btn:not(.active) .details-fav-icon {
    color: rgba(255, 255, 255, 0.6);
}