/* Release 2.1 cell editing (John 2:29 PM JST). Kirby's kirby-premium/cell-edit/cell-edit.css, verbatim below the
   app glue at the end of this file. Desktop: anchored popover (.ce-pop). Phone: bottom sheet (.ce-sheet). */

/* ---- editable cell states (desktop table and phone table cells) ---- */
.ce-cell { position: relative; border-radius: 6px; }
.ce-cell[data-editable="true"] { cursor: pointer; }
@media (hover: hover) and (min-width: 900px) {
  .ce-cell[data-editable="true"]:hover { background: var(--hover); box-shadow: inset 0 0 0 1px var(--hairline-strong); }
  .ce-cell[data-editable="true"]:hover::after, .ce-cell[data-editable="true"]:focus-visible::after {
    content: ''; position: absolute; right: 6px; top: 50%; width: 14px; height: 14px; margin-top: -7px; background: var(--text-3);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat; }
}
.ce-cell[data-editable="true"]:focus-visible { outline: none; box-shadow: var(--focus); }   /* magenta focus ring */
.ce-cell[aria-expanded="true"], .ce-cell.ce-active { background: var(--hover); box-shadow: inset 0 0 0 1px var(--text-3); }
.ce-cell.ce-saving { opacity: .6; }
.ce-cell.ce-error { box-shadow: inset 0 0 0 1px var(--danger); }
.ce-cell[data-editable="false"] { cursor: default; }                                   /* view-only: no hover, no chevron */

/* ---- popover (desktop) ---- */
.ce-pop { position: absolute; z-index: 60; width: 280px; max-height: 360px; display: flex; flex-direction: column; background: var(--panel); color: var(--text); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; font: var(--type-body-sm); }
.ce-pop.wide { width: 300px; }
.ce-search { padding: 2px 2px 6px; }
.ce-search input { width: 100%; height: 32px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--input-bg); color: var(--text); padding: 0 10px; font: var(--type-field-sm); }
.ce-search input:focus, .ce-search input:focus-visible { outline: none; box-shadow: none; border-color: var(--field-focus); } /* r2-13: focus changes only the field's own 1px border */
.ce-list { overflow: auto; margin: 0; padding: 0; list-style: none; }
.ce-group { font: var(--type-overline); letter-spacing: var(--type-track-caps); text-transform: uppercase; color: var(--text-2); padding: 8px 8px 4px; }
.ce-opt { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 8px; border-radius: 8px; cursor: pointer; color: var(--text); }
.ce-opt:hover { background: var(--hover); }
.ce-opt.active { background: var(--selected); }                                         /* keyboard highlight */
.ce-opt[aria-selected="true"]::after { content: ''; margin-left: auto; width: 14px; height: 8px; border: solid var(--text); border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -2px); flex: none; }
.ce-opt .ce-sub { color: var(--text-2); font: var(--type-caption); margin-left: auto; padding-right: 4px; }
.ce-opt[aria-selected="true"] .ce-sub { margin-right: 20px; }
.ce-av { width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--initials-bg); color: var(--initials-ink); font: var(--type-initials-md); text-align: center; }
.ce-av.none { background: transparent; border: 1px dashed var(--hairline-strong); color: var(--text-3); line-height: var(--type-lh-avatar-dashed); } /* 24px box minus the dashed border */
.ce-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dot-grey); }
.ce-opt .chip { height: 20px; line-height: var(--type-lh-pill); }                                     /* solid tag pills from theme.css, same size as in the table */
.ce-create .chip { opacity: .95; }
.ce-foot { border-top: 1px solid var(--hairline); margin: 6px -6px -6px; padding: 4px 6px; display: flex; gap: 4px; }
.ce-foot button { height: 32px; border: 0; background: none; color: var(--text-2); font: var(--type-control); padding: 0 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; }
.ce-foot button:hover { background: var(--hover); color: var(--text); }
.ce-empty { padding: 12px 8px; color: var(--text-2); }
.ce-errbar { background: var(--error-bg); border-left: 3px solid var(--error-border); color: var(--text); margin: 4px 2px; padding: 6px 8px; border-radius: 6px; font: var(--type-caption); }

/* date: quick chips + native input */
.ce-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 8px; }
.ce-chip { height: 30px; padding: 0 12px; border: 1px solid var(--hairline-strong); border-radius: 15px; background: var(--surface); color: var(--text); font: var(--type-chip); white-space: nowrap; }
.ce-chip:hover { background: var(--hover); }
.ce-chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.ce-chip .ce-d { color: var(--text-2); font-weight: var(--type-w-regular); margin-left: 6px; font-variant-numeric: tabular-nums; }
.ce-chip[aria-pressed="true"] .ce-d { color: inherit; opacity: .75; }
.ce-datefield { padding: 4px; display: flex; gap: 8px; align-items: center; }
.ce-datefield input[type=date] { flex: 1; height: 36px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--input-bg); color: var(--text); padding: 0 10px; font: var(--type-field); font-variant-numeric: tabular-nums; }
.ce-datefield input[type=date]:focus, .ce-datefield input[type=date]:focus-visible { outline: none; box-shadow: none; border-color: var(--field-focus); } /* r2-13: focus changes only the field's own 1px border */
.ce-clear { height: 36px; border: 0; background: none; color: var(--text-2); font: var(--type-control); padding: 0 8px; border-radius: 8px; }

