/* --- The board editor (031): the board is the editor. Top bar (who, the
   one field, status, Preview), groups left, the real board center, the
   word card right only while a word is selected. Calm by default. --- */
#editor { display: none; }
body.editor #topbar, body.editor #strip, body.editor #coachbar,
body.editor #groupgrid, body.editor #kb,
body.editor > #grid { display: none !important; } /* home when a group shows */
body.editor #editor { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 10px; }

/* Top bar */
#ed-head { display: flex; align-items: center; gap: 14px; min-height: 52px; }
.ed-gear {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.ed-gear:hover { border-color: var(--muted); }
.ed-gear svg { width: 24px; height: 24px; }
.ed-who { position: relative; flex: none; }
.ed-person {
  border: none; background: none; padding: 6px 8px; border-radius: 10px;
  font-family: var(--word-font); font-weight: 700; font-size: 20px; color: var(--ink-text);
}
.ed-person:not(:disabled):hover { background: var(--tray); }
.ed-person:disabled { cursor: default; }
.ed-person .caret { color: var(--muted); font-size: 14px; }
.ed-pop:not([hidden]), .ed-gmenu {
  position: absolute; z-index: 30; min-width: 200px;
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(30, 26, 20, 0.16);
}
.ed-pop:not([hidden]) { top: 100%; left: 0; margin-top: 4px; }
.ed-pop button, .ed-gmenu button {
  border: none; background: none; text-align: left; padding: 11px 16px;
  font-size: 16px; font-weight: 700; color: var(--ink);
}
.ed-pop button:hover, .ed-gmenu button:hover { background: var(--tray); }
.ed-pop button.on::after { content: " ✓"; }
.ed-gmenu button.danger { color: #c62828; }

.ed-find { position: relative; flex: 1; max-width: 680px; }
#ed-q {
  width: 100%; height: 46px; padding: 0 44px 0 16px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 18px; color: var(--ink-text);
}
#ed-q:focus { outline: none; border-color: var(--ink-text); }
.ed-kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font: 700 13px/1 -apple-system, sans-serif; color: var(--muted);
  border: 1.5px solid var(--line); border-radius: 6px; padding: 3px 7px; pointer-events: none;
}
#ed-q:focus + .ed-kbd { display: none; }
.ed-drop:not([hidden]) {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(70vh, 620px); overflow-y: auto; padding: 8px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  box-shadow: 0 14px 36px rgba(30, 26, 20, 0.18);
  display: flex; flex-direction: column; gap: 4px;
}
.ed-dhead {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin: 8px 8px 2px;
}
.ed-dhead:first-child { margin-top: 2px; }
.ed-dempty { color: var(--muted); padding: 10px; }
.ed-drow {
  display: flex; align-items: center; gap: 12px; padding: 6px 8px;
  border-radius: 10px; border: 2px solid transparent; cursor: pointer;
}
.ed-drow:hover { background: var(--cream); }
.ed-drow.hi { border-color: var(--ink-text); }
.ed-drow .pic, .ed-wrow .pic {
  width: 42px; height: 42px; flex: none; border-radius: 8px;
  border: 3px solid var(--rb, var(--edge)); background: var(--rf, #fff);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-family: var(--word-font); font-weight: 700; font-size: 18px; color: var(--ink-text);
}
.ed-drow .pic img, .ed-wrow .pic img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.ed-drow .pic.photo img, .ed-wrow .pic.photo img { object-fit: cover; }
.ed-drow .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ed-drow .lb { font-family: var(--word-font); font-weight: 700; font-size: 17px; color: var(--ink-text); }
.ed-drow .sub, .ed-wrow .sub {
  font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ed-act {
  flex: none; border: 2px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 5px 12px; font-size: 14px; font-weight: 700;
}
.ed-act:hover { border-color: var(--muted); }
.ed-drow.hi .ed-act.primary { background: var(--ink); border-color: var(--ink); color: var(--cream); }

.ed-status { font-size: 14px; color: var(--muted); white-space: nowrap; margin-left: auto; }
.ed-status[data-tone="ok"] { color: #2e7d32; }
.ed-status[data-tone="warn"] { color: #a15c00; }
.ed-preview, .ed-exit { width: auto; padding: 9px 16px; font-size: 15px; flex: none; }

/* Main area */
#ed-main {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 250px minmax(0, 1fr) auto; gap: 16px;
}
#ed-left { min-height: 0; overflow-y: auto; padding-right: 4px; }
.ed-groups { display: flex; flex-direction: column; gap: 1px; }
.ed-groups hr { border: none; border-top: 2px solid var(--tray); margin: 8px 4px; }
.ed-grow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; border-radius: 10px; padding: 5px 8px;
  text-align: left; color: var(--ink-text);
}
.ed-grow:hover { background: rgba(0, 0, 0, 0.04); }
.ed-grow.on { background: var(--tray); }
.ed-grow.on .ed-gname { font-weight: 700; }
.ed-grow.drop { box-shadow: inset 0 0 0 2px var(--ink-text); }
.ed-grow .glyph {
  width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--tray);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-family: var(--word-font); font-weight: 700; font-size: 15px; color: var(--ink);
}
.ed-grow.on .glyph { background: #fff; }
.ed-grow .glyph img { width: 100%; height: 100%; object-fit: cover; }
.ed-grow .glyph img.gicon { width: 72%; height: 72%; object-fit: contain; }
.ed-grow .glyph.main { font-size: 18px; }
.ed-gname { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-gcount { font-size: 13px; color: var(--muted); }
.ed-gitem { position: relative; display: flex; align-items: center; }
.ed-gitem .ed-grow { flex: 1; min-width: 0; }
.ed-gmore {
  position: absolute; right: 4px; width: 28px; height: 28px; border-radius: 8px;
  border: none; background: var(--cream); color: var(--ink); font-weight: 700;
  opacity: 0;
}
.ed-gitem:hover .ed-gmore, .ed-gmore:focus-visible { opacity: 1; }
.ed-gitem:hover .ed-gcount { visibility: hidden; }
.ed-gmenu { top: 100%; right: 0; margin-top: 2px; }
.ed-icons {
  position: absolute; z-index: 30; top: 100%; left: 0; right: 0; margin-top: 2px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(30, 26, 20, 0.16);
}
.ed-icons button { aspect-ratio: 1; border: none; border-radius: 8px; background: var(--cream); padding: 4px; }
.ed-icons button:hover { background: var(--tray); }
.ed-icons img { width: 100%; height: 100%; object-fit: contain; }
.ed-rename {
  width: 100%; margin: 2px 0; padding: 7px 10px; font-size: 15px;
  border: 2px solid var(--ink-text); border-radius: 10px;
}
.ed-gsec summary {
  list-style: none; cursor: pointer; padding: 8px 8px 4px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.ed-gsec summary::-webkit-details-marker { display: none; }
.ed-gsec summary::before { content: "▸ "; }
.ed-gsec[open] summary::before { content: "▾ "; }
.ed-newgroup .ed-gname { color: var(--ink); font-weight: 700; }
.ed-newgroup .glyph { background: #fff; border: 2px dashed var(--line); }

#ed-mid { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
.ed-crumbbar { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.ed-crumb { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--ink-text); }
.ed-crumb .linkbtn { font-weight: 400; color: var(--muted); }
.ed-crumb .sep { color: var(--muted); }
.ed-navbtn { display: none; }
.ed-pager { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.ed-pager button {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line);
  background: #fff; color: var(--ink); font-size: 18px;
}
.ed-hello:not([hidden]) {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px;
  font-size: 15px; color: var(--ink-text);
}
.ed-x { margin-left: auto; border: none; background: none; color: var(--muted); font-size: 16px; }
.ed-selbar:not([hidden]) {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--ink); color: var(--cream); border-radius: 12px; padding: 8px 14px; font-weight: 700;
}
.ed-selbar .linkbtn { color: var(--cream); }
.ed-selmove select { margin-left: 6px; font: inherit; font-size: 14px; border-radius: 8px; padding: 3px 6px; }

.ed-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ed-stage > #grid, #ed-grid { flex: 1; min-height: 0; }
#ed-grid { display: grid; gap: var(--gap, 8px); align-content: stretch; }
#ed-grid .gcell { min-height: 0; height: auto; }

/* Calm board: no ✕ (Delete or the card removes), faint empties that
   show "+" on hover, reserved main-board cells dimmed, one selection ring. */
body.editor #ed-stage .x { display: none; }
body.editor #ed-stage .empty:not(.reserved) {
  border-color: transparent; background: rgba(0, 0, 0, 0.025);
  position: relative; display: flex; align-items: center; justify-content: center;
}
body.editor #ed-stage .empty:not(.reserved):hover {
  border: 2px dashed var(--line); background: #fff; cursor: pointer;
}
body.editor #ed-stage .empty:not(.reserved):hover::after {
  content: "+"; font-size: 28px; font-weight: 700; color: var(--muted);
}
body.editor #ed-stage .reserved { opacity: 0.42; }
body.editor #ed-stage .sel {
  box-shadow: 0 0 0 3px var(--cream), 0 0 0 7px var(--ink-text); z-index: 2;
}
body.editor.dragover #ed-stage { outline: 3px dashed var(--ink); outline-offset: 4px; border-radius: 14px; }

