/* ===== CSS VARIABLES — Light & Dark ===== */
:root {
    --bg: #e8f4fd;
    --bg2: #ffffff;
    --surface: #ffffff;
    --surface2: #f0f7ff;
    --border: #b0d4f1;
    --text: #111111;
    --text2: #444444;
    --text3: #666666;
    --blue: #1565c0;
    --blue-light: #42a5f5;
    --blue-pale: #deedfb;
    --green: #2e7d32;
    --green-pale: #a5d6a7;
    --green-done: #1b5e20;
    --red: #c62828;
    --orange: #e65100;
    --shadow: rgba(0,0,0,0.10);
    --shadow-md: rgba(0,0,0,0.18);
    --nav-bg: #ffffff;
    --nav-border: #b0d4f1;
    --header-bg: #1565c0;
    --header-text: #ffffff;
    --reason-bg: #c9e4fa;
    --reason-border: #90caf9;
    --task-btn-bg: #deedfb;
    --task-btn-text: #0d47a1;
    --task-btn-done-bg: #a5d6a7;
    --task-btn-done-text: #1b5e20;
    --task-btn-done-border: #66bb6a;
    --input-bg: #ffffff;
    --input-border: #90caf9;
    --diary-bg: #deedfb;
    --overview-h3: #0d47a1;
    --sub-title: #1565c0;
    --sub-border: #b0d4f1;
    --list-border: #e0e0e0;
    --small-text: #555555;
    --modal-bg: #ffffff;
    --undo-bg: #333333;
    --clock-bg: #0d47a1;
    --clock-text: #ffffff;
    --med-urgent: #fff3e0;
    --med-urgent-border: #fb8c00;
    --countdown-bg: #fff8e1;
    --countdown-border: #ffd54f;
    --countdown-text: #5d4037;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --bg2: #161b22;
        --surface: #1c2433;
        --surface2: #1a2235;
        --border: #2d3f55;
        --text: #e6edf3;
        --text2: #b0bec5;
        --text3: #78909c;
        --blue: #58a6ff;
        --blue-light: #79c0ff;
        --blue-pale: #1c2d42;
        --green: #3fb950;
        --green-pale: #1a3a1f;
        --green-done: #56d364;
        --red: #f85149;
        --orange: #f0883e;
        --shadow: rgba(0,0,0,0.4);
        --shadow-md: rgba(0,0,0,0.6);
        --nav-bg: #161b22;
        --nav-border: #2d3f55;
        --header-bg: #0d2137;
        --header-text: #e6edf3;
        --reason-bg: #1c2d42;
        --reason-border: #2d3f55;
        --task-btn-bg: #1c2d42;
        --task-btn-text: #79c0ff;
        --task-btn-done-bg: #1a3a1f;
        --task-btn-done-text: #56d364;
        --task-btn-done-border: #3fb950;
        --input-bg: #1c2433;
        --input-border: #2d3f55;
        --diary-bg: #1c2d42;
        --overview-h3: #79c0ff;
        --sub-title: #58a6ff;
        --sub-border: #2d3f55;
        --list-border: #2d3f55;
        --small-text: #78909c;
        --modal-bg: #1c2433;
        --undo-bg: #1c2433;
        --clock-bg: #0d2137;
        --clock-text: #79c0ff;
        --med-urgent: #2a1800;
        --med-urgent-border: #fb8c00;
        --countdown-bg: #1e1700;
        --countdown-border: #b8860b;
        --countdown-text: #ffd54f;
    }
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 1rem;
    padding-bottom: 70px;
    transition: background 0.2s, color 0.2s;
}

body.large-text { font-size: 1.3rem; }

/* ===== HEADER ===== */
header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 14px 20px 10px;
    text-align: center;
    font-size: 1.7rem;
    font-weight: bold;
    box-shadow: 0 2px 8px var(--shadow-md);
    line-height: 1.2;
}

.header-date {
    font-size: 0.82rem;
    font-weight: 400;
    opacity: 0.85;
    margin-top: 2px;
}

.reason {
    padding: 8px 16px;
    text-align: center;
    font-size: 0.92rem;
    color: var(--text2);
    background: var(--reason-bg);
    border-bottom: 2px solid var(--reason-border);
}

.day-banner {
    text-align: center;
    padding: 8px 10px;
    font-size: 0.92rem;
    color: var(--green-done);
    background: var(--green-pale);
    display: none;
    font-weight: 600;
}

.day-banner.show { display: block; }

