/* 63_draft.css - KP Equipment editor release. B0 scaffold: empty on purpose (Fable fills it in wave 5). */

/* ---- F9b: the "Discarded on this device" list inside the Changes menu (#dft-discarded-host, built by 63_draft_ui.js).
   Every rule is scoped to the host, so the unsaved-changes bar (a later slice) can style the same dft-* names
   (.dft-list, .dft-item, .dft-note, .dft-btn, .dft-group-title) without a clash in either direction.
   An entry can be restored once. Hooks for a used entry (not written by the JS yet): li.dft-item.is-used, with the
   button either left out and span.dft-item-state "Already restored" in its place, or kept with aria-disabled="true". ---- */
.dft-discarded-host { margin-top: var(--sp-2); padding: var(--sp-3) var(--sp-2) var(--sp-1); border-top: 1px solid var(--line); }
.dft-discarded-host[hidden] { display: none; }
.dft-discarded-host .dft-discarded { margin: 0; padding: 0; }
.dft-discarded-host .dft-group-title { margin: 0 0 var(--sp-2); padding: 0; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.35; }
.dft-discarded-host .dft-discarded-result:empty { display: none; }
/* the result of a Restore: the words carry the meaning, the edge colour only backs them up */
.dft-discarded-host .dft-note { margin: 0 0 var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-left: 4px solid var(--success); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--ink); font-size: 14px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.dft-discarded-host .dft-note.is-partial { border-left-color: var(--warning); }
.dft-discarded-host .dft-note.is-refused { border-left-color: var(--danger); }
.dft-discarded-host .dft-skipped { margin: 0 0 var(--sp-2); padding: 0 0 0 var(--sp-5); color: var(--ink-soft); font-size: 13px; line-height: 1.4; }
.dft-discarded-host .dft-skipped-item { margin: 0; padding: 2px 0; overflow-wrap: anywhere; }
.dft-discarded-host .dft-list { order: 0; flex: none; list-style: none; max-height: none; margin: 0; padding: 0; overflow: visible; border: 0; font-size: 14px; }
.dft-discarded-host .dft-item { display: flex; align-items: center; gap: var(--sp-3); margin: 0; padding: var(--sp-1) 0; border-top: 1px solid var(--line); }
.dft-discarded-host .dft-item:first-child { border-top: 0; }
.dft-discarded-host .dft-item-text { flex: 1 1 auto; min-width: 0; color: var(--ink); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.dft-discarded-host .dft-btn { flex: none; box-sizing: border-box; min-width: 88px; min-height: 44px; margin: 0; padding: 0 var(--sp-4); border: 1px solid var(--ink-muted); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.dft-discarded-host .dft-btn:hover { background: var(--surface-alt); }
.dft-discarded-host .dft-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* a Restore that is running, or an entry that was already restored: the button steps back and cannot be mistaken for live */
.dft-discarded-host .dft-btn[aria-disabled="true"] { border-style: dashed; background: transparent; color: var(--ink-muted); opacity: 1; cursor: default; }
.dft-discarded-host .dft-item.is-used .dft-item-text { color: var(--ink-soft); }
.dft-discarded-host .dft-item-state { flex: none; min-width: 88px; color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1.4; text-align: right; }

/* ==== F12b (Fable, 15/11/2026): the unsaved-changes bar (.dft-bar) and its dialogs (.dft-dialog) ====
 * Both are built by 63_draft_ui.js into #dft-host, the last child of <body>. Every rule below starts at .dft-host,
 * .dft-bar or .dft-dialog (the two "keep clear" rules in the phone block are marked), so the F9b block above, scoped
 * to #dft-discarded-host, is not touched in either direction.
 *
 * WHERE THE BAR SITS. On the bottom edge, the same place on every screen.
 *   PC and tablet: a row of its own under the footer line (row 7 of the body.plan-root grid; rows 1-6 belong to the
 *   page). The host is display: contents, so the bar itself is the grid item. The plan's row is the flexible one, so
 *   the plan / the Sheet give up the bar's height at their bottom edge: nothing is pushed down, nothing is covered.
 *   Phone, in Edit: fixed, docked on the tool dock (--editbar-h); with the Sheet open in Edit (G8) the dock is hidden
 *   and the bar sits on the bottom edge of the screen.
 * Why not under the Edit toolbar, as the F0b mock drew it: with the Sheet open in Edit that row is hidden, so a bar
 * at the top either pushes the Sheet down or lies on the Sheet's own bar.
 * Do NOT give the bar a row or a column that another body child already has (kp-bar 1, toolbar 2, editbar 3,
 * plan-main 4, foot 5): those children set only their row, so the grid moves them into a new second column and the
 * plan leaves the screen. Seen in the first F12b proof.
 *
 * KEEP CLEAR (phone only; the PC grid does it by itself). 63_draft_ui.js writes the bar's height to --dft-h on <html>
 * (0px with no bar), so with no bar these two rules give the neighbours' own values:
 *   1. --eb-h (65_editor.css: "keep clear of the edit bar") grows by --dft-h: the plan, the record and the full
 *      record follow by themselves.
 *   2. .sel-bar (66_select.css docks it on --editbar-h) is lifted by the same amount.
 *   Their better home is 65_editor.css and 66_select.css.
 * "Show changes" opens ABOVE the bar as a panel, out of flow, so --dft-h stays slim. The list of what was just saved
 * shows by itself, so it sits inside the bar and covers nothing.
 *
 * DIALOGS. role="dialog" <div>s inside the host (Save N changes?, Leave Edit, Discard changes): fixed, centred, above
 * everything. The scrim is the dialog's own shadow; ::before is a clear full-screen layer that takes the presses
 * outside the card. The leave and discard steps carry no title element, so their aria-label is shown as the title
 * (::after). If 63_draft_ui.js gains a real .dft-dialog-title there, delete that one rule. ==== */
.dft-host { display: contents; }

/* ---- the bar ---- */
.dft-bar {
  --dft-c: var(--brand); --dft-bg: transparent; --dft-lift: 0 -4px 12px rgba(15,23,42,.07);
  grid-row: 7; grid-column: 1; position: relative; z-index: 26;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-4);
  box-sizing: border-box; min-width: 0; margin: 0; padding: var(--sp-1) var(--sp-4) var(--sp-1) calc(var(--sp-4) + 4px);
  border-top: 1px solid var(--line); box-shadow: inset 4px 0 0 var(--dft-c), var(--dft-lift);
  background: linear-gradient(var(--dft-bg), var(--dft-bg)), var(--surface); color: var(--ink); font-size: 15px; line-height: 1.4;
}
.dft-bar[hidden] { display: none; }
[data-theme="dark"] .dft-bar { --dft-lift: 0 -4px 12px rgba(0,0,0,.4); }
/* the state: the words say it, the icon shape repeats it, the colour only backs them up */
.dft-bar:is([data-state="saving"], [data-state="unconfirmed"]) { --dft-c: var(--info); }
.dft-bar[data-state="saved"] { --dft-c: var(--success-fg); --dft-bg: var(--success-bg); }
.dft-bar:is([data-state="offline"], [data-state="toomany"], [data-state="busy"], [data-state="waiting"]) { --dft-c: var(--warning-fg); --dft-bg: var(--warning-bg); }
.dft-bar:is([data-state="refused"], [data-state="conflict"], [data-state="discard"]) { --dft-c: var(--danger-fg); --dft-bg: var(--danger-bg); }
.dft-bar p, .dft-dialog p { margin: 0; }
.dft-bar .dft-main { display: flex; align-items: center; gap: var(--sp-1) var(--sp-2); flex: 1 1 300px; min-width: 0; min-height: 44px; }
.dft-bar .dft-msg { position: relative; flex: 0 1 auto; min-width: 0; max-width: 78ch; padding-left: 26px; }
.dft-bar .dft-text { font-weight: 600; overflow-wrap: anywhere; }
.dft-bar .dft-why { margin-top: 2px; overflow-wrap: anywhere; }
.dft-bar .dft-sub { margin-top: 2px; color: var(--ink-soft); font-size: 14px; }
/* state icon, drawn in CSS: ring + dot = waiting to be saved; clock = being sent; tick = saved; ! = needs a look */
.dft-bar .dft-ic { position: absolute; left: 0; top: 1px; box-sizing: border-box; width: 18px; height: 18px; border: 2px solid var(--dft-c); border-radius: 50%; }
.dft-bar .dft-ic::before, .dft-bar .dft-ic::after { content: ""; position: absolute; box-sizing: border-box; }
.dft-bar .dft-ic::after { left: 3px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--dft-c); }
.dft-bar:is([data-state="saving"], [data-state="unconfirmed"]) .dft-ic::after { left: 6px; top: 2px; width: 5px; height: 6px; border: solid var(--dft-c); border-width: 0 0 2px 2px; border-radius: 0; background: none; }
.dft-bar[data-state="saved"] .dft-ic::after { left: 4.5px; top: 1.5px; width: 5px; height: 9px; border: solid var(--dft-c); border-width: 0 2px 2px 0; border-radius: 0; background: none; transform: rotate(45deg); }
.dft-bar:is([data-state="offline"], [data-state="toomany"], [data-state="busy"], [data-state="waiting"], [data-state="refused"], [data-state="conflict"], [data-state="discard"]) .dft-ic::after { left: 6px; top: 2.5px; width: 2px; height: 6px; border-radius: 1px; background: var(--dft-c); }
.dft-bar:is([data-state="offline"], [data-state="toomany"], [data-state="busy"], [data-state="waiting"], [data-state="refused"], [data-state="conflict"], [data-state="discard"]) .dft-ic::before { left: 6px; top: 9.5px; width: 2px; height: 2px; border-radius: 50%; background: var(--dft-c); }
/* Show changes / Hide changes / Close: a quiet text button with a full-size target */
.dft-bar .dft-link { flex: none; box-sizing: border-box; min-width: 44px; min-height: 44px; margin: 0; padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; cursor: pointer; }
.dft-bar .dft-link:hover { background: var(--surface-alt); }
.dft-bar .dft-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-left: auto; }

