:root {
    color-scheme: light;
    --bg: #fff;
    --surface: #ffffff;
    --surface-soft: #f1eee8;
    --text: #333;
    --muted: #666a73;
    --border-color: #222;
    --border: 1px solid #202124;
    --accent: tomato;
    --accent-strong: #86273d;
    --pink-soft: #f9dce3;
    --orange: #d9783c;
    --gold: #b88a22;
    --green: #587f62;
    --shadow: 0 20px 50px rgba(32, 33, 36, 0.08);
    --font-size-calendar: clamp(1.5rem, 3.2vw, 2.2rem);
    --max-width: 1440px;
    --gap-s: 24px;
    --gap-m: 40px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Outfit", Georgia, serif;
    letter-spacing: -0.01em;
    font-size: 16px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    padding: 0;
}
.app-left {
    padding: var(--gap-s);
}

.app-title {
    /*color: #989898;*/
    font-size: clamp(2rem, 5vw, 3.6rem);
    font-weight: 400;
    line-height: 1.05;
    margin: 0 auto 8px;
    /*max-width: var(--max-width);*/
    /*text-align: center;*/
    width: 100%;
}

.topbar {
    align-items: center;
    display: block;
    margin: 0 auto 8px;
    max-width: var(--max-width);
    width: 100%;
}

h1,
h2,
h3,
p {
    font-weight: 400;
    letter-spacing: -0.02em;
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 4.5vw, 4.25rem);
    line-height: 0.95;
}

h2 {
    font-size: 1rem;
    line-height: 1.2;
}

@keyframes summary-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.summary-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    max-width: 520px;
    opacity: 0;
    pointer-events: none;
    width: min(100%, 520px);
}

.summary-grid > div {
    border-left: var(--border);
    opacity: 0;
    padding-left: 12px;
}

.summary-grid.visible {
    opacity: 1;
    pointer-events: auto;
}

.summary-grid.visible > div {
    animation: summary-fade-in 0.4s ease forwards;
}

.summary-grid.visible > div:nth-child(1) {
    animation-delay: 0ms;
}
.summary-grid.visible > div:nth-child(2) {
    animation-delay: 120ms;
}
.summary-grid.visible > div:nth-child(3) {
    animation-delay: 240ms;
}
.summary-grid.visible > div:nth-child(4) {
    animation-delay: 360ms;
}

.disclaimer {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 8px;
    opacity: 0;
}

.topbar:has(.summary-grid.visible) ~ .disclaimer {
    animation: summary-fade-in 0.4s ease 640ms forwards;
}

.summary-grid:has(.mood-forecast-card:not([hidden])) {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    max-width: 680px;
}

.summary-grid span {
    display: block;
    font-size: var(--font-size-calendar);
    font-weight: 400;
    line-height: 1.05;
    margin-bottom: 4px;
}

.summary-grid small,
.panel p,
.history-item small {
    color: var(--muted);
}

.workspace {
    display: block;
    margin: 0 auto;
    max-width: var(--max-width);
    width: 100%;
}

.panel {
    /*background: var(--surface);*/
    /*border: 1px solid var(--line);*/
    /*border-radius: 8px;*/
    /*box-shadow: var(--shadow);*/
    /*padding: 18px;*/
}

.panel-head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 16px;
}

form {
    display: grid;
    gap: 14px;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 0.84rem;
    font-weight: 400;
    gap: 6px;
}

input,
select,
textarea {
    background: #fbfbf9;
    border-radius: 8px;
    color: var(--text);
    min-height: 40px;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    resize: vertical;
}

fieldset {
    /*border: 1px solid var(--line);*/
    border-radius: 8px;
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 12px;
}

legend {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 400;
    padding: 0 6px;
}

fieldset label {
    align-items: center;
    color: var(--text);
    display: flex;
    font-weight: 400;
}

fieldset input {
    accent-color: var(--accent);
    min-height: auto;
    width: auto;
}

.primary-button,
.text-button,
.icon-button {
    border: 0;
    border-radius: 8px;
    font-weight: 400;
}

.primary-button {
    background: var(--accent);
    color: white;
    min-height: 48px;
    padding: 0 16px;
}

.text-button {
    background: var(--surface-soft);
    color: var(--accent-strong);
    min-height: 40px;
    padding: 0 12px;
}