/* ===== LIVE CLOCK ===== */
#live-clock {
    background: var(--clock-bg);
    color: var(--clock-text);
    text-align: center;
    padding: 10px 20px;
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    border-bottom: 3px solid var(--border);
}

#live-clock-date {
    font-size: 0.78rem;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 1px;
    letter-spacing: 0.03em;
}

/* ===== COUNTDOWN BANNER ===== */
#countdown-banner {
    background: var(--countdown-bg);
    border-bottom: 2px solid var(--countdown-border);
    color: var(--countdown-text);
    padding: 10px 16px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    display: none;
}

#countdown-banner.show { display: block; }

/* ===== MED QUICK-ACCESS ===== */
#med-quick {
    background: var(--surface);
    border-bottom: 2px solid var(--med-urgent-border);
    padding: 10px 14px;
    display: none;
}

#med-quick.show { display: block; }

#med-quick h4 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--orange);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#med-quick .button-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 92vw;
}

.toast {
    background: var(--blue);
    color: #fff;
    padding: 12px 22px;
    border-radius: 40px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 4px 14px var(--shadow-md);
    animation: toastIn 0.3s ease, toastOut 0.4s ease 2.4s forwards;
    text-align: center;
}

.toast.success { background: var(--green); }
.toast.warning { background: var(--orange); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ===== UNDO BAR ===== */
.undo-bar {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--undo-bg);
    color: #fff;
    padding: 10px 18px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1500;
    font-size: 0.9rem;
    box-shadow: 0 4px 14px var(--shadow-md);
    white-space: nowrap;
}

.undo-action-btn {
    background: var(--blue-light);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--nav-bg);
    border-top: 2px solid var(--nav-border);
    box-shadow: 0 -2px 10px var(--shadow);
    z-index: 1000;
    height: 64px;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px 2px;
    transition: background 0.15s;
    color: var(--text3);
    -webkit-tap-highlight-color: transparent;
    min-width: 44px;
    min-height: 44px;
}

.nav-btn.active {
    color: var(--blue);
    background: var(--blue-pale);
}

.nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; }

/* ===== MAIN CONTENT ===== */
main {
    flex-grow: 1;
    padding: 10px 12px 16px;
}

.tab-section { display: none; }
.tab-section.active { display: block; }

.section-title {
    font-size: 1.45rem;
    font-weight: bold;
    color: var(--blue);
    margin: 10px 0 12px;
    text-align: center;
}

.sub-section { margin-bottom: 8px; }

.sub-section-title {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--sub-title);
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--sub-border);
}

/* ===== CARDS ===== */
.category {
    background: var(--surface);
    border-radius: 20px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px var(--shadow);
}

.category-title {
    font-size: 1.05rem;
    color: var(--overview-h3);
    margin-bottom: 12px;
    font-weight: 700;
}

/* ===== ESSENTIAL TASK BUTTONS ===== */
.button-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.task-btn {
    background: var(--task-btn-bg);
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 18px 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--task-btn-text);
    box-shadow: 0 2px 5px var(--shadow);
    transition: transform 0.1s ease, background 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    line-height: 1.35;
    min-height: 64px;
    text-align: center;
}

.task-btn.done {
    background: var(--task-btn-done-bg);
    color: var(--task-btn-done-text);
    border-color: var(--task-btn-done-border);
    font-weight: 700;
}

.task-btn:active { transform: scale(0.96); }

/* Med-specific compact buttons (Today quick strip) */
.task-btn.compact {
    padding: 12px 6px;
    font-size: 0.9rem;
    min-height: 52px;
    border-radius: 14px;
}

/* ===== FORMS ===== */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

input[type="text"],
input[type="date"],
textarea,
select.time-select {
    padding: 13px 16px;
    border-radius: 40px;
    border: 1.5px solid var(--input-border);
    font-size: 1rem;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue-light);
}

.field-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: -4px;
    padding-left: 6px;
}

.time-picker-row {
    display: flex;
    gap: 8px;
}

.time-select {
    flex: 1;
    appearance: auto;
}

textarea {
    border-radius: 20px;
    resize: vertical;
}

/* ===== BUTTONS ===== */
.primary-btn {
    background: var(--blue-light);
    color: #fff;
    border: none;
    border-radius: 40px;
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    width: 100%;
    min-height: 48px;
}