/* ---- buttons, in the bar and in the dialogs: Save is the one filled button; Discard is plain; the last "Discard N
   changes" is red in words, border and ink ---- */
:is(.dft-bar, .dft-dialog) .dft-btn { flex: none; box-sizing: border-box; min-width: 88px; min-height: 44px; margin: 0; padding: 0 var(--sp-4); border: 1px solid var(--ink-muted); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap; cursor: pointer; }
:is(.dft-bar, .dft-dialog) .dft-btn:hover { background: var(--surface-alt); }
:is(.dft-bar, .dft-dialog) .dft-btn-primary { border-color: var(--brand-solid); background: var(--brand-solid); color: var(--acc-ink); }
:is(.dft-bar, .dft-dialog) .dft-btn-primary:hover { border-color: var(--brand-solid-hover); background: var(--brand-solid-hover); }
:is(.dft-bar, .dft-dialog) .dft-btn-danger { border-color: var(--danger-fg); background: linear-gradient(var(--danger-bg), var(--danger-bg)), var(--surface); color: var(--danger-fg); }
:is(.dft-bar, .dft-dialog) .dft-btn-danger:hover { background: linear-gradient(var(--danger-bg), var(--danger-bg)), var(--surface-alt); }
/* a button that cannot be used right now steps back: dashed edge, no fill (not only a paler colour) */
:is(.dft-bar, .dft-dialog) .dft-btn[aria-disabled="true"] { border-style: dashed; border-color: var(--ink-muted); background: transparent; color: var(--ink-muted); cursor: default; }
.dft-bar .dft-btn:focus-visible, .dft-bar .dft-link:focus-visible, .dft-bar .mk-focus:focus, .dft-dialog .dft-btn:focus { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- the list. Show changes (asked for): a panel above the bar. What was just saved (shows by itself): inside the
   bar, under the words, so it never lies on the plan or on the selection bar. ---- */
.dft-bar .dft-list { position: absolute; left: var(--sp-4); bottom: calc(100% + var(--sp-2)); box-sizing: border-box; width: min(560px, calc(100% - 2 * var(--sp-4))); max-height: min(260px, 45dvh); margin: 0; padding: var(--sp-2) var(--sp-4) var(--sp-2) 40px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.4; }
.dft-bar .dft-list:empty { display: none; }
.dft-bar .dft-item { margin: 0; padding: 6px 0 6px 2px; overflow-wrap: anywhere; }
.dft-bar .dft-item + .dft-item { border-top: 1px solid var(--line-soft); }
.dft-bar[data-state="saved"] .dft-list { position: static; flex: 1 1 100%; width: auto; max-height: 92px; margin: 0 0 var(--sp-1); padding: 0 var(--sp-2) 0 50px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.dft-bar[data-state="saved"] .dft-item { padding: 2px 0 2px 2px; border-top: 0; }

/* ---- refused / changed by someone else: the words take the full width, the buttons sit under them ---- */
.dft-bar:is([data-state="refused"], [data-state="conflict"]) { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.dft-bar:is([data-state="refused"], [data-state="conflict"]) .dft-main { flex-basis: 100%; }
.dft-bar:is([data-state="refused"], [data-state="conflict"]) .dft-acts { margin-left: 26px; }
.dft-bar .dft-units { list-style: none; margin: var(--sp-2) 0; padding: 0; }
.dft-bar .dft-unit { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); padding: 3px 0; }
.dft-bar .dft-unit-id { font-family: var(--mono); font-weight: 700; }
.dft-bar .dft-unit-mark { padding: 1px var(--sp-2); border: 1px solid var(--dft-c); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
/* a note inside the bar (e.g. "Removing one change is not ready yet"). The focus ring is for the day the JS moves
   focus to a note (tabindex="-1"); today no .dft-note is focusable. It also covers the notes of the F9b list. */
.dft-bar .dft-note { margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--ink-muted); border-left: 4px solid var(--warning-fg); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.dft-note:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- the dialogs ---- */
.dft-dialog {
  position: fixed; inset: 0; z-index: 1001; display: flex; flex-direction: column; box-sizing: border-box;
  width: min(440px, calc(100vw - 2 * var(--sp-4))); height: fit-content; max-height: calc(100dvh - 2 * var(--sp-4));
  margin: auto; padding: var(--sp-5); overflow: auto; border: 0; border-radius: var(--r-modal);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg), 0 0 0 100vmax var(--scrim);
  font-size: 15px; line-height: 1.4; animation: dft-in var(--dur) var(--ease-out);
}
.dft-dialog::before { content: ""; position: fixed; inset: 0; z-index: -1; }
.dft-dialog:is([data-step="leave"], [data-step="discard"])::after { content: attr(aria-label); order: -1; margin: 0 0 var(--sp-2); font-size: 18px; font-weight: 600; line-height: 1.3; }
.dft-dialog .dft-dialog-title { font-size: 18px; font-weight: 600; line-height: 1.3; }
.dft-dialog .dft-dialog-text { color: var(--ink-soft); }
.dft-dialog .dft-group { margin: var(--sp-4) 0 0; }
.dft-dialog .dft-group-title { margin: 0 0 var(--sp-1); color: var(--ink); font-size: 14px; font-weight: 600; }
.dft-dialog .dft-list { box-sizing: border-box; max-height: min(220px, 30dvh); margin: 0; padding: var(--sp-1) var(--sp-3) var(--sp-1) 36px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--ink); font-size: 14px; }
.dft-dialog .dft-outside { margin-top: var(--sp-3); padding-left: var(--sp-3); list-style: none; border-left: 4px solid var(--warning-fg); }
.dft-dialog .dft-item { margin: 0; padding: 5px 0 5px 2px; overflow-wrap: anywhere; }
.dft-dialog .dft-dialog-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }
@keyframes dft-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dft-dialog { animation: none; } }

