* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface2: #f4f5fa;
  --border: #e2e5ef;
  --text: #1e2235;
  --text2: #555b6e;
  --accent1: #667eea;
  --accent2: #764ba2;
  --btn-public-1: #60a5fa;
  --btn-public-2: #3b82f6;
  --btn-private-1: #9ca3af;
  --btn-private-2: #6b7280;
  --btn-default-1: #667eea;
  --btn-default-2: #764ba2;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --shadow: rgba(30, 34, 53, 0.10);
  --topbar-bg: #ffffff;
  --topbar-shadow: rgba(30, 34, 53, 0.13);
  --tag-scroll-track: rgba(30, 34, 53, 0.04);
  --tag-scroll-thumb: rgba(30, 34, 53, 0.12);
  --tag-scroll-thumb-hover: rgba(30, 34, 53, 0.18);
  --tag-scroll-thumb-border: transparent;
}

body.dark {
  --bg: #0f1117;
  --surface: #181c27;
  --surface2: #1e2235;
  --border: #2a2f45;
  --text: #e8eaf2;
  --text2: #adb4c9;
  --shadow: rgba(0, 0, 0, 0.4);
  --topbar-bg: #13161f;
  --topbar-shadow: rgba(0, 0, 0, 0.5);
  --tag-scroll-track: rgba(255, 255, 255, 0.03);
  --tag-scroll-thumb: rgba(255, 255, 255, 0.08);
  --tag-scroll-thumb-hover: rgba(255, 255, 255, 0.14);
  --tag-scroll-thumb-border: transparent;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

body.dark {
  color-scheme: dark;
}

input::placeholder,
textarea::placeholder {
  color: var(--text2);
  opacity: 1;
}

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px var(--topbar-shadow);
  z-index: 500;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

#hamburger {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}

#hamburger:hover {
  background: var(--surface2);
}

.hamburger-icon {
  width: 20px;
  height: 20px;
}

#searchWrap {
  flex: 1;
  max-width: 420px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text2);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 7px 36px 7px 34px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent1);
}

#clearSearchBtn {
  position: absolute;
  right: 5px;
  display: inline-flex;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
}

#clearSearchBtn:hover { background: var(--border); color: var(--text); }
#clearSearchBtn svg { width: 14px; height: 14px; }
#clearSearchBtn[hidden], #addSectionBtn[hidden] { display: none; }

#searchInput::placeholder {
  opacity: 1;
  transition: opacity .15s ease;
}

#searchInput.search-placeholder-changing::placeholder { opacity: 0; }

#searchType {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

#menuOverlay {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 54px;
  left: 12px;
  width: min(280px, calc(100% - 24px));
  max-height: calc(100vh - 74px);
  overflow-y: auto;
  background: var(--topbar-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px var(--topbar-shadow);
  z-index: 499;
  padding: 12px;
  gap: 10px;
  animation: slideDown 0.18s ease;
}

#menuOverlay::-webkit-scrollbar,
.shortcuts-scroll::-webkit-scrollbar { width: 10px; }

#menuOverlay::-webkit-scrollbar-track,
.shortcuts-scroll::-webkit-scrollbar-track {
  background: var(--tag-scroll-track);
  border-radius: 8px;
  margin: 6px 0;
}

#menuOverlay::-webkit-scrollbar-thumb,
.shortcuts-scroll::-webkit-scrollbar-thumb {
  min-height: 28px;
  border: 2px solid var(--tag-scroll-thumb-border);
  border-radius: 8px;
  background-color: var(--tag-scroll-thumb);
}

#menuOverlay::-webkit-scrollbar-thumb:hover,
.shortcuts-scroll::-webkit-scrollbar-thumb:hover {
  background-color: var(--tag-scroll-thumb-hover);
}

#menuOverlay.open {
  display: flex;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: -1px 0;
}

.menu-submenu { display: flex; flex-direction: column; gap: 6px; }
.menu-submenu[hidden] { display: none; }

