* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    background: #1a1a1a;
    color: #fff;
    min-height: 100vh;
}

h1 { text-align: center; margin-bottom: 10px; font-size: 1.5em; }

.targets {
    text-align: center;
    color: #888;
    margin-bottom: 20px;
    font-size: 0.9em;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
}

.tab-button {
    flex: 1;
    padding: 10px;
    background: #333;
    color: #888;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.tab-button.active {
    background: #4CAF50;
    color: #fff;
}

.tab-content {
    display: none;
}

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

.totals {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.total-label { color: #888; }
.total-value { font-weight: bold; font-size: 1.2em; }

.progress-bar {
    height: 8px;
    background: #333;
    border-radius: 4px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.cal-remaining {
    text-align: right;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.cal-remaining.over { color: #f44336; }

.progress-fill.cal { background: #4CAF50; }
.progress-fill.protein { background: #2196F3; }
.progress-fill.over { background: #f44336; }

.input-area {
    margin-bottom: 20px;
}

.entry-mode-toggle {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    background: #333;
    color: #888;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #2196F3;
    color: #fff;
}

.entry-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#quick-description,
#quick-calories,
#quick-protein {
    width: 100%;
    padding: 12px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
}

#quick-description::placeholder,
#quick-calories::placeholder,
#quick-protein::placeholder {
    color: #666;
}

textarea {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: #2a2a2a;
    color: #fff;
    font-size: 16px;
    resize: none;
    min-height: 80px;
}

textarea::placeholder { color: #666; }
textarea:focus { outline: 2px solid #4CAF50; }

button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: #4CAF50;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

button:hover { background: #45a049; }
button:disabled { background: #333; color: #666; }

button.undo {
    background: #333;
    margin-top: 10px;
}

button.undo:hover { background: #444; }

.result {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 12px;
    margin-top: 20px;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
}

.result.error { border-left: 4px solid #f44336; }
.result.success { border-left: 4px solid #4CAF50; }

.loading {
    text-align: center;
    padding: 20px;
    color: #888;
}

.entries {
    margin-top: 20px;
}

.entry {
    background: #2a2a2a;
    padding: 12px;
    padding-right: 32px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    position: relative;
    cursor: pointer;
}

.entry:hover { background: #333; }

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.entry-time { color: #666; font-size: 12px; }
.entry-totals { font-weight: bold; margin-bottom: 8px; }

.entry-items {
    color: #aaa;
    font-size: 13px;
    line-height: 1.6;
}

.entry-item { margin: 4px 0; }

.entry-prompt {
    color: #666;
    font-size: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #333;
    font-style: italic;
    display: none;
}

.entry-prompt.expanded { display: block; }

.expand-indicator {
    text-align: center;
    color: #666;
    font-size: 12px;
    margin-top: 8px;
    user-select: none;
}

.expand-indicator::after {
    content: '▼';
    font-size: 10px;
    margin-left: 4px;
}

.entry-prompt.expanded ~ .expand-indicator::after {
    content: '▲';
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    color: #f44336;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    padding: 0;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
}

.delete-btn:hover {
    opacity: 1;
    background: none;
    color: #f44336;
}

/* History */
.history-controls {
    margin-top: 20px;
    margin-bottom: 15px;
    text-align: center;
}

.history-controls select {
    padding: 10px;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 14px;
}

.history-day {
    background: #2a2a2a;
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
}

.history-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    user-select: none;
}

.history-day-header:hover {
    background: #333;
}

.history-day-summary {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.history-date {
    font-weight: bold;
    font-size: 15px;
}

.day-totals {
    font-size: 13px;
    color: #888;
}

.history-day-arrow {
    color: #666;
    font-size: 18px;
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 10px;
}

.history-day.expanded .history-day-arrow {
    transform: rotate(90deg);
}

.history-day-body {
    display: none;
    padding: 0 15px 15px;
    border-top: 1px solid #333;
    padding-top: 10px;
}

.history-day.expanded .history-day-body {
    display: block;
}

/* Calendar */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.calendar-nav {
    background: #333;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    width: auto;
    margin-top: 0;
    flex: 1;
}

.calendar-nav:hover {
    background: #444;
}

.calendar-title {
    flex: 2;
    display: flex;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.calendar-day {
    background: #2a2a2a;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    min-height: 60px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.calendar-day-header {
    font-size: 11px;
    color: #666;
    font-weight: bold;
    padding: 5px;
    text-align: center;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.green {
    background: #2d5016;
}

.calendar-day.yellow {
    background: #665200;
}

.calendar-day.red {
    background: #4d1515;
}

.calendar-day.gray {
    background: #222;
    color: #444;
    cursor: default;
}

.calendar-day:not(.empty):not(.gray):hover {
    opacity: 0.8;
}

.calendar-date {
    font-weight: bold;
    font-size: 16px;
}

.calendar-cals {
    font-size: 11px;
    color: #aaa;
    margin-top: 5px;
}

.weight-dot {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: #FF9800;
    border-radius: 50%;
    cursor: default;
}

.weight-dot::after {
    content: attr(data-weight);
    position: absolute;
    bottom: calc(100% + 5px);
    right: -3px;
    background: #222;
    border: 1px solid #555;
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 10;
}

.weight-dot:hover::after {
    opacity: 1;
}

/* Edit Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #2a2a2a;
    padding: 25px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
}

.modal-header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
}

.modal-input {
    width: 100%;
    padding: 12px;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
}

.modal-preview {
    background: #1a1a1a;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

.modal-button.save {
    background: #4CAF50;
    color: #fff;
}

.modal-button.save:hover {
    background: #45a049;
}

.modal-button.cancel {
    background: #333;
    color: #fff;
}

.modal-button.cancel:hover {
    background: #444;
}

.modal-error {
    color: #f44336;
    margin-bottom: 10px;
    font-size: 14px;
}

/* Export Controls */
.export-controls {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.export-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.weight-row {
    display: flex;
    gap: 10px;
}

.weight-input {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: #1a1a1a;
    color: #fff;
    font-size: 16px;
}

.weight-input::placeholder { color: #666; }
.weight-input:focus { outline: 2px solid #FF9800; }

button.weight-btn {
    width: auto;
    padding: 12px 24px;
    margin-top: 0;
}

button.weight-delete-btn {
    width: auto;
    padding: 2px 8px;
    margin-top: 0;
    background: #333;
    font-size: 12px;
    border-radius: 6px;
}

button.weight-delete-btn:hover { background: #f44336; }

.export-select {
    flex: 1;
    padding: 10px;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 8px;
    font-size: 14px;
}

/* Charts */
.chart-container {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
}

.edit-btn {
    background: #2196F3;
    color: #fff;
    border: none;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 8px;
    cursor: pointer;
    width: auto;
    min-width: 24px;
    line-height: 1;
}

.edit-btn:hover {
    background: #1976D2;
}

.save-btn {
    background: #4caf50;
    color: #fff;
    border: none;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 8px;
    cursor: pointer;
    width: auto;
    min-width: 24px;
    line-height: 1;
}

.save-btn:hover {
    background: #45a049;
}
