:root {
    /* Colours from suvamsahoo.com: warm paper, near-black ink, orange accent,
       mint for present, brick red for absent. Soft shadows, rounded corners. */
    --color-bg: #f5f2ec;
    --color-surface: #fffdf8;
    --color-sunk: #ebe6dc;
    --color-text: #111111;
    --color-ink: #111111;
    --color-muted: #6b665e;
    --color-border: #1111111f;
    --color-accent: #ff5a1f;
    --color-accent-hover: #f04d12;
    --color-accent-soft: #ffe8dd;
    --color-accent-text: #b83c08;
    --color-accent-contrast: #ffffff;
    --color-electric: #1b4dff;
    --shadow-card: 0 1px 2px #1111110d, 0 8px 24px -12px #11111129;
    --shadow-button: 0 1px 2px #11111126, 0 4px 12px -4px #ff5a1f66;
    --color-present: #0b7d5c;
    --color-present-bg: #e2f1ea;
    --color-absent: #c0392b;
    --color-absent-bg: #f9e4e0;
    --color-holiday-bg: #ebe6dc;
    --color-partial-bg: #fcf0d6;
    --color-partial-text: #8a5300;
    --color-full-bg: #cbe7db;
    --color-full-text: #096547;
    --color-day-absent-bg: #f4cdc6;
    --color-day-absent-text: #a02b1f;
    --color-day-partial-absent-bg: #f9e4e0;
    --color-warn: #e08a00;
    --radius: 14px;
    --gap: 12px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Google Sans Flex', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    min-height: 100vh;
}

a {
    color: inherit;
}

button, select, input {
    font-family: inherit;
    font-size: 1rem;
}

/* Header */

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

.app-header h1 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}

.app-header .user-name {
    font-size: 0.85rem;
    color: var(--color-muted);
    display: block;
    margin-top: 2px;
}

.logout-link {
    font-size: 0.85rem;
    color: var(--color-muted);
    text-decoration: none;
    border: 1px solid var(--color-border);
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--color-surface);
}

/* Dashboard */

.dashboard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 20px;
}

.mascot-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.mascot-emoji {
    font-size: 1.5rem;
    display: inline-block;
    animation: mascot-bounce 2.4s ease-in-out infinite;
}

.mascot-text {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.dashboard-percent {
    font-size: 2.4rem;
    font-weight: 600;
    line-height: 1;
}

.dashboard-fraction {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.unmarked-banner {
    display: block;
    text-decoration: none;
    background: var(--color-partial-bg);
    color: var(--color-partial-text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 14px;
}

.projection-line {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-top: 6px;
}

.projection-line.projection-warn {
    color: var(--color-partial-text);
}

.tomorrow-card {
    background: var(--color-bg);
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 14px;
}

.tomorrow-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 8px;
}

.tomorrow-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 3px 0;
}

.tomorrow-value {
    font-weight: 600;
}

.tomorrow-value.good { color: var(--color-present); }
.tomorrow-value.bad { color: var(--color-absent); }

.export-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-muted);
    text-decoration: none;
}

.subject-list {
    margin-top: 16px;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}

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

.subject-row .subject-name {
    color: var(--color-text);
}

.subject-row .subject-percent {
    font-weight: 500;
    color: var(--color-muted);
}

.empty-note {
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* Calendar */

.calendar-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.calendar-nav button {
    border: none;
    background: none;
    font-size: 1.1rem;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--color-text);
}

.calendar-nav .month-label {
    font-weight: 600;
    font-size: 0.95rem;
}

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

.calendar-weekdays div {
    text-align: center;
    font-size: 0.72rem;
    color: var(--color-muted);
    padding-bottom: 4px;
}

.day-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--color-bg);
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--color-text);
    position: relative;
}

.day-cell.blank {
    visibility: hidden;
    cursor: default;
}

.day-cell.before_semester,
.day-cell.after_semester {
    color: #c9c3b7;
    cursor: default;
    background: transparent;
}

