/* Owner-controlled layout; source order and all care controls remain mounted. */
.kn-layout-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.kn-layout-tools p {
  flex-basis: 100%;
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}
.kn-layout-tools button,
.kn-layout-controls button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--fieldline);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  padding: 8px;
}
.kn-layout-tools button:focus-visible,
.kn-layout-controls button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.kn-live-canvas {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 16px;
}
.kn-layout-free {
  position: relative;
}
.kn-layout-free > .kn-layout-item {
  position: absolute !important;
  margin: 0 !important;
  min-width: 0;
  overflow: auto;
  box-sizing: border-box;
}
.kn-layout-controls {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  position: sticky;
  top: 0;
  z-index: 2;
}
.kn-layout-editing .kn-layout-controls {
  display: flex;
}
.kn-layout-controls button[data-layout-move],
.kn-layout-controls button[data-layout-resize] {
  touch-action: none;
  cursor: move;
}
.kn-layout-controls button[data-layout-resize] {
  cursor: nwse-resize;
}
.kn-layout-item:focus-within {
  z-index: 3;
}
.kn-layout-active {
  z-index: 4;
  outline: 2px solid var(--blue);
}
@media (max-width: 600px) {
  .kn-layout-tools {
    margin: 12px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .kn-layout-item {
    scroll-behavior: auto;
  }
}

.kn-layout-archived {
  display: none !important;
}
#kn-layout-saved {
  flex-basis: 100%;
  min-width: 0;
}
#kn-layout-saved > summary {
  min-height: 44px;
  padding: 8px;
  cursor: pointer;
}
#kn-layout-saved-list > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
#kn-layout-saved-list > div > span {
  flex: 1 1 160px;
}
.kn-layout-tools {
  max-width: 540px;
  width: calc(100% - 32px);
  margin: 16px auto;
}
.kn-layout-tools p {
  font-size: 16px;
  line-height: 1.4;
}
.kn-layout-controls button[data-layout-move]::before {
  content: '\283F  ';
  font-weight: 700;
}
.kn-layout-editing > .kn-layout-item {
  outline: 2px dashed var(--blue);
  outline-offset: 2px;
}

/* Compact per-card bar: Move grip, Resize, More. The fine steps live in the More sheet. */
.kn-layout-controls button {
  min-height: 48px;
  font-size: 1rem;
  white-space: nowrap;
}
.kn-layout-controls > button {
  flex: 1 1 0;
  min-width: 0;
}
.kn-layout-more {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 4px;
}
.kn-layout-more[hidden] {
  display: none;
}
.kn-layout-more button {
  min-height: 48px;
  white-space: normal;
  line-height: 1.2;
}
.kn-layout-more .kn-layout-remove {
  grid-column: 1 / -1;
  border-color: var(--blue);
  font-weight: 700;
}
.kn-layout-controls button[aria-expanded='true'] {
  background: var(--navy);
  color: #fff;
}
.kn-layout-controls button[data-layout-more]::after {
  content: ' \25BE';
}
/* Drag from anywhere on the card while unlocked. Locked cards keep normal page scrolling. */
.kn-layout-editing > .kn-layout-item {
  touch-action: none;
  cursor: grab;
}
.kn-layout-editing > .kn-layout-item a,
.kn-layout-editing > .kn-layout-item button,
.kn-layout-editing > .kn-layout-item summary,
.kn-layout-editing > .kn-layout-item input,
.kn-layout-editing > .kn-layout-item select {
  cursor: pointer;
}
.kn-layout-editing > .kn-layout-item.kn-layout-lifted {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 18px 40px rgba(23, 23, 25, 0.3);
  transform: scale(1.015);
  outline: 3px solid var(--blue);
}
@media (prefers-reduced-motion: reduce) {
  .kn-layout-editing > .kn-layout-item.kn-layout-lifted {
    transform: none;
  }
}