.primary-btn:hover, .primary-btn:active { background: #1976d2; }
.primary-btn:active { transform: scale(0.98); }

.secondary-btn {
    background: var(--surface2);
    color: var(--text2);
    border: 1.5px solid var(--border);
    border-radius: 40px;
    padding: 11px 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 44px;
}

.secondary-btn:hover, .secondary-btn:active { background: var(--border); }

.mic-btn {
    background: var(--surface2);
    border: 1.5px solid var(--input-border);
    border-radius: 40px;
    padding: 0 16px;
    font-size: 1.4rem;
    cursor: pointer;
    min-width: 52px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ===== LISTS ===== */
.list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px;
    border-bottom: 1px solid var(--list-border);
    font-size: 0.95rem;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 52px;
}

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

.list li span.small {
    font-size: 0.8rem;
    color: var(--text3);
}

.list li button {
    border: none;
    background: var(--red);
    color: #fff;
    border-radius: 30px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 40px;
    min-width: 60px;
}

.list li button:hover { opacity: 0.85; }
.list li div { display: flex; gap: 6px; }

/* Past appointment style */
.list li.past-item {
    opacity: 0.5;
}

.list li.past-item > div > span:first-child {
    text-decoration: line-through;
}

/* ===== DIARY ===== */
.diary-box {
    min-height: 60px;
    background: var(--diary-bg);
    border-radius: 20px;
    padding: 14px;
    font-size: 0.95rem;
    white-space: pre-line;
    line-height: 1.6;
    color: var(--text);
}

.diary-list {
    max-height: 520px;
    overflow-y: auto;
    font-size: 0.95rem;
}

.diary-day {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--list-border);
}

.diary-day-title {
    font-weight: 700;
    color: var(--overview-h3);
    margin-bottom: 6px;
    font-size: 1.05rem;
}

.diary-day-content {
    white-space: pre-line;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text2);
}

/* ===== TODAY OVERVIEW ===== */
.today-overview {
    background: var(--surface);
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}

.overview-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--list-border);
}

.overview-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.overview-section h3 {
    color: var(--overview-h3);
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 700;
}

.overview-section pre {
    margin: 0;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text2);
}

/* Summary sentence (natural language) */
.today-summary-sentence {
    background: var(--blue-pale);
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 14px;
    font-weight: 500;
}

/* ===== MISC ===== */
.small-note {
    font-size: 0.8rem;
    color: var(--small-text);
    margin: 4px 0 0;
    line-height: 1.4;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 0;
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    z-index: 2100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--modal-bg);
    margin: auto;
    padding: 24px;
    border-radius: 24px;
    width: 92%;
    max-width: 440px;
    box-shadow: 0 6px 28px var(--shadow-md);
    color: var(--text);
    max-height: 88vh;
    overflow-y: auto;
}

.confirm-modal-content { text-align: center; }

.confirm-modal-content p {
    font-size: 1.08rem;
    line-height: 1.5;
    margin: 0 0 6px;
}

.close-modal {
    float: right;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    color: var(--text3);
    padding: 4px 8px;
}

/* ===== QUICK-ADD VOICE ROW ===== */
.quick-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.quick-add-row input { flex: 1; }

/* ===== LARGE TEXT OVERRIDES ===== */
body.large-text .task-btn,
body.large-text .primary-btn,
body.large-text .secondary-btn,
body.large-text .mic-btn,
body.large-text input,
body.large-text textarea { font-size: 1.2rem; padding: 16px; }

body.large-text .nav-label { font-size: 0.75rem; }
body.large-text .nav-icon { font-size: 1.5rem; }
body.large-text .time-select { font-size: 1.2rem; padding: 16px; }
body.large-text .field-label { font-size: 1.05rem; }
body.large-text #live-clock { font-size: 2.8rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 360px) {
    .button-row { grid-template-columns: 1fr; }
    .scan-buttons { grid-template-columns: 1fr; }
    #med-quick .button-row { grid-template-columns: 1fr; }
}

/* ===== SHARE BUTTON ===== */
.share-btn {
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: 40px;
    padding: 13px 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    min-height: 48px;
    transition: background 0.15s;
}

.share-btn:hover { background: #1da851; }

/* ===== SETTINGS CATEGORY SPACING ===== */
#settings .category + .category { margin-top: 4px; }

/* ===== CONVERSATION QUICK MODE ===== */
.conv-quick-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.conv-quick-row button {
    background: var(--blue-pale);
    color: var(--blue);
    border: 1.5px solid var(--border);
    border-radius: 30px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
}

/* ===== ARCHIVED NOTICE ===== */
.archived-notice {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text3);
    padding: 6px 0 2px;
    font-style: italic;
}
