/*
 * editor.css — the tile card and the collection screen (§6.2–6.3).
 *
 * LIGHT, BECAUSE THE THING BEING MADE IS LIGHT. The editor used to be a
 * dark dialog with white islands in it — the blocks, the preview — because
 * the map is dark. But the map is the FRAME, not the subject: what this
 * screen makes is a paper tile with ink on it, and an editor drawn in the
 * colours of its own output is the only one where "what you see" and "what
 * the server draws" are the same statement. The dark canvas stays visible
 * around the sheet, so it is still obvious you are over the map.
 *
 * CRIMSON MEANS EXACTLY ONE THING: this is what the picture on the right is
 * drawn from. The active row, the selected layer, a column a layer binds.
 * It is not the save button (that is ink), not "selected tab" (segments are
 * ink), and not an armed delete (that is signal red, --danger, and only
 * after the first press). Unsaved has a colour of its own — gold — and
 * nothing else in the editor is gold.
 *
 * Tokens come from brand.css. Values are repeated here only where a token
 * does not exist for them (the crimson row tint of an active row).
 */

/* `#vp-edit` is a stacking context of its own (fixed, z-index 5), so the
   panel's own z-index cannot lift it over the crumbs and the marks. While
   the editor is open, the host goes up with it. */
#vp-edit[data-editor] { z-index: 14; }

.vp-editor {
  position: fixed;
  inset: 0;
  /* Over every piece of shell chrome (crumbs and marks at 6, the aiming
     crosshair at 13): while the editor is open it IS the screen. */
  z-index: 14;
  display: flex;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 8, 11, 0.5);
  pointer-events: auto;
  font-family: var(--font-sans);
  color: var(--g-100);
  -webkit-text-size-adjust: 100%;
  /* The shell turns selection off so a long press cannot start a native
     drag. This is the one surface where selecting text is the work. */
  -webkit-user-select: text;
  user-select: text;
}

.vp-ed-panel {
  position: relative;
  width: 100%;
  max-width: 1280px;
  /* A flex item's automatic minimum size beats its max-width, so without
     this the card grows to whatever its widest row wants to be. */
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--g-white);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* A single tile's card is one column and does not want the map's width. */
.vp-ed-panel.is-card { max-width: 560px; align-self: center; max-height: 100%; }

/* ------------------------------------------------------------ the header */

.vp-ed-head {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  min-height: 52px;
  padding: 6px 16px 6px 20px;
  border-bottom: 1px solid var(--g-100);
}

.vp-ed-eyebrow {
  font: 500 11px/14px var(--font-mono);
  letter-spacing: 1.6px;
  color: var(--g-60);
  white-space: nowrap;
}

.vp-ed-name {
  font: 400 20px/28px var(--font-sans);
  color: var(--g-100);
  border: 0;
  border-bottom: 1px dashed var(--g-30);
  background: transparent;
  padding: 0 2px;
  min-width: 80px;
  max-width: 40%;
  width: auto;
  field-sizing: content;
  flex: 0 1 auto;
}

.vp-ed-name:focus { outline: 0; border-bottom-color: var(--g-100); }
.vp-ed-meta { font: 400 12px/16px var(--font-sans); color: var(--g-60); white-space: nowrap; }
.vp-ed-short { display: none; }
.vp-ed-gap { flex: 1; }

.vp-ed-state {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 400 12px/16px var(--font-sans);
  color: var(--g-70);
  white-space: nowrap;
}

.vp-ed-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

/* The armed header: one question, two targets, and no second ✕ anywhere. */
.vp-ed-head.is-armed { background: var(--g-white); }
.vp-ed-ask { font: 400 13px/18px var(--font-sans); color: var(--g-100); }
.vp-ed-head.is-armed .vp-ed-ask { flex: 1; text-align: right; }

/* The bar that runs out under the armed button: 3 s, then the header
   returns. It sits under THAT button, so what is hot is unambiguous. */
