:root {
    --color-primary: #1A1A1A;
    --color-primary-hover: #333333;
    --color-background: #FAFAFA;
    --color-surface: #FFFFFF;
    --color-border: #E5E5E5;
    --color-text-primary: #1A1A1A;
    --color-text-secondary: #737373;
    --color-text-tertiary: #A3A3A3;
    --color-success: #22C55E;
    --color-error: #EF4444;
    --color-on-primary: #FFFFFF;
    --color-memorial: #6366F1;
    --color-bet: #7C3AED;
    --font-display: 'Sora', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --drawer-overlay-bg: rgba(15, 23, 42, 0.42);
    --drawer-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    --drawer-border: rgba(148, 163, 184, 0.28);
    --drawer-text: var(--color-text-primary);
    --drawer-muted: var(--color-text-secondary);
    --drawer-handle: rgba(148, 163, 184, 0.55);
    --drawer-soft-bg: rgba(15, 23, 42, 0.06);
    --drawer-soft-bg-hover: rgba(15, 23, 42, 0.12);
    --drawer-avatar-bg: #E2E8F0;
    --drawer-online: #22C55E;
    --drawer-card-bg: rgba(255, 255, 255, 0.68);
    --drawer-card-border: rgba(148, 163, 184, 0.22);
    --drawer-link-hover-bg: rgba(15, 23, 42, 0.06);
    --drawer-link-hover-border: rgba(148, 163, 184, 0.36);
    --drawer-help-bg: rgba(34, 197, 94, 0.14);
    --drawer-help-text: #166534;
    --drawer-logout-bg: rgba(239, 68, 68, 0.14);
    --drawer-logout-border: rgba(239, 68, 68, 0.36);
    --drawer-logout-text: #B91C1C;
    --drawer-login-bg: rgba(34, 197, 94, 0.14);
    --drawer-login-border: rgba(34, 197, 94, 0.36);
    --drawer-login-text: #166534;
    --drawer-version: var(--drawer-muted);
}

:root[data-theme="dark"] {
    --drawer-overlay-bg: rgba(2, 6, 23, 0.64);
    --drawer-bg: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(2, 6, 23, 0.98) 100%);
    --drawer-border: rgba(148, 163, 184, 0.3);
    --drawer-text: #E2E8F0;
    --drawer-muted: #94A3B8;
    --drawer-handle: rgba(148, 163, 184, 0.72);
    --drawer-soft-bg: rgba(255, 255, 255, 0.08);
    --drawer-soft-bg-hover: rgba(255, 255, 255, 0.16);
    --drawer-avatar-bg: rgba(148, 163, 184, 0.24);
    --drawer-online: #22C55E;
    --drawer-card-bg: rgba(15, 23, 42, 0.62);
    --drawer-card-border: rgba(148, 163, 184, 0.26);
    --drawer-link-hover-bg: rgba(148, 163, 184, 0.12);
    --drawer-link-hover-border: rgba(148, 163, 184, 0.42);
    --drawer-help-bg: rgba(34, 197, 94, 0.18);
    --drawer-help-text: #BBF7D0;
    --drawer-logout-bg: rgba(239, 68, 68, 0.18);
    --drawer-logout-border: rgba(248, 113, 113, 0.45);
    --drawer-logout-text: #FECACA;
    --drawer-login-bg: rgba(34, 197, 94, 0.18);
    --drawer-login-border: rgba(74, 222, 128, 0.45);
    --drawer-login-text: #BBF7D0;
    --drawer-version: #94A3B8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    min-height: 100dvh;
    padding-bottom: 80px;
}

/* App Bar */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 16px;
}

.app-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 480px;
    margin: 0 auto;
}

.search-wrapper {
    flex: 1;
    position: relative;
}

.search-wrapper.search-hidden {
    display: none;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 52px;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--color-text-primary);
    background-color: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
    transition: all 0.15s ease;
}

.search-input::placeholder {
    color: var(--color-text-tertiary);
}

.search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.global-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 320;
    display: none;
    max-height: min(60vh, 440px);
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 8px;
}

.global-search-dropdown.open {
    display: block;
}

.global-search-main-results {
    max-width: 480px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: auto;
    max-height: calc(100dvh - 124px);
    -webkit-overflow-scrolling: touch;
}

.global-search-main-results.open {
    display: block;
}

.global-search-main-body {
    padding: 10px;
}

.global-search-main-status {
    padding: 28px 12px;
}

.global-search-shell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.global-search-query {
    padding: 12px 14px 0;
    font-size: 0.82rem;
    color: var(--color-text-secondary);
}

