:root {
    --bg: #f9f7f2; --card-bg: #ffffff; --ink: #1a1a1a; --sepia: #8b7355; --border: #e2dfd7;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
}
body.dark-mode {
    --bg: #141413; --card-bg: #22211f; --ink: #f9f7f2; --sepia: #d4c1a8; --border: #33322e; --placeholder: #4a4945;
}
body { 
    font-family: 'Georgia', serif; background-color: var(--bg); color: var(--ink); 
    margin: 0; display: flex; justify-content: center; min-height: 100vh; transition: background-color 0.4s ease;
}

.card { 
    position: relative; width: 92%; max-width: 380px; background: var(--card-bg); 
    padding: 30px; border: 1px solid var(--border); box-shadow: 0 4px 15px rgba(0,0,0,0.02); 
    margin: 20px 0; height: fit-content;
}

h1 { text-align: center; font-weight: normal; font-size: 26px; margin: 0 0 25px 0; letter-spacing: 0.5px; }

label, .label { display: block; font-family: var(--sans); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #999; margin-bottom: 6px; }

input { 
    width: 100%; border: none; border-bottom: 1.5px solid var(--border); padding: 8px 0; font-size: 19px; 
    outline: none; background: transparent; font-family: var(--sans) !important; color: var(--ink); border-radius: 0; 
}
input:focus { border-bottom: 1.5px solid var(--sepia); }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.field { margin-bottom: 25px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.grid .field { margin-bottom: 0; }

.progress-container { width: 100%; height: 5px; background: var(--border); margin-bottom: 25px; overflow: hidden; border-radius: 2px; }
.progress-bar { height: 100%; background: var(--sepia); width: 0%; transition: width 0.6s ease; }

.display { text-align: center; margin-bottom: 25px; }
#result { font-size: 64px; line-height: 1; margin-bottom: 6px; font-weight: normal; }
#subtext { font-size: 14px; font-style: italic; color: #888; }

.options-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.toggle-wrap { display: inline-flex; align-items: center; cursor: pointer; }
.toggle-text { font-family: var(--sans); font-size: 11px; color: #aaa; text-transform: uppercase; letter-spacing: 0.8px; margin-left: 8px; line-height: 1; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; cursor: pointer; filter: grayscale(1) opacity(0.5); }

.text-button { background: none; border: none; color: #bbb; font-family: var(--sans); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; text-decoration: underline; padding: 0; line-height: 1; }

.schedule-view { max-height: 130px; overflow-y: auto; background: rgba(0,0,0,0.01); padding: 0 15px; border-left: 1.5px solid var(--border); margin-bottom: 20px; margin-top: 10px; }
.hidden { display: none !important; }
.sched-row { display: flex; justify-content: space-between; font-family: var(--sans); font-size: 11px; padding: 6px 0; border-bottom: 1px solid var(--border); color: #888; }

.stats-row { padding-top: 15px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.streak-mini { text-align: left; min-width: 50px; }
#streakCount { font-family: var(--sans); font-size: 20px; font-weight: 600; color: var(--ink); }

.history-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; flex-grow: 1; }
.history-item { text-align: center; }
.history-item .day { font-size: 9px; font-family: var(--sans); color: #bbb; margin-bottom: 4px; display: block; }
.history-item .val { font-size: 10px; font-family: var(--sans); color: var(--sepia); display: block; }

.footer-actions { text-align: center; color: #bbb; }
.dot-sep { margin: 0 5px; font-size: 10px; }

.theme-toggle { position: absolute; top: 12px; right: 12px; background: none; border: 1px solid var(--border); color: var(--sepia); padding: 5px 10px; cursor: pointer; border-radius: 4px; font-size: 15px; }

/* MODAL STYLES */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: var(--card-bg); padding: 30px; width: 90%; max-width: 320px; border: 1px solid var(--border); text-align: left; }
.modal-content h3 { font-family: 'Georgia', serif; font-weight: normal; margin-top: 0; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.modal-content p { font-family: var(--sans); font-size: 13px; line-height: 1.5; color: var(--ink); }

/* SURGICAL FIX: Unified button and label styles */
.tool-button { 
    display: block; 
    box-sizing: border-box; 
    width: 100%; 
    margin-top: 15px; 
    background: none; 
    border: 1px solid var(--border); 
    color: var(--sepia); 
    padding: 8px 15px; 
    cursor: pointer; 
    border-radius: 4px; 
    font-family: var(--sans); 
    font-size: 11px; 
    text-transform: uppercase; 
    text-align: center; 
}
.modal-actions { display: flex; flex-direction: column; gap: 0; }

@media (max-width: 420px) {
    .card { padding: 25px; max-width: 320px; margin: 10px 0; }
    #result { font-size: 58px; }
}