.day-cell.not_recorded {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.day-cell.holiday {
    background: var(--color-holiday-bg);
    color: var(--color-muted);
}

.day-cell.partial {
    background: var(--color-partial-bg);
    color: var(--color-partial-text);
    border: 1.5px dashed var(--color-partial-text);
}

.day-cell.full {
    background: var(--color-full-bg);
    color: var(--color-full-text);
}

.day-cell.absent {
    background: var(--color-day-absent-bg);
    color: var(--color-day-absent-text);
}

.day-cell.partial_absent {
    background: var(--color-day-partial-absent-bg);
    color: var(--color-day-absent-text);
    border: 1.5px dashed var(--color-day-absent-text);
}

.day-cell.today {
    box-shadow: 0 0 0 2px var(--color-accent) inset;
    font-weight: 600;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    font-size: 0.72rem;
    color: var(--color-muted);
}

.calendar-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.holiday { background: var(--color-holiday-bg); border: 1px solid var(--color-border); }
.legend-dot.partial { background: var(--color-partial-bg); border: 1.5px dashed var(--color-partial-text); }
.legend-dot.full { background: var(--color-full-bg); }
.legend-dot.absent { background: var(--color-day-absent-bg); }
.legend-dot.partial_absent { background: var(--color-day-partial-absent-bg); border: 1.5px dashed var(--color-day-absent-text); }
.legend-dot.not_recorded { background: var(--color-surface); border: 1px solid var(--color-border); }

/* Insights */

.insights-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-top: 16px;
}

.insights-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 12px;
}

.insights-subhead {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0 0 10px;
}

.insights-block {
    margin-top: 18px;
}

.insights-block:first-of-type {
    margin-top: 4px;
}

.streak-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--color-text);
    background: var(--color-full-bg);
    border-radius: 999px;
    padding: 8px 14px;
}

.streak-row.streak-none {
    background: var(--color-bg);
    color: var(--color-muted);
}

.streak-emoji {
    display: inline-block;
    animation: streak-pulse 1.8s ease-in-out infinite;
}

.streak-none .streak-emoji {
    animation: none;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.82rem;
}

.bar-row:last-child {
    margin-bottom: 0;
}

.bar-label {
    width: 64px;
    flex-shrink: 0;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    flex: 1;
    height: 8px;
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    transition: width 0.7s ease;
    background: var(--color-accent);
}

.bar-fill.bar-good { background: var(--color-present); }
.bar-fill.bar-warn { background: var(--color-warn); }
.bar-fill.bar-bad { background: var(--color-absent); }

.bar-value {
    width: 36px;
    flex-shrink: 0;
    text-align: right;
    color: var(--color-muted);
}

.paw-trail {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 18px;
    font-size: 1rem;
    opacity: 0.7;
}

.paw-trail span {
    display: inline-block;
    opacity: 0;
    animation: paw-in 0.5s ease forwards;
}

.paw-trail span:nth-child(1) { animation-delay: 0s; }
.paw-trail span:nth-child(2) { animation-delay: 0.1s; }
.paw-trail span:nth-child(3) { animation-delay: 0.2s; }
.paw-trail span:nth-child(4) { animation-delay: 0.3s; }
.paw-trail span:nth-child(5) { animation-delay: 0.4s; }

@keyframes mascot-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes streak-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes paw-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 0.7; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .mascot-emoji, .streak-emoji, .paw-trail span, .bar-fill {
        animation: none !important;
        transition: none !important;
    }
}

/* Login */

.login-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px 22px;
    width: 100%;
    max-width: 340px;
}

.login-mascot {
    display: block;
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--color-border);
}

.login-card h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 20px;
    text-align: center;
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 0.82rem;
    color: var(--color-muted);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
}

.field input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.form-error {
    color: var(--color-absent);
    font-size: 0.85rem;
    margin-top: 10px;
    text-align: center;
    min-height: 1.2em;
}

/* Day editor */

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    font-size: 0.9rem;
    color: var(--color-muted);
    text-decoration: none;
}

.day-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 16px;
}

.segmented {
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 3px;
    margin-bottom: 18px;
}

.segmented button {
    flex: 1;
    border: none;
    background: none;
    padding: 10px;
    border-radius: 999px;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
}

.segmented button.active {
    background: var(--color-accent);
    color: var(--color-accent-contrast);
}

.bulk-row {
    margin-bottom: 16px;
}

.bulk-label {
    display: block;
    font-size: 0.82rem;
    color: var(--color-muted);
    margin-bottom: 8px;
}

.period-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.period-card .period-label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.period-card .period-time {
    color: var(--color-muted);
    font-size: 0.78rem;
    margin-bottom: 10px;
}

.period-card select,
.period-card .subject-text-input {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    margin-bottom: 8px;
}

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

.status-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-muted);
    font-weight: 500;
    cursor: pointer;
}

.status-btn.present.active {
    background: var(--color-present-bg);
    border-color: var(--color-present);
    color: var(--color-present);
}

.status-btn.absent.active {
    background: var(--color-absent-bg);
    border-color: var(--color-absent);
    color: var(--color-absent);
}