/* ---- bottom sheet (phone) ---- */
.ce-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 59; }
[data-theme="dark"] .ce-scrim { background: rgba(0,0,0,.6); }
.ce-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 82dvh; display: flex; flex-direction: column; background: var(--panel); color: var(--text); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-pop); padding-bottom: env(safe-area-inset-bottom); font: var(--type-option-touch); }
.ce-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--hairline-strong); margin: 8px auto 0; flex: none; }
.ce-sheet-head { display: flex; align-items: center; min-height: 52px; padding: 0 4px 0 20px; flex: none; }
.ce-sheet-head h3 { flex: 1; margin: 0; font: var(--type-group); letter-spacing: var(--type-track-caps); text-transform: uppercase; color: var(--text-2); }
.ce-sheet-head .ce-x { width: 44px; height: 44px; border: 0; background: none; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }
.ce-sheet .ce-search { padding: 0 16px 8px; }
.ce-sheet .ce-search input { height: 44px; font: var(--type-field-touch); border-radius: 10px; }
.ce-sheet .ce-list { padding: 0 8px 8px; }
.ce-sheet .ce-opt { min-height: 48px; padding: 0 12px; font: var(--type-option-touch); border-radius: 10px; }
.ce-sheet .ce-opt .chip { height: 22px; font: var(--type-pill-touch); padding: 0 10px; border-radius: 11px; }  /* sheet pills slightly larger for touch */
.ce-sheet .ce-av { width: 32px; height: 32px; font: var(--type-initials-lg); }
.ce-sheet .ce-foot { margin: 0; padding: 6px 12px 10px; }
.ce-sheet .ce-foot button { height: 44px; font: var(--type-control-touch); }
.ce-sheet .ce-chips { padding: 4px 16px 12px; gap: 8px; }
.ce-sheet .ce-chip { height: 44px; border-radius: 22px; padding: 0 16px; font: var(--type-chip-touch); }
.ce-sheet .ce-datefield { padding: 4px 16px 8px; }
.ce-sheet .ce-datefield input[type=date] { height: 48px; font: var(--type-field-touch); border-radius: 10px; }
.ce-sheet .ce-clear { height: 48px; font: var(--type-control-touch); padding: 0 12px; }
.ce-done { margin: 4px 16px 16px; height: 48px; border: 0; border-radius: 10px; background: var(--primary); color: var(--primary-ink); font: var(--type-button); }

/* ---- app glue (r21) ---- */
.ce-pop { overflow: hidden; }
.ce-pop .ce-list { flex: 1 1 auto; min-height: 0; }
.ce-sheet .ce-list { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.ce-opt[hidden], .ce-empty[hidden] { display: none; }
.ce-opt .ce-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-none { color: var(--text-2); }
.ce-create { gap: 8px; }
.ce-list:focus { outline: none; }
.ce-foot button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.ce-sheet-head .ce-x svg { width: 20px; height: 20px; }
.ce-chip, .ce-clear, .ce-done, .ce-x, .ce-foot button { cursor: pointer; }
.ce-chip:focus-visible, .ce-clear:focus-visible, .ce-done:focus-visible, .ce-x:focus-visible, .ce-foot button:focus-visible { outline: none; box-shadow: var(--focus); }
.ce-search input::-webkit-search-cancel-button { cursor: pointer; }
.ce-sheet .ce-chips { flex-wrap: wrap; }
/* the cell keeps the table's layout: the state lives on the cell box itself */
.task > .ce-cell[data-editable="true"]:focus { outline: none; }
.task > .ce-cell[data-editable="true"]:hover::after, .task > .ce-cell[data-editable="true"]:focus-visible::after { z-index: 1; }
/* phone: empty cells show an en dash */
@media (max-width: 899px) {
  main.grid .pt-inner .task > .ce-cell.ce-empty-cell::before { content: '–'; color: var(--text-3); }
  main.grid .pt-inner .task > .ce-cell { border-radius: 0; }
  main.grid .pt-inner .task > .ce-cell.ce-active, main.grid .pt-inner .task > .ce-cell[aria-expanded="true"] { background: var(--hover); box-shadow: inset 0 0 0 1px var(--text-3); border-radius: 6px; }
  main.grid .pt-inner .task > .ce-cell.ce-error { box-shadow: inset 0 0 0 1px var(--danger); }
}
@media (prefers-reduced-motion: reduce) { .ce-sheet, .ce-pop, .ce-scrim { transition: none; animation: none; } }
/* desktop: an empty cell is still a 24px target; 6px inner padding so the outline clears the text (text stays in place) */
@media (min-width: 900px) {
  .grid .task > .ce-cell { min-height: 24px; line-height: var(--type-lh-cell); padding: 0 22px 0 6px; margin-left: -6px; align-self: center; }
  .grid .task > .ce-cell[data-editable="false"] { padding-right: 6px; }
}
/* r21 Notes: one line with an ellipsis; desktop types straight into the cell (no popover, no chevron) */
.task > .ce-cell.c-tnotes { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task > .ce-cell[data-cell="notes"] { cursor: text; }
.task > .ce-cell[data-cell="notes"]::after { display: none !important; }
.task > .ce-cell.ce-editing { padding-right: 6px; overflow: visible; box-shadow: none; }
.ce-inline { width: calc(100% + 6px); height: 24px; margin-left: -6px; border: 1px solid var(--input-border); border-radius: 6px; outline: none; box-shadow: none; background: var(--input-bg); color: var(--text); font: inherit; padding: 0 5px; }
.ce-inline:focus, .ce-inline:focus-visible { outline: none; box-shadow: none; border-color: var(--field-focus); } /* r2-13: focus changes only the field's own 1px border */
.ce-sheet .ce-notes-field { width: 100%; height: 44px; font: var(--type-field-touch); border-radius: 10px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--text); padding: 0 12px; }
.ce-sheet .ce-notes-field:focus, .ce-sheet .ce-notes-field:focus-visible { outline: none; box-shadow: none; border-color: var(--field-focus); } /* r2-13: focus changes only the field's own 1px border */
.ce-text { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