.menu-submenu-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.menu-submenu-toggle:hover,
.menu-submenu-toggle.open { border-color: var(--accent1); color: var(--accent1); }
.menu-submenu-toggle .chevron-icon { transition: transform .18s ease; }
.menu-submenu-toggle.open .chevron-icon { transform: rotate(180deg); }

.menu-submenu-body {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding-left: 10px;
  margin-left: 10px;
  border-left: 1px solid var(--border);
}

.menu-submenu-body.open { display: flex; }

.menu-advanced { display: flex; flex-direction: column; gap: 6px; }
.menu-advanced[hidden] { display: none; }

.menu-setting-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 9px;
  padding: 7px 9px 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.menu-setting-row select {
  min-width: 104px;
  margin-left: auto;
  padding: 5px 26px 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.menu-setting-row select:focus { border-color: var(--accent1); }


.menu-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: 100%;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.menu-btn:hover {
  background: var(--border);
  border-color: var(--accent1);
}

.menu-btn.active {
  background: rgba(102, 126, 234, 0.12);
  border-color: var(--accent1);
  color: var(--accent1);
}

.menu-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.menu-btn-label {
  flex: 1;
  text-align: left;
}

.menu-btn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  flex-shrink: 0;
  display: none;
}

.menu-btn.active .menu-btn-dot {
  display: block;
}

.menu-btn-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--red);
}

.menu-btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.menu-btn[disabled] {
  opacity: 0.56;
  cursor: not-allowed;
  filter: grayscale(0.06);
  pointer-events: none;
}

.menu-edit-subitem {
  display: none;
  position: relative;
  width: calc(100% - 18px);
  margin-left: 18px;
}

body.edit-mode .menu-edit-subitem {
  display: flex;
}

.menu-edit-subitem::before {
  content: '';
  position: absolute;
  top: -7px;
  bottom: 50%;
  left: -11px;
  border-left: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  border-bottom-left-radius: 6px;
}

/* Indicador de criptografia no botao Exportar (Alt+C alterna) */
.export-lock-icon {
  display: none;
  color: var(--yellow);
  margin-left: -2px;
}

#exportBtn.encryption-on .export-lock-icon {
  display: inline-flex;
}

#main {
  padding: 64px 20px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-wrap {
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  user-select: none;
}

.section-collapse-btn,
.section-add-btn,
.section-del-btn,
.section-rename-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
}

.section-collapse-btn {
  font-size: 16px;
  color: var(--text2);
  transition: background 0.2s, transform 0.2s;
}

.section-collapse-btn:hover {
  background: var(--border);
}

.section-wrap.collapsed .section-collapse-btn {
  transform: rotate(-90deg);
}

.section-add-btn {
  font-size: 15px;
  color: var(--green);
}