.vp-ed-hot { position: relative; display: inline-flex; }

.vp-ed-fuse {
  position: absolute;
  left: 0;
  bottom: -2px;
  height: 2px;
  background: var(--danger);
  animation: vp-ed-burn 3s linear forwards;
}

@keyframes vp-ed-burn { from { width: 100%; } to { width: 0; } }

/* ----------------------------------------------------------- the buttons */

.vp-editor button {
  font: 400 13px/16px var(--font-sans);
  color: var(--g-100);
  background: var(--g-white);
  border: 1px solid var(--g-30);
  border-radius: 0;
  height: 32px;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}

.vp-editor button:hover { background: var(--g-10); }
.vp-editor button:disabled { color: var(--g-40); cursor: default; background: var(--g-white); }
.vp-editor button.is-ink { background: var(--g-100); border-color: var(--g-100); color: var(--g-white); font-weight: 500; padding: 0 16px; }
.vp-editor button.is-ink:hover { background: #000; }
.vp-editor button.is-ink:disabled { background: var(--g-20); border-color: var(--g-20); color: var(--g-50); }
.vp-editor button.is-quiet { border-color: transparent; background: transparent; color: var(--g-60); }
.vp-editor button.is-quiet:hover { color: var(--g-100); background: var(--g-10); }
.vp-editor button.is-danger { border-color: var(--danger); color: var(--danger); background: var(--g-white); }
.vp-editor button.is-danger:hover { background: var(--danger); color: var(--g-white); }
.vp-editor button.is-danger.is-solid { background: var(--danger); color: var(--g-white); }
.vp-editor button.is-danger.is-solid:hover { background: #b81922; border-color: #b81922; }
.vp-editor button.is-small { height: 28px; padding: 0 10px; font-size: 12px; }
.vp-editor button.is-tiny { height: 24px; padding: 0 8px; font-size: 12px; }
.vp-editor button.is-icon { width: 26px; padding: 0; }

/* ------------------------------------------------------------- the body  */

.vp-ed-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 488px;
  grid-template-areas: "left right";
  min-width: 0;
  min-height: 0;
}

.vp-ed-panel.is-card .vp-ed-body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "right"; }

.vp-ed-left {
  grid-area: left;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 0;
  border-right: 1px solid var(--g-20);
}

.vp-ed-right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  background: var(--paper);
}

/* A section bar: mono eyebrow, a sentence of why, then its own controls. */
.vp-ed-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--g-20);
}

.vp-ed-left > .vp-ed-bar { padding-left: 20px; }
.vp-ed-bar h3 { margin: 0; font: 500 11px/14px var(--font-mono); letter-spacing: 1.6px; color: var(--g-100); white-space: nowrap; }
.vp-ed-bar p { margin: 0; font: 400 12px/16px var(--font-sans); color: var(--g-60); min-width: 0; }
.vp-ed-bar .vp-ed-gap { flex: 1; }

/* -------------------------------------------------------------- the table */

.vp-ed-rows { overflow: auto; min-height: 0; padding-left: 4px; }
.vp-ed-rows table { border-collapse: collapse; width: 100%; font: 400 13px/18px var(--font-sans); }
.vp-ed-rows th { text-align: left; vertical-align: bottom; border-bottom: 1px solid var(--g-100); padding: 0; position: sticky; top: 0; background: var(--g-white); z-index: 2; }
.vp-ed-rows th.is-bound { background: var(--crimson-soft); }
.vp-ed-rows th.is-gutter { width: 16px; padding: 0; }
.vp-ed-rows th.is-end { width: 1%; }

.vp-editor .vp-ed-colhead {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px 6px;
  cursor: pointer;
  white-space: normal;
}
.vp-editor .vp-ed-colhead:hover { background: rgba(0, 0, 0, 0.04); }
.vp-editor .vp-ed-colhead b { font-weight: 600; }
.vp-editor .vp-ed-colhead em { font-style: normal; font: 500 11px/14px var(--font-mono); }
.vp-editor .vp-ed-colhead small { display: block; font: 400 10px/14px var(--font-mono); letter-spacing: 1px; color: var(--g-60); }
.vp-ed-rows th.is-bound .vp-ed-colhead small { color: var(--crimson); }