/* All words */
.ed-words:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.ed-wordsbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
#ed-wq { flex: 1; min-width: 220px; height: 40px; padding: 0 12px; border: 2px solid var(--line); border-radius: 10px; font-size: 16px; }
.ed-wlist { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ed-wrow {
  display: grid; grid-template-columns: 42px minmax(120px, 1fr) minmax(120px, 1.4fr) 120px auto;
  align-items: center; gap: 12px; padding: 5px 8px; border-radius: 10px; cursor: pointer;
}
.ed-wrow:hover { background: rgba(0, 0, 0, 0.04); }
.ed-wrow.sel { background: var(--tray); }
.ed-wrow .lb { font-family: var(--word-font); font-weight: 700; font-size: 16px; }
.ed-voice { font-size: 13px; color: var(--muted); }

/* The card: only while a word is selected. */
#ed-right { width: 380px; min-height: 0; overflow-y: auto; }
#ed-right:not(:has(#wordcard.open)) { display: none; }
body.editor #ed-right > .overlay { position: static; background: none; z-index: 0; }
body.editor #ed-right > .overlay.open { display: flex; }
body.editor #ed-right .sheet {
  width: auto; max-height: none; padding: 16px; gap: 14px;
  border: 2px solid var(--line); border-radius: 16px;
}
body.editor #toast { z-index: 60; }