.section-add-btn:hover {
  background: rgba(16, 185, 129, 0.1);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.section-count {
  font-size: 12px;
  color: var(--text2);
  background: var(--border);
  padding: 2px 7px;
  border-radius: 99px;
}

.section-del-btn,
.section-rename-btn {
  display: none;
  font-size: 14px;
}

.section-del-btn {
  color: var(--red);
}

.section-rename-btn {
  color: var(--yellow);
}

body.edit-mode .section-del-btn,
body.edit-mode .section-rename-btn {
  display: flex;
}

.section-body {
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 52px;
}

.section-wrap.collapsed .section-body {
  display: none;
}

.btn-wrap {
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-wrap:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

body.edit-mode .btn-wrap {
  animation: shake 0.5s ease-in-out infinite;
  cursor: grab;
}

body.edit-mode.edit-animation-off .btn-wrap {
  animation: none;
}

body.edit-mode .btn-wrap:hover,
body.edit-mode .section-wrap:hover .btn-wrap {
  animation: none;
}

body.edit-mode .btn-wrap.dragging {
  opacity: 0.4;
  animation: none;
  cursor: grabbing;
}

@keyframes shake {

  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(-2px, -1px);
  }

  50% {
    transform: translate(2px, 1px);
  }

  75% {
    transform: translate(-2px, 1px);
  }
}

.copy-btn {
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: white;
  transition: filter 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  max-width: 340px;
}

.copy-btn:hover {
  filter: brightness(1.08);
}

.copy-btn.copied {
  filter: brightness(0.85);
}

.copy-btn.copied > :not(.copy-feedback) {
  display: none;
}

.copy-btn.vis-public {
  background: linear-gradient(135deg, var(--btn-public-1), var(--btn-public-2));
}

.copy-btn.vis-private {
  background: linear-gradient(135deg, var(--btn-private-1), var(--btn-private-2));
}

.copy-btn.vis-other {
  background: var(--other-button-bg, linear-gradient(135deg, var(--btn-default-1), var(--btn-default-2)));
}

.copy-btn .btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn .online-button-icon { display: none; }

body.button-visual-new .copy-btn:not(.copied) .online-button-icon { display: inline-block; }

#buttonPreviewTooltip {
  position: fixed;
  background: var(--surface);
  color: var(--text);
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  max-width: 280px;
  word-wrap: break-word;
  box-shadow: 0 4px 14px var(--shadow);
  border: 1.5px solid var(--accent1);
  display: none;
  pointer-events: none;
  z-index: 2100;
}

#buttonPreviewTooltip.show {
  display: block;
}

.tool-tabs { display: flex; gap: 6px; margin: 12px 0; border-bottom: 1px solid var(--border); }
.tool-tab { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text2); cursor: pointer; }
.tool-tab.active { color: var(--accent1); border-bottom-color: var(--accent1); }
.tool-panel[hidden] { display: none; }
.diagnostic-summary { padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; background: var(--surface2); color: var(--text2); font-size: 13px; }
.diagnostic-issues { display: flex; flex-direction: column; gap: 8px; max-height: 42vh; overflow: auto; }
.diagnostic-group { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); }
.diagnostic-group h3 { margin: 0 0 6px; font-size: 13px; }
.diagnostic-group p, .diagnostic-group li { margin: 4px 0; color: var(--text2); font-size: 12px; line-height: 1.4; }
.diagnostic-group ul { margin: 6px 0; padding-left: 18px; }
.diagnostic-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.json-modal { width: min(720px, calc(100vw - 24px)); }
.json-view-text { width: 100%; min-height: 320px; resize: vertical; box-sizing: border-box; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); color: var(--text); font: 12px/1.45 Consolas, monospace; }
.json-view-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.json-size-meta { margin: 8px 0; color: var(--text2); font-size: 11px; line-height: 1.4; }

.json-modal {
  width: min(640px, calc(100vw - 24px));
  max-width: 640px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.json-modal.view-active { height: min(86vh, 760px); }

.json-modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface2);
}

.json-modal-tab {
  padding: 8px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.json-modal-tab.active { background: var(--accent1); color: white; }
.json-modal-panel[hidden] { display: none; }
.json-modal-panel.active { flex: 1; min-height: 0; overflow-y: auto; }
#jsonViewPanel.active { display: flex; flex-direction: column; overflow: hidden; }

.json-diagnostic-summary {
  padding: 11px 12px;
  margin-bottom: 8px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.json-diagnostic-summary.ok { border-color: rgba(34, 197, 94, .5); background: rgba(34, 197, 94, .08); }
.json-diagnostic-summary.warning { border-color: rgba(245, 158, 11, .55); background: rgba(245, 158, 11, .08); }

.json-diagnostic-issues {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 2px;
}

.json-toolbox { padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface2); }
.json-toolbox-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 11px; color: var(--text); font-size: 13px; }
.json-toolbox-heading span, .json-toolbox-label { color: var(--text2); font-size: 10.5px; }
.json-toolbox-label { margin: 9px 0 6px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.json-tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }

