:root {
    --paper: #f3ecdf;
    --panel: rgba(248, 243, 234, 0.96);
    --ink: #1f1a15;
    --muted: #65594f;
    --accent: #b4432f;
    --accent-soft: #ead8cb;
    --event: #8b5e3c;
    --event-soft: rgba(139, 94, 60, 0.12);
    --event-fill: rgba(241, 232, 216, 0.92);
    --line: rgba(67, 52, 39, 0.22);
    --line-strong: rgba(67, 52, 39, 0.42);
    --success: #2c6753;
    --success-soft: rgba(44, 103, 83, 0.12);
    --done-fill: rgba(234, 243, 238, 0.75);
    font-family: "Aptos", "Yu Gothic UI", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(180, 67, 47, 0.08), transparent 18%),
        linear-gradient(180deg, #ece2d0 0%, #f7f1e5 100%);
}

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

button,
input,
textarea {
    font: inherit;
}

input,
textarea {
    width: 100%;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.58);
}

textarea {
    min-height: 5rem;
    resize: vertical;
}

button,
.ghost-button,
.button-link,
.icon-button,
.icon-link,
.card,
.login-panel,
.stat-card,
.task-card,
.count-pill,
.pill,
.error-banner,
.empty-state,
.bar-track,
.bar-fill {
    border-radius: 0;
}

button,
.ghost-button,
.button-link,
.icon-button,
.icon-link {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

button:hover,
.ghost-button:hover,
.button-link:hover,
.icon-button:hover,
.icon-link:hover {
    background: rgba(180, 67, 47, 0.08);
}

.accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.accent:hover {
    background: #973826;
}

.danger-button {
    color: var(--accent);
    border-color: rgba(180, 67, 47, 0.4);
}

.danger-button:hover {
    background: rgba(180, 67, 47, 0.12);
}

.shell {
    width: min(1500px, calc(100vw - 0.75rem));
    margin: 0 auto;
    padding: 0.35rem 0 0.9rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--line);
}

.wordmark {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tagline,
.eyebrow,
.muted,
.meta-row,
.stat-label,
.strip-meta,
.history-row,
.done-block summary,
.task-link,
.notes {
    color: var(--muted);
}

.tagline,
.eyebrow,
.page-header p,
.login-panel p,
.stat-label,
.strip-meta,
.meta-row {
    font-size: 0.78rem;
}

.tagline {
    margin: 0.05rem 0 0;
}

.nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav a,
.nav button {
    padding: 0.22rem 0.5rem;
    min-height: 1.85rem;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.nav-link-with-badge {
    white-space: nowrap;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border: 1px solid rgba(180, 67, 47, 0.42);
    background: rgba(180, 67, 47, 0.12);
    color: var(--accent);
    font-size: 0.64rem;
    line-height: 1;
    vertical-align: text-top;
    margin-left: 0.25rem;
}

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


.card,
.login-panel,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 0.5rem;
}

.page-header,
.stats-grid,
.analytics-grid,
.detail-grid {
    display: grid;
    gap: 0.5rem;
}

.page-header {
    grid-template-columns: 1fr auto;
    align-items: end;
    margin-bottom: 0.45rem;
}

.page-header h1,
.login-panel h1 {
    margin: 0.1rem 0;
    font-size: 1.15rem;
}

.page-header p,
.login-panel p {
    margin: 0;
}

.week-nav,
.inline-form,
.meta-row,
.history-row,
.bar-row,
.task-strip,
.strip-actions,
.add-row,
.menu-row,
.stats-grid {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.week-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-wrap: wrap;
}

.week-nav-row {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.week-nav .ghost-button {
    padding: 0.14rem 0.36rem;
    min-height: 1.55rem;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
}

.week-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    min-width: 1.55rem;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1;
}

.board-scroll {
    overflow-x: auto;
    padding-bottom: 0.2rem;
}

.board {
    display: grid;
    grid-template-columns: repeat(7, minmax(158px, 1fr));
    gap: 0.35rem;
    min-width: 1140px;
}

.day-column {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 32rem;
    padding: 0.4rem;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--line);
}

.day-counts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.18rem;
}

