:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: #f3f5f9;
    --surface-hover: #edf1f8;
    --text: #172033;
    --text-soft: #5d687c;
    --text-faint: #8d97a8;
    --border: #dfe4ed;
    --border-strong: #ccd3df;
    --accent: #2f66e8;
    --accent-hover: #2456c8;
    --accent-soft: #e8efff;
    --accent-text: #214dad;
    --danger: #c93643;
    --danger-soft: #fff0f1;
    --task: #3675e8;
    --task-soft: #e7f0ff;
    --todo: #df8715;
    --todo-soft: #fff3dd;
    --reminder: #8656d9;
    --reminder-soft: #f1eaff;
    --event: #2d9b6f;
    --event-soft: #e4f6ee;
    --shadow: 0 18px 54px rgba(28, 39, 63, .14);
    --radius: 12px;
    --hour-height: 64px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1420;
    --surface: #171d2a;
    --surface-raised: #1c2332;
    --surface-muted: #202838;
    --surface-hover: #273143;
    --text: #f2f5fa;
    --text-soft: #adb7c8;
    --text-faint: #7c879b;
    --border: #2d3749;
    --border-strong: #3c475a;
    --accent: #6b97ff;
    --accent-hover: #81a6ff;
    --accent-soft: #202f52;
    --accent-text: #b9ceff;
    --danger: #ff747f;
    --danger-soft: #46232a;
    --task: #6a9bff;
    --task-soft: #223252;
    --todo: #f2ac4d;
    --todo-soft: #49341d;
    --reminder: #ad87f0;
    --reminder-soft: #36294c;
    --event: #5ac79c;
    --event-soft: #203e35;
    --shadow: 0 22px 64px rgba(0, 0, 0, .34);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-width: 320px;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

body {
    min-height: 100dvh;
    overflow: hidden;
}

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

button,
select,
summary {
    -webkit-tap-highlight-color: transparent;
}

button {
    border: 0;
}

button:not(:disabled),
select:not(:disabled),
summary {
    cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: .58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.noscript {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 2rem;
    background: var(--bg);
    text-align: center;
}

.eyebrow {
    margin: 0 0 .2rem;
    color: var(--accent);
    font-size: .75rem;
    font-weight: 750;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.button,
.icon-button,
.segmented button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .12s ease;
}

.button {
    gap: .45rem;
    padding: .58rem .9rem;
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 700;
}

.button:active,
.icon-button:active,
.segmented button:active {
    transform: translateY(1px);
}

.button.primary {
    background: var(--accent);
    color: #fff;
}

.button.primary:hover {
    background: var(--accent-hover);
}

:root[data-theme="dark"] .button.primary {
    color: #0b1324;
}

.button.subtle {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text-soft);
}

.button.subtle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.button.danger,
.button.danger-quiet:hover {
    background: var(--danger);
    color: #fff;
}

.button.danger-quiet {
    background: var(--danger-soft);
    color: var(--danger);
}

.button.wide {
    width: 100%;
}

.icon-button {
    width: 40px;
    min-width: 40px;
    padding: 0;
    background: transparent;
    color: var(--text-soft);
}

.icon-button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.icon-button svg,
.button svg,
.floating-add svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-muted);
}

.segmented button {
    min-height: 32px;
    padding: .35rem .72rem;
    background: transparent;
    color: var(--text-soft);
    font-size: .8125rem;
    font-weight: 700;
}

.segmented button.is-active {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(25, 35, 55, .1);
    color: var(--text);
}

label {
    display: grid;
    gap: .38rem;
    color: var(--text-soft);
    font-size: .8125rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: .9375rem;
}

input,
select {
    min-height: 42px;
    padding: .52rem .68rem;
}

textarea {
    resize: vertical;
    padding: .65rem .7rem;
    line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-faint);
}

.key-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8125rem;
    letter-spacing: -.01em;
}

.label-note,
label small {
    color: var(--text-faint);
    font-size: .75rem;
    font-weight: 500;
}

label small {
    display: block;
    line-height: 1.35;
}

