:root {
    color-scheme: light;
    --bg: #f4f1e8;
    --panel: #fffdf8;
    --panel-border: #d8cfbc;
    --accent: #355c4a;
    --accent-strong: #274034;
    --text: #26231f;
    --muted: #6f665b;
    --danger: #aa3d2f;
    --shadow: 0 14px 30px rgba(53, 92, 74, 0.08);
    --highlight-yellow: #f4e77b;
    --highlight-blue: #9cd2ff;
    --highlight-green: #b8e3a6;
    --highlight-pink: #ffbfd9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(53, 92, 74, 0.08), transparent 28%),
        linear-gradient(180deg, #efe7d6 0%, var(--bg) 100%);
}

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

.site-header,
.page-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    padding: 2rem 0 1rem;
}

.page-shell {
    padding-bottom: 2rem;
}

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

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

.main-nav {
    display: flex;
    gap: 1.35rem;
    margin-right: 30px;
}

.main-nav a {
    position: relative;
    color: var(--accent-strong);
    text-decoration: none;
    font-weight: 700;
}

.main-nav a + a::before {
    content: "|";
    position: absolute;
    left: -0.82rem;
    color: #8d877d;
    font-weight: 400;
}

.nav-logout-form {
    display: inline-flex;
    margin: 0;
}

.nav-logout-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent-strong);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.nav-logout-form::before {
    content: "|";
    margin-right: 1.35rem;
    color: #8d877d;
    font-weight: 400;
}

.mobile-nav-logout-form {
    display: block;
}

.mobile-nav-logout-form::before {
    content: none;
}

.mobile-nav-logout-form .nav-logout-button {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    text-align: left;
}

.mobile-nav-logout-form .nav-logout-button:hover {
    background: #f1eadc;
}

.mobile-nav {
    display: none;
    position: relative;
}

.mobile-nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.28rem;
    width: 2.8rem;
    height: 2.8rem;
    padding: 0.6rem;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: rgba(255, 253, 248, 0.94);
    box-shadow: var(--shadow);
    cursor: pointer;
    list-style: none;
}

.mobile-nav-toggle::-webkit-details-marker {
    display: none;
}

.mobile-nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: var(--accent-strong);
}

.mobile-nav-panel {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    z-index: 1000;
    display: grid;
    min-width: 11rem;
    padding: 0.45rem;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.98);
    box-shadow: 0 14px 30px rgba(38, 35, 31, 0.14);
}

.mobile-nav-panel a {
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    color: var(--accent-strong);
    text-decoration: none;
    font-weight: 700;
}

.mobile-nav-panel a:hover {
    background: #f1eadc;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

.project-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 0.75rem;
}

.project-tab,
.primary-button,
.secondary-button,
table button {
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    cursor: pointer;
}

.project-tab {
    background: #e3dbc8;
    color: var(--accent-strong);
    font-weight: 700;
}

.project-tab.active,
.primary-button,
table button {
    background: var(--accent);
    color: white;
}

.secondary-button {
    background: #e3dbc8;
    color: var(--accent-strong);
}

.danger {
    background: var(--danger);
    color: white;
}

.add-item-panel {
    margin-bottom: 1.25rem;
}

.add-item-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 0.9rem 1.1rem;
    background: #f8f3e8;
    color: var(--accent-strong);
    cursor: pointer;
    font-weight: 700;
}

.plus-sign {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    font-size: 1.6rem;
    line-height: 1;
}

.item-form-shell {
    margin-top: 0.9rem;
    padding: 1rem;
    border: 1px solid #e9e0cf;
    border-radius: 18px;
    background: #fffcf5;
}

.item-form-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 110px 110px 110px;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.item-form-grid label {
    display: grid;
    gap: 0.35rem;
}

.wide {
    grid-column: 1 / -1;
}

.compact-field,
.compact-input,
.status-input,
.when-input {
    width: 5.5rem;
}

.compact-field input,
.compact-input {
    max-width: 5.5rem;
}

.compact-field select,
.status-input,
.when-input {
    width: 100%;
    min-width: 6.5rem;
}

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

