:root {
    --ink: #13211f;
    --ink-2: #263936;
    --muted: #65736f;
    --paper: #fbfaf6;
    --paper-2: #f1f4ef;
    --card: rgba(255, 255, 252, 0.92);
    --card-solid: #fffffc;
    --line: rgba(31, 53, 49, 0.16);
    --line-strong: rgba(31, 53, 49, 0.28);
    --teal: #0d7f71;
    --teal-dark: #075d55;
    --teal-soft: #dff5ee;
    --coral: #e8543f;
    --coral-dark: #b83225;
    --coral-soft: #ffe5df;
    --gold: #d99a1b;
    --gold-soft: #fff0c8;
    --blue: #3159b8;
    --blue-soft: #e8eeff;
    --danger: #b42318;
    --danger-bg: #fff0ed;
    --success: #067647;
    --success-bg: #e7f8ee;
    --shadow-hard: 7px 7px 0 rgba(19, 33, 31, 0.14);
    --shadow-soft: 0 20px 45px rgba(22, 37, 35, 0.13);
    --radius: 8px;
    --tap: 46px;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(13, 127, 113, 0.12) 0 22%, transparent 22% 100%),
        linear-gradient(165deg, transparent 0 66%, rgba(232, 84, 63, 0.13) 66% 100%),
        repeating-linear-gradient(90deg, rgba(19, 33, 31, 0.035) 0 1px, transparent 1px 42px),
        var(--paper);
    font-family: "Manrope", Arial, sans-serif;
    font-weight: 650;
    line-height: 1.48;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.42;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(19, 33, 31, 0.11) 1px, transparent 0);
    background-size: 18px 18px;
    mix-blend-mode: multiply;
}

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

a:hover { color: var(--teal-dark); }

svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

:focus-visible {
    outline: 3px solid rgba(232, 84, 63, 0.45);
    outline-offset: 3px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    min-height: 78px;
    padding: 14px clamp(16px, 3vw, 36px);
    background: rgba(251, 250, 246, 0.88);
    border-bottom: 2px solid var(--ink);
    box-shadow: 0 10px 0 rgba(19, 33, 31, 0.04);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    color: var(--ink);
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 34px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1;
}

.brand::before {
    content: "";
    width: 15px;
    height: 31px;
    margin-right: 10px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: linear-gradient(180deg, var(--coral) 0 50%, var(--teal) 50% 100%);
    box-shadow: 3px 3px 0 var(--ink);
    transform: rotate(-10deg);
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.main-nav a,
.main-nav button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 13px;
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(255, 255, 252, 0.58);
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 850;
}

.main-nav a:hover,
.main-nav button:hover {
    border-color: var(--ink);
    background: var(--gold-soft);
    color: var(--ink);
    box-shadow: 4px 4px 0 var(--ink);
    transform: translate(-1px, -1px);
}

.main-nav form { margin: 0; }

.container {
    width: min(1160px, 100%);
    margin: 0 auto;
    padding: 34px clamp(14px, 3vw, 30px) 54px;
}

.auth-card,
aside,
.day-card,
.note,
.empty,
table,
.summary,
.filters,
.note-form {
    background: var(--card);
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    backdrop-filter: blur(12px);
}

.auth-card {
    max-width: 440px;
    margin: 76px auto;
    padding: 30px;
    background:
        linear-gradient(145deg, rgba(255, 229, 223, 0.95), rgba(255, 255, 252, 0.94) 42%),
        var(--card-solid);
}

.page-head {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
}

.page-head::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -11px;
    width: min(180px, 48vw);
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
}

h1,
h2,
p { margin-top: 0; }

h1 {
    margin-bottom: 4px;
    font-family: "Instrument Serif", Georgia, serif;
    font-size: clamp(39px, 5.4vw, 62px);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 0.95;
}

h2 {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 21px;
    font-weight: 850;
    line-height: 1.18;
}

h2::before {
    content: "";
    width: 10px;
    height: 22px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--coral);
}

p,
small {
    color: var(--muted);
    font-weight: 650;
}

p { margin-bottom: 0; }

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

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 850;
}