.vp-ed-rows td { padding: 0; border-bottom: 1px solid var(--g-20); }
.vp-ed-rows td.is-gutter { width: 16px; background: transparent; }
.vp-ed-rows tr.is-on td { background: #fdf7f7; }
.vp-ed-rows tr.is-on td.is-gutter { background: var(--crimson); }
.vp-ed-rows tr.is-armed td { background: var(--g-10); color: var(--g-60); }
.vp-ed-rows tr.is-armed input { text-decoration: line-through; color: var(--g-60); }

.vp-ed-rows td input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 8px 11px;
  box-sizing: border-box;
}

.vp-ed-rows td input:focus { outline: 0; border-color: var(--g-100); background: var(--g-white); }
.vp-ed-rows td.is-num input { font-variant-numeric: tabular-nums; }
.vp-ed-rows tr.is-on td.is-first input { font-weight: 500; }
.vp-ed-rows td.is-end { text-align: right; padding-right: 8px; white-space: nowrap; }
.vp-ed-ghost td { color: var(--g-60); }
.vp-ed-ghost td { padding: 0; }
.vp-ed-ghost > td > button { border-color: transparent; background: transparent; color: var(--g-60); padding-left: 12px; }
.vp-ed-ghost .vp-ed-blank { margin: 12px; }
.vp-ed-ghost button:hover { color: var(--g-100); }

/* Every menu is one popover, placed in viewport coordinates from where it
   was opened — an absolute one would be clipped by the table's own scroll
   box, which is where the column menu has to appear. */
.vp-ed-menu { display: inline-flex; }
.vp-ed-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vp-editor label.is-check { display: inline-flex; align-items: center; gap: 6px; font: 400 12px/16px var(--font-sans); }

.vp-ed-pop {
  position: fixed;
  z-index: 12;
  min-width: 232px;
  padding: 10px 12px 0;
  background: var(--g-white);
  border: 1px solid var(--g-100);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font: 400 13px/18px var(--font-sans);
  text-align: left;
}

.vp-ed-pop.is-right { transform: translateX(-100%); margin-left: 26px; }
.vp-ed-pop label { display: block; font: 400 10px/14px var(--font-mono); letter-spacing: 1px; color: var(--g-60); margin-bottom: 3px; }
.vp-ed-pop input[type="text"] { width: 100%; box-sizing: border-box; height: 30px; padding: 0 8px; border: 1px solid var(--g-30); background: var(--g-white); font: 400 13px/18px var(--font-sans); color: var(--g-100); }
.vp-ed-pop hr { border: 0; border-top: 1px solid var(--g-20); margin: 10px -12px 0; }
.vp-ed-pop .vp-ed-row { display: flex; margin: 0 -12px; }
.vp-ed-pop .vp-ed-row button { flex: 1; height: 34px; border: 0; border-top: 1px solid var(--g-20); justify-content: flex-start; text-align: left; }
.vp-ed-pop menu { margin: 0 -12px; padding: 0; list-style: none; }
.vp-ed-pop menu button { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--g-20); height: 34px; }
.vp-ed-pop menu button.is-warn { color: var(--danger); }
.vp-ed-pop .vp-ed-note { font: 400 11px/15px var(--font-sans); color: var(--g-60); padding: 6px 0 10px; }

/* Segments: the enum with German values, ink for the chosen one. */
.vp-ed-seg { display: flex; border: 1px solid var(--g-30); height: 28px; }
.vp-ed-seg button { flex: 1; height: 100%; border: 0; padding: 0 6px; font-size: 11px; background: var(--g-white); }
.vp-ed-seg button.is-on { background: var(--g-100); color: var(--g-white); }
.vp-ed-seg.is-wrap { display: grid; grid-template-columns: repeat(3, 1fr); height: auto; }
.vp-ed-seg.is-wrap button { height: 30px; border-top: 1px solid var(--g-30); }
.vp-ed-seg.is-wrap button:nth-child(-n+3) { border-top: 0; }