.icon-button {
    align-items: center;
    background: var(--surface-soft);
    color: var(--text);
    display: inline-flex;
    height: 36px;
    justify-content: center;
    min-width: 36px;
    padding: 0 10px;
}

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

.main-column {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.calendar-panel {
    overflow: hidden;
    padding: var(--gap-s);
}

.visual-calendar-head {
    align-items: center;
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 12px;
}

.visual-calendar-head strong {
    color: #000;
    font-size: clamp(2.2rem, 5vw, 5rem);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1;
}

.visual-weekdays {
    display: grid;
    font-size: var(--font-size-calendar);
    font-weight: 400;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    margin-left: calc(clamp(120px, 18vw, 160px) + var(--gap-s));
    margin-bottom: 12px;
    text-align: center;
}

.visual-weekdays span:nth-last-child(-n + 2) {
    color: #989898;
}

.sticky-month {
    color: #000;
    display: none;
    font-size: var(--font-size-calendar);
    font-weight: 400;
    left: clamp(18px, 3vw, 42px);
    line-height: 1;
    pointer-events: none;
    position: sticky;
    top: 12px;
    z-index: 10;
}

.sticky-month.visible {
    display: block;
}

.visual-calendar {
    display: grid;
    gap: 4px;
    width: 100%;
}

.visual-week {
    align-items: center;
    display: grid;
    gap: var(--gap-s);
    grid-template-columns: clamp(120px, 18vw, 160px) minmax(0, 1fr);
    margin-bottom: 8px;
}

.month-name {
    align-items: center;
    display: flex;
    padding-top: 0;
}

.month-name span {
    color: #000;
    font-size: var(--font-size-calendar);
    font-weight: 400;
    line-height: 1;
}

.week-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.visual-day {
    align-items: center;
    background: transparent;
    border: 1.5px solid transparent;
    color: var(--text);
    display: flex;
    font-size: var(--font-size-calendar);
    height: calc(var(--font-size-calendar) * 1.5);
    font-weight: 400;
    justify-content: center;
    line-height: 1;
    min-width: 0;
    overflow: visible;
    padding: 0;
    position: relative;
    z-index: 0;
}

/*.visual-day:not(.empty-day):not(.period-day):hover::before {
    aspect-ratio: 1;
    background: #ece9e3;
    border-radius: 999px;
    content: "";
    height: calc(100% + 10px);
    left: 50%;
    pointer-events: none;
    position: absolute;
    top: -5px;
    transform: translateX(-50%);
    z-index: -100;
}*/

.visual-day:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
    z-index: -1;
}

@keyframes today-spin {
    to {
        transform: translateX(-50%) translateY(-50%) rotate(360deg);
    }
}

.visual-day.today::after {
    animation: today-spin 12s linear infinite;
    aspect-ratio: 1;
    background: #e5e5e5;
    clip-path: polygon(
        30% 0%,
        70% 0%,
        100% 30%,
        100% 70%,
        70% 100%,
        30% 100%,
        0% 70%,
        0% 30%
    );
    content: "";
    height: calc(100% + 14px);
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    z-index: -1;
}

.visual-day.today.period-day {
    color: #000;
}

.visual-day.today.period-day::after {
    display: none;
}

.visual-day.period-day {
    border-color: transparent;
}

.visual-day.period-day::before {
    border-bottom: var(--border);
    border-top: var(--border);
    content: "";
    inset: -5px -2px;
    pointer-events: none;
    position: absolute;
    z-index: -1;
}

.visual-day.period-start::before {
    border-left-color: var(--border-color);
    border-left-style: solid;
    border-left-width: 1px;
    border-bottom-left-radius: 999px;
    border-top-left-radius: 999px;
    left: 0;
}

.visual-day.period-end::before {
    border-right-color: var(--border-color);
    border-right-style: solid;
    border-right-width: 1px;
    border-bottom-right-radius: 999px;
    border-top-right-radius: 999px;
    right: 0;
}

.empty-day {
    pointer-events: none;
}

.future-day {
    color: #c0bcb6;
    pointer-events: none;
}

/* Mood icon anchor (top-right of day cell) */
.mood-icon {
    color: #aaa;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    right: -2px;
    top: -2px;
    transition: opacity 0.1s;
    z-index: 1;
}

.mood-icon::before {
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    content: "";
    inset: -4px;
    position: absolute;
    z-index: -1;
}

.visual-day:hover .day-num {
    color: #000;
}