input,
textarea,
select,
button,
.button {
    min-height: var(--tap);
    border: 2px solid var(--line-strong);
    border-radius: var(--radius);
    font: inherit;
    letter-spacing: 0;
    padding: 11px 13px;
}

input,
textarea,
select {
    width: 100%;
    background: rgba(255, 255, 252, 0.94);
    color: var(--ink);
    font-weight: 650;
}

input:hover,
textarea:hover,
select:hover { border-color: var(--ink); }

input:focus,
textarea:focus,
select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(13, 127, 113, 0.16);
    outline: none;
}

textarea {
    min-height: 126px;
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: max-content;
    cursor: pointer;
    background: var(--teal);
    border-color: var(--ink);
    color: #fffdf7;
    font-weight: 850;
    line-height: 1.15;
    text-align: center;
    box-shadow: 4px 4px 0 var(--ink);
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

button:hover,
.button:hover {
    background: var(--teal-dark);
    color: #fffdf7;
    box-shadow: 2px 2px 0 var(--ink);
    transform: translate(2px, 2px);
}

button:active,
.button:active {
    box-shadow: 0 0 0 var(--ink);
    transform: translate(4px, 4px);
}

.inline-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
    gap: 16px;
}

.day-card {
    position: relative;
    display: grid;
    gap: 8px;
    min-height: 128px;
    padding: 20px;
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(223, 245, 238, 0.98), rgba(255, 255, 252, 0.94) 52%),
        var(--card-solid);
}

.day-card::after {
    content: "";
    position: absolute;
    right: -18px;
    bottom: -18px;
    width: 72px;
    height: 72px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background: var(--coral-soft);
}

.day-card:hover {
    box-shadow: 3px 3px 0 var(--ink);
    transform: translate(4px, 4px) rotate(-0.6deg);
}

.day-card strong {
    position: relative;
    z-index: 1;
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 32px;
    font-weight: 400;
    line-height: 1;
}

.day-card span {
    position: relative;
    z-index: 1;
    color: var(--muted);
    font-weight: 850;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(310px, 370px);
    gap: 24px;
    align-items: start;
}

aside {
    position: sticky;
    top: 104px;
    padding: 18px;
    background:
        linear-gradient(160deg, rgba(255, 240, 200, 0.62), rgba(255, 255, 252, 0.94) 45%),
        var(--card-solid);
}

aside form + form,
aside .empty + form,
aside small + form { margin-top: 14px; }

.note-form {
    margin-bottom: 18px;
    padding: 16px;
    background:
        linear-gradient(135deg, rgba(255, 255, 252, 0.96), rgba(223, 245, 238, 0.62)),
        var(--card-solid);
}

.timeline {
    display: grid;
    gap: 14px;
}

.note {
    position: relative;
    padding: 16px;
    background: var(--card-solid);
}

.note::before {
    content: "";
    position: absolute;
    inset: 12px auto 12px -2px;
    width: 6px;
    border-radius: 0 999px 999px 0;
    background: linear-gradient(180deg, var(--teal), var(--coral));
}

.note time {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 2px 9px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--gold-soft);
    color: var(--ink);
    font-weight: 850;
}

.note p {
    color: var(--ink);
    white-space: normal;
}

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

.note-head small {
    flex: 0 0 auto;
    padding-top: 4px;
}

.edit-note { gap: 10px; }

.actions,
.delete-form,
.inline-action {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.delete-form,
.inline-action { margin-top: 10px; }

.danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--ink);
}

.danger:hover {
    background: #ffd8cf;
    color: var(--danger);
}

.filters {
    display: grid;
    grid-template-columns: minmax(180px, 1.15fr) minmax(130px, 0.8fr) 150px 150px auto auto auto;
    align-items: end;
    gap: 14px;
    margin-bottom: 24px;
    padding: 16px;
    background:
        linear-gradient(120deg, rgba(255, 229, 223, 0.46), rgba(255, 255, 252, 0.92) 38%),
        var(--card-solid);
}

.compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.empty {
    padding: 18px;
    color: var(--muted);
    background: rgba(255, 255, 252, 0.78);
}

.summary {
    padding: 16px;
    margin-bottom: 12px;
    background: rgba(255, 255, 252, 0.78);
    line-height: 1.58;
}

