:root {
    --ink: #111;
    --muted: #686868;
    --line: #b7b7b7;
    --line-dark: #333;
    --paper: #fff;
    --soft: #f4f4f2;
    --soft-2: #e9e9e6;
    --column-width: 252px;
    color-scheme: light;
    font-family: "DejaVu Sans Mono", "Liberation Mono", "Courier New", monospace;
    font-size: 15px;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; min-width: 320px; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-header {
    align-items: center;
    background: var(--ink);
    color: white;
    display: flex;
    height: 54px;
    justify-content: space-between;
    padding: 0 clamp(18px, 4vw, 56px);
}
.app-header form { margin: 0; }
.brand { font-size: .82rem; font-weight: 700; letter-spacing: .12em; text-decoration: none; }
.app-main { margin: 0 auto; max-width: 1800px; padding: 28px clamp(18px, 4vw, 56px) 64px; }
.app-main-login { align-items: center; display: flex; justify-content: center; min-height: 100vh; }

.button, .add-button, .icon-button, .text-button {
    background: var(--paper);
    border: 1px solid var(--ink);
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    text-decoration: none;
    transition: background .14s ease, color .14s ease, transform .14s ease;
}
.button:hover, .button:focus-visible, .add-button:hover, .icon-button:hover { background: var(--ink); color: white; }
.button:active, .add-button:active { transform: translateY(1px); }
.button-primary { background: var(--ink); color: white; }
.button-primary:hover { background: #444; }
.button-quiet { background: transparent; border-color: #777; color: white; min-height: 30px; padding: 4px 10px; }
.icon-button { border-color: transparent; height: 28px; min-height: 28px; padding: 2px 7px; }
.text-button { border: 0; color: var(--muted); min-height: 0; padding: 2px; text-decoration: underline; }
.text-button:hover { color: var(--ink); }
.add-button { font-size: 1.35rem; height: 30px; min-height: 30px; padding: 0; width: 30px; }

.eyebrow { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .14em; margin: 0 0 7px; }
.muted { color: var(--muted); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { font-size: clamp(1.65rem, 3vw, 2.6rem); letter-spacing: -.045em; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .92rem; line-height: 1.45; margin: 0; }

.breadcrumbs { align-items: center; color: var(--muted); display: flex; flex-wrap: wrap; font-size: .78rem; gap: 7px; margin-bottom: 22px; }
.breadcrumbs a:hover { color: var(--ink); }
.page-heading { align-items: flex-start; border-bottom: 2px solid var(--ink); display: flex; gap: 20px; justify-content: space-between; padding-bottom: 20px; }
.page-heading .muted { margin-bottom: 0; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.board-details { border-bottom: 2px solid var(--ink); padding: 22px 0 32px; }
.detail-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); margin-top: 16px; }
.detail-block { border: 1px solid var(--line-dark); padding: 18px; }
.date-summary { align-items: center; display: flex; gap: 28px; width: max-content; }
.date-summary span { display: grid; gap: 4px; }
.date-summary small { color: var(--muted); font-size: .66rem; letter-spacing: .12em; }
.date-summary .date-arrow { display: block; }
.section-title { align-items: center; display: flex; gap: 18px; justify-content: space-between; margin-bottom: 16px; }
.markdown-section { min-height: 250px; }
.markdown-body { line-height: 1.62; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body pre { background: var(--soft); border-left: 3px solid var(--ink); overflow-x: auto; padding: 12px; }
.markdown-body code { background: var(--soft); padding: 1px 4px; }
.markdown-body pre code { padding: 0; }
.markdown-body blockquote { border-left: 3px double var(--line-dark); color: #444; margin-left: 0; padding-left: 16px; }
.markdown-body img { max-width: 100%; }
.markdown-body a { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.markdown-body hr { border: 0; border-top: 1px solid var(--line); }

.progress-track { background: var(--soft-2); height: 5px; margin-bottom: 13px; overflow: hidden; }
.progress-track span { background: var(--ink); display: block; height: 100%; transition: width .2s ease; }
.checklist { max-height: 310px; overflow-y: auto; }
.checklist-item { align-items: center; border-bottom: 1px solid var(--soft-2); display: flex; gap: 8px; justify-content: space-between; min-height: 39px; }
.check-label { align-items: flex-start; cursor: pointer; display: flex; gap: 9px; line-height: 1.4; padding: 8px 0; }
.check-label input { accent-color: var(--ink); flex: none; height: 16px; margin: 2px 0 0; width: 16px; }
.check-label input:checked + span { color: var(--muted); text-decoration: line-through; }
.inline-actions { display: flex; gap: 2px; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; }
.inline-form input { min-width: 0; width: 100%; }
.comments-section { margin-top: 16px; }
.comment-form { border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-bottom: 18px; }
.form-footer { align-items: center; display: flex; font-size: .75rem; gap: 12px; justify-content: space-between; margin-top: 8px; }
.comment { border-top: 1px solid var(--line); padding: 16px 0; }
.comment header { align-items: center; display: flex; justify-content: space-between; margin-bottom: 12px; }
.comment time { color: var(--muted); font-size: .75rem; }
.comment-edit-form[hidden], [data-comment-rendered][hidden] { display: none; }
.comment-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

input, textarea { background: white; border: 1px solid var(--line-dark); border-radius: 0; display: block; padding: 9px 10px; width: 100%; }
textarea { line-height: 1.5; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
label { display: grid; font-size: .78rem; gap: 6px; }

.kanban-section { padding-top: 28px; }
.kanban-title { align-items: flex-end; }
.kanban-title h2 { font-size: 1.45rem; }
.kanban { display: grid; gap: 10px; grid-template-columns: repeat(5, minmax(var(--column-width), 1fr)); overflow-x: auto; padding: 1px 1px 14px; }
.kanban-column { background: var(--soft); border: 1px solid var(--line-dark); min-height: 410px; }
.kanban-column > header { align-items: center; background: var(--paper); border-bottom: 1px solid var(--line-dark); display: flex; font-size: .76rem; font-weight: 700; justify-content: space-between; letter-spacing: .07em; min-height: 48px; padding: 8px 10px; }
.kanban-column > header small { background: var(--soft-2); border-radius: 20px; font-size: .66rem; padding: 2px 6px; }
.card-list { min-height: 352px; padding: 9px; transition: background .15s ease; }
.card-list.drag-over { background: #dededb; }
.board-card { background: var(--paper); border: 1px solid var(--line-dark); cursor: grab; margin-bottom: 8px; transition: box-shadow .15s ease, opacity .15s ease, transform .15s ease; }
.board-card:hover { box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -1px); }
.board-card.dragging { cursor: grabbing; opacity: .35; transform: scale(.98); }
.board-card.card-warning { border-style: dashed; border-width: 2px; }
.board-card > a { display: block; padding: 12px; text-decoration: none; }
.card-dates, .period-warning { color: var(--muted); font-size: .69rem; margin: 8px 0 0; }
.period-warning { color: var(--ink); }
.board-card footer { border-top: 1px solid var(--soft-2); color: var(--muted); display: flex; font-size: .63rem; gap: 8px; justify-content: space-between; margin-top: 12px; padding-top: 8px; }

.notice { background: repeating-linear-gradient(-45deg, #fff, #fff 6px, var(--soft) 6px, var(--soft) 12px); border: 1px solid var(--ink); margin: 16px 0; padding: 12px; }
.archive-list { border-top: 1px solid var(--line); margin-top: 24px; }
.archive-item { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 18px; justify-content: space-between; padding: 20px 0; }
.archive-item h2 a { text-underline-offset: 3px; }
.archive-item .muted { font-size: .75rem; margin-bottom: 0; }
.empty-state { margin: 12vh auto; max-width: 680px; text-align: center; }
.empty-state h1, .empty-state h2 { margin-bottom: 18px; }

.login-panel { border: 2px solid var(--ink); box-shadow: 9px 9px 0 var(--soft-2); max-width: 440px; padding: clamp(28px, 5vw, 48px); width: 100%; }
.login-panel h1 { font-size: 2rem; }
.login-panel > .muted { line-height: 1.5; margin: 10px 0 28px; }
.stack-form { display: grid; gap: 16px; }
.stack-form .button { margin-top: 4px; width: 100%; }

.modal { border: 2px solid var(--ink); border-radius: 0; box-shadow: 10px 10px 0 #777; max-width: 510px; padding: 24px; width: calc(100% - 32px); }
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal-wide { max-width: 760px; }
.modal form { display: grid; gap: 16px; }
.modal-heading { align-items: flex-start; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.date-inputs { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

.toast { background: var(--ink); bottom: 22px; color: white; max-width: min(420px, calc(100vw - 36px)); opacity: 0; padding: 12px 16px; pointer-events: none; position: fixed; right: 22px; transform: translateY(15px); transition: opacity .18s, transform .18s; z-index: 100; }
.toast.visible { opacity: 1; transform: none; }
.toast.error { background: white; border: 2px solid var(--ink); color: var(--ink); }

.gantt-panel { border: 1px solid var(--line-dark); margin-top: 25px; overflow-x: auto; }
.gantt-range { align-items: center; border-bottom: 1px solid var(--line-dark); display: flex; justify-content: space-between; min-width: 850px; padding: 12px 18px; }
.gantt-range span { color: var(--muted); font-size: .74rem; }
.gantt-chart { min-width: 850px; }
.gantt-row { display: grid; grid-template-columns: 260px minmax(580px, 1fr); min-height: 66px; }
.gantt-row + .gantt-row { border-top: 1px solid var(--line); }
.gantt-label { border-right: 1px solid var(--line-dark); display: flex; flex-direction: column; gap: 4px; justify-content: center; padding: 10px 14px; }
.gantt-label a { font-size: .83rem; font-weight: 700; }
.gantt-label small, .gantt-label span { color: var(--muted); font-size: .65rem; }
.gantt-track { background: repeating-linear-gradient(90deg, transparent, transparent calc(10% - 1px), var(--soft-2) calc(10% - 1px), var(--soft-2) 10%); position: relative; }
.gantt-bar { background: var(--ink); height: 18px; min-width: 3px; position: absolute; top: calc(50% - 9px); }
.gantt-warning .gantt-bar { background: repeating-linear-gradient(45deg, #111, #111 4px, #777 4px, #777 8px); outline: 1px dashed var(--ink); outline-offset: 3px; }
.undated-section { border: 1px solid var(--line-dark); margin-top: 22px; padding: 18px; }
.undated-list { display: grid; gap: 8px; }
.undated-list a { align-items: center; background: var(--soft); border: 1px solid var(--line); display: flex; justify-content: space-between; padding: 11px; text-decoration: none; }
.undated-list a:hover { border-color: var(--ink); }
.undated-list span { color: var(--muted); font-size: .68rem; }

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
    .page-heading, .archive-item { align-items: stretch; flex-direction: column; }
    .heading-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
    :root { --column-width: 82vw; font-size: 14px; }
    .app-header, .app-main { padding-left: 16px; padding-right: 16px; }
    .page-heading { gap: 16px; }
    .heading-actions .button { flex: 1; }
    .date-summary { justify-content: space-between; width: 100%; }
    .detail-block { padding: 14px; }
    .inline-form, .form-footer { align-items: stretch; flex-direction: column; }
    .date-inputs { grid-template-columns: 1fr; }
    .archive-item .heading-actions { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
