:root {
    --text: #1f2328;
    --muted: #6a737d;
    --border: #d0d7de;
    --code-bg: #f8f6e8;
    --paper: #fffdf6;
    --card-bg: #ffffff;

    --page-width: 1180px;
    --article-width: 900px;
    --footer-height: 72px;
    --calendar-gap: 32px;
    --calendar-size: 360px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: var(--text);

    line-height: 1.65;
}

/* warm paper background for the whole site */
body { background: var(--paper); }

nav,
main,
footer {
    width: min(var(--page-width), calc(100% - 48px));
    margin: 0 auto;
}

article {
    width: min(var(--article-width), 100%);
}

nav {
    display: flex;
    gap: 24px;

    padding: 24px 0;

    border-bottom: 1px solid var(--border);
}

nav a {
    color: inherit;
    text-decoration: none;
}

nav a:first-child {
    font-weight: 600;
    margin-right: auto;
}

main {
    padding: 48px 0 calc(var(--footer-height) + 24px);
}

article h1 {
    font-size: 2.4rem;
    line-height: 1.15;
    margin-bottom: 8px;
}

article h2 {
    margin-top: 48px;
}

article h3 {
    margin-top: 36px;
}

.date {
    color: var(--muted);
    margin-top: 0;
}

pre {
    overflow-x: auto;

    padding: 18px;

    background: var(--code-bg);

    border: 1px solid var(--border);
    border-radius: 6px;
}

code {
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;
}

p code {
    padding: 2px 5px;
    background: var(--code-bg);
    border-radius: 4px;
}

a {
    color: #0969da;
}

footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--footer-height);
    padding: 16px 0;
    background: white;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.brain-cell-meter {
    display: flex;
    align-items: center;
    gap: 7px;

    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.72rem;

    color: var(--muted);
}

.brain-cell-label {
    white-space: nowrap;
}

.battery {
    position: relative;

    width: 30px;
    height: 13px;

    border: 1.5px solid currentColor;
    border-radius: 3px;

    padding: 2px;
}

.battery::after {
    content: "";

    position: absolute;

    right: -4px;
    top: 3px;

    width: 2px;
    height: 5px;

    background: currentColor;
    border-radius: 0 1px 1px 0;
}

.battery-level {
    width: 37%;
    height: 100%;

    background: currentColor;
    border-radius: 1px;
}

.brain-cell-value {
    min-width: 3ch;
}

.post-gif {
    display: block;
    width: min(100%, 520px);
    height: auto;
    margin: 24px 0;
    border-radius: 8px;
}

.godbolt {
    display: block;
    width: 100%;
    height: 650px;
    margin: 32px 0;

    border: 1px solid var(--border);
    border-radius: 8px;
}

.calendar-component {
    position: fixed;
    top: 120px;
    /* responsive square size */
    width: var(--calendar-size);
    aspect-ratio: 1 / 1;
    /* keep the calendar outside the centered content but clamp extremes */
    right: max(12px, calc((100% - min(var(--page-width), calc(100% - 48px))) / 2 - var(--calendar-gap)));
    z-index: 60;
}

.calendar-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 8px 28px rgba(28,31,35,0.08);
}

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

/* responsive: hide calendar on narrow screens */
@media (max-width: 980px) {
  .calendar-component { display: none; }
}

/* narrower desktop sizes - avoid cramped placement */
@media (max-width: 1400px) {
    .calendar-component {
        width: clamp(260px, 30vw, 380px);
        right: 18px;
        top: 100px;
    }
}

@media (max-width: 1200px) {
    .calendar-component {
        width: 300px;
        right: 12px;
        top: 96px;
    }
}

.calendar-card #calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    font-size: 0.95rem;
    /* allow calendar grid to grow and scroll if necessary inside square card */
    flex: 1 1 auto;
    overflow: auto;
}

.cal-day {
    padding: 8px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
}

.cal-day:hover { background: #f6f8fa; }
.cal-day.other-month { color: var(--muted); opacity: 0.6; }
.cal-day.today { border: 1px solid #0969da; }
.cal-badge { display:inline-block; background:#0969da; color:#fff; font-size:0.65rem; padding:2px 6px; border-radius:999px; margin-left:6px; }

#dayTasks, .day-tasks { margin-top: 12px; }
#tasksList { list-style: none; padding: 0; margin: 8px 0 0; }
#tasksList li { display:flex; align-items:center; gap:8px; padding:6px 4px; border-bottom:1px dashed var(--border); }
#tasksList li.completed { color: var(--muted); text-decoration: line-through; }
