/* <x-print-editor>: the sheet with its elements on the left, the chosen element on the right. The sheet is always white:
   it is paper, also in the dark theme. It floats a little above a work table of dots (agreed 2026-11-03). */
x-print-editor {
  display: block;
  margin-top: 8px;

  .editor-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
  .editor-tools .button .ic { width: 16px; height: 16px; }

  .editor-main { display: flex; gap: 20px; align-items: flex-start; }

  .stage {
    flex: 1;
    min-width: 0;
    padding: 32px 32px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background-color: var(--zebra);
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1.4px);
    background-size: 18px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    outline: none;
    touch-action: none;
    user-select: none;

    &:focus-visible { border-color: var(--accent); }
  }

  .sheet {
    position: relative;
    flex: none;
    background: #ffffff;
    border-radius: 2px;
    transform: translateY(-3px);
    box-shadow: 0 2px 4px rgba(16, 24, 32, 0.12), 0 14px 32px rgba(16, 24, 32, 0.22);
  }
  .sheet-size { color: var(--fg-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
  .sheet canvas { position: absolute; inset: 0; display: block; }
  .boxes, .guides { position: absolute; inset: 0; }
  .guides { pointer-events: none; }

  /* Every element has a box to grab: a thin dashed line, the chosen one green with a handle. */
  .box {
    position: absolute;
    outline: 1px dashed rgba(86, 98, 110, 0.45);
    cursor: move;
    color: #8a96a2;
    font-size: 12px;
    font-style: italic;
    display: flex;
    align-items: center;
    padding-left: 4px;
    white-space: nowrap;
    overflow: visible;
  }
  .box:hover { outline-color: rgba(35, 120, 74, 0.7); }
  .box.selected { outline: 2px solid #23784a; }
  .handle { position: absolute; width: 12px; height: 12px; border: 2px solid #23784a; border-radius: 2px; background: #ffffff; }
  .handle.side { right: -7px; top: 50%; margin-top: -6px; cursor: ew-resize; }
  .handle.corner { right: -7px; bottom: -7px; cursor: nwse-resize; }
  .handle.bottom { bottom: -7px; left: 50%; margin-left: -6px; cursor: ns-resize; }
  /* A text turned a quarter: it stands upright, so "Lege tekst" does too. */
  .box.upright { writing-mode: vertical-rl; padding-left: 0; padding-top: 4px; }

  .guide { position: absolute; background: #e0398c; }
  .guide.vertical { top: -12px; bottom: -12px; width: 1px; margin-left: -0.5px; }
  .guide.horizontal { left: -12px; right: -12px; height: 1px; margin-top: -0.5px; }

  .inspector { width: 300px; flex: none; display: flex; flex-direction: column; gap: 12px; }
  .inspector-empty, .inspector-note { color: var(--fg-3); font-size: 13px; }
  .inspector-title { font-weight: 600; }
  .inspector-row { display: flex; gap: 10px; align-items: flex-end; }
  .inspector-row .field { flex: 1; min-width: 0; }
  .inspector-row .field.size { flex: none; width: 104px; }
  .with-unit { position: relative; display: block; }
  .with-unit .input { padding-right: 34px; text-align: right; }
  .with-unit .unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--fg-3); font-size: 12px; pointer-events: none; }
  .inspector .button.remove { align-self: flex-start; }
  .inspector .button.remove .ic, .inspector .button.rotate .ic { width: 16px; height: 16px; }
  .inspector-actions { display: flex; gap: 8px; flex-wrap: wrap; }

  .text {
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--input-bg);
    line-height: 20px;
    outline: none;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);

    &:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  }
  .variables { display: flex; flex-direction: column; gap: 8px; }
  .free-row { display: flex; gap: 8px; }
  .free-row .input { flex: 1; min-width: 0; }
  .background-preview { width: 100%; max-height: 110px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius); background: #ffffff; }

  kbd {
    display: inline-block;
    padding: 0 6px;
    margin: 0 1px;
    border-radius: 4px;
    background: var(--muted-soft);
    color: var(--fg);
    font-family: inherit;
    font-size: 0.9em;
    line-height: 1.5;
    user-select: all;
  }
  /* A free variable: the extra field of an import, dashed so it is seen apart from the fixed ones. */
  kbd.free { background: none; border: 1px dashed var(--fg-3); }

  .toggles { display: flex; gap: 4px; }
  .toggle {
    width: 36px;
    height: 40px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--fg-3);
    font-weight: 700;
    display: grid;
    place-items: center;
    transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);

    &:hover { color: var(--fg); border-color: var(--line-strong); }
    &.on { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
    .ic { width: 18px; height: 18px; }
  }
}

/* Narrow: the chosen element under the sheet. */
@media (max-width: 900px) {
  x-print-editor .editor-main { flex-direction: column; align-items: stretch; }
  x-print-editor .inspector { width: auto; }
}