.visual-day:hover .mood-icon {
    opacity: 1;
    pointer-events: auto;
}

.visual-day:hover .mood-icon:hover {
    color: var(--text);
}

/* Mood tooltip */
.mood-tooltip {
    background: #fff;
    border-radius: 14px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.13),
        0 1px 4px rgba(0, 0, 0, 0.08);
    display: none;
    left: 0;
    /*padding: 8px;*/
    position: fixed;
    top: 0;
    z-index: 1000;
}

.mood-tooltip.visible {
    display: block;
}

.mood-tooltip-inner {
    display: flex;
}

.mood-btn {
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    width: 80px;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    transition: background 0.12s;
}

.mood-btn:hover {
    background: #f3f0ea;
}

.mood-btn.active {
    background: #f3f0ea;
}

.mood-icon.material-symbols-rounded,
.mood-btn .material-symbols-rounded {
    font-size: 28px;
    font-variation-settings:
        "FILL" 0,
        "wght" 400,
        "GRAD" 0,
        "opsz" 28;
    line-height: 1;
}

.mood-btn[data-mood="elevated"] .material-symbols-rounded {
    color: #19975d;
}
.mood-btn[data-mood="content"] .material-symbols-rounded {
    color: #00838a;
}
.mood-btn[data-mood="neutral"] .material-symbols-rounded {
    color: #0078bf;
}
.mood-btn[data-mood="low"] .material-symbols-rounded {
    color: #ff6f4c;
}
.mood-btn[data-mood="anxious"] .material-symbols-rounded {
    color: #ff48b0;
}

.mood-label {
    color: #666;
    font-weight: 400;
    line-height: 1;
}

/* Mood color on calendar day numbers */
.visual-day.mood-elevated {
    color: #19975d;
}
.visual-day.mood-content {
    color: #00838a;
}
.visual-day.mood-neutral {
    color: #0078bf;
}
.visual-day.mood-low {
    color: #ff6f4c;
}
.visual-day.mood-anxious {
    color: #ff48b0;
}

@keyframes mood-pop {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.2);
    }
    55% {
        transform: scale(1.1);
    }
    75% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.visual-day.mood-just-set .day-num {
    animation: mood-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.disclaimer {
    opacity: 0;
    font-size: 1em;
    color: var(--muted);
    margin-top: 12px;
}

/* Mood forecast message */
.mood-forecast-message {
    /*color: var(--muted);*/
    font-size: var(--font-size-calendar);
    line-height: 1.2em;
    /*font-weight: 350;*/
    /*letter-spacing: 0;*/
    margin: 4px auto 16px;
    max-width: var(--max-width);
    overflow: hidden;
    width: 100%;
}

.mood-message-elevated {
    color: #19975d;
}
.mood-message-content {
    color: #00838a;
}
.mood-message-neutral {
    color: #0078bf;
}
.mood-message-low {
    color: #ff6f4c;
}
.mood-message-anxious {
    color: #ff48b0;
}

.mood-keyword {
    /*font-style: italic;*/
}
.mood-keyword-elevated {
    color: #19975d;
}
.mood-keyword-content {
    color: #00838a;
}
.mood-keyword-neutral {
    color: #0078bf;
}
.mood-keyword-low {
    color: #ff6f4c;
}
.mood-keyword-anxious {
    color: #ff48b0;
}

/* Mood forecast summary card */
.mood-forecast-card {
    display: flex;
    flex-direction: column;
}

.mood-forecast-icon {
    font-size: var(--font-size-calendar);
    font-variation-settings:
        "FILL" 1,
        "wght" 300,
        "GRAD" 0,
        "opsz" 40;
    line-height: 1.05;
    margin-bottom: 4px;
}

.mood-forecast-elevated .mood-forecast-icon {
    color: #19975d;
}
.mood-forecast-content .mood-forecast-icon {
    color: #00838a;
}
.mood-forecast-neutral .mood-forecast-icon {
    color: #0078bf;
}
.mood-forecast-low .mood-forecast-icon {
    color: #ff6f4c;
}
.mood-forecast-anxious .mood-forecast-icon {
    color: #ff48b0;
}

.mood-forecast-elevated #mood-forecast-label {
    color: #19975d;
}
.mood-forecast-content #mood-forecast-label {
    color: #00838a;
}
.mood-forecast-neutral #mood-forecast-label {
    color: #0078bf;
}
.mood-forecast-low #mood-forecast-label {
    color: #ff6f4c;
}
.mood-forecast-anxious #mood-forecast-label {
    color: #ff48b0;
}