.status-btn.no_class.active {
    background: var(--color-holiday-bg);
    border-color: var(--color-muted);
    color: var(--color-text);
}

.save-bar {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--color-bg) 70%, transparent);
    padding: 16px 0 4px;
    margin-top: 12px;
}

.save-bar button {
    width: 100%;
    padding: 14px;
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
}

.save-feedback {
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-present);
    margin-top: 8px;
    min-height: 1.2em;
}

.post-save-actions {
    margin-top: 4px;
}

.post-save-actions .next-day-btn {
    margin-bottom: 10px;
}

.post-save-actions .back-to-calendar-link {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-muted);
    text-decoration: none;
}

.loading-note {
    text-align: center;
    color: var(--color-muted);
    padding: 30px 0;
}

.site-footer {
    margin: 16px 0 0;
    font-size: 0.85rem;
    text-align: center;
}

.site-footer a {
    color: var(--color-muted);
}

.forgot-link {
    display: block;
    margin-top: 14px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--color-accent-text);
    text-decoration: none;
}

.privacy-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    line-height: 1.6;
}

.privacy-page h1 {
    font-size: 1.4rem;
    font-weight: 600;
}

.privacy-page h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 24px;
}

[hidden] {
    display: none !important;
}

/* Public landing / sign-up */

.login-wrap {
    padding: 24px 16px;
}

.login-tagline {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.9rem;
    margin: -12px 0 18px;
}

.field-hint {
    color: var(--color-muted);
    font-size: 0.75rem;
}

.about {
    width: 100%;
    max-width: 340px;
    margin-top: 20px;
    font-size: 0.88rem;
    color: var(--color-text);
}

.about h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 8px;
}

.about ul {
    margin: 0;
    padding-left: 18px;
}

.about li {
    margin-bottom: 6px;
}

/* Generic page + cards (setup, timetable, settings) */

.page-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 6px;
}

.page-sub {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin: 0 0 18px;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

.card-highlight {
    border-color: var(--color-accent);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 10px;
}

.card-text {
    font-size: 0.88rem;
    color: var(--color-muted);
    margin: 0 0 12px;
}

.card-text strong {
    color: var(--color-text);
}

.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
}

.inline-form input:focus,
.field input:focus,
.period-row input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.btn-secondary {
    display: inline-block;
    padding: 10px 16px;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-block {
    display: block;
    width: 100%;
    margin-top: 8px;
}

.btn-link {
    background: none;
    border: none;
    padding: 6px 4px;
    color: var(--color-accent-text);
    font-weight: 500;
    font-size: 0.88rem;
    cursor: pointer;
}

.btn-link:disabled {
    color: var(--color-muted);
    opacity: 0.5;
    cursor: default;
}

.btn-danger {
    color: var(--color-absent);
}

.card > .btn-link.btn-danger {
    display: block;
    margin: 10px auto 0;
}

.choice-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-weight: 500;
    cursor: pointer;
}

.choice-btn:last-child {
    margin-bottom: 0;
}

/* Timetable editor */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.chip-label, .chip-x {
    background: none;
    border: none;
    color: var(--color-text);
    font-size: 0.85rem;
    cursor: pointer;
}

.chip-label {
    padding: 6px 4px 6px 12px;
}

.chip-x {
    padding: 6px 10px 6px 6px;
    color: var(--color-muted);
}

.toggle-chip {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.toggle-chip.active {
    background: var(--color-holiday-bg);
    border-color: var(--color-muted);
    color: var(--color-text);
    font-weight: 500;
}

.period-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.period-row-label {
    width: 64px;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 500;
}

.period-row input {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
}

.row-actions {
    display: flex;
    justify-content: space-between;
}

.routine-day {
    border-top: 1px solid var(--color-border);
    padding: 10px 0;
}

.routine-day-name {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 6px;
}

.routine-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.routine-slot-label {
    width: 88px;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 500;
}

.routine-slot-label small {
    display: block;
    color: var(--color-muted);
    font-weight: 400;
    font-size: 0.7rem;
}

.routine-slot select {
    flex: 1;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
}

/* iOS Safari gives date inputs an intrinsic min-width (they overflow their
   column), centres the value, and collapses an empty one — undo all three. */
.field input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    min-width: 0;
    max-width: 100%;
    height: 44px;
    min-height: 44px;
    font: inherit;
    color: var(--color-text);
    text-align: left;
}

.field input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    min-height: 1.2em;
    margin: 0;
}