/* --------------------------------------------- the collection's own cover */

.vp-ed-owncover {
  border-top: 1px solid var(--g-100);
  padding: 12px 16px 12px 20px;
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr);
  gap: 16px;
}

.vp-editor .vp-ed-thumb2 { width: 144px; height: 144px; background: var(--paper); box-shadow: 0 0 0 1px var(--g-30); padding: 0; border: 0; cursor: pointer; }
.vp-editor .vp-ed-thumb2 svg { display: block; width: 100%; height: 100%; }
.vp-editor .vp-ed-thumb2.is-on { box-shadow: 0 0 0 2px var(--crimson); }
.vp-ed-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.vp-ed-side .vp-ed-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.vp-ed-side small, .vp-ed-hint { font: 400 12px/16px var(--font-sans); color: var(--g-60); }

.vp-ed-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.vp-ed-chips button { height: 26px; padding: 0 10px; font-size: 12px; }
.vp-ed-chips button.is-on { border-color: var(--crimson); border-width: 1.5px; color: var(--crimson); }

.vp-editor select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--g-30);
  border-radius: 0;
  background: var(--g-white);
  font: 400 12px/16px var(--font-sans);
  color: var(--g-100);
}

/* ------------------------------------------------------------ the address */

.vp-ed-addr { border-top: 1px solid var(--g-20); padding: 8px 16px 8px 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vp-ed-addr input { flex: 1 1 260px; min-width: 160px; border: 0; background: transparent; font: 400 12px/16px var(--font-mono); color: var(--g-100); padding: 0; }

/* -------------------------------------------------------- the layer stage */

.vp-ed-stagerow { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 12px; padding: 12px 16px 8px; }
.vp-ed-stagebox { display: flex; flex-direction: column; gap: 6px; }

.vp-ed-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--g-white);
  box-shadow: 0 0 0 1px var(--g-30);
  overflow: hidden;
  touch-action: none;
}

.vp-ed-stage svg { display: block; width: 100%; height: 100%; }

/* The 30 px the map's rounded corner cuts into, drawn so it is not guessed. */
.vp-ed-safe { position: absolute; inset: 5.86%; border: 1px dashed rgba(64, 77, 82, 0.35); pointer-events: none; }
.vp-ed-selbox { fill: none; stroke: var(--crimson); stroke-width: 3; }
.vp-ed-empty rect { fill: none; stroke: rgba(64, 77, 82, 0.35); stroke-dasharray: 8 6; }

.vp-ed-tag {
  position: absolute;
  padding: 1px 6px;
  background: var(--crimson);
  color: var(--g-white);
  font: 500 9px/14px var(--font-mono);
  letter-spacing: 0.6px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-100%);
}

.vp-ed-scale { font: 400 11px/14px var(--font-sans); color: var(--g-60); display: flex; gap: 8px; }
.vp-ed-scale .vp-ed-gap { flex: 1; }

/* What the server draws for this tile today, under an empty canvas: the
   uploaded photograph, or the card it generates from the title. Without it
   "no layers" looked like "no cover", which is not what the map shows. */
.vp-ed-served-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.vp-ed-shot { display: block; width: 120px; height: 120px; object-fit: cover; box-shadow: 0 0 0 1px var(--g-30); }

/* An empty cover is not a black square with a paragraph in it. */
.vp-ed-none {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font: 400 12px/17px var(--font-sans);
  color: var(--g-60);
}

.vp-ed-none button { pointer-events: auto; }
/* Over a picture the words need a ground of their own. */
.vp-ed-none.is-over { background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(1px); }

/* -------------------------------------------------------- the layer list  */

