/* Blocks, attributes, references, counts (ui/blockref.js). */
/* The block authoring palette (ui/block-author.js). */
/* Over the drawing at the dock's right, above it: the tools stay where they are. */
.block-author { position: absolute; right: 0; bottom: calc(100% + 8px); width: min(440px, calc(100vw - 24px)); padding: 6px 10px 8px; font-size: 13px; max-height: min(55vh, 560px); overflow: auto; }
.block-author[hidden] { display: none; }
.ba-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ba-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin: 6px 0; }
.ba-tab { border: 0; background: none; color: inherit; padding: 4px 8px; border-radius: 6px; cursor: pointer; font: inherit; }
.ba-tab.on { background: var(--hover, rgba(128, 128, 128, 0.15)); font-weight: 600; }
.ba-tools { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line, rgba(128, 128, 128, 0.25)); }
.ba-list { display: flex; flex-direction: column; gap: 3px; padding-top: 6px; }
.ba-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ba-row .field { flex: 1; min-width: 80px; }
.ba-row .ba-kind { min-width: 52px; color: var(--muted, #888); }
.ba-row .ba-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ba-row .warn { color: var(--danger, #d33); }
.ba-vs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding-left: 58px; }
.ba-vs .field { width: auto; min-width: 70px; flex: 1; }
.ba-vs-fields { display: contents; }
.ba-check { display: inline-flex; align-items: center; gap: 4px; }
.ba-scroll { overflow: auto; max-width: 100%; }
.ba-lookup .field { min-width: 64px; }
.ba-lookup-col { background: var(--hover, rgba(128, 128, 128, 0.08)); }
.ba-foot { justify-content: flex-end; border-top: 1px solid var(--line, rgba(128, 128, 128, 0.25)); padding-top: 6px; margin-top: 4px; }
.br-menu { width: min(480px, calc(100vw - 24px)); max-width: min(480px, calc(100vw - 24px)); gap: 6px; }
.dx-menu, .att-editor { width: min(620px, calc(100vw - 24px)); max-width: min(620px, calc(100vw - 24px)); }
.br-menu .sh2 { font-size: 12px; color: var(--muted, #888); margin-top: 6px; }
.br-row { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.br-row .br-k { min-width: 72px; color: var(--muted, #888); }
.br-row .field { flex: 1; min-width: 0; }
.br-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 10px; padding: 4px 0; }
.br-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.br-table th, .br-table td { border-bottom: 1px solid var(--line, rgba(128, 128, 128, 0.25)); padding: 3px 6px; text-align: left; white-space: nowrap; }
.br-table td.br-actions { display: flex; gap: 2px; align-items: center; }
.dx-preview { max-height: 240px; overflow: auto; border: 1px solid var(--line, rgba(128, 128, 128, 0.25)); border-radius: 6px; }
.dx-checks { display: flex; flex-wrap: wrap; gap: 2px 8px; max-height: 160px; overflow: auto; padding: 4px 0; }
.att-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.att-row { border: 1px solid var(--line, rgba(128, 128, 128, 0.25)); border-radius: 6px; padding: 2px 6px; }
.att-row.open { background: var(--hover, rgba(128, 128, 128, 0.08)); }
.att-head { display: grid; grid-template-columns: minmax(70px, auto) 1fr 1fr; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 4px 0; cursor: pointer; font: inherit; font-size: 13px; }
.att-head .att-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-list, .group-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.count-row, .group-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13px; padding: 2px 0; border-bottom: 1px solid var(--line, rgba(128, 128, 128, 0.2)); }
.count-row .name { flex: 1; min-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row .field { width: 120px; flex: 1; }
.btn.warn { color: var(--danger, #d33); }
.count-found { font-weight: 600; padding: 4px 0; }
.xref-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.refs-attach { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0; }

/* Block palette tabs: this drawing, recent, favorites. */
.block-tabs { margin: 0 6px 6px; }
.block-tabs .btn { flex: 1; }
.block-tabs .btn[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }

/* The REFEDIT bar: like the block editor banner (its own class, so the two are told apart). */
.refedit-banner { display: flex; align-items: center; gap: 8px; align-self: center; padding: 6px 6px 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.refedit-banner[hidden] { display: none; }

/* AI, 마크업 가져오기, 블록 감지 (ui/ai.js) */
.ai-panel { width: min(520px, calc(100vw - 24px)); max-width: min(520px, calc(100vw - 24px)); gap: 8px; display: flex; flex-direction: column; }
.ai-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.ai-msg { padding: 8px 10px; border-radius: var(--r-input); background: var(--panel2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.me { background: var(--tint); align-self: flex-end; max-width: 85%; }
.ai-msg.note { background: none; color: var(--muted); font-size: 12px; }
.ai-action { border: 1px solid var(--line); border-radius: var(--r-input); padding: 8px; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.ai-action.run, .ai-action.applied { border-color: var(--ok); }
.ai-action.skipped { opacity: 0.6; }
.detect-copies { display: flex; flex-wrap: wrap; gap: 4px; }
.detect-copy { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-input); padding: 1px 2px; }
.detect-copy.rep { border-color: var(--accent); }
.detect-copy.out { opacity: 0.5; }
.same-like { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 4px 0; }
.same-like .sh { width: 100%; }
.ai-action.failed { border-color: var(--danger); }
.ai-action-title { font-weight: 600; }
.ai-action-preview { font-size: 0.9em; color: var(--text); font-weight: 500; }
.ai-action-result { font-size: 12px; color: var(--muted); }
.ai-script { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; margin: 0; max-height: 160px; overflow: auto; }
.ai-input { width: 100%; resize: vertical; min-height: 44px; }
.ai-usage { font-weight: normal; font-size: 12px; }
/* 반영: 수동 / 자동 (2026-11-21): the small switch in the AI window's header, and the card's reason for asking. */
.ai-mode { float: right; font: inherit; font-size: 12px; font-weight: normal; min-height: 28px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-input); background: var(--panel2); color: var(--text); cursor: pointer; }
.ai-ask-why { flex: 1 1 100%; }
.ai-auto-undo { align-self: flex-start; }
/* AI's place (2026-11-20): tabs for the three AI panels, the wait in the
   conversation (dots; still when motion is reduced), the batch bar, the
   selection chip, 되돌리기, and a panel that keeps clear of the keyboard. */
.ai-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.ai-tab { flex: 1 1 0; min-height: 36px; padding: 0 8px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer; }
.ai-tab:hover { color: var(--text); }
.ai-tab[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.ai-msg.pending { display: flex; align-items: center; gap: 8px; background: var(--panel2); color: var(--muted); align-self: flex-start; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.ai-cancel { margin-left: 8px; }
@media (prefers-reduced-motion: no-preference) {
  .ai-dots i { opacity: 0.25; animation: ai-dot 1.2s infinite ease-in-out; }
  .ai-dots i:nth-child(2) { animation-delay: 0.2s; }
  .ai-dots i:nth-child(3) { animation-delay: 0.4s; }
}
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.ai-batch { border: 1px solid var(--line); border-radius: var(--r-input); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.ai-batch[hidden], .ai-chip-row[hidden] { display: none; }
.ai-batch-head { font-size: 12px; color: var(--muted); }
.ai-batch-list { margin: 0; padding-left: 18px; font-size: 13px; overflow-wrap: anywhere; }
.ai-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.ai-fields { display: flex; flex-direction: column; gap: 6px; }
.ai-fields-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ai-fields-head { font-size: 12px; width: 2.4em; flex: none; }
.ai-chip.on { border-color: var(--accent); background: var(--tint); color: var(--text); }
.ai-action-result { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ai-panel.over-keyboard { overflow: hidden; }
.ai-panel.over-keyboard .ai-list { flex: 1 1 auto; min-height: 56px; max-height: none; }
/* A finger's reach: every button, tab and the box at 40 px or more. */
@media (pointer: coarse) {
  .ai-panel .btn, .ai-panel .check, .ai-tab, .ai-chip, .br-menu .btn { min-height: 40px; }
  .ai-panel .ai-input { min-height: 48px; }
}
#app[data-size="phone"] .ai-panel .btn, #app[data-size="phone"] .ai-panel .check, #app[data-size="phone"] .ai-tab, #app[data-size="phone"] .ai-chip { min-height: 40px; }
#app[data-size="phone"] .ai-panel .ai-input { min-height: 48px; font-size: 16px; }
.pat-token { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; user-select: all; padding: 6px; background: var(--panel2); border-radius: var(--r-input); }

/* Tool palettes (TOOLPALETTES, ui/palettes.js): a floating window that
   stays open while one draws, moved by its header. */
.pal-win {
  position: absolute; top: calc(var(--top-h) + 12px); right: calc(var(--right-w) + 24px); z-index: 40;
  width: min(300px, calc(100vw - 32px)); max-height: min(560px, calc(100% - var(--top-h) - 100px));
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  background: var(--panel); color: var(--text); border-radius: var(--r-panel); box-shadow: var(--shadow);
}
#app[data-size="tablet"] .pal-win { right: 16px; }
.pal-unfold, .pal-phone-only { display: none; }
/* A phone: a sheet above the tool bar (tabs on one line, tools in two
   rows that scroll sideways); the saved place and dragging are for wider
   screens. A tool picked folds it to a pill above the dock. */
#app[data-size="phone"] .pal-win {
  top: auto !important; left: 8px !important; right: 8px !important; bottom: calc(var(--safe-b) + 84px);
  width: auto; max-height: 264px; padding: 6px 10px 10px; border-radius: 16px;
}
#app[data-size="phone"] .pal-win::before { content: ""; display: block; flex: none; width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 2px; }
#app[data-size="phone"] .pal-head .sh { font-size: 13px; }
#app[data-size="phone"] .pal-head [data-act="pal-edit"],
#app[data-size="phone"] .pal-win .pal-actions,
#app[data-size="phone"] .pal-win .pal-where { display: none; }
#app[data-size="phone"] .pal-phone-only { display: flex; }
#app[data-size="phone"] .pal-tabs { flex-wrap: nowrap; overflow-x: auto; max-height: none; scrollbar-width: none; }
#app[data-size="phone"] .pal-tabs > * { flex: none; }
#app[data-size="phone"] .pal-grid:not(:has(.pal-edit-row, .pal-form)) {
  grid-auto-flow: column; grid-template-rows: repeat(2, 64px); grid-template-columns: none; grid-auto-columns: 84px; overflow-x: auto; overflow-y: hidden;
}
#app[data-size="phone"] .pal-win.folded {
  left: auto !important; right: 8px !important; bottom: var(--pal-fold-b, calc(var(--safe-b) + 92px));
  max-height: none; padding: 0; background: none; box-shadow: none;
}
#app[data-size="phone"] .pal-win.folded::before,
#app[data-size="phone"] .pal-win.folded > :not(.pal-unfold) { display: none; }
#app[data-size="phone"] .pal-win.folded .pal-unfold {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 22px;
  background: var(--panel); box-shadow: var(--shadow);
}
.pal-head { display: flex; align-items: center; gap: 6px; cursor: move; touch-action: none; }
.pal-head .sh { margin: 0; white-space: nowrap; }
.pal-head .grow, .pal-win .grow { flex: 1; }
.pal-group { max-width: 110px; }
.pal-tabs { max-height: 72px; overflow: auto; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; overflow: auto; min-height: 60px; }
.pal-grid:has(.pal-edit-row), .pal-grid:has(.pal-form) { display: flex; flex-direction: column; }
.pal-tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; min-height: 56px;
  border: 1px solid transparent; border-radius: var(--r-tool); background: none; color: inherit; font: inherit; font-size: 12px; cursor: pointer;
}
.pal-tool:hover { background: var(--hover); border-color: var(--line); }
.pal-tool .name { text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.pal-edit-row { display: flex; align-items: center; gap: 2px; }
.pal-edit-row .pal-tool { flex: 1; flex-direction: row; min-height: 36px; justify-content: flex-start; }
.pal-form { display: flex; flex-direction: column; gap: 4px; }
.pal-field { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 6px; font-size: 12.5px; }
.pal-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.pal-menu { position: relative; }
.pal-menu > summary { list-style: none; }
.pal-menu > summary::-webkit-details-marker { display: none; }
.pal-menu .menu-list { position: absolute; right: 0; top: 100%; z-index: 2; min-width: 170px; padding: 4px; background: var(--panel); border-radius: var(--r-input); box-shadow: var(--shadow); }
.pal-menu .menu-item.danger { color: var(--danger); }

/* Data links (DATALINK, ui/datalink.js). */
.dl-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.dl-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--r-input); background: var(--hover); }
.dl-row .meta { flex: 1; min-width: 0; font-size: 12.5px; }
.dl-row .meta small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-form { display: flex; flex-direction: column; gap: 6px; }
.dl-preview { max-height: 180px; overflow: auto; font-size: 12px; border: 1px solid var(--line); border-radius: var(--r-input); }
.dl-preview table { border-collapse: collapse; }
.dl-preview td { border: 1px solid var(--line); padding: 2px 6px; white-space: nowrap; }

/* DesignCenter's search and favorites (ui/library.js). */
.library-find-results { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; }
.library-fav { margin-left: auto; }

/* 앱 관리자 (ui/apps.js): a plug-in a row — name, autoload, run, remove. */
.apps-menu { width: min(560px, calc(100vw - 32px)); max-width: min(560px, calc(100vw - 32px)); }
.apps-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.apps-row .apps-name { flex: 1 1 200px; min-width: 0; }
.apps-row select.field { width: auto; }

/* 빠른 실행 도구 막대 (ui/qat.js): small buttons by the file name. */
.qat-wrap { display: flex; align-items: center; gap: 0; margin-left: 4px; }
.qat { display: flex; align-items: center; gap: 0; }
.qat-btn { width: 32px; height: 32px; }
.qat-btn:has(.qat-name) { width: auto; padding: 0 6px; gap: 4px; }
.qat-name { font-size: 11px; }
.qat-menu { width: min(360px, calc(100vw - 32px)); }
.qat-row { display: flex; align-items: center; gap: 2px; }
.qat-row .qat-label { flex: 1; }

/* 정보 센터 (ui/infocenter.js): the count on its button. */
.info-center { position: relative; }
.info-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger, #d33); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.info-menu { width: min(380px, calc(100vw - 32px)); }
/* BESETTINGS: the fields in one column (each began where its name ended),
   a colour number with its colour beside it. */
.be-settings .br-row .br-k { flex: 0 0 13.5em; }
.be-swatch { flex: none; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 4px; }