/* Settings */

.semester-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.semester-row-name {
    flex: 1;
    font-size: 0.88rem;
}

.semester-row.active .semester-row-name {
    font-weight: 600;
}

.semester-row-badge {
    font-size: 0.72rem;
    color: var(--color-full-text);
    background: var(--color-full-bg);
    border-radius: 999px;
    padding: 3px 8px;
}

/* Install prompt */

.install-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px dashed var(--color-accent);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.85rem;
}

.install-banner > span {
    flex: 1;
}

.install-btn {
    margin-left: 6px;
    padding: 4px 12px;
    border: none;
    border-radius: 999px;
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
}

.install-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0 4px;
}

.semester-row-name small {
    color: var(--color-muted);
    font-weight: 400;
}

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

.field-row .field {
    flex: 1;
    min-width: 0;
}

.field select {
    width: 100%;
    padding: 11px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text);
}

a.btn-primary {
    display: block;
    text-align: center;
    text-decoration: none;
}

.remaining-line {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-top: 6px;
}

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

.dates-row .field {
    flex: 1;
    min-width: 0;
}

.dates-feedback {
    font-size: 0.8rem;
    color: var(--color-present);
    text-align: center;
    margin-top: 6px;
    min-height: 1em;
}

.dates-feedback.is-error {
    color: var(--color-absent);
}

/* ---- Accents: suvamsahoo.com colours, soft cards, pill buttons ---- */

.dashboard-card, .calendar-card, .insights-card, .card, .login-card, .period-card {
    background: var(--color-surface);
    border-color: var(--color-border);
    box-shadow: var(--shadow-card);
}

.app-header h1, .page-title, .login-card h1, .card-title {
    letter-spacing: -0.01em;
}

.dashboard-percent {
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.btn-primary, .save-bar button, .install-btn {
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    border: none;
    border-radius: 999px;
    font-weight: 600;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover, .save-bar button:hover, .install-btn:hover {
    background: var(--color-accent-hover);
    box-shadow: var(--shadow-button);
}

.btn-primary:active, .save-bar button:active, .install-btn:active {
    transform: scale(0.98);
}

.btn-secondary, .logout-link {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid #11111129;
    border-radius: 999px;
    font-weight: 500;
}

.segmented {
    background: var(--color-surface);
    border-color: var(--color-border);
}

.segmented button.active {
    background: var(--color-accent-soft);
    color: var(--color-accent-text);
}

.status-btn.present.active {
    background: var(--color-present-bg);
    border-color: var(--color-present);
    color: var(--color-present);
}

.status-btn.absent.active {
    background: var(--color-absent-bg);
    border-color: var(--color-absent);
    color: var(--color-absent);
}

.status-btn.no_class.active {
    background: var(--color-sunk);
    border-color: var(--color-muted);
    color: var(--color-text);
}

.day-cell.today {
    box-shadow: 0 0 0 2px var(--color-accent) inset;
    color: var(--color-accent-text);
    font-weight: 600;
}

.toggle-chip.active {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-accent-text);
}

.card-highlight {
    border: 1.5px solid var(--color-accent);
}

.install-banner {
    border: 1px solid var(--color-accent-soft);
    background: var(--color-accent-soft);
}

.tomorrow-card, .upi-box {
    background: var(--color-sunk);
}

.field input, .inline-form input, .period-row input, .field select,
.routine-slot select, .period-card select, .period-card .subject-text-input {
    background: var(--color-bg);
}

.field input:focus, .inline-form input:focus, .period-row input:focus,
.field select:focus, .routine-slot select:focus, .period-card select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px var(--color-accent);
}

.bar-track { background: var(--color-sunk); }

.bar-fill {
    background: var(--color-accent);
}

.disclaimer {
    max-width: 340px;
    margin: 8px auto 0;
    font-size: 0.75rem;
    color: var(--color-muted);
    text-align: center;
    line-height: 1.45;
}

/* Save celebration (assets/js/celebrate.js) */