.form-message {
    min-height: 1.25rem;
    margin: .65rem 0 0;
    color: var(--danger);
    font-size: .8125rem;
}

.form-message.is-success {
    color: var(--event);
}

/* Welcome */
.welcome {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    overflow: auto;
    padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background:
        radial-gradient(circle at 8% 4%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 32rem),
        var(--bg);
}

.welcome-card {
    width: min(100%, 620px);
    padding: clamp(1.25rem, 4vw, 2.2rem);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-raised);
    box-shadow: var(--shadow);
}

.welcome-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 1.1rem;
    align-items: start;
}

.app-mark {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border-radius: 14px;
    background: var(--accent);
    box-shadow: inset 0 10px 0 rgba(255, 255, 255, .18);
    color: #fff;
    font-size: .9rem;
    font-weight: 800;
}

.welcome h1 {
    max-width: 460px;
    margin: 0;
    font-size: clamp(1.65rem, 5vw, 2.25rem);
    letter-spacing: -.035em;
    line-height: 1.08;
}

.welcome-intro {
    margin: .7rem 0 0;
    color: var(--text-soft);
    font-size: .9375rem;
}

.privacy-note {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .8rem;
    margin: 1.4rem 0;
    padding: .9rem;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
    border-radius: 12px;
    background: var(--accent-soft);
}

.privacy-note svg {
    width: 24px;
    fill: var(--accent);
}

.privacy-note strong {
    color: var(--accent-text);
    font-size: .875rem;
}

.privacy-note p {
    margin: .2rem 0 0;
    color: var(--text-soft);
    font-size: .8125rem;
}

.welcome-tabs {
    display: flex;
    width: 100%;
    margin-bottom: 1rem;
}

.welcome-tabs button {
    flex: 1;
}

.setup-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
}

.setup-form .button,
.setup-form label:first-child:nth-last-child(4) {
    grid-column: 1 / -1;
}

/* Application shell */
.app-shell {
    display: flex;
    min-height: 100dvh;
    height: 100dvh;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
}