.vp-ed-layers { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vp-ed-layers > .vp-ed-row { display: flex; gap: 4px; }
.vp-ed-layers > .vp-ed-row > * { flex: 1; }
.vp-ed-layers > .vp-ed-row .vp-ed-menu > summary { width: 100%; }
.vp-ed-cap { font: 400 10px/14px var(--font-mono); letter-spacing: 1px; color: var(--g-60); padding: 2px 0; }

.vp-editor .vp-ed-layer {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  background: var(--g-white);
  border: 1px solid var(--g-20);
  font: 400 12px/16px var(--font-sans);
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

.vp-editor .vp-ed-layer.is-on { border: 1.5px solid var(--crimson); font-weight: 500; padding-right: 78px; }
.vp-editor .vp-ed-layer i { font: 500 9px/12px var(--font-mono); color: var(--g-60); width: 22px; font-style: normal; flex: 0 0 22px; }
.vp-editor .vp-ed-layer.is-on i { color: var(--crimson); }
.vp-editor .vp-ed-layer span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-editor .vp-ed-layer em { font-style: normal; color: var(--crimson); font-weight: 400; }
.vp-ed-layerbox { position: relative; }
.vp-ed-layerbox .vp-ed-ctl { position: absolute; right: 2px; top: 2px; display: flex; gap: 2px; }
.vp-ed-ctl button { width: 24px; height: 24px; padding: 0; border-color: transparent; background: transparent; color: var(--g-70); font-size: 12px; }
.vp-ed-ctl button:hover { background: var(--g-10); }

/* ------------------------------------------------------- layer properties */

.vp-ed-props {
  margin: 0 16px;
  padding: 10px 12px 12px;
  background: var(--g-white);
  border: 1px solid var(--g-20);
  border-top: 2px solid var(--crimson);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vp-ed-props.is-idle { border-top-color: var(--g-30); }
.vp-ed-props > h4 { margin: 0; display: flex; align-items: baseline; gap: 8px; font: 500 11px/14px var(--font-mono); letter-spacing: 1.6px; color: var(--crimson); }
.vp-ed-props.is-idle > h4 { color: var(--g-60); }
.vp-ed-props > h4 span { font: 400 12px/16px var(--font-sans); letter-spacing: 0; color: var(--g-60); }
.vp-ed-grid { display: grid; gap: 8px; align-items: end; }
.vp-ed-grid label { display: flex; flex-direction: column; gap: 3px; font: 400 10px/12px var(--font-mono); letter-spacing: 0.8px; color: var(--g-60); min-width: 0; }
.vp-ed-grid label.is-check { flex-direction: row; align-items: center; gap: 6px; height: 28px; font: 400 12px/16px var(--font-sans); letter-spacing: 0; color: var(--g-100); }

.vp-ed-grid input[type="text"],
.vp-ed-grid input[type="number"] {
  height: 28px;
  box-sizing: border-box;
  border: 1px solid var(--g-30);
  border-radius: 0;
  background: var(--g-white);
  padding: 0 6px;
  font: 400 12px/16px var(--font-sans);
  color: var(--g-100);
  width: 100%;
  min-width: 0;
}

.vp-ed-grid input[type="range"] { width: 100%; accent-color: var(--g-100); }
.vp-ed-hex { display: flex; align-items: center; gap: 6px; height: 28px; border: 1px solid var(--g-30); padding: 0 6px; font: 400 11px/16px var(--font-mono); }
.vp-ed-hex input[type="color"] { width: 16px; height: 16px; padding: 0; border: 0; background: none; flex: 0 0 16px; }
.vp-ed-hex input[type="text"] { border: 0; height: 26px; padding: 0; }

/* A bound text layer says so where the text would be. */
.vp-ed-bind { display: flex; align-items: center; height: 28px; border: 1px solid var(--g-30); padding: 0 6px; gap: 6px; background: var(--g-white); min-width: 0; }
.vp-ed-bind select { border: 0; height: 26px; padding: 0; background: transparent; font: 500 11px/16px var(--font-mono); color: var(--crimson); }
.vp-ed-bind select.is-free { color: var(--g-60); font-family: var(--font-sans); font-weight: 400; font-size: 12px; }
.vp-ed-bind input[type="text"] { flex: 1; border: 0; height: 26px; padding: 0; min-width: 40px; }

/* --------------------------------------------------------- title + content */

.vp-ed-titlerow { display: flex; align-items: center; gap: 10px; padding: 10px 16px 8px; }
.vp-ed-titlerow h3 { margin: 0; font: 500 11px/14px var(--font-mono); letter-spacing: 1.6px; white-space: nowrap; }
.vp-ed-titlerow input { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--g-30); background: var(--g-white); padding: 0 8px; font: 400 12px/16px var(--font-sans); color: var(--g-100); }
.vp-ed-titlerow small { font: 400 12px/16px var(--font-sans); color: var(--g-60); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.vp-ed-doc { margin: 0 16px 16px; background: var(--g-white); border: 1px solid var(--g-30); display: flex; flex-direction: column; min-height: 0; }
.vp-ed-doc .vp-ed-bar { padding: 8px 12px; }
.vp-ed-page { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 12px; min-height: 160px; }
.vp-ed-page textarea { width: 100%; box-sizing: border-box; min-height: 180px; border: 1px solid var(--g-20); padding: 8px; font: 400 12px/18px var(--font-mono); color: var(--g-100); resize: vertical; }
.vp-ed-page input[type="url"] { width: 100%; box-sizing: border-box; height: 32px; border: 1px solid var(--g-30); padding: 0 8px; font: 400 13px/18px var(--font-sans); }

.vp-ed-block { position: relative; padding: 4px 8px; margin: 0 -8px; border-left: 2px solid transparent; }
.vp-ed-block.is-on { border-left-color: var(--crimson); }
.vp-ed-block > .vp-ed-ctl { position: absolute; right: 0; top: -20px; display: none; gap: 2px; }
.vp-ed-block:hover > .vp-ed-ctl, .vp-ed-block.is-on > .vp-ed-ctl { display: flex; }
.vp-ed-block > .vp-ed-ctl button { width: auto; height: 20px; padding: 0 6px; font-size: 11px; border-color: var(--g-30); background: var(--g-white); }
.vp-ed-kind { font: 400 10px/14px var(--font-mono); letter-spacing: 1px; color: var(--g-60); margin-bottom: 4px; }
.vp-ed-bb { font: 400 14px/20px var(--font-sans); color: var(--g-80); outline: 0; }
.vp-ed-bb h1 { margin: 0; font: 600 22px/26px var(--font-sans); color: var(--g-100); }
.vp-ed-bb h2 { margin: 0; font: 600 16px/22px var(--font-sans); color: var(--g-100); }
.vp-ed-bb p { margin: 0 0 4px; }
.vp-ed-bb .lead { color: var(--g-80); }
.vp-ed-bb ul { margin: 0; padding-left: 18px; }
.vp-ed-bb blockquote { margin: 0; padding-left: 10px; border-left: 2px solid var(--g-30); font-style: italic; }
.vp-ed-bb hr { border: 0; border-top: 1px solid var(--g-30); }
.vp-ed-bb [data-slot]:empty::before { content: attr(data-ph); color: var(--g-40); }
.vp-ed-bb .imgbox { background: var(--g-10); min-height: 80px; display: flex; align-items: center; justify-content: center; color: var(--g-50); font-size: 12px; }
.vp-ed-bb .imgbox img { max-width: 100%; display: block; }
.vp-phx { background: var(--crimson-soft); color: var(--crimson); font: 500 12px/18px var(--font-mono); padding: 0 4px; }
.vp-ed-bb h1 .vp-phx { font-size: 15px; line-height: 20px; }

/* The server drawing the document, which is the only truth for raw HTML. */
.vp-ed-served { border-top: 1px solid var(--g-20); padding: 12px 16px; font: 400 13px/19px var(--font-sans); color: var(--g-80); background: var(--paper); }
.vp-ed-served > .vp-ed-cap { margin-bottom: 6px; }

/* An empty state is a sentence and a way out of it, not a black square. */
.vp-ed-blank { border: 1px dashed var(--g-30); padding: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font: 400 12px/17px var(--font-sans); color: var(--g-60); }
.vp-ed-blank p { margin: 0; flex: 1; min-width: 120px; }

/* The import form, opened above the rows it is about to add to. */
.vp-ed-import { display: flex; flex-direction: column; gap: 6px; margin: 12px 16px; padding: 10px 12px; background: var(--paper); border: 1px solid var(--g-30); }
.vp-ed-import textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--g-30); padding: 6px 8px; font: 400 12px/17px var(--font-mono); resize: vertical; }
.vp-ed-import input[type="file"] { font: 400 12px/16px var(--font-sans); max-width: 210px; }

/* ---------------------------------------------------------- the gallery   */

.vp-ed-gallery { grid-column: 1 / -1; margin: 0 0 8px; padding: 12px; background: var(--paper); border: 1px solid var(--g-30); }
.vp-ed-gallery > .vp-ed-bar { padding: 0 0 10px; border-bottom: 0; }
.vp-ed-grid-tpl { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 340px; overflow: auto; }
.vp-ed-grid-tpl button { display: block; width: 100%; height: auto; padding: 0; border: 1px solid var(--g-30); background: var(--g-white); }
.vp-ed-grid-tpl button:hover { border-color: var(--g-100); }
.vp-ed-grid-tpl svg { display: block; width: 100%; aspect-ratio: 1; }
.vp-ed-grid-tpl span { display: block; padding: 5px 6px; font: 400 12px/16px var(--font-sans); color: var(--g-100); text-align: left; border-top: 1px solid var(--g-20); }

/* Applying a template replaces everything, so it is offered back for 8 s. */
.vp-ed-undo { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--g-100); color: var(--g-white); font: 400 12px/16px var(--font-sans); }
.vp-ed-undo .vp-ed-gap { flex: 1; }
.vp-ed-undo button { height: 26px; }