.json-tool-action {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.json-tool-action:hover:not(:disabled) { border-color: var(--accent1); background: rgba(102, 126, 234, .08); }
.json-tool-action:disabled { opacity: .48; cursor: not-allowed; }
.json-tool-action .menu-icon { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; color: var(--accent1); }
.json-tool-action span { min-width: 0; }
.json-tool-action strong, .json-tool-action small { display: block; }
.json-tool-action strong { margin-bottom: 3px; font-size: 11.5px; }
.json-tool-action small { color: var(--text2); font-size: 9.5px; line-height: 1.35; }

.json-modal .diagnostic-group { padding: 11px 12px; }

.json-modal .json-view-text {
  flex: 1 1 180px;
  width: 100%;
  height: auto;
  min-height: 180px;
  max-height: 100%;
  resize: vertical;
  overflow: auto;
  padding: 12px;
  border-radius: 9px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.5;
  outline: none;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: var(--tag-scroll-thumb) var(--tag-scroll-track);
}

.json-view-text::-webkit-scrollbar { width: 10px; height: 10px; }
.json-view-text::-webkit-scrollbar-track { margin: 6px 0; border-radius: 8px; background: var(--tag-scroll-track); }
.json-view-text::-webkit-scrollbar-thumb { min-width: 28px; min-height: 28px; border: 2px solid var(--tag-scroll-thumb-border); border-radius: 8px; background-color: var(--tag-scroll-thumb); }
.json-view-text::-webkit-scrollbar-thumb:hover { background-color: var(--tag-scroll-thumb-hover); }
.json-view-text::-webkit-scrollbar-corner { background: transparent; }

.json-modal .json-view-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.json-view-actions .mbtn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-width: 0; min-height: 36px; padding-inline: 10px; white-space: nowrap; }
.json-view-actions .menu-icon { flex: 0 0 auto; width: 15px; height: 15px; }
.json-view-actions .json-compact-action { border-color: rgba(102, 126, 234, .65); color: var(--accent1); }

.json-modal > .modal-footer { flex-shrink: 0; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.json-modal > .modal-footer .mbtn { border: 1px solid var(--border); background: var(--surface2); color: var(--text); }
.json-modal > .modal-footer .mbtn:hover { border-color: var(--accent1); color: var(--accent1); background: rgba(102, 126, 234, .08); }
.context-menu { position: fixed; z-index: 2300; display: flex; flex-direction: column; min-width: 210px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 14px 36px var(--shadow); }
.context-menu[hidden] { display: none; }
.context-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.context-menu-item:hover, .context-menu-item:focus-visible { background: var(--surface2); outline: none; }
.context-menu-item:disabled { opacity: .4; cursor: default; }
.context-menu-item.danger { color: var(--red); }
.context-menu-item .menu-icon { width: 16px; height: 16px; }
.context-menu-separator { height: 1px; margin: 5px 4px; background: var(--border); }
.button-view-meta { margin-bottom: 10px; color: var(--text2); font-size: 12px; }
.button-view-text { max-height: 50vh; overflow: auto; padding: 12px; border-radius: 8px; background: var(--surface2); color: var(--text); font-family: inherit; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

#buttonViewModal .mbtn {
  border: 1px solid transparent;
  transition: transform .12s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease, filter .16s ease;
}

#buttonViewModal .mbtn.secondary:hover,
#buttonViewModal .mbtn.secondary:focus-visible {
  border-color: var(--accent1);
  background: color-mix(in srgb, var(--accent1) 10%, var(--surface2));
  color: var(--accent1);
}

#buttonViewModal .mbtn.primary:hover,
#buttonViewModal .mbtn.primary:focus-visible {
  filter: brightness(1.08);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent1) 25%, transparent);
}

#buttonViewModal .mbtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent1) 25%, transparent);
}

#buttonViewModal .mbtn:active {
  transform: translateY(1px) scale(.98);
}

