:root {
    --bg-color: var(--tg-theme-bg-color, #fff);
    --text-color: var(--tg-theme-text-color, #000);
    --hint-color: var(--tg-theme-hint-color, #888);
    --link-color: var(--tg-theme-link-color, #2481cc);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text-color: var(--tg-theme-button-text-color, #fff);
    --secondary-bg-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#app {
    padding: 16px;
    padding-bottom: 80px;
    /* Space for FAB */
}

h1 {
    font-size: 24px;
    margin-bottom: 16px;
}

/* Tabs */
#tabs {
    display: flex;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--hint-color);
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--hint-color);
    font-weight: 500;
    cursor: pointer;
}

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

/* List Items */
.med-item,
.history-item {
    background-color: var(--secondary-bg-color);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.med-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
}

.med-info p {
    margin: 0;
    font-size: 14px;
    color: var(--hint-color);
}

.delete-btn {
    color: #ff3b30;
    background: none;
    border: none;
    font-size: 20px;
    padding: 8px;
}

/* FAB */
#add-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--button-color);
    color: var(--button-text-color);
    border: none;
    border-radius: 50px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

/* Modal */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

#med-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-color);
    padding: 24px;
    border-radius: 16px;
    width: 80%;
    max-width: 300px;
    z-index: 11;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

#med-modal.hidden,
#modal-overlay.hidden,
.view {
    display: none;
}

.view.active {
    display: block;
}

input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--hint-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 16px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.actions button {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

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

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

/* Schedule Form */
select {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--hint-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 16px;
}

.hidden {
    display: none !important;
}

/* Day Selector */
.days-select {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.days-select span {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary-bg-color);
    font-size: 12px;
    cursor: pointer;
    border: 2px solid transparent;
}

.days-select span.selected {
    background: var(--button-color);
    color: var(--button-text-color);
    border-color: var(--button-color);
}

/* Time Inputs */
.time-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.remove-time {
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.small-btn {
    background: none;
    color: var(--link-color);
    border: none;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    cursor: pointer;
}

/* Archived Medications */
.med-item.archived {
    opacity: 0.5;
}

.med-item.archived h4 {
    text-decoration: line-through;
}

/* Form Row */
.form-row {
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* History Grouping */
.history-group {
    background-color: var(--secondary-bg-color);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.history-header {
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-items {
    padding-left: 28px;
    /* Indent under icon */
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-subitem {
    background: rgba(0, 0, 0, 0.05);
    /* slightly clearer than bg */
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 14px;
    display: inline-block;
}

/* Dark mode adjustment if needed */
@media (prefers-color-scheme: dark) {
    .history-subitem {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Weekly Hub */
#weekly-hub-container {
    background-color: var(--secondary-bg-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: center;
}

.weekly-header {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: var(--text-color);
}

.weekly-days {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.day-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.day-label {
    font-size: 12px;
    color: var(--hint-color);
    font-weight: 500;
}

.day-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e0e0e0;
    /* Default empty/pending */
    position: relative;
    /* We will use conic-gradient via inline style for charts */
}

.day-date {
    font-size: 10px;
    color: var(--hint-color);
    margin-top: 4px;
}