:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel2: rgba(255, 255, 255, 0.1);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.14);
  --primary: #4f7cff;
  --primary2: #2f5dff;
  --danger: #ff4f6d;
  --toolbar-h: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1400px 900px at 30% 10%, #17224b, var(--bg));
  color: var(--text);
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.title {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 16px;
}

.subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.searchbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.input.search {
  width: 240px;
  padding: 8px 10px;
  border-radius: 10px;
}

.sep {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.file input {
  display: none;
}

.file span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  user-select: none;
}

.main {
  display: grid;
  grid-template-columns: 240px 1fr 360px;
  gap: 14px;
  padding: 14px;
  flex: 1;
}

.thumbs {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.thumbs-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  height: 85px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.thumbs-title {
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.thumbs-goto-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.thumbs-goto {
  width: 68px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
}

.thumbs-list {
  padding: 10px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.thumb {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
}

.thumb.active {
  border-color: rgba(79, 124, 255, 0.75);
  box-shadow: 0 0 0 1px rgba(79, 124, 255, 0.25) inset;
}

.thumb canvas {
  width: 100%;
  border-radius: 8px;
  background: white;
  display: block;
}

.thumb .label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.viewer,
.side {
  min-height: 0;
}

.viewer {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewer-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  min-height: var(--toolbar-h);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolgroup {
  display: inline-flex;
  gap: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
}

.btn.tool {
  padding: 8px 9px;
  font-size: 12px;
}

.btn.tool.active {
  border-color: rgba(79, 124, 255, 0.7);
  background: rgba(79, 124, 255, 0.18);
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pageinfo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pageinfo input {
  width: 64px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
}

.tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-menu {
  position: relative;
  display: none; /* aparece em modo compacto */
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 280px;
  border: 1px solid var(--border);
  background: rgba(12, 16, 32, 0.98);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 50;
}

.menu-panel.open {
  display: block;
}

.menu-section {
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
}

.menu-section:last-child {
  margin-bottom: 0;
}

.menu-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.menu-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.menu-row:last-child {
  margin-bottom: 0;
}

.menu-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 12px;
}

/* Modo compacto: esconde itens grandes e mostra menu */
.viewer-toolbar.compact .searchbar,
.viewer-toolbar.compact .toggle,
.viewer-toolbar.compact .zoom,
.viewer-toolbar.compact .file span,
.viewer-toolbar.compact #toolExtra {
  display: none !important;
}

.viewer-toolbar.compact .toolbar-menu {
  display: inline-flex;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}

.toggle input {
  display: none;
}

.file span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  user-select: none;
}

.file span svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
}

.zoom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  overflow: auto;
  padding: 14px;
}

.continuous-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
}

.cpage {
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.cpage canvas {
  display: block;
}

#pdfCanvas {
  display: block;
  background: white;
  border-radius: 8px;
}

#overlayCanvas {
  position: absolute;
  left: 14px;
  top: 14px;
  pointer-events: none;
}

.inline-editor {
  position: absolute;
  z-index: 10;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 214, 102, 0.9);
  background: rgba(20, 20, 20, 0.92);
  color: var(--text);
  outline: none;
  font-size: 12px;
}

.hint {
  padding: 12px 14px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-title {
  font-weight: 700;
  font-size: 13px;
}

.field .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.value {
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  min-height: 40px;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
}

.row {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.btn:disabled,
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  border-color: rgba(79, 124, 255, 0.6);
  background: linear-gradient(180deg, rgba(79, 124, 255, 0.25), rgba(47, 93, 255, 0.18));
}

.btn.danger {
  border-color: rgba(255, 79, 109, 0.55);
  background: rgba(255, 79, 109, 0.12);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
  line-height: 1.35;
}

.list {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 10px;
  min-height: 84px;
  max-height: 220px;
  overflow: auto;
}

.list.empty {
  color: var(--muted);
  display: flex;
  align-items: center;
}

.edit-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.14);
  margin-bottom: 10px;
}

.edit-item:last-child {
  margin-bottom: 0;
}

.edit-item .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--muted);
}

.kvs {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 6px 8px;
  font-size: 12px;
}

.kvs .k {
  color: var(--muted);
}

.kvs .v {
  color: var(--text);
  word-break: break-word;
}

@media (max-width: 1100px) {
  .main {
    grid-template-columns: 1fr;
  }
  .thumbs {
    display: none;
  }
}

