:root {
    color-scheme: light;
    /* LIGHT MODE (Oq va Yashil) */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --accent: #10b981;
    --accent-hover: #059669;
    --header-bg: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
    color-scheme: dark;
    /* DARK MODE (To'q va Yashil) */
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #10b981;
    --accent-hover: #34d399;
    --header-bg: #1e293b;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    padding-top: 60px;
    /* Leave space for fixed header */
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
    /* Leave space for bottom menu */
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Header */
.header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.container {
    width: 90%;
    max-width: 900px;
    margin: 0 auto;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main) !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo svg {
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Controls (Theme & Latin) */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--bg-main);
}

.btn-latin {
    border: 1px solid var(--border);
    background: var(--bg-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
}

/* Search Box */
.search-wrapper {
    margin: 20px 0;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 16px;
    box-shadow: var(--shadow);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.word-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--accent);
}

.word-meaning {
    font-size: 16px;
    margin-bottom: 15px;
}

.word-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 15px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    background-color: var(--accent);
    color: #fff;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none !important;
}

.btn:hover {
    background-color: var(--accent-hover);
    color: #fff;
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

/* Comments */
.comment-box {
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.comment-box:last-child {
    border-bottom: none;
}

.comment-author {
    font-weight: 600;
    margin-bottom: 5px;
}

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

/* Bottom Menu */
.bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    gap: 4px;
    width: 60px;
    height: 50px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.bottom-menu-item i,
.bottom-menu-item svg {
    width: 24px;
    height: 24px;
    font-size: 24px;
    stroke-width: 1.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bottom-menu-item.active {
    color: var(--accent);
}

.bottom-menu-item.active i,
.bottom-menu-item.active svg {
    color: var(--accent);
}

.bottom-menu-item:hover:not(.active) {
    color: var(--accent);
}

/* Telegram login widget background fix */
#telegram-login-container iframe {
    color-scheme: light !important;
    background: transparent !important;
}

[data-theme="dark"] #telegram-login-container iframe {
    color-scheme: dark !important;
    background: transparent !important;
}

/* Dashboard Styles */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    margin-top: 10px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-number {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 10px;
}

.dashboard-col {
    flex: 1;
    min-width: 280px;
}

.list-group {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item a {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.list-group-item a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* Highlight Marker Styles */
mark {
    background-color: rgba(245, 158, 11, 0.25);
    /* Sleek soft amber highlight */
    color: inherit;
    padding: 0 4px;
    border-radius: 4px;
    font-weight: inherit;
}

[data-theme="dark"] mark {
    background-color: rgba(245, 158, 11, 0.35);
    /* Slightly brighter for dark theme readability */
}

/* Chat UI Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
    padding: 10px 0;
}

.chat-message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 80%;
}

.chat-message.me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.other {
    align-self: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-bubble {
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.chat-message.me .chat-bubble {
    background-color: var(--accent);
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.chat-message.other .chat-bubble {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 16px 16px 16px 4px;
}

.chat-author {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--accent);
}

.chat-message.me .chat-author {
    color: rgba(255, 255, 255, 0.9);
    text-align: right;
}

.chat-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.chat-message.me .chat-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Fixed Alphabet Index Sidebar */
.alpha-index {
    position: fixed;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    z-index: 99;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 3px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    user-select: none;
    max-height: calc(100vh - 160px - env(safe-area-inset-bottom));
}

.alpha-index button {
    background: none;
    border: none;
    color: var(--accent);
    font-weight: 700;
    font-size: 10px;
    width: 20px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 50%;
    padding: 0;
    margin: 1px 0;
}

.alpha-index button:hover:not(.is-off) {
    background: var(--accent);
    color: #fff;
}

.alpha-index button.is-off {
    color: var(--text-muted);
    opacity: 0.2;
    cursor: default;
}

/* Grouping style */
.group {
    margin-bottom: 25px;
}

.group__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(16, 185, 129, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 65px;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .group__title {
    background: rgba(16, 185, 129, 0.25);
}

.words-container-wrapper {
    padding-right: 32px;
}

@media (max-width: 600px) {
    .alpha-index {
        right: 0px;
        padding: 8px 1px;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        border-right: none;
    }

    .alpha-index button {
        margin: 1px 0;
    }

    .words-container-wrapper {
        padding-right: 20px;
    }

    .container {
        width: 95%;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
    width: 100%;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    color: var(--text-main);
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Prevent iOS auto-zoom on mobile inputs/textareas */
@media screen and (max-width: 768px) {

    input[type="text"],
    input[type="number"],
    input[type="tel"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}