.btn-edit,
.btn-del {
  display: none;
  border: none;
  padding: 0 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-edit {
  background: rgba(245, 158, 11, 0.10);
  color: var(--yellow);
  font-size: 14px;
}

.btn-del {
  background: rgba(239, 68, 68, 0.10);
  color: var(--red);
  font-size: 12px;
  border-radius: 0 8px 8px 0;
}

body.edit-mode .btn-edit,
body.edit-mode .btn-del {
  display: flex;
}

.btn-wrap.search-hidden,
.section-wrap.search-hidden {
  display: none;
}

#addSectionBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px auto 0;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  color: var(--text2);
  padding: 10px 24px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 800;
  justify-content: center;
  align-items: center;
}

.modal-bg.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 90%;
  max-width: 460px;
  box-shadow: 0 20px 60px var(--shadow);
}

/* O modal genérico é estreito; o visualizador precisa acomodar quatro ações. */
#jsonModal .json-modal {
  width: min(640px, calc(100vw - 32px));
  max-width: 640px;
  box-sizing: border-box;
}

.modal h2 {
  font-size: 16px;
  margin-bottom: 18px;
  color: var(--text);
}

.form-group {
  margin-bottom: 13px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.form-group textarea {
  resize: vertical;
  min-height: 130px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

.mbtn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.mbtn.primary {
  background: var(--accent1);
  color: white;
}

.mbtn.primary:hover {
  filter: brightness(1.08);
}

.mbtn.secondary {
  background: var(--border);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--text2) 38%, var(--border));
}

.import-actions .mbtn.secondary:not(:disabled) {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
}

.import-actions .mbtn.secondary:not(:disabled):hover {
  border-color: var(--accent1);
  color: var(--accent1);
  background: rgba(102, 126, 234, .08);
}

.mbtn:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.mbtn.cancel {
  border: 1px solid rgba(239, 68, 68, .5);
  background: rgba(239, 68, 68, .06);
  color: var(--red);
}

.mbtn.cancel:hover,
.mbtn.cancel:focus-visible {
  border-color: var(--red);
  background: var(--red);
  color: white;
  outline: none;
}


#appVersion {
  position: fixed;
  bottom: 10px;
  left: 12px;
  font-size: 10px;
  color: var(--text2);
  opacity: 0.9;
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 8px;
  border-radius: 6px;
  user-select: none;
  z-index: 1500;
  cursor: default;
  transition: opacity 0.2s;
  border: 0;
  font-family: inherit;
}

#appVersion:hover {
  opacity: 1;
  cursor: pointer;
}

.about-modal { max-width: 500px; max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box; }
.about-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.about-brand img { border-radius: 15px; box-shadow: 0 8px 22px rgba(30, 95, 217, .22); }
.about-brand h2 { margin: 0 0 4px; }
.about-brand span { color: var(--text2); font-size: 12px; }
.about-source-link { display: block; width: fit-content; margin-top: 3px; color: var(--text2); font-size: 10.5px; font-weight: 400; text-decoration: none; }
.about-source-link:hover { color: var(--accent1); text-decoration: underline; }
.about-description { margin: 0 0 16px; color: var(--text); font-size: 13px; line-height: 1.65; }
.about-privacy { display: grid; gap: 4px; margin-bottom: 16px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface2); font-size: 12px; line-height: 1.5; }
.about-privacy span { color: var(--text2); }
.about-details { display: grid; gap: 0; margin: 0 0 14px; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; }
.about-details > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 11px; border-bottom: 1px solid var(--border); font-size: 11.5px; }
.about-details > div:last-child { border-bottom: 0; }
.about-details dt { color: var(--text2); }
.about-details dd { margin: 0; color: var(--text); text-align: right; font-weight: 600; }
#aboutExtras { gap: 10px; }
#aboutExtras dt { flex: 0 0 auto; white-space: nowrap; }
#aboutExtras dd { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.about-extras-link { padding: 0; border: 0; background: none; color: var(--accent1); cursor: pointer; font: inherit; text-decoration: underline; }
.about-extras-modal { max-width: 420px; max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box; }
.about-extras-modal p { margin: 0 0 12px; color: var(--text2); font-size: 12px; }
.about-extras-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.about-extras-list li { padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface2); font-size: 12px; }
.about-extras-list li:last-child { border-bottom: 0; }