/* ------------------------------------------------------------- the picker */

.vp-ed-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; max-height: 300px; overflow: auto; padding: 12px 16px; }
.vp-editor .vp-ed-thumb { aspect-ratio: 1; height: auto; padding: 0; border: 1px solid var(--g-20); background: var(--g-10) center / cover no-repeat; }
.vp-ed-upload { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.vp-ed-upload input[type="file"] { font: 400 12px/16px var(--font-sans); }

/* --------------------------------------------------------------- the say  */

.vp-ed-say {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  background: var(--g-100);
  color: var(--g-white);
  font: 400 12px/16px var(--font-sans);
  z-index: 8;
}

/* -------------------------------------------------------------- the phone */
/*
 * One screen, same order: the tile stays at the top and shrinks as you
 * scroll past it, so what is being drawn is never out of sight. Everything
 * below it is a full-width row, and every target is at least 44 px.
 */
@media (max-width: 760px) {
  .vp-editor { padding: 0; }
  .vp-ed-panel, .vp-ed-panel.is-card { max-width: none; max-height: none; }
  /* Two rows on purpose: the name, then the four targets right-aligned at
     44 px. One row only fits by shrinking them under the thumb. */
  .vp-ed-head { flex-wrap: wrap; justify-content: flex-end; gap: 6px 8px; padding: 8px 12px; }
  .vp-ed-head > .vp-ed-gap { flex-basis: 100%; height: 0; }
  .vp-ed-eyebrow, .vp-ed-meta { display: none; }
  .vp-ed-long { display: none; }
  .vp-ed-short { display: inline; }
  .vp-ed-name { font-size: 17px; max-width: 100%; flex: 1 1 auto; }
  .vp-ed-state span { display: none; }
  .vp-editor button { height: 44px; padding: 0 10px; }
  .vp-editor button.is-small, .vp-editor button.is-tiny { height: 44px; }
  .vp-editor button.is-icon { width: 44px; }
  .vp-editor button.is-ink { padding: 0 12px; }
  .vp-editor .vp-ed-layer { height: 44px; }
  .vp-editor .vp-ed-colhead { height: auto; }
  .vp-ed-titlerow small { display: none; }

  /* One scroller, everything in it as tall as it is. A grid split the panel
     in half whatever the content was and drew the table straight over the
     template. The right column dissolves into `display: contents` so the
     tile's containing block is the SCROLLER — otherwise it unsticks the
     moment the column it lives in scrolls off, which is exactly when it is
     wanted. DOM order is already template-then-table. */
  .vp-ed-body { display: flex; flex-direction: column; overflow: auto; background: var(--paper); }
  .vp-ed-right { display: contents; }
  .vp-ed-body > *, .vp-ed-right > * { flex: 0 0 auto; }
  .vp-ed-left { grid-template-rows: none; border-right: 0; display: block; background: var(--g-white); }
  .vp-ed-rows { overflow: visible; padding: 0 12px; }

  /* The tile stays at the top under the row stepper and shrinks to a chip
     as you scroll past it; the layer list goes with it, so what is pinned
     is one strip and not a third of the screen. Tapping the chip scrolls
     the sheet back to it. */
  .vp-ed-right > .vp-ed-bar { position: sticky; top: 0; z-index: 4; background: var(--paper); }
  .vp-ed-stagerow { grid-template-columns: 200px minmax(0, 1fr); gap: 10px; position: sticky; top: 44px; z-index: 3; background: var(--paper); padding: 8px 12px; box-shadow: 0 1px 0 var(--g-20); transition: grid-template-columns 140ms ease; }
  .vp-ed-stagerow.is-small { grid-template-columns: 72px minmax(0, 1fr); }
  .vp-ed-stagerow.is-small .vp-ed-stage { cursor: zoom-in; }
  .vp-ed-stagerow.is-small .vp-ed-layers { display: none; }
  .vp-ed-scale { display: none; }
  .vp-ed-props, .vp-ed-doc { margin: 0 12px 12px; }
  .vp-ed-gallery { grid-column: 1 / -1; }

  /* The table becomes cards: the first column large, the rest one line. */
  .vp-ed-rows table, .vp-ed-rows tbody, .vp-ed-rows tr, .vp-ed-rows td { display: block; }
  .vp-ed-rows thead { display: none; }
  .vp-ed-rows tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; border: 1px solid var(--g-20); margin-bottom: 8px; padding: 6px 10px; }
  .vp-ed-rows tr.is-on { border-left: 3px solid var(--crimson); }
  .vp-ed-rows td { border: 0; }
  .vp-ed-rows td.is-gutter { display: none; }
  .vp-ed-rows td.is-first { flex: 1 0 100%; }
  .vp-ed-rows td.is-first input { font: 600 15px/22px var(--font-sans); }
  .vp-ed-rows td input { padding: 4px 2px; width: auto; max-width: 100%; min-width: 3ch; field-sizing: content; }
  .vp-ed-rows td.is-first input { width: 100%; }
  .vp-ed-rows td.is-num { margin-left: auto; }
  .vp-ed-rows td.is-end { flex: 1 0 100%; text-align: left; padding: 0; }
  .vp-ed-rows .vp-ed-ghost { border: 0; padding: 0; }

  .vp-ed-owncover { grid-template-columns: 96px minmax(0, 1fr); padding: 12px; gap: 12px; border-top: 1px solid var(--g-20); }
  .vp-editor .vp-ed-thumb2 { width: 96px; height: 96px; }
  .vp-ed-addr { padding: 12px; }
  .vp-ed-pop { position: fixed; left: 12px; right: 12px; top: 20%; min-width: 0; }
}