.day-header h2 {
    margin: 0.05rem 0 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ink);
}

.weekday {
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 800;
    color: var(--accent);
}

.count-pill,
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.08rem 0.32rem;
    border: 1px solid var(--line);
    background: rgba(180, 67, 47, 0.08);
    font-size: 0.68rem;
    line-height: 1.2;
    white-space: nowrap;
}

.pill.success {
    background: var(--success-soft);
    border-color: rgba(44, 103, 83, 0.35);
    color: var(--success);
}

.pill.scratched {
    background: rgba(31, 26, 21, 0.06);
    border-color: rgba(67, 52, 39, 0.3);
    color: var(--muted);
}

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

.grow {
    flex: 1;
}

.stack-form,
.task-list,
.done-list,
.stack-actions,
.meta-stack,
.history-table,
.bars,
.list-grid {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
}

.task-list {
    gap: 0.18rem;
    min-height: 6rem;
}

.task-list,
.done-list {
    gap: 0.1rem;
}

.task-card {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.42);
    padding: 0;
}

.task-card[data-task-card] {
    cursor: grab;
}

.task-card.is-dragging {
    opacity: 0.9;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(180, 67, 47, 0.14);
}

.task-card.done-card {
    background: var(--done-fill);
}

.task-card.done-card-late {
    background: var(--done-fill);
}

.task-card.scratched-card {
    background: rgba(31, 26, 21, 0.05);
}

.task-card.add-card {
    background: rgba(255, 255, 255, 0.5);
}

.task-body {
    flex: 1;
    min-width: 0;
    padding: 0.24rem 0.28rem;
}

.add-row {
    gap: 0;
}

.add-body {
    padding-top: 0.24rem;
    padding-bottom: 0.24rem;
}

.add-input {
    appearance: none;
    display: block;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
    height: auto;
    font-size: 0.84rem;
    line-height: 1.2;
    color: var(--ink);
}

.add-input:focus {
    outline: none;
}

.add-input::placeholder {
    color: var(--muted);
}

.task-strip {
    position: relative;
    min-width: 0;
}

.task-link {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
    color: var(--ink);
}

.scratched-card .task-link {
    text-decoration: line-through;
}

.strip-actions {
    margin-left: auto;
    flex-shrink: 0;
}

body.edit-mode .task-card .task-strip {
    padding-right: 1.8rem;
}

body.edit-mode .task-card .strip-actions {
    position: absolute;
    top: 50%;
    right: 0;
    margin-left: 0;
    transform: translateY(-50%);
}

.notes.inline-notes {
    margin: 0.12rem 0 0;
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--ink);
}

.icon-button,
.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    min-width: 1.55rem;
    height: 1.55rem;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1;
}

.wide-icon {
    width: 2rem;
    min-width: 2rem;
}

.done-rail-form {
    display: flex;
    align-items: stretch;
}

.task-rails {
    display: flex;
    align-items: stretch;
}

.task-status-marker {
    position: relative;
    align-self: stretch;
    width: 0.95rem;
    min-width: 0.95rem;
}

.late-done-marker {
    background-color: var(--done-fill);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    overflow: hidden;
}

.late-done-stripe {
    position: absolute;
    inset: 0;
    background: rgba(180, 67, 47, 0.3);
    clip-path: polygon(25% 100%, 50% 100%, 100% 100%, 100% 50%);
}

.done-rail {
    width: 1.35rem;
    min-width: 1.35rem;
    height: 100%;
    border: 0;
    border-left: 1px solid var(--line);
    background: rgba(180, 67, 47, 0.08);
    color: rgba(31, 26, 21, 0.72);
    font-size: 0.8rem;
    padding: 0;
}

.done-rail:hover {
    background: rgba(180, 67, 47, 0.14);
    color: var(--accent);
}

.scratch-rail {
    background: rgba(31, 26, 21, 0.06);
}

.scratch-rail:hover {
    background: rgba(31, 26, 21, 0.12);
    color: var(--ink);
}

.reopen-rail {
    background: rgba(44, 103, 83, 0.08);
}