#appVersion.unsaved {
  opacity: 1;
  color: var(--yellow);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.16) inset;
}

#tagModal .modal {
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}

.tag-filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tag-filter-row input {
  flex: 1;
  min-width: 0;
  width: auto;
}

.tag-clear-empty-btn {
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

#tagListWrap {
  overflow-y: auto;
  max-height: 260px;
  margin-bottom: 12px;
  padding-right: 2px;
}

#tagList {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  color: var(--text);
}

.tag-chip-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  line-height: 1;
}

.tag-chip-edit {
  color: var(--text2);
}

.tag-chip-edit:hover {
  color: var(--accent1);
}

.tag-chip-del {
  color: var(--red);
}

.tag-chip-count {
  background: var(--border);
  color: var(--text2);
  border-radius: 99px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}

.tag-empty-msg {
  display: none;
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  padding: 18px 8px;
}

.tag-empty-msg.show {
  display: block;
}

/* Scrollbar customizada (segue o tema manual via variáveis --tag-scroll-*) */
#tagListWrap {
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: var(--tag-scroll-thumb) var(--tag-scroll-track);
}

/* WebKit / Blink */
#tagListWrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#tagListWrap::-webkit-scrollbar-track {
  background: var(--tag-scroll-track);
  border-radius: 8px;
  margin: 6px 0;
}

#tagListWrap::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(102, 126, 234, 0.10), rgba(118, 75, 162, 0.06));
  background-color: var(--tag-scroll-thumb);
  border-radius: 8px;
  border: 2px solid var(--tag-scroll-thumb-border);
  min-height: 28px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) inset;
  transition: background-color 0.16s, transform 0.12s;
}

#tagListWrap::-webkit-scrollbar-thumb:hover {
  background-color: var(--tag-scroll-thumb-hover);
  transform: translateY(-1px);
}

#tagListWrap::-webkit-scrollbar-corner {
  background: transparent;
}

/* Destaque visível ao navegar até a lista via Tab (tagListWrap agora é focável) */
#tagListWrap:focus {
  outline: 2px solid rgba(102, 126, 234, 0.14);
  outline-offset: 2px;
}

.import-helper {
  margin-top: -4px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text2);
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.import-file-meta {
  font-size: 12px;
  color: var(--text2);
  min-height: 18px;
  word-break: break-word;
}

.mbtn.ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.mbtn.ghost:hover {
  border-color: var(--accent1);
  color: var(--accent1);
  background: rgba(102, 126, 234, 0.06);
}

#notifArea {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notif {
  background: var(--green);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.25s ease;
}

