/* Screen builder UI; .fjt-sheet is the only printed content. */
.food-journal-template-page {
    --fjt-ink: #c9541f;
    --tool-peek-bg: #c9541f;
}

.fjt-container { max-width: 820px; margin: auto; padding: 64px 24px; }
.fjt-title { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.12; text-wrap: balance; margin: 0 0 20px; }
.fjt-lede { font-size: 1.1rem; line-height: 1.7; max-width: 690px; margin-bottom: 30px; text-wrap: pretty; }

.fjt-form { display: grid; gap: 24px; padding-block: 12px 24px; }
.fjt-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.fjt-field legend { font-weight: 700; margin-bottom: 12px; }
.fjt-options { display: flex; flex-wrap: wrap; gap: 10px; }
.fjt-options input { position: absolute; opacity: 0; }
.fjt-options label {
    display: flex; align-items: center; gap: 8px; min-height: 44px;
    padding: 10px 16px; border-radius: 12px; background: #fff;
    box-shadow: 0 1px 4px rgb(0 0 0 / .08); cursor: pointer;
}
.fjt-options input:checked + label { background: var(--fjt-ink); color: #fff; }
.fjt-options input:focus-visible + label { outline: 2px solid var(--fjt-ink); outline-offset: 3px; }

.fjt-details { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fjt-detail { display: grid; gap: 7px; min-width: 0; }
.fjt-detail label { font-size: .85rem; }
.fjt-detail input {
    box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px;
    padding: 10px 12px; border: 1px solid #ccc; border-radius: 10px;
    background: #fff; color: #222; font: inherit;
}
.fjt-detail:first-child { grid-column: 1 / -1; }
.fjt-detail input:focus-visible { outline: 2px solid var(--fjt-ink); outline-offset: 2px; }

/* Prevent toolkit's fieldset label counter from repeating inside text-input groups. */
.food-journal-template-page .tk-app .tk-q .fjt-detail label::before {
    content: none !important;
    counter-increment: none;
}

.fjt-result-label { text-transform: uppercase; font-size: .75rem; letter-spacing: .1em; }
.fjt-result-headline { font-size: 1.8rem; font-weight: 700; margin: 8px 0 12px; }
.fjt-result-body { line-height: 1.6; }

.fjt-print-actions { display: flex; gap: 18px; align-items: center; margin: 20px 0 28px; }
.fjt-print-actions button {
    flex-shrink: 0; min-height: 48px; padding: 12px 20px; border: 0;
    border-radius: 14px; background: var(--fjt-ink); color: #fff;
    font: inherit; font-weight: 700; cursor: pointer; transition: transform .15s ease;
}
.fjt-print-actions button:active { transform: scale(.96); }
.fjt-print-actions button:focus-visible { outline: 2px solid var(--fjt-ink); outline-offset: 3px; }
.fjt-print-actions p { font-size: .8rem; line-height: 1.5; margin: 0; }

/* ----------------------------------------------------- printable sheet UI */
.fjt-sheet {
    --sheet-content: 840px;
    box-sizing: border-box;
    padding: 26px;
    background: #fff;
    color: #222;
    border: 1px solid #ddd;
    box-shadow: 0 8px 24px rgb(0 0 0 / .06);
    font-variant-numeric: tabular-nums;
}
.fjt-sheet[data-paper="letter"] { --sheet-content: 770px; }
.fjt-sheet .fjt-sheet-kicker { font-size: .65rem; letter-spacing: .12em; margin: 0; color: #555; }
.fjt-sheet h2 {
    font: 700 clamp(1.15rem, 3vw, 1.75rem)/1.25 var(--font-ui);
    overflow-wrap: anywhere; margin: 5px 0 14px;
}
.fjt-sheet-meta { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px 16px; margin-bottom: 16px; }
.fjt-sheet .fjt-write { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: .72rem; min-width: 0; }
.fjt-write span { flex-shrink: 0; }
.fjt-write b {
    font-weight: 400; min-width: 0; flex: 1; min-height: 1.45em;
    border-bottom: 1px solid #999; overflow-wrap: anywhere;
}
.fjt-sheet-content { min-height: var(--sheet-content); display: flex; flex-direction: column; gap: 12px; }

.fjt-sheet-rule {
    margin: 0; padding: 7px 10px; background: #fafafa; border: 1px solid #bbb;
    font-size: .68rem; line-height: 1.45; color: #222;
}

/* Cards (daily memory, 3-day sheets, daily dining stops) */
.fjt-card-stack { display: flex; flex-direction: column; gap: 10px; flex: 1; }
body.page-sketch .fjt-card, .fjt-card {
    flex: 1; display: flex; flex-direction: column; justify-content: space-between;
    margin: 0; padding: 9px 11px; background: #fff; border: 1px solid #999;
    font-size: .67rem; line-height: 1.42; gap: 6px;
}
.fjt-card-head {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
    gap: 6px 14px; padding-bottom: 4px; border-bottom: 1px solid #ccc; font-weight: 700; font-size: .73rem;
}
.fjt-card-tag {
    display: inline-block; padding: 1px 6px; border: 1px solid #333;
    font-size: .61rem; letter-spacing: .05em; font-weight: 700;
}
.fjt-card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.fjt-card-checks {
    display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-size: .64rem; color: #333;
}

/* 3-day dining table inside card */
.fjt-mini-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .63rem; }
.fjt-mini-table th, .fjt-mini-table td { border: 1px solid #bbb; padding: 4px 6px; text-align: left; }
.fjt-mini-table th { font-size: .59rem; background: #f5f5f5; }
.fjt-mini-table td { height: 26px; }
.fjt-col-slot { width: 18%; font-weight: 700; }
.fjt-col-spot { width: 28%; }
.fjt-col-dish { width: 32%; }
.fjt-col-rev { width: 22%; font-size: .59rem; }

/* Full-page tables (daily pattern, weekly memory/pattern, 10-spot dining) */
.fjt-table {
    width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .65rem; flex: 1;
}
.fjt-table th, .fjt-table td {
    border: 1px solid #999; padding: 6px 7px; text-align: left; vertical-align: top;
}
.fjt-table th {
    font-size: .61rem; background: #f5f5f5; letter-spacing: .03em; vertical-align: middle;
}
.fjt-table-daily td { height: 112px; }
.fjt-table-week td { height: 74px; }
.fjt-table-spots td { height: 48px; vertical-align: middle; }
.fjt-cell-day { font-weight: 700; }

/* Column widths */
.fjt-w-meal { width: 17%; }
.fjt-w-ate { width: 31%; }
.fjt-w-ctx { width: 25%; }
.fjt-w-felt { width: 27%; }

.fjt-w-day { width: 13%; }
.fjt-w-dish { width: 32%; }
.fjt-w-place { width: 27%; }
.fjt-w-note { width: 28%; }

.fjt-w-wk-day { width: 12%; }
.fjt-w-wk-block { width: 23%; }
.fjt-w-wk-place { width: 18%; font-size: .6rem; }
.fjt-w-wk-feel { width: 24%; }

.fjt-w-sp-num { width: 8%; text-align: center !important; font-weight: 700; }
.fjt-w-sp-place { width: 27%; }
.fjt-w-sp-dish { width: 27%; }
.fjt-w-sp-with { width: 20%; }
.fjt-w-sp-back { width: 18%; font-size: .6rem; }

body.page-sketch .fjt-foot-box, .fjt-foot-box {
    margin: 0; padding: 8px 11px; background: #fafafa; border: 1.5px solid #333;
    font-size: .65rem; line-height: 1.45; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
}
.fjt-foot-box-single { grid-template-columns: 1fr; }

.fjt-sheet-footer {
    display: flex; justify-content: space-between; gap: 10px;
    border-top: 1px solid #999; padding-top: 10px; margin-top: 14px; font-size: .64rem;
}

.fjt-prose { margin-top: 44px; line-height: 1.8; }
.fjt-prose h2 { margin-top: 30px; text-wrap: balance; }

@media (max-width: 720px) {
    .fjt-card-row, .fjt-foot-box { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .fjt-container { padding: 40px 16px; }
    .fjt-options { flex-direction: column; }
    .fjt-options label { width: 100%; box-sizing: border-box; }
    .fjt-details { grid-template-columns: 1fr; }
    .fjt-print-actions { flex-direction: column; align-items: stretch; }
    .fjt-sheet { padding: 12px; --sheet-content: 520px; }
    .fjt-sheet[data-paper="letter"] { --sheet-content: 480px; }
    .fjt-sheet-meta { grid-template-columns: 1fr; }
    .fjt-table, .fjt-mini-table { font-size: .56rem; }
    .fjt-sheet-footer { font-size: .56rem; flex-direction: column; gap: 4px; }
}

@media print {
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    body.food-journal-template-page > :not(main),
    main > :not(.fjt-container),
    .fjt-container > :not(.food-journal-template),
    .food-journal-template .tk-app > :not(.tk-r),
    .food-journal-template .tk-r > :not(.fjt-result),
    .fjt-result > :not(.fjt-sheet) { display: none !important; }
    main, .fjt-container, .food-journal-template, .food-journal-template .tk-app,
    .food-journal-template .tk-r, .fjt-result {
        display: block !important; position: static !important;
        margin: 0 !important; padding: 0 !important;
        width: 100% !important; max-width: none !important;
        height: auto !important; max-height: none !important;
        overflow: visible !important; border: 0 !important; box-shadow: none !important;
        background: #fff !important; transform: none !important; opacity: 1 !important;
    }
    .fjt-result *, .fjt-result *::before, .fjt-result *::after {
        animation: none !important; transition: none !important;
        opacity: 1 !important; transform: none !important;
    }
    /* Leave room for hardware margins and browser print headers/footers. */
    .fjt-sheet {
        display: flex; flex-direction: column;
        height: 252mm; padding: 0; margin: 0; border: 0; box-shadow: none;
        font-family: Arial, sans-serif; break-inside: avoid;
    }
    .fjt-sheet[data-paper="letter"] { height: 234mm; }
    .fjt-sheet-head { flex-shrink: 0; }
    .fjt-sheet h2 { font: 700 15pt/1.18 Arial, sans-serif; margin: 1mm 0 2mm; }
    .fjt-sheet .fjt-sheet-kicker { font-size: 7pt; }
    .fjt-sheet-meta { grid-template-columns: 1fr 1fr 1.25fr; margin-bottom: 2.2mm; gap: 1.5mm 4mm; }
    .fjt-sheet .fjt-write { font-size: 7.8pt; }
    .fjt-sheet-content { min-height: 0; flex: 1; gap: 2mm; }
    .fjt-sheet-rule { padding: 1.5mm 2.2mm; font-size: 7.2pt; }
    .fjt-card-stack { gap: 1.8mm; }
    .fjt-card { padding: 1.8mm 2.4mm; font-size: 7.1pt; gap: 1mm; }
    .fjt-card-head { font-size: 7.8pt; padding-bottom: 0.8mm; }
    .fjt-card-tag { font-size: 6.5pt; }
    .fjt-card-row { grid-template-columns: 1fr 1fr; gap: 1.2mm 3.5mm; }
    .fjt-card-checks { font-size: 6.9pt; gap: 1mm 3.5mm; }
    .fjt-mini-table { font-size: 6.8pt; }
    .fjt-mini-table th { font-size: 6.4pt; padding: 0.8mm 1.3mm; }
    .fjt-mini-table td { height: 6.4mm; padding: 0.8mm 1.3mm; }
    .fjt-sheet[data-paper="letter"] .fjt-mini-table td { height: 5.2mm; }
    .fjt-table { font-size: 7.2pt; }
    .fjt-table th { font-size: 6.7pt; padding: 1.1mm 1.6mm; }
    .fjt-table td { padding: 1.1mm 1.6mm; }
    .fjt-table-daily td { height: 28mm; }
    .fjt-sheet[data-paper="letter"] .fjt-table-daily td { height: 24mm; }
    .fjt-table-week td { height: 17mm; }
    .fjt-sheet[data-paper="letter"] .fjt-table-week td { height: 14.5mm; }
    .fjt-table-spots td { height: 11mm; }
    .fjt-sheet[data-paper="letter"] .fjt-table-spots td { height: 9.2mm; }
    .fjt-foot-box { grid-template-columns: 1fr 1fr; padding: 1.8mm 2.2mm; font-size: 7.1pt; gap: 1.2mm 3.5mm; }
    .fjt-foot-box-single { grid-template-columns: 1fr; }
    .fjt-sheet-footer { flex-direction: row; font-size: 7pt; margin-top: 2mm; padding-top: 1.6mm; }
}

@media (prefers-reduced-motion: reduce) {
    .fjt-print-actions button { transition: none; }
}
