/* ============================================================================
 * BOX BOX - prompt editor
 *
 * Loaded after style.css and built entirely from its variables. Nothing here
 * introduces a new colour, a new radius or a new type scale: this screen is
 * the reader pane in a different arrangement, not a different app.
 *
 * Every colour is a style.css token, which is also what makes this screen work
 * in both themes without a line of its own: --fail-text on red, --run-ink on
 * orange, --text-2 on a quiet panel. Type set in a status hue uses the -text
 * token, never the fill one. Two deliberate calls:
 *   1. The diff uses --done-tint/--done-ink for added lines and the fail pair
 *      for removed ones. "Jade means landed, red means gone" extends cleanly to
 *      "jade is what arrives, red is what leaves", and diff colour is one of
 *      the few conventions a reader already knows before she opens the screen.
 *      Note it is done and NOT accent: an added line is a settled fact, not a
 *      control, and the accent is only ever a control.
 *   2. The textarea is capped at a readable measure instead of filling a wide
 *      pane, for the same reason the reader is capped at --measure.
 * ==========================================================================*/

/* ------------------------------------------------------------------ shell - */

.pl { min-height: 0; }

.pl-cols {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 316px 1fr;
}

/* -------------------------------------------------------------- the index - */

.pl-index {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  min-height: 0; overflow-y: auto;
  padding: 8px;
}
.pl-rows { display: flex; flex-direction: column; gap: 2px; }

/* .row-item is display:block; a prompt row is three stacked lines. */
.pl-row { display: flex; flex-direction: column; gap: 5px; }
.pl-row .row-title { gap: 8px; }
.pl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* "this one is not what it shipped as" - a word, not an alarm */
.pl-flag {
  flex: none; margin-left: auto;
  font-size: 8.5px; letter-spacing: .14em;
  color: var(--run-text);
  border: 1px solid var(--run-line); border-radius: 3px;
  padding: 2px 5px; line-height: 1;
}

.pl-blurb {
  font-size: 12px; line-height: 1.45; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.pl-meta { font-size: 9.5px; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }

.pl-pad { padding: 14px 10px; }
.pl-pad-btn { margin: 0 10px; }

/* ------------------------------------------------------------- the editor - */

.pl-pane { position: relative; min-height: 0; display: flex; overflow: hidden; }

/* The editor column is the scroller of last resort. With nothing but the text
   in it there is free space and the textarea takes it; once a proposal with a
   long diff is open the column is taller than the pane, and this is what makes
   the bottom of it reachable instead of clipped. */
.pl-edit {
  flex: 1; min-width: 0; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px 24px 16px;
  width: 100%; max-width: 880px;      /* a measure, not a wall of monospace */
}

.pl-edit-head { display: flex; flex-direction: column; gap: 6px; flex: none; }
.pl-edit-top { display: none; }
.pl-h2 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.pl-h2:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 4px; }
.pl-file { font-size: 9.5px; letter-spacing: .14em; color: var(--faint); text-transform: uppercase; }
.pl-blurb-full { line-height: 1.55; }

/* The stakes. One line, accent edge, no shouting. */
.pl-stake {
  border-left: 2px solid var(--accent-line);
  padding: 1px 0 1px 11px;
  font-size: 12.5px; line-height: 1.5; color: var(--text-2);
}
.pl-stake-modal { margin: 12px 0; }

/* ------------------------------------------------------------------ chips - */

.pl-chips { flex: none; display: flex; flex-direction: column; gap: 6px; }
.pl-chips-label { color: var(--faint); }
.pl-chip-list { display: flex; flex-wrap: wrap; gap: 5px; }

.pl-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .06em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--accent-tint); color: var(--accent-text);
  cursor: default; user-select: none;
}
.pl-chip.is-unknown {
  border-style: dashed; border-color: var(--line-2);
  background: none; color: var(--muted);
}
.pl-chip.is-gone {
  border-style: dashed; border-color: var(--fail-line);
  background: var(--fail-tint); color: var(--fail-text);
}
.pl-chip-tag { font-size: 8.5px; letter-spacing: .12em; opacity: .85; }

/* --------------------------------------------------------------- the text - */

