:root {
    color-scheme: light;
    --bg: #f6f7f4;
    --surface: #ffffff;
    --surface-soft: #eef6f2;
    --text: #222725;
    --muted: #68706c;
    --line: #dde3de;
    --primary: #116b5f;
    --primary-strong: #0d5148;
    --accent: #c85f35;
    --success-bg: #e3f5df;
    --success-text: #246528;
    --open-bg: #fff0d8;
    --open-text: #845111;
    --shadow: 0 12px 28px rgba(31, 41, 36, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    margin: 0;
    min-width: 320px;
    overflow-x: hidden;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(17, 107, 95, 0.22);
    outline-offset: 2px;
}

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 16px clamp(16px, 4vw, 48px);
    position: sticky;
    top: 0;
    z-index: 10;
    min-width: 0;
}

.brand {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 800;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.nav a {
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
    padding: 8px 10px;
}

.nav a:hover {
    background: var(--surface-soft);
    color: var(--primary);
}

.page {
    margin: 0 auto;
    max-width: 1160px;
    min-width: 0;
    padding: 28px 40px 56px;
}

.week-header {
    align-items: end;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 22px;
    min-width: 0;
}

.week-header h1 {
    font-size: 3.25rem;
    line-height: 1;
    margin: 4px 0 10px;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
    margin: 0;
}

.week-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    min-width: 0;
}

.week-actions form {
    margin: 0;
}

.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    justify-content: center;
    line-height: 1.2;
    min-height: 40px;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    padding: 10px 14px;
    text-align: center;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
    white-space: normal;
}

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

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

.button.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--primary);
}

.button.secondary:hover,
.button.ghost:hover {
    background: var(--surface-soft);
}

.button.ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.grid {
    align-items: start;
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 0;
    padding: clamp(16px, 3vw, 24px);
}

.section-title {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-title h2 {
    font-size: 1.12rem;
    margin: 0;
}

.section-title span {
    background: var(--surface-soft);
    border-radius: 999px;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 800;
    min-width: 34px;
    padding: 6px 10px;
    text-align: center;
}

.assignment-list {
    display: grid;
    gap: 0;
}

.assignment-item {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.85fr);
    padding: 16px 0;
}

.assignment-item:first-child {
    padding-top: 0;
}

.assignment-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.assignment-item.done {
    color: var(--muted);
}

.assignment-item.done .task-name {
    text-decoration: line-through;
}

.assignment-main,
.assignment-meta,
.assignment-actions {
    min-width: 0;
}

.assignment-main,
.assignment-meta {
    grid-column: 1;
}

.assignment-label {
    color: var(--muted);
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.assignment-meta {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) minmax(82px, auto);
}

.assignment-actions {
    display: grid;
    gap: 8px;
    grid-column: 2;
    grid-row: 1 / span 2;
}

.assignment-actions form {
    margin: 0;
}

.assignment-actions .button {
    width: 100%;
}

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

.swap-form select {
    min-width: 0;
}

.task-name {
    display: block;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 800;
    justify-self: start;
    padding: 5px 9px;
    width: fit-content;
}

.done-badge {
    background: var(--success-bg);
    color: var(--success-text);
}

.open-badge {
    background: var(--open-bg);
    color: var(--open-text);
}

.swap-badge {
    background: var(--surface-soft);
    color: var(--primary);
}

.empty {
    color: var(--muted);
    margin: 0;
}

.inline-form,
.task-form {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.inline-form {
    grid-template-columns: minmax(0, 1fr) auto;
}

.task-form {
    grid-template-columns: minmax(150px, 1.4fr) minmax(130px, 1fr) minmax(92px, 0.6fr) auto;
}

label {
    display: grid;
    gap: 6px;
}

label span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

input,
select {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--primary);
}

.list {
    display: grid;
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.list li {
    align-items: center;
    background: #fbfcfb;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 12px;
}

.list li > span {
    display: grid;
    font-weight: 800;
    gap: 2px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.list form {
    flex-shrink: 0;
    margin: 0;
}

.list small {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.inactive {
    color: var(--muted);
    text-decoration: line-through;
}

.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media (max-width: 860px) {
    .page {
        padding: 24px 22px 44px;
    }

    .week-header {
        align-items: stretch;
        flex-direction: column;
    }

    .week-header h1 {
        font-size: 2.35rem;
    }

    .week-actions {
        justify-content: start;
    }

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

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

    .task-form .button {
        align-self: end;
    }
}

@media (max-width: 700px) {
    .panel {
        padding: 16px;
    }

    .assignment-item {
        border: 1px solid var(--line);
        border-radius: 8px;
        gap: 12px;
        grid-template-columns: 1fr;
        margin-bottom: 12px;
        padding: 12px;
    }

    .assignment-item:first-child {
        padding-top: 12px;
    }

    .assignment-item:last-child {
        margin-bottom: 0;
        padding-bottom: 12px;
    }

    .assignment-item.done {
        background: #f4faf2;
    }

    .assignment-main,
    .assignment-meta,
    .assignment-actions {
        grid-column: auto;
        grid-row: auto;
    }

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

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

@media (max-width: 560px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 14px 24px;
    }

    .brand {
        width: 100%;
    }

    .nav {
        display: grid;
        gap: 8px;
        grid-template-columns: 1fr;
        justify-content: stretch;
        width: 100%;
    }

    .nav a {
        background: var(--surface-soft);
        min-width: 0;
        text-align: center;
    }

    .page {
        padding: 20px 24px 36px;
    }

    .week-header {
        gap: 16px;
    }

    .week-header h1 {
        font-size: 1.85rem;
        line-height: 1.08;
    }

    .week-actions,
    .week-actions form,
    .week-actions .button,
    .inline-form .button,
    .task-form .button,
    .list .button {
        width: 100%;
    }

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

    .list li {
        align-items: stretch;
        flex-direction: column;
    }

    .list form {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .page {
        padding-left: 16px;
        padding-right: 16px;
    }

    .panel {
        padding: 12px;
    }

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