* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    color-scheme: light;
    --page: #edf2f6;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --ink: #17202a;
    --muted: #647386;
    --line: #d8e1eb;
    --accent: #0f8a8a;
    --accent-strong: #075e66;
    --rose: #d94c6a;
    --amber: #d89426;
    --green: #2d936c;
    --shadow: 0 16px 42px rgba(32, 47, 68, 0.12);
    --small-shadow: 0 8px 22px rgba(32, 47, 68, 0.08);
    --radius: 8px;
}

html { font-size: 16px; }

body {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 1fr auto;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(237, 242, 246, 0.94) 40%),
        radial-gradient(circle at 0 0, rgba(15, 138, 138, 0.18), transparent 30rem),
        radial-gradient(circle at 100% 8%, rgba(217, 76, 106, 0.12), transparent 27rem),
        var(--page);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(15, 138, 138, 0.28);
    outline-offset: 3px;
}

main {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 30px;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
    gap: 18px;
    align-items: end;
    margin-bottom: 10px;
}

.eyebrow,
.section-label {
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-label {
    margin-bottom: 10px;
}

h1 {
    margin: 6px 0 8px;
    color: var(--ink);
    font-size: clamp(40px, 6vw, 64px);
    line-height: 0.95;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

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

h1 a:hover {
    color: var(--accent-strong);
}

h2 {
    color: var(--ink);
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1;
    letter-spacing: 0;
}

.desc {
    max-width: 700px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.member-panel,
.calendar-section,
.agenda-section,
.export-section,
.admin-section {
    border: 1px solid rgba(216, 225, 235, 0.95);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.member-panel {
    padding: 14px;
}

.member-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
}

.member-form input,
.achievement-form input,
.achievement-form select,
.achievement-form textarea {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 14px;
}

.member-form input,
.achievement-form input,
.achievement-form select {
    height: 38px;
    padding: 0 12px;
}

.achievement-form textarea {
    padding: 11px 12px;
    resize: vertical;
}

.member-form button,
.line-button,
.achievement-form button,
.subscribe-link,
.inline-admin-form button {
    min-height: 38px;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 850;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.member-form button[type="submit"],
.line-button,
.achievement-form button {
    padding: 0 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 138, 138, 0.2);
}

.member-form button[type="button"],
.inline-admin-form button {
    padding: 0 14px;
    background: #e8edf3;
    color: var(--muted);
}

.member-form button:hover,
.line-button:hover,
.achievement-form button:hover,
.subscribe-link:hover,
.inline-admin-form button:hover {
    transform: translateY(-1px);
}

.member-meta,
.small-copy {
    margin-top: 9px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.small-copy a {
    color: var(--accent-strong);
    font-weight: 850;
    text-underline-offset: 3px;
}

.stats {
    display: grid;
    grid-template-columns: 1.1fr 1.1fr 1.1fr 1.1fr 0.9fr;
    gap: 10px;
    margin-bottom: 10px;
}

.stat {
    min-height: 64px;
    padding: 10px 12px;
    border: 1px solid rgba(216, 225, 235, 0.95);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--small-shadow);
}

.stat.accent-a { border-top: 4px solid var(--accent); }
.stat.accent-b { border-top: 4px solid var(--amber); }
.stat.accent-c { border-top: 4px solid var(--rose); }
.stat.accent-d { border-top: 4px solid var(--green); }
.compact-stat { border-top: 4px solid #8a6bd9; }

.stat-label {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.stat-value {
    color: var(--ink);
    font-size: 26px;
    font-weight: 850;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.calendar-section {
    padding: 14px;
    margin-bottom: 12px;
}

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

.calendar-head h2 {
    text-align: center;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--ink);
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: rgba(15, 138, 138, 0.42);
    background: #eefafa;
}

.icon-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.weekday-row {
    gap: 6px;
    margin-bottom: 5px;
}

.weekday-row span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
    text-align: center;
    text-transform: uppercase;
}

.calendar-grid {
    gap: 7px;
}

.day {
    min-height: 70px;
    padding: 5px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #fff, #f9fbfd);
}

.day:hover {
    border-color: rgba(15, 138, 138, 0.4);
    box-shadow: var(--small-shadow);
}

.day.muted {
    opacity: 0.48;
    background: #f4f7fa;
}

.day.today {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.day-number {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    margin-bottom: 3px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

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

.achievement-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: flex-start;
    height: calc(100% - 24px);
    padding-bottom: 2px;
}

.achievement-stack.count-1 {
    align-items: stretch;
}

.achievement-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(216, 225, 235, 0.95);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    padding: 0;
    box-shadow: 0 5px 14px rgba(32, 47, 68, 0.11);
    transition: filter 0.16s ease, opacity 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.achievement-stack.count-1 .achievement-icon {
    width: 100%;
    height: 100%;
    min-height: 40px;
    padding: 3px;
}

.calendar-grid .achievement-stack.count-1 .achievement-icon {
    height: 40px;
}

.calendar-grid .achievement-stack.count-1 .achievement-icon img {
    position: absolute;
    inset: 3px;
    width: calc(100% - 6px);
    height: calc(100% - 6px);
    object-fit: contain;
}

.achievement-stack.count-2 .achievement-icon,
.achievement-stack.count-3 .achievement-icon,
.achievement-stack.count-4 .achievement-icon {
    width: calc(50% - 3px);
    height: 29px;
}

.calendar-grid .achievement-icon:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(32, 47, 68, 0.16);
}

.achievement-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.achievement-stack.count-1 .achievement-icon img {
    object-fit: contain;
}

.achievement-icon.fallback {
    border-color: rgba(15, 20, 28, 0.86);
    background: linear-gradient(135deg, #111827, #05070a);
    color: #fff;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}

.achievement-icon.range::after {
    width: 16px;
    height: 4px;
    position: absolute;
    right: 4px;
    bottom: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 1px rgba(15, 20, 28, 0.16);
    content: "";
}

.achievement-icon.range.fallback::after {
    background: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.achievement-icon.owned {
    filter: grayscale(1);
    opacity: 0.34;
}

.agenda-section,
.export-section,
.admin-section {
    padding: 16px;
    margin-bottom: 14px;
}

.agenda-list {
    display: grid;
    gap: 8px;
}

.agenda-item {
    display: grid;
    grid-template-columns: 74px 38px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.agenda-date {
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.agenda-title {
    color: var(--ink);
    font-size: 14px;
    font-weight: 850;
    margin-bottom: 2px;
}

.agenda-title a {
    color: inherit;
    text-underline-offset: 3px;
}

.agenda-note {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.agenda-item.owned .agenda-title,
.agenda-item.owned .agenda-note {
    color: var(--muted);
}

.agenda-item.highlighted {
    border-color: rgba(15, 138, 138, 0.62);
    background: #eefafa;
    box-shadow: 0 0 0 3px rgba(15, 138, 138, 0.14), var(--small-shadow);
}

.export-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.export-section .section-label,
.export-section .small-copy {
    flex-basis: 100%;
}

.line-button,
.subscribe-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

.subscribe-link {
    min-height: 38px;
}

.secondary-line-button {
    background: #e8edf3;
    color: var(--muted);
    box-shadow: none;
}

.achievement-form {
    display: grid;
    gap: 10px;
}

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

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

.achievement-form label {
    display: grid;
    gap: 6px;
}

.achievement-form .checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.achievement-form .checkbox-row input {
    width: auto;
    height: auto;
}

.achievement-form label span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.admin-message {
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid rgba(15, 138, 138, 0.28);
    border-radius: var(--radius);
    background: rgba(231, 246, 245, 0.72);
    color: var(--accent-strong);
    font-size: 13px;
}

.admin-error {
    border-color: rgba(217, 76, 106, 0.34);
    background: rgba(217, 76, 106, 0.08);
    color: var(--rose);
}

.inline-admin-form {
    display: inline-block;
    margin: 0 8px 8px 0;
}

footer {
    width: min(1120px, calc(100% - 32px));
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin: 0 auto;
    padding: 0 0 22px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

@media (max-width: 820px) {
    main {
        width: min(100% - 22px, 720px);
        padding-top: 16px;
    }

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

    h1 {
        font-size: 42px;
        line-height: 1;
    }

    .desc {
        font-size: 15px;
    }

    .member-form,
    .form-row {
        grid-template-columns: 1fr;
    }

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

    .calendar-head {
        grid-template-columns: 38px minmax(0, 1fr) 38px;
        gap: 8px;
    }

    .icon-button {
        width: 38px;
        height: 38px;
    }

    .weekday-row,
    .calendar-grid {
        gap: 4px;
    }

    .weekday-row span {
        font-size: 9px;
    }

    .day {
        min-height: 70px;
        padding: 4px;
    }

    .day-number {
        width: 19px;
        height: 19px;
        margin-bottom: 3px;
        font-size: 10px;
    }

    .achievement-stack {
        gap: 3px;
        height: calc(100% - 24px);
    }

    .achievement-icon {
        width: 24px;
        height: 24px;
        border-radius: 6px;
        font-size: 9px;
    }

    .achievement-stack.count-1 .achievement-icon {
        min-height: 38px;
        padding: 3px;
    }

    .calendar-grid .achievement-stack.count-1 .achievement-icon {
        height: 38px;
    }

    .achievement-stack.count-2 .achievement-icon,
    .achievement-stack.count-3 .achievement-icon,
    .achievement-stack.count-4 .achievement-icon {
        height: 25px;
    }

    .agenda-item {
        grid-template-columns: 66px 30px minmax(0, 1fr);
        gap: 9px;
        padding: 9px;
    }

    footer {
        width: min(100% - 22px, 720px);
        flex-direction: column;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --page: #101317;
        --surface: #171c22;
        --surface-soft: #202731;
        --ink: #f2f6fa;
        --muted: #9aa8b7;
        --line: #2e3945;
        --accent: #42c4bb;
        --accent-strong: #82ddd8;
        --rose: #e86b85;
        --amber: #e3a83e;
        --green: #63c492;
        --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
        --small-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
    }

    body {
        background:
            linear-gradient(180deg, rgba(16, 19, 23, 0.48), var(--page) 42%),
            radial-gradient(circle at 0 0, rgba(66, 196, 187, 0.18), transparent 30rem),
            radial-gradient(circle at 100% 8%, rgba(232, 107, 133, 0.16), transparent 27rem),
            var(--page);
    }

    .member-panel,
    .calendar-section,
    .agenda-section,
    .export-section,
    .admin-section {
        background: rgba(23, 28, 34, 0.82);
    }

    .day,
    .stat,
    .agenda-item,
    .member-form input,
    .achievement-form input,
    .achievement-form select,
    .achievement-form textarea,
    .achievement-icon {
        background: var(--surface);
    }

    .day {
        background: linear-gradient(180deg, #1a2028, #151a20);
    }

    .day.muted {
        background: #14181e;
    }

    .agenda-item.highlighted {
        background: #183136;
        box-shadow: 0 0 0 3px rgba(66, 196, 187, 0.18), var(--small-shadow);
    }

    .member-form button[type="button"],
    .inline-admin-form button {
        background: #232b35;
    }

    .member-form button[type="submit"],
    .line-button,
    .achievement-form button {
        color: #071014;
    }
}