.alert {
    padding: 13px 15px;
    background: var(--success-bg);
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    margin-bottom: 20px;
    color: var(--success);
    font-weight: 850;
    box-shadow: var(--shadow-hard);
}

.error {
    padding: 11px 13px;
    background: var(--danger-bg);
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    color: var(--danger);
    margin-bottom: 12px;
    font-weight: 850;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: var(--card-solid);
}

th,
td {
    padding: 14px 12px;
    border-bottom: 2px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--ink);
    color: #fffdf7;
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

.check {
    display: flex;
    align-items: center;
    min-height: var(--tap);
    gap: 10px;
    font-weight: 850;
}

.check input {
    width: 22px;
    height: 22px;
    min-height: 22px;
    margin: 0;
    accent-color: var(--coral);
}

.table-action {
    display: inline-flex;
}

.secondary {
    background: #fffdf7;
    color: var(--ink);
    border-color: var(--ink);
}

.secondary:hover {
    background: var(--blue-soft);
    color: var(--blue);
}

code {
    display: inline-block;
    max-width: 100%;
    background: var(--paper-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 3px 7px;
    overflow-wrap: anywhere;
    font-weight: 850;
}

.filter-check {
    align-self: end;
    margin: 0;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 2px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal-dark);
    font-size: 12px;
    font-weight: 850;
    box-shadow: 2px 2px 0 var(--ink);
}

.badge.important {
    background: var(--gold-soft);
    color: #7a4b00;
}

@media (max-width: 980px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .main-nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .split {
        grid-template-columns: 1fr;
    }

    aside {
        position: static;
    }

    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    body {
        background:
            linear-gradient(145deg, rgba(13, 127, 113, 0.16) 0 28%, transparent 28% 100%),
            linear-gradient(20deg, transparent 0 70%, rgba(232, 84, 63, 0.18) 70% 100%),
            var(--paper);
    }

    .topbar {
        padding: 12px 14px 14px;
        border-bottom-width: 2px;
    }

    .brand {
        min-height: 38px;
        font-size: 31px;
    }

    .brand::before {
        width: 13px;
        height: 27px;
        margin-right: 9px;
    }

    .main-nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 9px;
    }

    .main-nav a,
    .main-nav form,
    .main-nav button {
        width: 100%;
    }

    .main-nav a,
    .main-nav button {
        min-height: 58px;
        flex-direction: column;
        gap: 4px;
        padding: 8px 6px;
        border: 2px solid var(--ink);
        border-radius: var(--radius);
        background: rgba(255, 255, 252, 0.85);
        color: var(--ink);
        box-shadow: 3px 3px 0 var(--ink);
        font-size: 12px;
    }

    .main-nav svg {
        width: 21px;
        height: 21px;
        color: var(--teal);
    }

    .container {
        padding: 22px 14px 36px;
    }

    .page-head {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 14px;
        margin-bottom: 22px;
    }

    h1 {
        font-size: 44px;
    }

    h2 {
        font-size: 20px;
    }

    .inline-form,
    .inline-form input,
    .inline-form button,
    .inline-form .button {
        width: 100%;
    }

    .inline-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .filters,
    .compact-grid {
        grid-template-columns: 1fr;
    }

    .filters button,
    .filters .button,
    .note-form button,
    aside button {
        width: 100%;
    }

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

    .auth-card,
    aside,
    .day-card,
    .note,
    .empty,
    .summary,
    .filters,
    .note-form {
        box-shadow: 4px 4px 0 var(--ink);
    }

    .note,
    .note-form,
    aside,
    .auth-card,
    .filters {
        padding: 15px;
    }

    .day-card {
        min-height: 118px;
    }

    .note-head {
        display: grid;
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .actions,
    .delete-form,
    .inline-action {
        justify-content: stretch;
    }

    .actions button,
    .delete-form button,
    .inline-action button {
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 360px) {
    .main-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 430px) {
    h1 {
        font-size: 40px;
    }

    input,
    textarea,
    select,
    button,
    .button {
        padding-left: 11px;
        padding-right: 11px;
    }
}