.item-form-actions {
    display: flex;
    gap: 0.75rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.secondary-link {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
}

.auth-panel,
.account-panel {
    max-width: 880px;
}

.auth-form,
.account-form {
    display: grid;
    gap: 0.9rem;
}

.auth-form label,
.account-form label {
    display: grid;
    gap: 0.35rem;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 1rem;
}

.account-card {
    padding: 1rem;
    border: 1px solid #e9e0cf;
    border-radius: 18px;
    background: #fffcf5;
}

.account-message {
    margin: 0 0 1rem;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    font-weight: 600;
}

.account-success {
    background: #e8f7ec;
    color: #166534;
}

.account-error {
    background: #fde8e8;
    color: #b91c1c;
}

.checkbox {
    align-self: end;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 0.65rem 0.75rem;
    background: white;
}

.table-wrap {
    overflow-x: auto;
}

.drag-column,
.drag-cell {
    width: 2.5rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
}

.status-column,
.status-cell {
    width: 1.6rem;
    padding-left: 0.1rem;
    padding-right: 0.1rem;
}

.title-column,
.item-title {
    min-width: 28rem;
}

.item-title {
    font-weight: 700;
}

.item-title.is-done .item-title-text {
    text-decoration: line-through;
    text-decoration-color: rgba(38, 35, 31, 0.42);
    font-weight: 400;
    opacity: 0.64;
}

.item-done-note {
    margin-left: 0.35rem;
    color: var(--muted);
    font-style: italic;
    font-weight: 400;
    opacity: 0.64;
}

.item-todo-note {
    margin-left: 0.35rem;
    color: var(--muted);
    font-style: italic;
    font-weight: 400;
}

.item-status-checkbox {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--accent);
}

.when-editor {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.when-display {
    white-space: nowrap;
}

.when-edit-button {
    min-width: 1.15rem;
    min-height: 1.15rem;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    line-height: 1;
}

.when-select {
    min-width: 7rem;
    padding: 0.2rem 0.35rem;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: white;
}

.drag-handle {
    width: 1.4rem;
    min-width: 1.4rem;
    min-height: 1.75rem;
    padding: 0.1rem 0.05rem;
    border-radius: 8px;
    background: #e3dbc8;
    color: var(--accent-strong);
    cursor: grab;
    font-weight: 700;
    line-height: 1;
}

.project-drag-handle {
    margin-right: 0.25rem;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-placeholder {
    display: block;
    width: 100%;
    height: 1.75rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.3rem 0.45rem;
    vertical-align: middle;
    border-bottom: 1px solid #e9e0cf;
    text-align: left;
}

td.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.delete-pill {
    min-width: 1.75rem;
    min-height: 1.75rem;
    padding: 0.1rem;
    border-radius: 8px;
    line-height: 1;
}

.week-project + .week-project {
    margin-top: 1.5rem;
}

.week-project-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.week-project-title {
    margin-bottom: 0;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid #d8cfbc;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex: 1;
}

.week-project-add-button {
    min-width: 1.6rem;
    min-height: 1.6rem;
    padding: 0.05rem;
    border-radius: 8px;
    line-height: 1;
}

.week-project-add-form {
    flex: 0 0 15rem;
}

.week-project-add-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: white;
}

.week-items {
    display: grid;
    gap: 0.5rem;
}

.week-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid #e9e0cf;
    border-radius: 12px;
    background: #fffaf0;
}

.week-item.is-today {
    background: #f5b05f;
    border-color: #df8d2e;
}

.week-item.is-highlighted {
    border-color: rgba(118, 108, 86, 0.28);
}

.week-item.is-highlighted.highlight-yellow {
    background: var(--highlight-yellow);
}

.week-item.is-highlighted.highlight-blue {
    background: var(--highlight-blue);
}

.week-item.is-highlighted.highlight-green {
    background: var(--highlight-green);
}

.week-item.is-highlighted.highlight-pink {
    background: var(--highlight-pink);
}

.week-item.is-done {
    background: #e1dfdb;
    border-color: #c9c3bb;
    color: #57524c;
}

.week-item-main {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.week-item-checkbox {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--accent);
}

.week-item-name {
    font-weight: 700;
}

.week-item-todo {
    color: var(--muted);
    font-size: 0.92em;
}

.week-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.week-item.is-done .week-item-name,
.week-item.is-done .week-item-meta {
    color: #57524c;
    opacity: 0.64;
}

.context-menu,
.context-submenu {
    position: fixed;
    z-index: 1000;
    min-width: 11rem;
    padding: 0.3rem;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: #fffdf8;
    box-shadow: 0 10px 24px rgba(38, 35, 31, 0.12);
}

.context-submenu {
    position: absolute;
    padding-left: 0.45rem;
}

.context-menu-separator {
    margin: 0.25rem 0.35rem;
    border-top: 1px solid #d7d0c1;
}

.context-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.context-menu-item:hover {
    background: #f1eadc;
}