/* ---- phone (the neighbours' breakpoint) ---- */
@media screen and (max-width: 700px), screen and (max-height: 500px) and (max-width: 960px) {
  /* --dft-dock = the height of the tool dock under the bar; 0 with the Sheet open in Edit (G8 hides the dock) */
  body.plan-root.is-editing { --dft-dock: var(--editbar-h, calc(72px + env(safe-area-inset-bottom, 0px))); }
  body.plan-root.is-editing.is-sheet { --dft-dock: 0px; }
  body.plan-root.is-editing:not(.is-sheet) { --eb-h: calc(var(--dft-dock, 0px) + var(--dft-h, 0px)); } /* keep clear 1 */
  body.plan-root.is-editing.is-sheet:has(.dft-bar) { --eb-h: var(--dft-h, 0px); } /* keep clear 1, Sheet: only while a bar is there */
  body.plan-root.is-editing .sel-bar { bottom: calc(var(--dft-dock, 0px) + var(--dft-h, 0px)); } /* keep clear 2 */
  body.is-editing .dft-bar { position: fixed; left: 0; right: 0; bottom: var(--dft-dock, 0px); }
  .dft-bar { gap: 6px var(--sp-2); padding: 6px var(--sp-3); box-shadow: inset 0 3px 0 var(--dft-c), var(--dft-lift); font-size: 14px; }
  body.is-sheet .dft-bar, body:not(.is-editing) .dft-bar { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  .dft-bar .dft-main { flex: 1 1 140px; gap: 0 var(--sp-2); }
  .dft-bar .dft-msg { padding-left: 24px; }
  .dft-bar .dft-btn { min-width: 64px; padding: 0 14px; white-space: normal; }
  /* 360 px: the count sits over "Show changes", so the bar is one 44 px row with Save and Discard. The link keeps a
     44 px target; it reaches up behind the count line instead of making the bar taller. */
  .dft-bar:not(:has(.dft-sub, .dft-why, .dft-units)) .dft-main:has(> [data-act="show"]) { flex-direction: column; align-items: flex-start; justify-content: center; }
  .dft-bar:not(:has(.dft-sub, .dft-why, .dft-units)) .dft-main > [data-act="show"] { margin: -14px 0 -6px 16px; }
  /* states with more words: the words first, the buttons under them, as wide as the bar */
  .dft-bar:has(.dft-sub, .dft-why, .dft-units) .dft-main { flex-basis: 100%; }
  .dft-bar:has(.dft-sub, .dft-why, .dft-units) .dft-acts { flex: 1 1 100%; margin-left: 0; }
  .dft-bar:has(.dft-sub, .dft-why, .dft-units) .dft-btn { flex: 1 1 auto; }
  .dft-bar:is([data-state="refused"], [data-state="conflict"]) .dft-btn { flex-basis: 100%; }
  .dft-bar .dft-list { left: 0; bottom: 100%; width: 100%; max-height: min(220px, 38dvh); padding: var(--sp-2) var(--sp-3) var(--sp-2) 36px; border: 0; border-top: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; box-shadow: 0 -8px 24px rgba(15,23,42,.16); }
  .dft-bar[data-state="saved"] .dft-list { max-height: 66px; padding: 0 var(--sp-1) 0 46px; border: 0; border-radius: 0; box-shadow: none; }
  .dft-dialog { padding: var(--sp-4); }
  .dft-dialog .dft-dialog-acts { margin-top: var(--sp-4); }
  .dft-dialog .dft-dialog-acts .dft-btn { flex: 1 1 100%; }
}
@media screen and (max-width: 560px) { body.plan-root.is-editing:not(.is-sheet) { --dft-dock: var(--editbar-h, calc(124px + env(safe-area-inset-bottom, 0px))); } }

/* an unsaved-changes bar and its dialogs never go on paper */
@media print { .dft-bar, .dft-dialog { display: none; } }