body.navigation-search-mode {
    padding-bottom: 0;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    touch-action: auto !important;
}

body.navigation-search-mode #globalSearchMainResults,
body.navigation-search-mode .global-search-main-results {
    width: min(100%, 480px);
    margin: 0 auto;
    height: calc(100dvh - 124px);
    max-height: calc(100dvh - 124px);
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

body.navigation-search-mode nav.bottom-nav[data-navigation="true"] {
    display: none !important;
}

body.navigation-search-mode .context-tab-bar:not(.search-results-tabbar),
body.navigation-search-mode .tab-bar:not(.search-results-tabbar),
body.navigation-search-mode .tabs:not(.search-results-tabbar),
body.navigation-search-mode .category-filters:not(.search-results-tabbar) {
    display: none !important;
}

body.navigation-search-mode .context-tab-bar.search-results-tabbar {
    display: block !important;
    position: sticky;
    top: 68px;
    z-index: 95;
    background: var(--context-tabs-surface);
    border-bottom: 1px solid var(--color-border);
}

body.navigation-search-mode .context-tab-bar.search-results-tabbar .context-tab-list {
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
}

body.navigation-search-mode .bet-top-row {
    display: none !important;
}

body.navigation-search-mode .bet-page-shell {
    justify-content: flex-start !important;
    padding: 8px 0 12px !important;
    overflow-y: auto;
    min-height: calc(100dvh - 72px);
}

body.navigation-search-mode .bet-main-area {
    justify-content: flex-start !important;
    padding-bottom: 0 !important;
    overflow-y: auto;
}

.global-search-section-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-tertiary);
    padding: 8px 10px 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.global-search-item {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
}

.global-search-item:hover,
.global-search-item:focus-visible {
    background: var(--color-surface-soft);
    outline: none;
}

.global-search-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-soft);
    color: var(--color-text-secondary);
    overflow: hidden;
}

.global-search-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.global-search-avatar-fallback {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.global-search-item-text {
    min-width: 0;
    flex: 1;
}

.global-search-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-item-subtitle {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    color: var(--color-text-secondary);
    font-size: 0.86rem;
    text-align: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-tertiary);
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.search-icon svg {
    width: 20px;
    height: 20px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.profile-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
    position: relative;
}

.profile-btn:hover {
    background-color: var(--color-surface);
}

.profile-btn img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

/* Drawer */
body.drawer-open {
    overflow: hidden;
}

.nav-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: var(--drawer-overlay-bg);
    backdrop-filter: blur(5px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
}

.nav-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.nav-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: min(90vw, 360px);
    height: 100%;
    background: var(--drawer-bg);
    border-left: 1px solid var(--drawer-border);
    box-shadow: -20px 0 44px rgba(2, 6, 23, 0.45);
    color: var(--drawer-text);
    transform: translateX(100%);
    transition: transform 0.24s ease;
    display: flex;
    flex-direction: column;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow: hidden;
}

.nav-drawer-overlay.open .nav-drawer {
    transform: translateX(0);
}

.nav-drawer .drawer-handle {
    width: 52px;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--drawer-handle);
    margin: 10px auto 0;
    opacity: 0.75;
}

.nav-drawer-header {
    padding: 12px 16px 14px;
    border-bottom: 1px solid var(--drawer-border);
    background: linear-gradient(180deg, var(--drawer-soft-bg) 0%, transparent 100%);
}

.nav-drawer .drawer-header-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.nav-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--drawer-soft-bg);
    color: var(--drawer-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.14s ease;
}

.nav-drawer-close:hover {
    background: var(--drawer-soft-bg-hover);
}

.nav-drawer .profile-section {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.nav-drawer .avatar-wrapper {
    position: relative;
    width: fit-content;
}

.nav-drawer-avatar {
    width: 72px;
    height: 72px;
    background: var(--drawer-avatar-bg);
    border: 2px solid var(--drawer-card-border);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.nav-drawer .online-indicator {
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    background: var(--drawer-online);
    border: 2px solid var(--drawer-bg);
}

.nav-drawer .help-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.nav-drawer .help-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-full);
    background: var(--drawer-help-bg);
    color: var(--drawer-help-text);
    font-size: 0.82rem;
    font-weight: 700;
}

.nav-drawer .help-score-badge .icon {
    font-size: 18px;
}

.nav-drawer .help-score-label {
    color: var(--drawer-muted);
    font-size: 0.72rem;
    line-height: 1;
}

.nav-drawer-user-info {
    margin-top: 12px;
}

.nav-drawer-username {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 0;
    color: var(--drawer-text);
    line-height: 1.2;
}