.pl-ta {
  /* The floor matters: inside a scrolling column a flex item with an auto
     basis collapses to its two default rows the moment anything overflows. */
  flex: 1 1 auto; min-height: 220px;
  font-family: var(--mono); font-size: 13px; line-height: 1.62;
  padding: 14px 16px; border-radius: var(--radius-lg);
  resize: none; overflow: auto; tab-size: 2;
  white-space: pre-wrap; word-break: break-word;
}

/* ------------------------------------------------------------------- bar - */

.pl-bar { flex: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pl-state { text-transform: uppercase; color: var(--faint); }
.pl-state.is-dirty { color: var(--run-text); }
.pl-counts { color: var(--faint); letter-spacing: .08em; margin-right: auto; }
.pl-bar-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* --------------------------------------------------------------- assistant */

/* No scrollbar of its own: the column above scrolls, the diff inside has its
   own viewport, and a third nested scroller would be one too many. */
.pl-assist {
  flex: none;
  border-top: 1px solid var(--line); padding-top: 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.pl-assist-head { display: flex; align-items: center; gap: 8px; }
.pl-assist-form { display: flex; gap: 6px; }
.pl-assist-input { flex: 1; min-width: 0; }
.pl-assist-hint, .pl-assist-elsewhere {
  font-size: 12px; line-height: 1.5; color: var(--faint);
}
.pl-assist-elsewhere { color: var(--run-text); }

.pl-run { display: flex; flex-direction: column; gap: 8px; }
.pl-run .sectors { margin: 2px 0 0; }
.pl-run-row { display: flex; align-items: center; gap: 10px; }
.pl-run-msg { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.pl-run-detail { font-size: 11.5px; line-height: 1.45; color: var(--faint); }

.pl-proposal { display: flex; flex-direction: column; gap: 10px; }
.pl-proposal-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
/* Sticky, because the diff above it can be long and the two ways out of a
   proposal must never be something she has to go looking for. */
.pl-proposal-acts {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 0 2px; margin-top: -4px;
  background: var(--bg); border-top: 1px solid var(--line);
}
.pl-proposal-acts .btn-primary { margin-left: auto; }
.pl-warn-inline { font-size: 11.5px; color: var(--run-ink); }

/* What the model wanted to say about the request. It goes above its own work
   because it is usually the reason the work is not what she asked for. */
.pl-note {
  background: var(--run-tint); border: 1px solid var(--run-line);
  border-radius: var(--radius); padding: 10px 13px;
  display: flex; flex-direction: column; gap: 4px;
}
.pl-note p { font-size: 13px; line-height: 1.55; color: var(--run-ink); }
/* The kicker inside carries .ulabel.accent from the markup — overruled here
   for the same reason #dock-kind is: this panel is a caveat, not a control. */
.pl-note .ulabel.accent { color: var(--run-text); }

.pl-sum { font-size: 13px; font-weight: 600; color: var(--text); }

/* ----------------------------------------------------------------- issues - */

.pl-issues { border-radius: var(--radius); padding: 11px 13px; display: flex; flex-direction: column; gap: 6px; }
.pl-issues.is-blocking { background: var(--fail-tint); border: 1px solid var(--fail-line); }
.pl-issues.is-warning  { background: var(--run-tint);         border: 1px solid var(--run-line); }
.pl-issues-head { letter-spacing: .16em; }
.pl-issues.is-blocking .pl-issues-head { color: var(--fail-text); }
.pl-issues.is-warning  .pl-issues-head { color: var(--run-text); }
.pl-issue-list { margin: 0 0 0 17px; padding: 0; }
.pl-issue-list li { font-size: 13px; line-height: 1.55; margin: 3px 0; }
.pl-issues.is-blocking .pl-issue-list li { color: var(--fail-text); }
.pl-issues.is-warning  .pl-issue-list li { color: var(--run-ink); }
.pl-issues-foot { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ diff - */

.pl-diff {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); overflow: hidden;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
}
.pl-diff-inline { max-height: 34vh; overflow-y: auto; }
.pl-diff-body { padding: 6px 0; }

.dl { display: flex; padding: 0 10px; }
.dl-n {
  flex: none; width: 46px; padding-right: 12px; text-align: right;
  color: var(--faint); user-select: none; font-variant-numeric: tabular-nums;
}
.dl-g { flex: none; width: 14px; color: var(--faint); user-select: none; }
.dl-t { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.dl-same .dl-t { color: var(--muted); }
.dl-add { background: var(--done-tint); }
.dl-add .dl-g, .dl-add .dl-t { color: var(--done-ink); }   /* --done, lifted for 12px mono sitting on its own tint - 7.5:1 */
.dl-del { background: var(--fail-tint); }
.dl-del .dl-g, .dl-del .dl-t { color: var(--fail-text); }   /* the danger ink style.css already uses */

/* "… 42 unchanged lines" - a real button, because it is one. */
.pl-gap {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: none;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  color: var(--muted); font: inherit; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  padding: 6px 10px 6px 68px; margin: 4px 0; cursor: pointer;
}
.pl-gap::before { content: "⋯ "; color: var(--accent-text); }
.pl-gap:hover { background: var(--surface-2); color: var(--text); }

.pl-diff-more { display: block; width: 100%; margin-top: 8px; }

/* ----------------------------------------------------------------- dialog - */

.pl-modal .pl-card { max-width: 520px; }
.pl-modal .pl-card-wide { max-width: 920px; }
.pl-dlg-body { max-height: min(64vh, 620px); overflow-y: auto; margin-top: 4px; }
/* One scroller per dialog: the body scrolls, the diff inside it does not. */
.pl-modal .pl-diff, .pl-modal .pl-diff-inline { max-height: none; overflow: visible; }
.pl-p { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin-top: 8px; }
.pl-p-strong { color: var(--text); font-weight: 600; }
.pl-dlg-body > .pl-sum { margin-bottom: 12px; }
.pl-dlg-body > .pl-issues { margin-bottom: 12px; }

.pl-versions { display: flex; flex-direction: column; margin-top: 10px; }
.pl-version {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.pl-version:last-child { border-bottom: none; }
.pl-version-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pl-version-when { font-size: 13.5px; }
.pl-version-size { font-size: 10px; letter-spacing: .1em; color: var(--faint); }

/* ------------------------------------------------------------- empty/flash */

.pl-empty {
  margin: auto; max-width: 420px; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 30px;
}
.pl-empty-big { font-size: 16px; font-weight: 700; }

/* Confirmation that something happened, where she is already looking. */
.pl-flash {
  position: absolute; right: 18px; bottom: 16px; z-index: 20;
  max-width: min(420px, calc(100% - 36px));
  background: var(--surface-3); border: 1px solid var(--line-2);
  color: var(--text); font-size: 13px; font-weight: 600;
  padding: 9px 15px; border-radius: 999px; box-shadow: var(--shadow);
}
.pl-flash.is-bad { border-color: var(--fail-line); color: var(--fail-text); }

/* ------------------------------------------------------------- responsive - */

/* One pane at a time. The reader is already sharing the window with the rail
   and the library list, so the split has to fold long before a phone. */
@media (max-width: 1100px) {
  .pl-cols { grid-template-columns: 1fr; }
  .pl-index, .pl-pane { grid-column: 1; grid-row: 1; }
  .pl-index { border-right: none; }
  .pl[data-pl-pane="edit"] .pl-index { display: none; }
  .pl[data-pl-pane="index"] .pl-pane { display: none; }
  .pl-edit-top { display: block; }
  .pl-edit { max-width: none; padding: 16px 18px 14px; }
}

@media (max-width: 720px) {
  .pl-edit { padding: 14px 15px 12px; }
  .pl-ta { font-size: 13.5px; }        /* thumb-sized text beats dense text */
  .pl-ta { min-height: 180px; }
  .pl-bar-acts { width: 100%; }
  .pl-bar-acts .btn { flex: 1; }
  .pl-counts { margin-right: 0; }
  .dl-n { width: 34px; padding-right: 8px; }
  .pl-gap { padding-left: 46px; }
  .pl-flash { left: 12px; right: 12px; bottom: 12px; max-width: none; text-align: center; }
}

/* The one motion this screen owns beyond style.css's own guards. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="on"]) .pl-gap { transition: none; }
}