.notif.err {
  background: var(--red);
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drag-placeholder {
  width: var(--drag-placeholder-width, 80px);
  height: var(--drag-placeholder-height, 40px);
  flex: 0 0 auto;
  box-sizing: border-box;
  border: 2px dashed var(--accent1);
  border-radius: 8px;
  background: rgba(102, 126, 234, 0.07);
  pointer-events: none;
}

/* Shift system */
body.shift-mode:not(.shift-locked) .section-wrap {
  outline: 2px dashed #f59e0b
}

body.shift-locked .section-wrap {
  outline: 2px dashed #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, .25), 0 0 6px rgba(34, 197, 94, .35)
}

body.shift-mode .section-del-btn,
body.shift-mode .section-rename-btn {
  display: none !important
}

.section-move-controls {
  display: none;
  margin-left: auto;
  gap: 6px
}

body.shift-mode .section-move-controls {
  display: flex
}

.section-move-controls button {
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer
}

.section-wrap.dragging {
  opacity: .6
}

.section-drag-placeholder {
  height: 0;
  border-top: 2px dashed #f59e0b;
  margin: 6px 0
}

body.shift-locked .section-drag-placeholder {
  border-top: 2px dashed #22c55e
}

body.drag-preview-off .drag-placeholder,
body.drag-preview-off .section-drag-placeholder {
  display: none;
}



/* ShiftLock: reorganização horizontal de botões — [‹] [botão] [›] */
body.shift-locked .btn-wrap.blu-button-shift-row {
  gap: 4px;
  overflow: visible;
  box-shadow: none;
  animation: none;
  align-items: center;
}

body.shift-locked .btn-wrap.blu-button-shift-row:hover {
  transform: none;
  box-shadow: none;
}

body.shift-locked .btn-wrap.blu-button-shift-row .copy-btn {
  border-radius: 8px;
}

.blu-btn-move-horizontal {
  width: 30px;
  min-width: 30px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.blu-btn-move-horizontal:hover:not(:disabled) {
  border-color: var(--accent1);
  filter: brightness(1.08);
}

.blu-btn-move-horizontal:active:not(:disabled) {
  transform: scale(0.96);
}

.blu-btn-move-horizontal:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.blu-button-hidden-in-shiftlock {
  display: none !important;
}

.blu-button-moved-feedback {
  outline: 2px solid #22c55e;
  outline-offset: 2px;
  transition: outline 0.18s ease;
}

/* Lembrete de backup (export pendente)
   Escondido via translateY(150%) em vez de um "bottom" fixo em px:
   a altura do banner varia (quebra de texto, empilhamento em telas
   estreitas), entao um offset fixo podia nao ser suficiente para
   tira-lo totalmente da tela. translateY(%) se ajusta a altura real
   do proprio elemento, sempre. */
#backupBanner {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(150%);
  opacity: 0;
  pointer-events: none;
  z-index: 1800;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  background: var(--surface);
  border: 1.5px solid var(--yellow);
  box-shadow: 0 10px 30px var(--shadow);
  padding: 12px 16px;
  border-radius: 12px;
  width: min(420px, calc(100% - 24px));
  box-sizing: border-box;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#backupBanner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.backup-banner-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.backup-banner-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  flex: 1 1 180px;
  min-width: 0;
}

.backup-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.backup-banner-actions button {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.backup-banner-actions .bb-export {
  background: var(--yellow);
  color: #2a1f02;
}

.backup-banner-actions .bb-dismiss {
  background: var(--border);
  color: var(--text2);
}

@media (max-width: 420px) {
  #backupBanner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: 12px 14px;
  }

  .backup-banner-actions {
    margin-left: 0;
    justify-content: center;
  }

  .backup-banner-actions button {
    flex: 1;
  }
}

/* Diálogo customizado (substitui confirm()/prompt() nativos) */
.mbtn.danger {
  border: 1px solid rgba(239, 68, 68, .5);
  background: rgba(239, 68, 68, .06);
  color: var(--red);
}

.mbtn.danger:hover,
.mbtn.danger:focus-visible {
  border-color: var(--red);
  background: var(--red);
  color: white;
  filter: none;
  outline: none;
}

#dialogModal .modal {
  max-width: 400px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-sizing: border-box;
}

#dialogMessage {
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.5;
  white-space: pre-wrap;
}

#dialogModal.danger-dialog #dialogMessage {
  color: var(--text);
  text-transform: none;
}

#dialogInputWrap {
  margin-top: 14px;
}

#shortcutsModal .modal {
  max-width: 420px;
  max-height: min(82vh, 680px);
  display: flex;
  flex-direction: column;
}

.shortcuts-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: var(--tag-scroll-thumb) var(--tag-scroll-track);
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}