.reopen-rail:hover {
    background: rgba(44, 103, 83, 0.16);
    color: var(--success);
}

.add-rail {
    width: 1.55rem;
    min-width: 1.55rem;
    font-size: 0.95rem;
}

.task-menu {
    position: relative;
}

.task-menu summary {
    list-style: none;
}

.task-menu summary::-webkit-details-marker {
    display: none;
}

.task-menu-panel {
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid var(--line-strong);
    background: var(--panel);
    min-width: 11.5rem;
}

.task-menu-panel input[type="date"] {
    min-width: 8rem;
    height: 1.55rem;
}

.done-block {
    margin-top: 0.15rem;
    border-top: 1px solid var(--line);
    padding-top: 0.2rem;
}

.scratched-block {
    margin-top: 0.15rem;
    border-top: 1px solid var(--line);
    padding-top: 0.2rem;
}

.done-block summary {
    display: none;
}

.scratched-block summary {
    display: none;
}

.empty-state,
.error-banner {
    padding: 0.28rem 0.38rem;
    border: 1px solid var(--line);
    background: rgba(180, 67, 47, 0.08);
    font-size: 0.76rem;
}

.compact-empty {
    background: rgba(31, 26, 21, 0.04);
}

.drop-zone {
    min-height: 0.45rem;
    border: 1px dashed transparent;
}

.drop-zone.is-empty {
    min-height: 3.2rem;
    background:
        linear-gradient(180deg, rgba(31, 26, 21, 0.015), rgba(31, 26, 21, 0.035));
    border-color: rgba(67, 52, 39, 0.22);
}

.event-card {
    background: rgba(242, 232, 217, 0.6);
    border-color: rgba(139, 94, 60, 0.24);
    margin-bottom: 0;
}

.event-card .task-link {
    font-weight: 600;
}

.event-card .task-rails {
    margin-left: auto;
}

.event-card .strip-actions {
    margin-left: 0;
}

.event-pill,
.event-rail {
    background: var(--event-soft);
    color: var(--event);
}

.event-state-todo {
    background: rgba(242, 232, 217, 0.6);
}

.event-state-done {
    background: rgba(234, 243, 238, 0.75);
}

.event-state-scratched {
    background: rgba(31, 26, 21, 0.05);
}

.task-list.is-drop-target .drop-zone {
    border-color: rgba(180, 67, 47, 0.38);
    background: rgba(180, 67, 47, 0.08);
}

.drag-placeholder {
    border: 1px dashed rgba(67, 52, 39, 0.35);
    background: rgba(180, 67, 47, 0.07);
    min-height: 2rem;
}

.backlog-create,
.login-panel {
    margin-bottom: 0.5rem;
}

.backlog-card .task-topline,
.task-topline,
.history-row,
.bar-row {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
    align-items: center;
}

.inline-form {
    flex-wrap: wrap;
}

.inline-form-actions input[type="date"] {
    flex: 1 1 10rem;
}

.detail-actions {
    margin-top: 0.5rem;
}

.split-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem;
}

.split-actions form,
.split-actions button,
.split-actions .button-link {
    width: 100%;
}

.backlog-panel .stack-form button,
.backlog-panel .split-actions button,
.backlog-panel .button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.7rem;
    padding: 0.18rem 0.45rem;
    line-height: 1.2;
}

body:not(.edit-mode) .edit-only {
    display: none;
}

body.hide-completed .done-block {
    display: none;
}

body.hide-completed .scratched-block {
    display: none;
}

body.dragging-board {
    user-select: none;
}

.history-row {
    padding: 0.24rem 0;
    border-bottom: 1px solid rgba(67, 52, 39, 0.08);
    font-size: 0.78rem;
}

.mono {
    font-family: Consolas, monospace;
}

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

.stat-card strong {
    display: block;
    margin-top: 0.1rem;
    font-size: 1.5rem;
}

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

.full-span {
    grid-column: 1 / -1;
}

.event-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(18rem, 0.9fr);
    gap: 0.5rem;
    align-items: start;
}

.backlog-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(18rem, 0.9fr);
    gap: 0.5rem;
    align-items: start;
}

