/* Page edit tool (editor/ui-editor.js). */
html.uie-loading #app { visibility: hidden; }
/* Closed: a small tab on the left edge, clear of every screen's own controls. */
.uie-tab {
  position: fixed; left: 0; top: 50%; z-index: 50; transform: translateY(-50%); writing-mode: vertical-rl;
  margin: 0; min-width: 0; padding: 10px 5px; border: 1px solid #c9c6b9; border-left: 0; border-radius: 0 6px 6px 0;
  background: #f6f3eae6; color: #1f2420; font: 12px/1 system-ui, sans-serif; letter-spacing: .1em; cursor: pointer; opacity: .75;
}
.uie-tab:hover { opacity: 1; }
.uie-tab[hidden] { display: none; }
.uie-primary { background: #b0344a !important; border-color: #b0344a !important; color: #fff !important; }
.uie-primary:disabled { opacity: .6; }
.uie-link { border: 0 !important; background: none !important; padding: 0 !important; color: #6c7068 !important; text-decoration: underline; justify-self: start; }
.uie-lead { margin: 0; }
.uie-key { display: grid; gap: 6px; }
.uie-key label { display: grid; gap: 4px; color: #6c7068; }
.uie-key input { font: 13px system-ui, sans-serif; padding: 7px 8px; border: 1px solid #c9c6b9; }
.uie-key a { color: #b0344a; }
.uie-tools button:disabled { opacity: .4; cursor: default; }
:root {
  --uie-ink: #1f2420;
  --uie-paper: #f6f3ea;
  --uie-line: #c9c6b9;
  --uie-accent: #b0344a;
  --uie-added: #2f6f8f;
  --uie-muted: #6c7068;
}

.uie-bar {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: grid; gap: 5px; max-width: calc(100vw - 20px); overflow-x: auto;
  padding: 5px; background: var(--uie-paper); border: 1px solid var(--uie-line); box-shadow: 0 4px 16px #1f242018;
  font: 12px/1.2 system-ui, sans-serif; color: var(--uie-ink);
}
.uie-bar[hidden], .uie-layer[hidden], .uie-panel[hidden], .uie-tag[hidden] { display: none !important; }
.uie-bar button, .uie-panel button, .uie-modal button {
  font: inherit; color: var(--uie-ink); background: #fff; border: 1px solid var(--uie-line);
  padding: 6px 10px; white-space: nowrap; cursor: pointer;
}
.uie-bar button:hover, .uie-panel button:hover, .uie-modal button:hover { border-color: var(--uie-ink); }
.uie-toggle { font-weight: 600; }
.uie-toggle[aria-pressed="true"] { background: var(--uie-accent) !important; border-color: var(--uie-accent) !important; color: #fff !important; }
.uie-row { display: flex; gap: 6px; align-items: center; }
.uie-tools, .uie-align { display: none; gap: 6px; align-items: center; }
.uie-on .uie-tools, .uie-on .uie-align { display: flex; }
.uie-align { padding-top: 5px; border-top: 1px solid var(--uie-line); }
.uie-align strong { white-space: nowrap; padding: 0 2px; }
.uie-align .uie-gap { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--uie-line); }
/* Keep reordered parts (z-index, even negative) inside their screen instead of behind the page. */
#title-screen, #martial-screen, #game-screen, #dojo-screen { isolation: isolate; }
.uie-align button { padding: 5px 8px; }
.uie-align button:disabled { opacity: .4; cursor: default; border-color: var(--uie-line); }
.uie-ref { color: var(--uie-muted); white-space: nowrap; padding-left: 4px; }
.uie-check { display: flex; gap: 4px; align-items: center; padding: 0 4px; white-space: nowrap; cursor: pointer; }
.uie-danger { color: var(--uie-accent) !important; }

/* Parts while editing */
.uie-gone { visibility: hidden; }
.uie-on .uie-gone { visibility: visible; opacity: .3; }
.uie-on #title-screen [data-uie], .uie-on #martial-screen [data-uie], .uie-on #game-screen [data-uie], .uie-on #dojo-screen [data-uie] { cursor: move; user-select: none; -webkit-user-select: none; }
.uie-on #title-screen[data-uie], .uie-on #martial-screen[data-uie], .uie-on #game-screen[data-uie], .uie-on #dojo-screen[data-uie] { cursor: default; }
.uie-on .uie-hover:not(#title-screen):not(#martial-screen):not(#game-screen):not(#dojo-screen) { outline: 1px dashed var(--uie-accent); outline-offset: 2px; }
.uie-on #app img { -webkit-user-drag: none; }

/* Things added with the tool (shown with or without edit mode) */
.uie-added { position: absolute; z-index: 3; box-sizing: border-box; margin: 0; }
.uie-added-button {
  width: 160px; height: 46px; padding: 0 18px; border: 1px solid var(--ink, #1f2420); background: transparent;
  color: var(--ink, #1f2420); font: inherit; letter-spacing: .2em; white-space: pre-line;
}
.uie-added-text { min-width: 24px; min-height: 1em; font-family: var(--serif, serif); font-size: 16px; color: var(--ink, #1f2420); white-space: pre-line; }
.uie-added-box {
  width: 220px; height: 140px; display: grid; place-items: center; text-align: center; white-space: pre-line;
  border: 1px dashed #9a9d92; background: #ffffff55; color: var(--muted, #6c7068);
}

/* Overlay: name tags and selection frame */
.uie-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.uie-tag {
  position: fixed; z-index: 3; pointer-events: auto; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 6px; border: 0; background: var(--uie-ink); color: #fff; font: 11px/1.4 system-ui, sans-serif; cursor: pointer; opacity: .82;
}
.uie-tag.is-added { background: var(--uie-added); }
.uie-tag.is-selected { background: var(--uie-accent); opacity: 1; }
.uie-frame { position: fixed; z-index: 1; outline: 2px solid var(--uie-accent); outline-offset: 2px; }
.uie-frame[hidden], .uie-handle[hidden], .uie-marquee[hidden] { display: none; }
.uie-frame.is-key { outline: 3px double var(--uie-added); outline-offset: 3px; }
.uie-marquee { position: fixed; z-index: 1; border: 1px dashed var(--uie-added); background: #2f6f8f1a; }
.uie-handle {
  position: fixed; z-index: 2; width: 12px; height: 12px; pointer-events: auto; cursor: nwse-resize;
  background: #fff; border: 2px solid var(--uie-accent); border-radius: 50%; touch-action: none;
}
.uie-on #title-screen, .uie-on #martial-screen, .uie-on #game-screen, .uie-on #dojo-screen { touch-action: none; }

/* Inspector */
.uie-panel {
  position: fixed; right: 12px; bottom: 12px; z-index: 50; width: 290px; max-height: calc(100dvh - 80px); overflow-y: auto;
  display: grid; gap: 10px; padding: 12px; background: var(--uie-paper); border: 1px solid var(--uie-line);
  box-shadow: 0 8px 28px #1f242026; font: 12px/1.4 system-ui, sans-serif; color: var(--uie-ink);
}
.uie-panel header { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.uie-panel header strong { display: block; font-size: 14px; }
.uie-panel header small { color: var(--uie-muted); }
.uie-panel .uie-close { border: 0; background: none; font-size: 18px; line-height: 1; padding: 0 4px; }
.uie-panel label { display: grid; gap: 4px; color: var(--uie-muted); }
.uie-panel input, .uie-panel textarea, .uie-modal textarea {
  font: 13px/1.4 system-ui, sans-serif; color: var(--uie-ink); background: #fff; border: 1px solid var(--uie-line);
  padding: 6px 7px; box-sizing: border-box; width: 100%; resize: vertical;
}
.uie-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.uie-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.uie-list { margin: 0; padding-left: 18px; }
.uie-list .is-key { color: var(--uie-added); font-weight: 600; }
.uie-hint { margin: 0; color: var(--uie-muted); font-size: 11px; }

/* Request dialog */
.uie-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: #1f242055; }
.uie-modal-card {
  width: min(560px, 100%); display: grid; gap: 10px; padding: 16px; background: var(--uie-paper);
  border: 1px solid var(--uie-line); font: 12px/1.4 system-ui, sans-serif; color: var(--uie-ink);
}
.uie-modal-card strong { font-size: 15px; }
.uie-status { flex: 1; color: var(--uie-muted); }

@media (max-width: 700px) {
  .uie-panel { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 48dvh; }
}

/* In the 무공록 view the portrait normally lets presses through to the tree; while editing it can be picked. */
.uie-on .hub--tree .hub-portrait { pointer-events: auto; }