#mood-forecast-label {
    display: block;
    font-size: var(--font-size-calendar);
    font-weight: 400;
    line-height: 1.05;
    margin-bottom: 4px;
}

/* Mood-tinted insight items */
.mood-insight-label.mood-insight-elevated {
    color: #19975d;
}
.mood-insight-label.mood-insight-content {
    color: #00838a;
}
.mood-insight-label.mood-insight-neutral {
    color: #0078bf;
}
.mood-insight-label.mood-insight-low {
    color: #ff6f4c;
}
.mood-insight-label.mood-insight-anxious {
    color: #ff48b0;
}

.insights-row {
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr;
    padding: var(--gap-s);
    height: 100vh;
}

.insight-list {
    display: grid;
    list-style: none;
    margin: var(--gap-s) 0 0;
    padding: 0;
}

.insight-list li {
    /*align-items: center;*/
    border-top: 1px solid black;
    /*display: flex;*/
    font-size: var(--font-size-calendar);
    line-height: 1.2em;
    padding: 8px 0;
    gap: 4px;
}

.insight-list li::before {
    display: inline-block;
    background: #202124;
    border-radius: 50%;
    content: "";
    flex-shrink: 0;
    height: 24px;
    width: 24px;
    margin-right: 16px;
}

.hide {
    display: none;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    align-items: center;
    background: #fbfbf9;
    border-radius: 8px;
    display: grid;
    gap: 12px;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    padding: 12px;
}

.history-item h3 {
    font-size: 0.98rem;
}

.history-item p {
    font-size: 0.9rem;
    margin-top: 4px;
}

.flow-dot {
    border-radius: 999px;
    height: 14px;
    width: 14px;
}

.flow-light {
    background: var(--gold);
}

.flow-not-recorded {
    background: #8f949c;
}

.flow-medium {
    background: var(--accent);
}

.flow-heavy {
    background: var(--accent-strong);
}

.flow-spotting {
    background: var(--orange);
}

.font-picker {
    bottom: 20px;
    left: 20px;
    position: fixed;
    z-index: 100;
}

.font-picker select {
    appearance: none;
    background: var(--bg)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M5 7l5 5 5-5' stroke='%23202124' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E")
        no-repeat right 14px center;
    background-size: 20px 20px;
    border: var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    min-height: auto;
    padding: 12px 48px 12px 16px;
    width: auto;
}

.empty {
    color: var(--muted);
    padding: 18px 0 4px;
}

@media (max-width: 960px) {
    --font-size-calendar: 20px;

    .topbar,
    .workspace,
    .insights-row {
        grid-template-columns: 1fr;
    }

    .workspace {
        border-top: var(--border);
    }

    .topbar {
        align-items: stretch;
        display: grid;
    }

    .summary-grid {
        width: 100%;
    }
}

@media (max-width: 620px) {
    :root {
        --gap-s: 16px;
        --gap-m: 24px;
    }
    .visual-calendar-head {
        gap: 8px;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .visual-weekdays {
        margin-left: 80px;
    }

    .visual-calendar {
        gap: 10px;
    }

    .visual-week {
        gap: 12px;
        grid-template-columns: 68px minmax(0, 1fr);
    }

    .month-name {
        display: block;
    }
    .month-name:after {
        content: attr(data-text);
        font-size: 16px;
    }

    .month-name span {
        display: block;
        /*font-size: clamp(0.95rem, 4.4vw, 1.35rem);*/
        /*line-height: clamp(34px, 9vw, 44px);*/
        overflow-wrap: anywhere;
    }

    .visual-day {
        height: clamp(34px, 9vw, 44px);
    }
}

@media (min-width: 1200px) {
    .app-shell {
        display: grid;
        grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
        column-rule: var(--border);
        margin: 0 auto;
        min-height: 100vh;
    }

    .app-left {
        /*padding: 32px 0;*/
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .app-title {
        margin: 0;
        max-width: none;
    }

    .mood-forecast-message {
        max-width: none;
    }

    .topbar {
        margin: 0;
        max-width: none;
    }

    .workspace {
        margin: 0;
        max-width: none;
        padding: 0;
    }
}