.task-detail-board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(18rem, 0.92fr);
    gap: 0.5rem;
    align-items: start;
}

.event-column,
.backlog-column,
.task-detail-column,
.event-week-list,
.event-week-items,
.event-list-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.event-column-header {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
    align-items: center;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--line);
}

.event-column-header h2 {
    margin: 0;
    font-size: 0.96rem;
}

.event-panel {
    position: sticky;
    top: 0.4rem;
}

.backlog-panel {
    position: sticky;
    top: 0.4rem;
}

.task-detail-panel,
.task-history-column {
    position: sticky;
    top: 0.4rem;
}

.event-week-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.event-week-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.event-empty-week {
    padding: 0.35rem 0.4rem;
    border: 1px dashed rgba(67, 52, 39, 0.22);
    background: rgba(31, 26, 21, 0.03);
    font-size: 0.74rem;
    color: var(--muted);
}

.event-list-item {
    display: grid;
    grid-template-columns: 6rem 1fr;
    gap: 0.5rem;
    padding: 0.35rem 0.4rem;
    border: 1px solid rgba(139, 94, 60, 0.18);
    background: rgba(255, 250, 244, 0.9);
}

.event-list-item.is-selected {
    border-color: rgba(180, 67, 47, 0.42);
    box-shadow: 0 0 0 1px rgba(180, 67, 47, 0.15);
}

.event-list-item-done {
    background: rgba(234, 243, 238, 0.75);
}

.event-list-item-scratched {
    background: rgba(31, 26, 21, 0.05);
}

.event-list-meta {
    display: flex;
    gap: 0.3rem;
    align-items: baseline;
    white-space: nowrap;
    font-size: 0.72rem;
    color: var(--muted);
}

.event-list-body strong {
    font-size: 0.82rem;
}

.event-list-description {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.74rem;
    color: var(--ink);
}

.backlog-list,
.backlog-list-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.backlog-list-item {
    grid-template-columns: 6rem 1fr;
}

.backlog-list-item.is-selected {
    border-color: rgba(180, 67, 47, 0.42);
    box-shadow: 0 0 0 1px rgba(180, 67, 47, 0.15);
}

.overdue-list-item {
    background: rgba(255, 245, 236, 0.92);
    border-color: rgba(180, 67, 47, 0.2);
}

.backlog-list-meta {
    display: flex;
    flex-direction: column;
    gap: 0.14rem;
    align-items: flex-start;
}

.backlog-meta {
    display: flex;
    flex-direction: column;
    gap: 0.16rem;
    font-size: 0.72rem;
    color: var(--muted);
    text-align: right;
}

.task-detail-board label > span {
    display: inline-block;
    margin-bottom: 0.16rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.task-detail-board textarea {
    min-height: 11rem;
}

.task-control-form input[type="date"] {
    width: 100%;
}

.task-action-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.25rem;
}

.task-action-strip button {
    width: 100%;
}

.task-action-strip-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.task-action-strip-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.task-detail-board .compact-form textarea,
.task-detail-board .compact-form input[type="date"] {
    min-height: 0;
}

.task-history-row {
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr);
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0;
}

.task-history-row strong {
    font-size: 0.76rem;
    letter-spacing: 0.03em;
}

.task-history-row span:last-child {
    min-width: 0;
}

.bar-track {
    flex: 1;
    height: 0.45rem;
    border: 1px solid var(--line);
    background: rgba(29, 25, 20, 0.05);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    min-width: 2px;
    background: linear-gradient(90deg, var(--accent), #d8844b);
}

.bar-fill.warm {
    background: linear-gradient(90deg, #d6682a, #e2bb5f);
}

.login-panel {
    width: min(28rem, 100%);
    margin: 8vh auto 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 900px) {
    .shell {
        width: calc(100vw - 0.4rem);
    }

    .page-header,
    .analytics-grid,
    .detail-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

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

    .event-panel,
    .backlog-panel {
        position: static;
    }

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

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

    .task-detail-panel,
    .task-history-column {
        position: static;
    }

    .task-action-strip-two,
    .task-action-strip-three,
    .task-history-row {
        grid-template-columns: 1fr;
    }
}