.toolbar {
    position: relative;
    z-index: 5;
    display: grid;
    min-height: 68px;
    grid-template-columns: minmax(190px, 1fr) auto minmax(240px, 1fr);
    gap: 1rem;
    align-items: center;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.calendar-controls,
.view-controls,
.date-navigation {
    display: flex;
    min-width: 0;
    align-items: center;
}

.calendar-controls {
    gap: .3rem;
}

.calendar-select {
    width: min(100%, 240px);
    flex: 1 1 auto;
    min-height: 40px;
    border-color: transparent;
    background: var(--surface-muted);
    font-weight: 750;
    text-overflow: ellipsis;
}

.date-navigation {
    justify-content: center;
}

.date-title {
    display: flex;
    min-width: 180px;
    justify-content: center;
    gap: .35rem;
}

.date-title button {
    padding: .35rem .1rem;
    background: transparent;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 780;
    letter-spacing: -.02em;
}

.date-title button:hover {
    color: var(--accent);
}

.view-controls {
    justify-content: flex-end;
    gap: .5rem;
}

.mobile-today-button {
    display: none;
}

.moon-icon {
    display: none;
}

:root[data-theme="dark"] .sun-icon {
    display: none;
}

:root[data-theme="dark"] .moon-icon {
    display: block;
}

.sync-banner {
    padding: .45rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: .8125rem;
    text-align: center;
}

.calendar-workspace {
    display: grid;
    min-width: 0;
    min-height: 0;
    flex: 1;
    grid-template-columns: minmax(0, 1fr) 360px;
    overflow: hidden;
}

.app-shell.view-day .calendar-workspace {
    grid-template-columns: minmax(0, 1fr);
}

.app-shell.view-day .month-pane {
    display: none;
}

.app-shell.view-day .day-panel {
    width: min(100%, 920px);
    justify-self: center;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* Month */
.month-pane {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-rows: 38px minmax(0, 1fr);
    padding: .75rem 1rem 1rem;
    background: var(--bg);
}

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

.weekday-row {
    align-items: center;
    color: var(--text-faint);
    font-size: .75rem;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.weekday-row span {
    min-width: 0;
    padding-left: .7rem;
}

.weekday-row i {
    display: none;
    font-style: normal;
}

.month-grid {
    min-height: 0;
    grid-template-rows: repeat(6, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
}

.day-cell {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: .42rem .46rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-align: left;
}

.day-cell:nth-child(7n) {
    border-right: 0;
}

.day-cell:nth-last-child(-n+7) {
    border-bottom: 0;
}

.day-cell:hover {
    background: var(--surface-hover);
}

.day-cell.is-outside {
    background: color-mix(in srgb, var(--surface-muted) 58%, var(--surface));
    color: var(--text-faint);
}

.day-cell.is-selected {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.day-number {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    font-size: .8125rem;
    font-weight: 750;
}

.day-cell.is-today .day-number {
    background: var(--accent);
    color: #fff;
}

.month-entries {
    display: grid;
    gap: 2px;
    margin-top: 2px;
}

.month-entry {
    display: flex;
    min-width: 0;
    height: 21px;
    align-items: center;
    gap: .35rem;
    padding: 0 .32rem;
    border-radius: 5px;
    background: var(--surface-muted);
    color: var(--text-soft);
    font-size: .72rem;
    font-weight: 650;
    line-height: 1;
}

.month-entry:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.month-entry span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-dot,
.mobile-dot {
    width: 7px;
    height: 7px;
    min-width: 7px;
    border-radius: 50%;
    background: var(--entry-color);
}

.more-entries {
    padding: 1px .35rem;
    color: var(--text-faint);
    font-size: .7rem;
    font-weight: 700;
}

.mobile-dots {
    display: none;
}

/* Day */
.day-panel {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--surface);
}

.day-header {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem .8rem;
}

.day-header p {
    margin: 0;
    color: var(--text-soft);
    font-size: .75rem;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.day-header h2 {
    margin: .12rem 0 0;
    font-size: 1.18rem;
    letter-spacing: -.025em;
    line-height: 1.15;
}

.add-button {
    flex: 0 0 auto;
}

.all-day-section {
    display: grid;
    grid-template-columns: 55px minmax(0, 1fr);
    gap: .45rem;
    padding: .55rem .8rem .7rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.all-day-section h3 {
    margin: .32rem 0 0;
    color: var(--text-faint);
    font-size: .67rem;
    font-weight: 750;
    text-align: right;
    text-transform: uppercase;
}

.all-day-list {
    display: grid;
    min-width: 0;
    gap: .3rem;
}

.all-day-list:empty::after {
    content: "No all-day entries";
    padding: .3rem .5rem;
    color: var(--text-faint);
    font-size: .75rem;
}

.all-day-entry {
    display: flex;
    min-width: 0;
    min-height: 30px;
    align-items: center;
    gap: .45rem;
    padding: .32rem .52rem;
    border-left: 3px solid var(--entry-color);
    border-radius: 6px;
    background: var(--entry-soft);
    color: var(--text);
    font-size: .78rem;
    font-weight: 700;
    text-align: left;
}

.all-day-entry span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-scroll {
    min-width: 0;
    min-height: 0;
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--border-strong) transparent;
}

.timeline {
    position: relative;
    min-width: 0;
}

.time-row {
    position: relative;
    height: var(--hour-height);
    margin-left: 56px;
    border-top: 1px solid var(--border);
}

.time-row:first-child {
    border-top: 0;
}

.time-row:first-child .time-label {
    top: .2rem;
}

.time-label {
    position: absolute;
    top: -.55rem;
    right: calc(100% + 8px);
    width: 45px;
    color: var(--text-faint);
    font-size: .67rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.timed-entry {
    position: absolute;
    z-index: 2;
    left: 64px;
    right: 9px;
    min-height: 28px;
    overflow: hidden;
    padding: .35rem .5rem;
    border-left: 4px solid var(--entry-color);
    border-radius: 6px;
    background: var(--entry-soft);
    color: var(--text);
    text-align: left;
}

.timed-entry:hover,
.all-day-entry:hover {
    filter: brightness(.98);
    box-shadow: 0 1px 4px rgba(20, 31, 50, .12);
}

:root[data-theme="dark"] .timed-entry:hover,
:root[data-theme="dark"] .all-day-entry:hover {
    filter: brightness(1.12);
}

.timed-entry strong,
.timed-entry span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timed-entry strong {
    font-size: .78rem;
    line-height: 1.2;
}

.timed-entry span {
    margin-top: .12rem;
    color: var(--text-soft);
    font-size: .67rem;
    font-variant-numeric: tabular-nums;
}

.timeline-empty {
    position: absolute;
    inset: 42px 1rem auto 64px;
    z-index: 1;
    padding: 1rem;
    color: var(--text-faint);
    font-size: .8125rem;
    text-align: center;
    pointer-events: none;
}

.floating-add {
    display: none;
}

/* Dialogs */
.modal {
    width: min(calc(100% - 2rem), 580px);
    max-width: none;
    max-height: min(90dvh, 840px);
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 17px;
    background: transparent;
    color: var(--text);
    box-shadow: var(--shadow);
}

.modal::backdrop {
    background: rgba(13, 20, 34, .58);
    backdrop-filter: blur(3px);
}

.modal-card {
    max-height: min(90dvh, 840px);
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface-raised);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    letter-spacing: -.025em;
    line-height: 1.2;
}

.close-button {
    margin: -.4rem -.45rem 0 0;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .55rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.split-actions {
    justify-content: space-between;
}

.split-actions > div {
    display: flex;
    gap: .55rem;
}

.type-pill {
    display: inline-block;
    margin-bottom: .35rem;
    padding: .2rem .45rem;
    border-radius: 999px;
    background: var(--entry-soft);
    color: var(--entry-color);
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.detail-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: .45rem 1.25rem .9rem;
}

.detail-list > div {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: .7rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-list > div:last-child {
    border-bottom: 0;
}

.detail-list dt {
    color: var(--text-faint);
    font-size: .75rem;
    font-weight: 750;
    text-transform: uppercase;
}

.detail-list dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: .875rem;
}

.pre-line {
    white-space: pre-line;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem;
    padding: 1.1rem 1.25rem .7rem;
}

.span-2 {
    grid-column: 1 / -1;
}

.type-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .4rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.type-options legend {
    margin-bottom: .38rem;
    color: var(--text-soft);
    font-size: .8125rem;
    font-weight: 700;
}

.type-options label {
    position: relative;
}

.type-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-options span {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: .78rem;
}

.type-options input:focus-visible + span {
    outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.type-options input:checked + span {
    border-color: var(--entry-color);
    background: var(--entry-soft);
    color: var(--entry-color);
}

.type-task { --entry-color: var(--task); --entry-soft: var(--task-soft); }
.type-todo { --entry-color: var(--todo); --entry-soft: var(--todo-soft); }
.type-reminder { --entry-color: var(--reminder); --entry-soft: var(--reminder-soft); }
.type-event { --entry-color: var(--event); --entry-soft: var(--event-soft); }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.checkbox-row input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--accent);
}

.checkbox-row span {
    color: var(--text);
    font-size: .875rem;
}

.editor-modal .form-message {
    margin: 0 1.25rem;
}

.settings-modal {
    width: min(calc(100% - 2rem), 660px);
}

.settings-intro {
    margin: 0;
    padding: 1rem 1.25rem .5rem;
    color: var(--text-soft);
    font-size: .8125rem;
}

.settings-list {
    display: grid;
    gap: .7rem;
    padding: .65rem 1.25rem 1rem;
}

.settings-item {
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-muted);
}

.settings-item.is-active {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.settings-item-header {
    display: flex;
    justify-content: space-between;
    gap: .7rem;
    margin-bottom: .65rem;
}

.settings-item-title {
    min-width: 0;
    font-size: .875rem;
    font-weight: 800;
}

.settings-item-title span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.active-label {
    color: var(--accent);
    font-size: .67rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.settings-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
}

.key-row {
    display: flex;
    min-width: 0;
    grid-column: 1 / -1;
    gap: .4rem;
}

.key-preview {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    padding: .58rem .65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-item-actions {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .65rem;
}

.settings-item-actions .button {
    min-height: 34px;
    padding: .35rem .6rem;
    font-size: .75rem;
}

.add-calendar-details {
    margin: 0 1.25rem 1rem;
    border: 1px solid var(--border);
    border-radius: 11px;
}

.add-calendar-details summary {
    padding: .8rem .9rem;
    color: var(--accent);
    font-size: .8125rem;
    font-weight: 750;
}

.add-calendar-details[open] summary {
    border-bottom: 1px solid var(--border);
}

.settings-add-tabs {
    display: flex;
    margin: .8rem .8rem 0;
}

.settings-add-tabs button {
    flex: 1;
}

.compact-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
    padding: .8rem;
}

.compact-form .button {
    grid-column: 1 / -1;
}

.add-calendar-details .form-message {
    margin: 0 .8rem .7rem;
}

.picker-modal {
    width: min(calc(100% - 2rem), 430px);
}

.year-picker-label {
    margin: 1rem 1.25rem .7rem;
}

.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .45rem;
    margin: 0;
    padding: .3rem 1.25rem 1.15rem;
    border: 0;
}

.month-choice {
    position: relative;
}

.month-choice input {
    position: absolute;
    opacity: 0;
}

.month-choice span {
    display: grid;
    min-height: 38px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-soft);
    font-size: .8rem;
    font-weight: 700;
}

.month-choice input:checked + span {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.month-choice input:focus-visible + span {
    outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.confirm-modal {
    width: min(calc(100% - 2rem), 420px);
    text-align: center;
}

.confirm-modal .modal-card {
    padding-top: 1.3rem;
}

.confirm-icon {
    display: grid;
    width: 50px;
    height: 50px;
    margin: 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--danger-soft);
    color: var(--danger);
}

.confirm-icon svg {
    width: 24px;
    fill: currentColor;
}

.confirm-modal h2 {
    margin: .8rem 1rem .25rem;
    font-size: 1.25rem;
}

.confirm-modal p {
    margin: 0 auto 1rem;
    padding: 0 1.3rem;
    color: var(--text-soft);
    font-size: .875rem;
}

.confirm-modal .modal-actions {
    justify-content: center;
}

.toast-region {
    position: fixed;
    z-index: 200;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    display: grid;
    width: min(calc(100% - 2rem), 360px);
    gap: .5rem;
    pointer-events: none;
}

.toast {
    padding: .75rem .9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
    box-shadow: 0 10px 32px rgba(18, 28, 45, .2);
    color: var(--text);
    font-size: .8125rem;
    font-weight: 650;
    animation: toast-in .2s ease-out;
}

.toast.is-error {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
    color: var(--danger);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 1050px) {
    .toolbar {
        grid-template-columns: minmax(170px, 1fr) auto minmax(190px, 1fr);
        gap: .45rem;
    }

    .calendar-workspace {
        grid-template-columns: minmax(0, 1fr) 330px;
    }

}

@media (max-width: 820px) {
    body {
        overflow: hidden;
    }

    .toolbar {
        min-height: 112px;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: 48px 48px;
        gap: 0 .4rem;
        padding: .4rem .65rem;
    }

    .calendar-controls {
        grid-column: 1;
        grid-row: 1;
    }

    .calendar-select {
        width: min(100%, 260px);
    }

    .view-controls {
        grid-column: 2;
        grid-row: 1;
    }

    .today-button {
        display: none;
    }

    .date-navigation {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: space-between;
    }

    .mobile-today-button {
        display: inline-flex;
        min-height: 34px;
        padding: .35rem .6rem;
    }

    .date-title {
        min-width: 0;
    }

    .calendar-workspace,
    .app-shell.view-month .calendar-workspace {
        display: flex;
        flex-direction: column;
    }

    .app-shell.view-month .month-pane {
        display: grid;
        min-height: 41%;
        flex: 0 0 41%;
    }

    .app-shell.view-month .day-panel {
        display: flex;
        min-height: 0;
        flex: 1;
    }

    .app-shell.view-day .day-panel {
        width: 100%;
        flex: 1;
        border-right: 0;
        border-left: 0;
    }

    .month-pane {
        grid-template-rows: 26px minmax(0, 1fr);
        padding: .35rem .55rem .5rem;
    }

    .weekday-row span {
        padding-left: 0;
        text-align: center;
    }

    .weekday-row b {
        display: none;
    }

    .weekday-row i {
        display: inline;
    }

    .month-grid {
        border-radius: 10px;
    }

    .day-cell {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: .18rem .08rem;
    }

    .day-number {
        width: 25px;
        height: 25px;
        font-size: .72rem;
    }

    .month-entries {
        display: none;
    }

    .mobile-dots {
        display: flex;
        max-width: 100%;
        gap: 2px;
        justify-content: center;
        margin-top: 2px;
        overflow: hidden;
    }

    .mobile-dot {
        width: 5px;
        height: 5px;
        min-width: 5px;
    }

    .day-panel {
        border-top: 1px solid var(--border);
        border-left: 0;
    }

    .day-header {
        padding: .62rem .75rem .5rem;
    }

    .day-header h2 {
        font-size: 1rem;
    }

    .add-button {
        min-height: 36px;
        padding: .4rem .65rem;
    }

    .all-day-section {
        grid-template-columns: 48px minmax(0, 1fr);
        padding: .4rem .65rem .45rem 0;
    }
}

@media (max-width: 560px) {
    .toolbar {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .calendar-select {
        width: 100%;
        max-width: 180px;
    }

    .view-switch button {
        padding-right: .52rem;
        padding-left: .52rem;
    }

    .view-controls > .icon-button {
        width: 36px;
        min-width: 36px;
    }

    .date-title button {
        font-size: .96rem;
    }

    .date-navigation > .icon-button {
        width: 34px;
        min-width: 34px;
    }

    .mobile-today-button {
        padding-right: .48rem;
        padding-left: .48rem;
        font-size: .75rem;
    }

    .welcome-card {
        border-radius: 16px;
    }

    .welcome-header {
        grid-template-columns: 1fr;
        gap: .8rem;
    }

    .app-mark {
        width: 46px;
        height: 46px;
    }

    .setup-form,
    .form-grid,
    .settings-fields,
    .compact-form {
        grid-template-columns: 1fr;
    }

    .setup-form label,
    .setup-form .button,
    .span-2,
    .key-row,
    .compact-form .button {
        grid-column: 1;
    }

    .type-options {
        grid-template-columns: 1fr 1fr;
    }

    .modal {
        width: min(calc(100% - 1rem), 580px);
        max-height: calc(100dvh - 1rem);
    }

    .modal-card {
        max-height: calc(100dvh - 1rem);
    }

    .modal-header,
    .modal-actions {
        padding-right: .9rem;
        padding-left: .9rem;
    }

    .form-grid,
    .settings-list,
    .detail-list {
        padding-right: .9rem;
        padding-left: .9rem;
    }

    .settings-intro {
        padding-right: .9rem;
        padding-left: .9rem;
    }

    .add-calendar-details {
        margin-right: .9rem;
        margin-left: .9rem;
    }

    .detail-list > div {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .floating-add {
        position: fixed;
        z-index: 8;
        right: max(1rem, env(safe-area-inset-right));
        bottom: max(1rem, env(safe-area-inset-bottom));
        display: grid;
        width: 48px;
        height: 48px;
        place-items: center;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 38%, transparent);
        color: #fff;
    }

    .toast-region {
        right: .5rem;
        bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 58px);
        width: calc(100% - 1rem);
    }
}

@media (max-height: 650px) and (max-width: 820px) {
    .toolbar {
        min-height: 96px;
        grid-template-rows: 42px 42px;
    }

    .app-shell.view-month .month-pane {
        min-height: 46%;
        flex-basis: 46%;
    }

    .day-header {
        padding-top: .45rem;
        padding-bottom: .4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