/* Preview: the child's board, one tap back. */
.ed-previewbar:not([hidden]) {
  position: fixed; z-index: 70; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 2px solid var(--ink-text); border-radius: 999px;
  padding: 6px 6px 6px 18px; box-shadow: 0 10px 28px rgba(30, 26, 20, 0.22);
  font-size: 15px; white-space: nowrap;
}
.ed-previewbar .btn { width: auto; padding: 8px 16px; font-size: 15px; border-radius: 999px; }

/* Paste a list (029 § 5) shares these preview rows. */
#bulk-paste {
  min-height: 140px; resize: vertical;
  font: inherit; font-size: 15px;
  border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.ed-prow { display: flex; align-items: center; gap: 8px; }
.ed-prow .tag {
  font-size: 12px; font-weight: 700; border-radius: 6px;
  padding: 1px 8px; border: 1.5px solid var(--edge);
  background: var(--tray); color: var(--neutral-text); flex: none;
}
.ed-prow .tag.new { border-style: dashed; }
.ed-prow .tag.already { color: var(--muted); }
.ed-prow.over { text-decoration: line-through; color: var(--muted); }

/* Narrow screens (031 G): groups become a drawer, the card a bottom
   sheet — same actions. */
.ed-scrim:not([hidden]) { position: fixed; inset: 0; z-index: 44; background: rgba(30, 26, 20, 0.35); }
@media (max-width: 960px) {
  #ed-head { flex-wrap: wrap; gap: 8px 12px; }
  .ed-find { order: 5; flex-basis: 100%; max-width: none; }
  #ed-main { grid-template-columns: minmax(0, 1fr); }
  .ed-navbtn {
    display: inline-flex; border: 2px solid var(--line); background: #fff; border-radius: 999px;
    padding: 5px 12px; font-weight: 700; font-size: 14px; color: var(--ink);
  }
  #ed-left {
    position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: min(300px, 84vw);
    background: var(--cream); padding: 16px 10px; box-shadow: 8px 0 28px rgba(30, 26, 20, 0.2);
    transform: translateX(-105%); transition: transform 0.2s ease;
  }
  body.ed-drawer #ed-left { transform: none; }
  #ed-right {
    position: fixed; z-index: 46; left: 0; right: 0; bottom: 0; width: auto; max-height: 74vh;
    border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(30, 26, 20, 0.22); background: #fff;
  }
  body.editor #ed-right > .overlay.open { display: block; }
  body.editor #ed-right .sheet {
    border: none; border-radius: 18px 18px 0 0; width: 100%; max-width: 680px; margin: 0 auto;
  }
  .ed-wrow { grid-template-columns: 42px 1fr auto; }
  .ed-wrow .sub, .ed-voice { display: none; }
}
@media (prefers-reduced-motion: reduce) { #ed-left { transition: none; } }
#ed-wtabs button { white-space: nowrap; }