.shortcuts-table td {
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.shortcuts-table tr:last-child td {
  border-bottom: none;
}

.shortcuts-table td:first-child {
  white-space: nowrap;
  width: 1%;
  padding-right: 16px;
}

.shortcuts-table td:last-child {
  color: var(--text2);
}

kbd {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  line-height: 1.5;
}

.no-results {
  display: none;
  text-align: center;
  color: var(--text2);
  font-size: 14px;
  padding: 36px 16px;
}

.no-results.show {
  display: block;
}

.no-results strong {
  color: var(--text);
}

@media (max-width: 560px) {
  #jsonModal .json-view-actions {
    gap: 6px;
  }

  #jsonModal .json-view-actions .mbtn {
    min-height: 38px;
    padding-inline: 8px;
  }

  #jsonModal .json-view-actions .mbtn span {
    display: none;
  }

  #jsonModal .json-view-actions .menu-icon {
    width: 17px;
    height: 17px;
  }
}

/* Rolagem consistente nas telas e campos internos. */
.diagnostic-issues,
.json-modal-panel.active,
.json-diagnostic-issues,
.json-view-text,
.button-view-text,
#tagListWrap,
.shortcuts-scroll,
.form-group textarea {
  scrollbar-color: var(--tag-scroll-thumb) var(--tag-scroll-track);
  scrollbar-width: auto;
}

.diagnostic-issues::-webkit-scrollbar,
.json-modal-panel.active::-webkit-scrollbar,
.json-diagnostic-issues::-webkit-scrollbar,
.json-view-text::-webkit-scrollbar,
.button-view-text::-webkit-scrollbar,
#tagListWrap::-webkit-scrollbar,
.shortcuts-scroll::-webkit-scrollbar,
.form-group textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.diagnostic-issues::-webkit-scrollbar-track,
.json-modal-panel.active::-webkit-scrollbar-track,
.json-diagnostic-issues::-webkit-scrollbar-track,
.json-view-text::-webkit-scrollbar-track,
.button-view-text::-webkit-scrollbar-track,
#tagListWrap::-webkit-scrollbar-track,
.shortcuts-scroll::-webkit-scrollbar-track,
.form-group textarea::-webkit-scrollbar-track {
  margin: 6px 0;
  border-radius: 8px;
  background: var(--tag-scroll-track);
}

.diagnostic-issues::-webkit-scrollbar-thumb,
.json-modal-panel.active::-webkit-scrollbar-thumb,
.json-diagnostic-issues::-webkit-scrollbar-thumb,
.json-view-text::-webkit-scrollbar-thumb,
.button-view-text::-webkit-scrollbar-thumb,
#tagListWrap::-webkit-scrollbar-thumb,
.shortcuts-scroll::-webkit-scrollbar-thumb,
.form-group textarea::-webkit-scrollbar-thumb {
  min-width: 28px;
  min-height: 28px;
  border: 2px solid var(--tag-scroll-thumb-border);
  border-radius: 8px;
  background-color: var(--tag-scroll-thumb);
}

.diagnostic-issues::-webkit-scrollbar-thumb:hover,
.json-modal-panel.active::-webkit-scrollbar-thumb:hover,
.json-diagnostic-issues::-webkit-scrollbar-thumb:hover,
.json-view-text::-webkit-scrollbar-thumb:hover,
.button-view-text::-webkit-scrollbar-thumb:hover,
#tagListWrap::-webkit-scrollbar-thumb:hover,
.shortcuts-scroll::-webkit-scrollbar-thumb:hover,
.form-group textarea::-webkit-scrollbar-thumb:hover {
  background-color: var(--tag-scroll-thumb-hover);
}

.diagnostic-issues::-webkit-scrollbar-corner,
.json-modal-panel.active::-webkit-scrollbar-corner,
.json-diagnostic-issues::-webkit-scrollbar-corner,
.json-view-text::-webkit-scrollbar-corner,
.button-view-text::-webkit-scrollbar-corner,
#tagListWrap::-webkit-scrollbar-corner,
.shortcuts-scroll::-webkit-scrollbar-corner,
.form-group textarea::-webkit-scrollbar-corner {
  background: transparent;
}
