/* Checklists: the Process → Checklists page, the checklists on a task, and
   the Checklist field in a form.

   Written phone first. The base rules are the phone layout (one column,
   44px touch targets, a full-screen editor); the min-width rules at the end
   give wider screens a centred column and an ordinary dialog. */

/* Small secondary text here is a shade darker than --color-muted: on the
   page background that token is 4.47:1, just under the 4.5:1 minimum. */
.cl-page,
.cl-editor-dialog,
.task-checklists-dialog,
.form-checklist { --cl-muted: #6b6560; }

/* ---- Process → Checklists -------------------------------------------- */
.cl-page { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.cl-page-head { display: flex; flex-direction: column; gap: 8px; }
.cl-page-head h2 { margin: 0; font-size: 18px; }
.cl-page-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cl-page-actions:has(> :only-child) { grid-template-columns: 1fr; }
.cl-page-actions button { min-height: 44px; font-size: 15px; }
.cl-page-hint { margin: 0; color: var(--cl-muted); font-size: 13px; line-height: 1.4; }
.cl-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cl-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: stretch;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}
.cl-card-open {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    min-width: 0;
    padding: 4px 8px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    text-align: left;
    font: inherit;
    cursor: pointer;
}
.cl-card-name { font-size: 15px; overflow-wrap: anywhere; }
.cl-card-meta { color: var(--cl-muted); font-size: 12px; }
.cl-card-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.cl-card-btn.is-danger { color: var(--color-danger); }
.cl-card-open:focus-visible,
.cl-card-btn:focus-visible,
.cl-icon-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
@media (hover: hover) {
    .cl-card-open:hover { background: var(--color-bg); }
    .cl-card-btn:hover { background: var(--color-bg); }
}

/* ---- Editor (fills the screen on a phone) ------------------------------- */
.dialog.cl-editor-dialog,
.dialog.task-checklists-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
}
.cl-editor,
.tcl-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.cl-editor-head,
.tcl-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}
.cl-editor-head h2,
.tcl-head h2 { margin: 0; font-size: 17px; }
.cl-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.cl-icon-btn:disabled { opacity: 0.35; cursor: default; }
.cl-icon-btn.is-danger { color: var(--color-danger); }
.cl-name-field,
.cl-add-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--cl-muted); }
.cl-name-field { padding: 10px 12px 6px; }
.cl-instructions-field { padding-top: 0; }
.cl-instructions-field textarea {
    min-height: 60px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 16px;
    line-height: 1.35;
    resize: vertical;
}
.cl-instructions-field textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
/* Everything between the title bar and the Save bar scrolls as one, so
   the Options section sits at the bottom of the window. */
.cl-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.cl-add-field { flex: 1 1 auto; min-width: 0; }
.cl-name-field input,
.cl-add input,
.cl-entry-name {
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 16px;   /* 16px keeps iOS from zooming the page on focus */
    min-width: 0;
}
.cl-name-field input:focus,
.cl-add input:focus,
.cl-entry-name:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }
.cl-entries {
    margin: 0;
    padding: 6px 12px 10px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cl-entries-empty { color: var(--cl-muted); font-size: 14px; padding: 12px 2px; }
.cl-entry {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}
.cl-entry.is-indented { margin-left: 22px; }
.cl-entry.is-heading { background: #f5f3ff; border-color: #ddd6fe; }
.cl-entry.is-heading .cl-entry-name { font-weight: 700; color: #5b21b6; }
.cl-entry-move { display: inline-flex; gap: 4px; }
/* With Select on, every row starts with a selection box (headings keep an
   empty cell so the columns line up). */
.cl-entries.is-selecting .cl-entry { grid-template-columns: 28px auto minmax(0, 1fr) auto auto; }
.cl-entry-select { display: flex; align-items: center; justify-content: center; width: 28px; min-height: 40px; }
.cl-entry-select input { width: 22px; height: 22px; margin: 0; accent-color: var(--color-accent); cursor: pointer; }
.cl-entry-main { display: flex; align-items: center; gap: 4px; min-width: 0; }
.cl-entry-main .cl-entry-name { flex: 1 1 auto; width: 100%; }
.cl-entry-spacer { width: 40px; }
.cl-entry-tag { color: #5b21b6; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 4px; }
.cl-entry-type {
    flex: 0 0 auto;
    padding: 2px 5px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 11px;
    font-weight: 700;
}
.cl-entry.is-yesno { border-color: #bae6fd; }
.cl-entry-indent[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent); }
.cl-add {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}
.cl-add-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cl-add-buttons button { min-height: 44px; }

/* Options, at the bottom of the editor. */
.cl-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 14px;
    border-top: 1px solid var(--color-border);
}
.cl-options h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--cl-muted); }
/* Labelled rows: a short label column, then controls sized to their text
   (not stretched across the window), so Select / Select All and the field
   type with its Update button each read as one line. */
.cl-options-grid {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
}
.cl-options-label { font-size: 13px; color: var(--cl-muted); white-space: nowrap; }
.cl-options-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.cl-options-controls button,
.cl-options-foot button { min-height: 44px; min-width: 84px; padding: 6px 14px; white-space: nowrap; }
.cl-options-controls button.is-active,
.cl-options-controls button[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent); background: #e8f4f0; }
.cl-options-grid .cl-options-note { grid-column: 2; }
.cl-options-foot { display: flex; }
.cl-type-row select {
    flex: 0 1 10.5em;
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 16px;
}
.cl-options-note { margin: 0; color: var(--cl-muted); font-size: 12px; line-height: 1.4; }
.cl-require-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 15px;
    cursor: pointer;
}
.cl-require-field input { width: 22px; height: 22px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--color-accent); cursor: pointer; }
.cl-require-field small { display: block; margin-top: 2px; color: var(--cl-muted); font-size: 12px; }
.cl-editor-foot,
.tcl-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}
.cl-editor-count { margin-right: auto; color: var(--cl-muted); font-size: 13px; }
.cl-editor-foot button { min-height: 44px; min-width: 88px; }