.context-menu-caret {
    color: var(--muted);
}

.danger-text {
    color: var(--danger);
}

tr.is-dragging {
    opacity: 0.5;
}

@media (max-width: 900px) {
    .account-grid {
        grid-template-columns: 1fr;
    }

    .site-header,
    .panel-heading {
        flex-direction: column;
        align-items: start;
    }

    .item-form-grid {
        grid-template-columns: minmax(0, 1fr) 110px 110px 110px;
    }
}

@media (max-width: 640px) {
    .site-header {
        flex-direction: row;
        align-items: start;
        gap: 1rem;
    }

    .site-header > div {
        min-width: 0;
        flex: 1;
    }

    .main-nav {
        display: none;
    }

    .mobile-nav {
        display: block;
        margin-left: auto;
    }

    .project-tabs,
    .item-form-grid {
        grid-template-columns: 1fr;
    }

    .wide {
        grid-column: auto;
    }

    td.actions {
        min-width: 150px;
    }

    .week-item {
        flex-direction: column;
        align-items: start;
    }

    .week-item-meta {
        white-space: normal;
    }

    .week-project-header {
        flex-wrap: wrap;
    }

    .week-project-add-form {
        flex-basis: 100%;
    }
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.panel-heading-actions {
    align-items: center;
}

.project-tab-label,
.project-title-heading,
.week-project-title,
.my-week-project-title {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.project-title-heading {
    margin-bottom: 0;
}

.item-form-grid-projects {
    grid-template-columns: minmax(220px, 1fr) 150px 150px 110px;
}

.item-form-grid-domains,
.item-form-grid-export {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.item-form-grid-domains {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.week-project-title,
.my-week-project-title {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.project-title-heading {
    margin-bottom: 0;
}

.item-form-grid-projects {
    grid-template-columns: minmax(220px, 1fr) 150px 150px 110px;
}

.item-form-grid-domains,
.item-form-grid-export {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.item-form-grid-domains {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.domain-badge {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    justify-content: center;
    width: 2rem;
    min-width: 2rem;
    height: 2.45rem;
    color: var(--domain-color);
    overflow: visible;
}

.domain-badge.small {
    width: 1.5rem;
    min-width: 1.5rem;
    height: 2.1rem;
}

.domain-badge-rod {
    position: absolute;
    top: 0.08rem;
    left: 0.12rem;
    width: calc(100% - 0.24rem);
    height: 0.2rem;
    border-radius: 0.2rem;
    background: var(--domain-color);
}

.domain-badge-rod::before,
.domain-badge-rod::after {
    display: none;
}

.domain-badge-flag {
    position: absolute;
    top: 0.28rem;
    left: 0.22rem;
    width: calc(100% - 0.44rem);
    height: calc(100% - 0.72rem);
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 0.15rem solid var(--domain-color);
    border-right: 0.15rem solid var(--domain-color);
    border-top: 0.18rem solid var(--domain-color);
    background: rgba(255, 255, 255, 0.92);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    padding-top: 0.05rem;
    overflow: visible;
}

.domain-badge-flag::before,
.domain-badge-flag::after {
    content: "";
    position: absolute;
    bottom: -0.08rem;
    width: 0.9rem;
    height: 0.15rem;
    background: var(--domain-color);
    border-radius: 999px;
}

.domain-badge-flag::before {
    left: -0.06rem;
    transform-origin: left center;
    transform: rotate(32deg);
}

.domain-badge-flag::after {
    right: -0.06rem;
    transform-origin: right center;
    transform: rotate(-32deg);
}

.domain-badge.small .domain-badge-flag {
    top: 0.22rem;
    left: 0.16rem;
    width: calc(100% - 0.32rem);
    height: calc(100% - 0.58rem);
    border-left-width: 0.12rem;
    border-right-width: 0.12rem;
    border-top-width: 0.15rem;
    font-size: 0.54rem;
}

.domain-badge.small .domain-badge-flag::before,
.domain-badge.small .domain-badge-flag::after {
    bottom: -0.06rem;
    width: 0.7rem;
    height: 0.12rem;
}

.week-project-title,
.my-week-project-title {
    border-bottom: 2px solid #d8cfbc;
}

.export-form {
    display: grid;
    gap: 1rem;
}

@media (max-width: 900px) {
    .item-form-grid-projects,
    .item-form-grid-export {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .item-form-grid-projects,
    .item-form-grid-domains,
    .item-form-grid-export {
        grid-template-columns: 1fr;
    }

    .panel-heading-actions {
        align-items: start;
    }
}