.nav-drawer-handle {
    margin: 3px 0 0;
    font-size: 0.82rem;
    color: var(--drawer-muted);
}

.nav-drawer-links {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
}

.nav-drawer .menu-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-drawer-link.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--drawer-text);
    border: 1px solid var(--drawer-card-border);
    background: var(--drawer-card-bg);
    transition: all 0.16s ease;
}

.nav-drawer .icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--drawer-soft-bg);
    color: var(--drawer-text);
}

.nav-drawer .menu-item-content {
    flex: 1;
    min-width: 0;
}

.nav-drawer .menu-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.25;
}

.nav-drawer .menu-item-subtitle {
    font-size: 0.75rem;
    color: var(--drawer-muted);
    margin-top: 2px;
    line-height: 1.35;
}

.nav-drawer-link.menu-item:hover {
    background: var(--drawer-link-hover-bg);
    border-color: var(--drawer-link-hover-border);
    transform: translateX(-1px);
}

.nav-drawer-link .material-icons-round {
    font-size: 20px;
}

.nav-drawer .chevron {
    color: var(--drawer-muted);
}

.nav-drawer-footer {
    margin-top: auto;
    padding: 14px 12px 8px;
    border-top: 1px solid var(--drawer-border);
}

.nav-drawer-auth-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--drawer-link-hover-border);
    background: var(--drawer-link-hover-bg);
    color: var(--drawer-text);
    transition: all 0.16s ease;
}

.nav-drawer-auth-btn.login-btn {
    border-color: var(--drawer-login-border);
    background: var(--drawer-login-bg);
    color: var(--drawer-login-text);
}

.nav-drawer-auth-btn.logout-btn,
.nav-drawer-logout.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--drawer-logout-border);
    background: var(--drawer-logout-bg);
    color: var(--drawer-logout-text);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
}

.nav-drawer-auth-btn:hover,
.nav-drawer-logout.logout-btn:hover {
    filter: brightness(1.06);
}

.nav-drawer .drawer-version {
    margin-top: 10px;
    text-align: center;
    font-size: 0.74rem;
    color: var(--drawer-version);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--color-error);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-background);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 480px;
    margin: 0 auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 24px;
    color: var(--color-text-tertiary);
    text-decoration: none;
    transition: color 0.15s ease;
    background: none;
    border: none;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    color: var(--color-text-primary);
}

.nav-item .icon {
    font-size: 24px;
}

.nav-item span:not(.icon):not(.nav-emoji-icon) {
    font-size: 0.625rem;
    font-weight: 500;
}

/* Emoji icons for navigation */
.nav-emoji-icon {
    font-size: 24px;
    line-height: 1;
}

.drawer-emoji-icon {
    font-size: 20px;
    line-height: 1;
}

.empty-state-emoji {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 16px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background-color: var(--color-primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Utility / Common */
.content {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

/* Avatar Utilities (if not in avatar.css) */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background-color: #1A1A1A;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar .avatar-initials {
    color: #FFFFFF;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
}

/* Event Card & Text Utilities */
.event-description {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    /* Ensure long words break */
}

.event-description.clamped {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.read-more-btn {
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0;
    cursor: pointer;
    margin-bottom: 14px;
    display: inline-flex;
    align-items: center;
}

.read-more-btn:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Action Buttons */
.card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.action-left {
    display: flex;
    gap: 4px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: none;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
}

.action-btn.active {
    color: var(--color-primary);
}

/* Comment Thread Styles */
.comment-thread {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.comment-input-area {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.comment-input-wrapper {
    flex: 1;
    position: relative;
}

.comment-input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    background-color: var(--color-surface-soft);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    outline: none;
    transition: all 0.2s;
}

.comment-input::placeholder {
    color: var(--color-text-tertiary);
}

.comment-input:focus {
    border-color: var(--color-primary);
    background-color: var(--color-surface);
}

.send-comment-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: none;
    border: none;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.45;
    pointer-events: none;
    transition: all 0.2s;
}

.comment-input:not(:placeholder-shown)+.send-comment-btn {
    opacity: 1;
    pointer-events: auto;
    background-color: var(--color-primary);
    color: var(--color-on-primary, #fff);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    display: flex;
    gap: 12px;
}

.comment-bubble {
    background-color: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    padding: 10px 14px;
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-author {
    font-size: 0.8125rem;
    font-weight: 600;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
}

.comment-text {
    font-size: 0.875rem;
    color: var(--color-text-primary);
    line-height: 1.5;
    word-break: break-word;
}