/* ---- Checklists on a task ---------------------------------------------- */
.tcl-head-text { min-width: 0; }
.tcl-task { color: var(--cl-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcl-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tcl-empty { color: var(--cl-muted); font-size: 14px; margin: 8px 0; }
.tcl-list { border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.tcl-list-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 12px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    border-radius: var(--radius) var(--radius) 0 0;
}
.tcl-list-head h3 { margin: 0; font-size: 15px; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tcl-required {
    flex: 0 0 auto;
    padding: 2px 7px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-weight: 700;
}
.tcl-instructions,
.form-checklist-instructions {
    margin: 0;
    padding: 8px 12px;
    border-bottom: 1px solid #ececea;
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.tcl-progress {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: #ecece8;
    color: var(--color-text);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.tcl-progress.is-complete { background: #d1fae5; color: #065f46; }
.tcl-items,
.form-checklist-items { list-style: none; margin: 0; padding: 0; }
.tcl-heading,
.form-checklist-heading {
    padding: 10px 12px 4px;
    color: #5b21b6;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tcl-item + .tcl-item,
.tcl-heading + .tcl-item,
.tcl-yn-head + .tcl-item { border-top: 1px solid #ececea; }
/* Y / N items: the name, then a Y column and an N column. */
.tcl-yn-head,
.form-checklist-yn-head,
.tcl-item.is-yesno,
.form-checklist-item.is-yesno {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px 48px;
    align-items: stretch;
}
.tcl-yn-head,
.form-checklist-yn-head {
    padding: 6px 0 2px 12px;
    color: var(--cl-muted);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
/* A Y/N item's name starts where a checkbox item's name does (past the
   12px pad, the 22px box and the 12px gap), so the item text lines up down
   the list; indented ones add the same 18px as a checkbox item. */
.tcl-item.is-yesno,
.form-checklist-item.is-yesno { min-height: 44px; padding-left: 46px; }
.tcl-item.is-yesno.is-indented,
.form-checklist-item.is-yesno.is-indented { padding-left: 64px; }
.tcl-item.is-yesno .tcl-item-text { padding: 10px 0; }
/* The Y and N boxes sit level with the item's name line, like a checkbox
   item's box (top 10px pad + 1px margin), and each cell stays the full row
   height as the tap target. Beats the `.tcl-item label` /
   `.form-checklist-item label` defaults (flex-start, 10px 12px padding). */
.tcl-yn-cell,
.form-checklist-yn-cell,
.tcl-item.is-yesno label.tcl-yn-cell,
.form-checklist-item.is-yesno label.form-checklist-yn-cell {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    min-height: 44px;
    padding: 10px 0 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tcl-yn-head > span,
.form-checklist-yn-head > span { align-self: end; }
.tcl-item.is-no .tcl-item-name { text-decoration: none; color: #9a3412; }
.tcl-item label,
.form-checklist-item label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    cursor: pointer;
}
.tcl-item.is-indented label,
.form-checklist-item.is-indented label { padding-left: 30px; }
.tcl-item input[type="checkbox"],
.form-checklist-item input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 1px 0 0;
    flex: 0 0 auto;
    accent-color: var(--color-accent);
    cursor: pointer;
}
.tcl-item input[type="checkbox"]:disabled,
.form-checklist-item input[type="checkbox"]:disabled { cursor: default; }
.tcl-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.tcl-item-by { color: var(--cl-muted); font-size: 11px; }
.tcl-item.is-checked .tcl-item-name { color: var(--cl-muted); text-decoration: line-through; }
.tcl-foot { flex-wrap: wrap; }
.tcl-foot select {
    flex: 1 1 180px;
    min-width: 0;
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font: inherit;
    font-size: 16px;
}
.tcl-foot button { min-height: 44px; }
.tcl-foot-note { flex: 1 1 100%; margin: 0; color: var(--cl-muted); font-size: 12px; }


/* ---- Checklist field in a form ------------------------------------------ */
.form-checklist { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-checklist-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.form-checklist-count { color: var(--cl-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.form-checklist-items { border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.form-checklist-item + .form-checklist-item,
.form-checklist-heading + .form-checklist-item { border-top: 1px solid #ececea; }
.form-checklist-item label { font-size: 14px; }
.form-checklist-item.is-yesno { font-size: 14px; color: var(--color-text); }
.form-checklist-item.is-yesno .form-checklist-name { padding: 10px 0; overflow-wrap: anywhere; }
.form-checklist-missing { color: var(--cl-muted); font-size: 13px; font-style: italic; }

/* ---- Checklist Log -------------------------------------------------------- */
.cl-log-filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
.cl-log-filters { min-width: 0; }
.cl-log-filters label { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; color: var(--cl-muted); }
.cl-log-filters select,
.cl-log-filters input {
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 16px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.cl-log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cl-log-empty { color: var(--cl-muted); font-size: 14px; padding: 12px 2px; }
.cl-log-entry details { border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.cl-log-entry summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 44px;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
}
.cl-log-entry summary::-webkit-details-marker { display: none; }
.cl-log-entry summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.cl-log-entry details[open] summary { border-bottom: 1px solid #ececea; }
.cl-log-title { display: flex; align-items: center; gap: 8px; font-size: 15px; overflow-wrap: anywhere; }
.cl-log-no-count { flex: 0 0 auto; white-space: nowrap; padding: 1px 7px; border-radius: 999px; background: #ffedd5; color: #9a3412; font-size: 11px; font-weight: 700; }
.cl-log-task { font-size: 13px; color: var(--color-text); overflow-wrap: anywhere; }
.cl-log-meta { font-size: 12px; color: var(--cl-muted); }
.cl-log-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; padding: 10px 12px; font-size: 13px; }
.cl-log-facts dt { color: var(--cl-muted); }
.cl-log-facts dd { margin: 0; overflow-wrap: anywhere; }
.cl-log-items { list-style: none; margin: 0; padding: 0 12px 10px; font-size: 14px; }
.cl-log-heading { padding: 8px 0 2px; color: #5b21b6; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.cl-log-item { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; border-top: 1px solid #f1f0ee; overflow-wrap: anywhere; }
.cl-log-item.is-indented { padding-left: 18px; }
.cl-log-answer {
    flex: 0 0 auto;
    min-width: 24px;
    padding: 1px 0;
    border-radius: 4px;
    background: #ecece8;
    color: var(--cl-muted);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.cl-log-answer.is-yes { background: #d1fae5; color: #065f46; }
.cl-log-answer.is-no { background: #ffedd5; color: #9a3412; }
.cl-log-more { display: flex; justify-content: center; }
.cl-log-more button { min-height: 44px; min-width: 160px; }

/* ---- Wider screens ------------------------------------------------------ */
@media (min-width: 640px) {
    .cl-page-head { flex-direction: row; align-items: center; justify-content: space-between; }
    .cl-page-actions { display: flex; }
    .cl-log-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .dialog.cl-editor-dialog,
    .dialog.task-checklists-dialog {
        width: min(92vw, 560px);
        max-width: 560px;
        height: min(86vh, 760px);
        max-height: 86vh;
        margin: auto;
        border: 1px solid var(--color-border);
        border-radius: 10px;
    }
    .cl-add { flex-direction: row; align-items: flex-end; }
    .cl-add-buttons { display: flex; flex: 0 0 auto; }
}

/* Form Builder: the note under a Checklist field's picker. */
.form-settings-note { margin: 0; color: var(--color-muted); font-size: 12px; line-height: 1.4; }

/* ---- Checklist window: compact ----------------------------------------
   The checklist editor uses smaller fields, buttons and text than the rest
   of the checklist screens, so more of a long list fits on a phone. Text in
   the fields is 14px: the page's viewport (maximum-scale=1) already stops
   iOS from zooming in on a field under 16px. Scoped to the editor; the
   task's checklist window keeps its larger answer rows. */
.cl-editor-dialog .cl-editor-head { padding: 6px 10px; }
.cl-editor-dialog .cl-editor-head h2 { font-size: 15px; }
.cl-editor-dialog .cl-icon-btn { width: 30px; height: 30px; font-size: 15px; }
.cl-editor-dialog .cl-name-field,
.cl-editor-dialog .cl-add-field { gap: 2px; font-size: 12px; }
.cl-editor-dialog .cl-name-field { padding: 6px 10px 4px; }
.cl-editor-dialog .cl-instructions-field { padding-top: 0; }
.cl-editor-dialog .cl-name-field input,
.cl-editor-dialog .cl-add input,
.cl-editor-dialog .cl-entry-name,
.cl-editor-dialog .cl-type-row select {
    min-height: 32px;
    padding: 4px 8px;
    font-size: 14px;
}
.cl-editor-dialog .cl-instructions-field textarea { min-height: 44px; padding: 4px 8px; font-size: 14px; }
.cl-editor-dialog .cl-entries { gap: 4px; padding: 4px 10px 8px; }
.cl-editor-dialog .cl-entry { gap: 4px; padding: 3px; }
.cl-editor-dialog .cl-entry.is-indented { margin-left: 16px; }
.cl-editor-dialog .cl-entries.is-selecting .cl-entry { grid-template-columns: 22px auto minmax(0, 1fr) auto auto; }
.cl-editor-dialog .cl-entry-select { width: 22px; min-height: 30px; }
.cl-editor-dialog .cl-entry-select input { width: 18px; height: 18px; }
.cl-editor-dialog .cl-entry-move { gap: 3px; }
.cl-editor-dialog .cl-entry-spacer { width: 30px; }
.cl-editor-dialog .cl-entry-tag,
.cl-editor-dialog .cl-entry-type { font-size: 10px; }
.cl-editor-dialog .cl-entries-empty { font-size: 13px; padding: 8px 2px; }
.cl-editor-dialog .cl-add { gap: 4px; padding: 6px 10px; }
.cl-editor-dialog .cl-add-buttons { gap: 4px; }
.cl-editor-dialog .cl-add-buttons button { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.cl-editor-dialog .cl-options-controls button,
.cl-editor-dialog .cl-options-foot button { min-height: 32px; min-width: 72px; padding: 4px 12px; font-size: 13px; }
.cl-editor-dialog .cl-options { gap: 8px; padding: 8px 10px 10px; }
.cl-editor-dialog .cl-options h3 { font-size: 12px; }
.cl-editor-dialog .cl-options-grid { column-gap: 8px; row-gap: 6px; }
.cl-editor-dialog .cl-options-label { font-size: 12px; }
.cl-editor-dialog .cl-options-note { font-size: 11px; }
.cl-editor-dialog .cl-require-field { gap: 8px; min-height: 0; padding: 6px 8px; font-size: 13px; }
.cl-editor-dialog .cl-require-field input { width: 18px; height: 18px; }
.cl-editor-dialog .cl-require-field small { font-size: 11px; }
.cl-editor-dialog .cl-editor-foot { gap: 6px; padding: 6px 10px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.cl-editor-dialog .cl-editor-foot button { min-height: 32px; min-width: 70px; padding: 4px 12px; font-size: 14px; }
.cl-editor-dialog .cl-editor-count { font-size: 12px; }
/* app.css forces 16px on every field on touch screens (!important) as an
   iOS zoom guard; the viewport's maximum-scale=1 already does that job, so
   the checklist window takes its 14px fields back there too. */
@media (hover: none) and (pointer: coarse) {
    .cl-editor-dialog input,
    .cl-editor-dialog select,
    .cl-editor-dialog textarea { font-size: 14px !important; }
}

/* ---- Save / Submit / Approve, files (v476) -------------------------------- */
.tcl-file-dialog,
.task-plan { --cl-muted: #6b6560; }
.tcl-approval-badge {
    flex: 0 0 auto;
    padding: 2px 7px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 11px;
    font-weight: 700;
}
.tcl-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #ececea; }
.form-checklist-files:empty { display: none; }
.form-checklist-files .tcl-files { padding: 0 0 6px; border-bottom: 0; }
.tcl-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-accent);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tcl-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tcl-file:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
@media (hover: hover) { .tcl-file:hover { background: var(--color-bg); } }

.tcl-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #ececea;
    background: var(--color-bg);
    border-radius: 0 0 var(--radius) var(--radius);
}
.form-checklist-record .tcl-actions { margin-top: 6px; border: 1px solid var(--color-border); border-radius: var(--radius); }
.form-checklist-record:empty { display: none; }
.tcl-status { flex: 1 1 200px; margin: 0; font-size: 13px; color: var(--color-text); }
.tcl-status.is-submitted { color: #92400e; }
.tcl-status.is-approved { color: #065f46; font-weight: 600; }
.tcl-action-buttons { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.tcl-action-buttons button { min-height: 40px; min-width: 88px; }
.tcl-dirty { color: #92400e; font-size: 12px; font-weight: 600; }
.tcl-list.is-submitted,
.form-checklist.is-locked .form-checklist-items { background: #fffbeb; }
.tcl-list.is-approved { background: #f0fdf4; }

/* The in-app file viewer. */
.dialog.tcl-file-dialog {
    width: min(960px, 100vw);
    max-width: 100vw;
    height: min(90dvh, 100dvh);
    max-height: 100dvh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dialog.tcl-file-dialog:not([open]) { display: none; }
.tcl-file-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--color-border); }
.tcl-file-head h2 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcl-file-body { flex: 1 1 auto; min-height: 0; overflow: auto; background: #f4f4f2; display: flex; align-items: flex-start; justify-content: center; }
.tcl-file-image { max-width: 100%; height: auto; display: block; margin: auto; }
.tcl-file-frame { width: 100%; height: 100%; min-height: 60dvh; border: 0; background: #fff; }
.tcl-file-video { max-width: 100%; max-height: 100%; margin: auto; }
.tcl-file-text { width: 100%; margin: 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; background: #fff; }
.tcl-file-other { margin: auto; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Editor: files. */
.cl-file-list { grid-column: 1 / -1; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cl-file-list[hidden] { display: none; }
.cl-file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 13px;
}
.cl-file-item.is-pending { border-style: dashed; }
.cl-file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-file-tag { flex: 0 0 auto; color: var(--cl-muted); font-size: 11px; }
.cl-editor-dialog .cl-file-item .cl-icon-btn { width: 28px; height: 28px; min-height: 28px; font-size: 14px; }

/* ---- Task dropdown: Add File and Add Task Plan -------------------------- */
.task-plan { position: relative; }
/* Same size as the Info / DDB / Well Test buttons below them. */
.file-pick-row .detail-add-file-btn,
.file-pick-row .task-plan-btn { min-height: 0; font-size: 13px; padding: 4px 10px; white-space: nowrap; }
.task-plan-btn { display: inline-flex; align-items: center; gap: 6px; }
.task-plan-count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--color-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.task-plan-count[hidden] { display: none; }
.task-plan-caret { font-size: 10px; }
.task-plan-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 40;
    width: min(320px, calc(100vw - 32px));
    max-height: min(60vh, 360px);
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
}
.task-plan-menu[hidden] { display: none; }
.task-plan-hint,
.task-plan-empty { margin: 0 0 6px; color: var(--cl-muted); font-size: 12px; }
.task-plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.task-plan-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    min-height: 40px;
    padding: 4px 6px;
    border-radius: var(--radius);
    cursor: pointer;
}
.task-plan-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-accent); grid-row: span 2; }
.task-plan-name { font-size: 14px; color: var(--color-text); overflow-wrap: anywhere; }
.task-plan-meta { grid-column: 2; color: var(--cl-muted); font-size: 11px; }
@media (hover: hover) { .task-plan-option:hover { background: var(--color-bg); } }
.task-plan-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--color-border); }
.task-plan-open { width: 100%; min-height: 36px; }
.task-plan-open-count { font-weight: 700; font-variant-numeric: tabular-nums; }