.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.celebrate-badge {
    position: fixed;
    left: 50%;
    top: 38%;
    transform: translate(-50%, -50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 22px 26px 18px;
    background: var(--color-surface);
    border-radius: 20px;
    box-shadow: 0 2px 6px #1111111a, 0 16px 40px -12px #11111140;
    pointer-events: none;
    animation: celebrate-pop 0.42s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.celebrate-badge.celebrate-out {
    animation: celebrate-fade 0.4s ease forwards;
}

.celebrate-circle {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
}

.celebrate-circle svg {
    width: 64px;
    height: 64px;
}

.celebrate-ring {
    fill: var(--color-present-bg);
    stroke: var(--color-present);
    stroke-width: 3;
    stroke-dasharray: 145;
    stroke-dashoffset: 145;
    animation: celebrate-draw 0.5s ease-out 0.1s forwards;
}

.celebrate-check {
    fill: none;
    stroke: var(--color-present);
    stroke-width: 4.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: celebrate-draw 0.35s ease-out 0.45s forwards;
}

.celebrate-partial .celebrate-ring {
    fill: var(--color-accent-soft);
    stroke: var(--color-accent-text);
}

.celebrate-partial .celebrate-check {
    stroke: var(--color-accent-text);
}

.celebrate-emoji {
    font-size: 2.6rem;
    animation: celebrate-wiggle 0.8s ease 0.2s;
}

.celebrate-text {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text);
    white-space: nowrap;
}

@keyframes celebrate-pop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes celebrate-fade {
    to { opacity: 0; transform: translate(-50%, -56%) scale(0.96); }
}

@keyframes celebrate-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes celebrate-wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-12deg); }
    75% { transform: rotate(10deg); }
}

@media (prefers-reduced-motion: reduce) {
    .celebrate-badge, .celebrate-badge.celebrate-out, .celebrate-emoji { animation: none; }
    .celebrate-ring, .celebrate-check { animation: none; stroke-dashoffset: 0; }
}

.coffee-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 500;
    text-decoration: none;
    box-shadow: var(--shadow-card);
}

.coffee-link:hover {
    background: var(--color-accent-soft);
}

/* Chai button at the bottom of the app pages */

.chai-footer {
    text-align: center;
    margin: 28px 0 32px;
}

.chai-footer .coffee-link {
    margin-top: 0;
}

/* Buy me a coffee page */

.coffee-card {
    text-align: center;
}

.coffee-emoji {
    font-size: 2.8rem;
    line-height: 1;
    margin-bottom: 8px;
}

.coffee-intro {
    color: var(--color-muted);
    font-size: 0.92rem;
    line-height: 1.55;
    margin: -8px 0 20px;
}

.coffee-pay {
    display: block;
    text-decoration: none;
}

.coffee-hint {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin: 8px 0 18px;
}

.upi-box {
    background: var(--color-bg);
    border-radius: 12px;
    padding: 12px 14px;
    text-align: left;
}

.upi-label {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.upi-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.upi-id {
    flex: 1;
    min-width: 0;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: all;
}

.upi-copy {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.qr-box {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.qr-box img {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
}

/* ---- Smoothness: tap feedback, reserved space, loading/offline states ---- */

button, a, .day-cell {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Every tappable thing answers the finger immediately. */
.day-cell:not(.blank):not(.before_semester):not(.after_semester):active,
.status-btn:active, .segmented button:active, .choice-btn:active,
.toggle-chip:active, .btn-secondary:active, .calendar-nav button:active,
.logout-link:active, .unmarked-banner:active, .coffee-link:active {
    transform: scale(0.95);
}

.day-cell, .status-btn, .segmented button, .choice-btn, .toggle-chip,
.btn-secondary, .calendar-nav button, .logout-link, .unmarked-banner, .coffee-link {
    transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Hold the dashboard card's space on the very first visit so the calendar
   doesn't jump down when the numbers arrive. */
.dashboard-card:empty {
    min-height: 236px;
}

.app-header .user-name:empty::before {
    content: '\00a0';
}

/* Month drawn, statuses still on their way. */
.day-cell.pending {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-muted);
}

.calendar-grid.is-loading .day-cell {
    cursor: default;
}

.calendar-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 0;
}

.save-feedback.is-error {
    color: var(--color-absent);
}

.save-bar button:disabled {
    opacity: 0.7;
    cursor: default;
}

.offline-note {
    background: var(--color-sunk);
    color: var(--color-text);
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 14px;
    font-size: 0.85rem;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .day-cell, .status-btn, .segmented button, .choice-btn, .toggle-chip,
    .btn-secondary, .calendar-nav button, .logout-link, .unmarked-banner, .coffee-link {
        transition: none;
    }
}

/* index.html starts as <html class="booting"> and drops it once the first
   paint from cache is ready (see its script). The delayed animation is a
   failsafe: the page shows after 1.5s even if the script never runs. */
.booting .app {
    visibility: hidden;
    animation: reveal 0s 1.5s forwards;
}

@keyframes reveal {
    to { visibility: visible; }
}
