body {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    padding: clamp(14px, 2.7vw, 32px);
    color: var(--text-main);
}

body, button, input, select { font-family: "Noto Sans SC", Inter, system-ui, sans-serif; }
button, select { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

#app-window {
    width: min(100%, 1080px);
    height: min(100%, 860px);
    max-width: none;
    border: 1px solid var(--card-border);
}

.web-header {
    min-height: 54px;
    padding-inline: 19px;
}

.app-brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--primary-grad);
    box-shadow: 0 3px 9px rgb(110 120 216 / 23%);
}

.desktop-body { position: relative; min-height: 0; }
.desktop-body > aside { width: 74px; }
#web-content {
    min-width: 0;
    min-height: 0;
    overscroll-behavior: contain;
    scrollbar-width: none;
    overflow-x: hidden;
}
#web-content::-webkit-scrollbar { display: none; }

#side-nav .nav-btn {
    width: 53px;
    height: 51px;
    flex-direction: column;
    gap: 2px;
}
.nav-label { font-size: 11px; line-height: 1.3; font-weight: 550; }
#nav-active-pill {
    top: 20px;
    left: 0;
    width: 53px;
    height: 51px;
    transition: transform 290ms cubic-bezier(.22, 1.15, .36, 1);
}

.hero-chara-card { min-height: 116px; }
.hero-emblem {
    width: min(174px, 40%);
    min-height: 106px;
    display: grid;
    place-items: center;
    flex: none;
    pointer-events: none;
    transition: filter .35s ease;
}
.hero-emblem img {
    width: 91px;
    height: 91px;
    object-fit: contain;
    opacity: .78;
    filter: saturate(.72);
}
.hero-emblem.spirit-blessing { filter: drop-shadow(0 0 14px rgb(135 150 243 / 78%)); }
body.moonlit-night .hero-emblem img { opacity: .9; }
.hero-date { font-size: 13px; }
.summary-grid .metric-card { min-width: 0; text-align: left; }
.metric-card[aria-pressed="true"]:focus-visible,
button:focus-visible { outline: 2px solid #7180df; outline-offset: 2px; }

#task-list-container { min-width: 0; }
.task-row { margin-inline: 0; }
.task-actions { gap: clamp(5px, 1.1vw, 13px); }
.task-category { white-space: nowrap; }
.task-title-text { min-width: 0; }
.task-row [data-action="delete"]:focus-visible { opacity: 1; }
.task-row [data-action="delete"] { min-width: 24px; }
.task-row [data-action="delete"] svg { margin-inline: auto; }

.elastic-toggle-track { flex: 0 0 48px; }
#todo-title-input { overflow-wrap: anywhere; }
#todo-modal-card select { min-height: 40px; }

body.moonlit-night .nornes-checkbox:not(.checked) {
    background: #2a345c;
    border-color: #8794ca;
}
body.moonlit-night .task-timing { color: #aeb9da; }
body.moonlit-night .task-timing.font-medium { color: #f79d9d; }
body.moonlit-night #filter-mode-chip { color: #dbe2fc; background: #38446f; border-color: #6775ad; }
body.moonlit-night #side-nav .nav-btn { color: #aebce7; }
body.moonlit-night #side-nav [aria-current="page"] { color: #eef1ff; }

@media (max-width: 860px) {
    .calendar-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
    body { padding: 0; background: var(--window-bg); }
    #app-window {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
        background: var(--window-bg);
        backdrop-filter: none;
        box-shadow: none;
    }
    .web-header {
        min-height: 48px;
        padding-inline: max(14px, env(safe-area-inset-left));
    }
    .desktop-body { flex-direction: column; }
    #web-content { order: 0; padding: 13px 13px 16px; }
    #workspace-view { gap: 13px; }
    .desktop-body > aside {
        order: 1;
        width: 100%;
        padding: 5px max(9px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
        border-right: 0;
        border-top: 1px solid var(--divider-color);
        background: var(--card-bg);
    }
    #side-nav {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 3px;
    }
    #side-nav .nav-btn { width: 100%; min-height: 46px; height: 46px; }
    #nav-active-pill { top: 5px; left: max(9px, env(safe-area-inset-left)); }
    .scroll-overlay { display: none; }

    .hero-chara-card { min-height: 105px; }
    .hero-emblem { min-height: 98px; }
    .hero-emblem img { width: 80px; height: 80px; }
    .summary-grid { gap: 7px; }
    .summary-grid .metric-card {
        display: grid;
        gap: 3px;
        align-content: center;
        padding: 8px 8px 9px;
        min-height: 74px;
        border-radius: 13px;
    }
    .summary-grid .metric-card > div { gap: 4px; white-space: nowrap; }
    .summary-grid .metric-card > div > div { width: 19px; height: 19px; }
    .summary-grid .metric-card > div > span { font-size: 12px; }
    .summary-grid .metric-card > span { line-height: 1.1; font-size: 21px; }
    #open-add-modal-btn { min-height: 42px; padding-inline: 11px; white-space: nowrap; }
    #list-section-title { font-size: 14px; }
    .task-row { padding: 5px 0 4px; }
    .task-drag-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
    .task-primary { gap: 7px; }
    .task-title-text { white-space: normal; overflow-wrap: anywhere; line-height: 1.43; font-size: 15px; }
    .task-title-text { text-decoration: line-through transparent; transition: color .3s ease, text-decoration-color .34s ease; }
    .task-row.is-completed .task-title-text { text-decoration-color: #9aa3c2; }
    .task-row.is-completed .task-title-text::after { content: none; }
    .task-primary .drag-grip { min-width: 30px; min-height: 42px; }
    .nornes-checkbox::before { content: ""; position: absolute; inset: -8px; }
    .task-actions {
        display: grid;
        grid-template-columns: auto minmax(28px, 1fr) auto auto auto;
        column-gap: 3px;
        justify-items: center;
        padding-left: 37px;
        min-height: 36px;
    }
    .task-actions:has(.task-archive-btn) { grid-template-columns: auto minmax(25px, 1fr) auto auto auto auto; }
    .task-actions .task-timing { justify-self: start; width: auto; text-align: left; white-space: nowrap; }
    .task-timing svg { flex: none; }
    .task-time-value { font-size: 11px; line-height: 1.15; }
    .task-actions button { min-width: 36px; min-height: 40px; }
    .task-actions .todo-edit-btn { width: 36px; }
    .task-actions .star-btn { display: grid; place-items: center; }
    .task-actions [data-action="delete"] { opacity: 1; }
    .task-archive-btn { font-size: 11px; padding-inline: 3px; }
    #toast-box { bottom: calc(65px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); text-align: center; }

    #todo-modal {
        top: var(--dialog-top, 0px);
        bottom: auto;
        height: var(--dialog-height, 100dvh);
        padding: 10px;
    }
    #todo-modal-card { padding: 17px; }
    #todo-modal-card button:not(.todo-ink-swatch) { min-height: 40px; }
    #todo-modal-card .reminder-options button { min-height: 32px; }
    #todo-modal-card :is([contenteditable], select), #calendar-form :is([contenteditable], select) { font-size: 16px; }
    .todo-palette-strip { flex-wrap: wrap; }
    .calendar-page-header { margin-bottom: 12px; }
    .calendar-panel { padding: 12px; }
    .calendar-cell { height: 42px; }
    .calendar-arrow { width: 37px; height: 37px; }
    .calendar-neutral, .calendar-primary { min-height: 37px; }
}

@media (max-width: 367px) {
    #web-content { padding-inline: 9px; }
    .summary-grid .metric-card { padding-inline: 7px; }
    .task-actions { padding-left: 8px; }
    .task-actions button { min-width: 29px; }
    .task-actions .todo-edit-btn { width: 29px; }
}

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