:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #000000);
    --hint: var(--tg-theme-hint-color, #999999);
    --link: var(--tg-theme-link-color, #2481cc);
    --btn: var(--tg-theme-button-color, #2481cc);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 20px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--hint);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.tab {
    flex: 1;
    padding: 12px 4px;
    border: none;
    background: none;
    color: var(--hint);
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s;
}

.tab.active {
    color: var(--link);
    border-bottom: 2px solid var(--link);
}

.tab-content {
    display: none;
    padding: 16px;
}

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

.list {
    margin-bottom: 12px;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--secondary-bg);
    border-radius: 10px;
    margin-bottom: 8px;
    gap: 10px;
}

.list-item .emoji {
    font-size: 24px;
    width: 36px;
    text-align: center;
}

.list-item .info {
    flex: 1;
}

.list-item .info .name {
    font-weight: 600;
    font-size: 15px;
}

.list-item .info .meta {
    font-size: 12px;
    color: var(--hint);
}

.list-item .actions {
    display: flex;
    gap: 6px;
}

.list-item .actions button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.btn-primary {
    background: var(--btn);
    color: var(--btn-text);
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--hint);
    margin-bottom: 6px;
    font-weight: 600;
}

.input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--hint);
    border-radius: 8px;
    font-size: 15px;
    background: var(--secondary-bg);
    color: var(--text);
    outline: none;
}

.input:focus {
    border-color: var(--link);
}

select.input {
    appearance: none;
    -webkit-appearance: none;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.emoji-btn {
    padding: 8px;
    font-size: 22px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--secondary-bg);
    cursor: pointer;
}

.emoji-btn.selected {
    border-color: var(--link);
    background: var(--bg);
}

.more-emoji-toggle {
    margin-top: 8px;
    padding: 8px;
    font-size: 13px;
}

#more-emoji-grid {
    margin-top: 8px;
}

#more-emoji-grid.hidden {
    display: none;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-size: 15px !important;
    color: var(--text) !important;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg);
    width: 100%;
    padding: 24px 16px;
    border-radius: 16px 16px 0 0;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
}

/* Book items */
.book-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: transparent;
    border: 2px solid var(--secondary-bg);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    gap: 10px;
    transition: all 0.2s;
}

.book-item.selected {
    background: var(--secondary-bg);
    border-color: var(--link);
}

.book-item .check {
    font-size: 20px;
    width: 28px;
}

.book-item .book-info {
    flex: 1;
}

.book-item .book-info .book-title {
    font-weight: 600;
    font-size: 15px;
}

.book-item .book-info .book-author {
    font-size: 12px;
    color: var(--hint);
}

/* Settings sections */
.settings-section {
    background: var(--secondary-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-section-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--hint);
    margin-bottom: 12px;
}

/* Stats */
.stats-block {
    background: var(--secondary-bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.stats-block-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--hint);
    margin-bottom: 8px;
}

.streak-row {
    padding: 8px 0;
    font-size: 15px;
}

.streak-counts {
    font-size: 13px;
    color: var(--hint);
    margin-top: 2px;
    padding-left: 2px;
}

.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 15px;
}

.streak-row:not(:last-child), .report-row:not(:last-child) {
    border-bottom: 1px solid rgba(128,128,128,0.1);
}

.streak-value {
    font-weight: 600;
    color: var(--link);
}

.report-status {
    font-size: 18px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--hint);
}

/* Screens */
.screen.hidden {
    display: none;
}

/* Language selection */
.lang-header {
    text-align: center;
    padding: 40px 16px 24px;
}

.lang-header h2 {
    font-size: 22px;
}

.lang-list {
    padding: 0 16px;
}

.lang-btn {
    display: block;
    width: 100%;
    padding: 16px;
    margin-bottom: 10px;
    border: none;
    border-radius: 12px;
    background: var(--secondary-bg);
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.lang-btn:active {
    background: var(--btn);
    color: var(--btn-text);
}

.lang-btn.active {
    background: var(--btn);
    color: var(--btn-text);
    border: 2px solid var(--link);
}

/* Days picker */
.days-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.day-btn {
    flex: 1;
    min-width: 40px;
    padding: 10px 4px;
    border: 2px solid var(--secondary-bg);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.day-btn.selected {
    background: var(--btn);
    color: var(--btn-text);
    border-color: var(--link);
}

/* Field validation error */
.field-error {
    color: #e53935;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

.field-error.hidden {
    display: none;
}
