:root {
  --paper: #fafaf8;
  --ink: #111111;
  --accent: #111111;
  --ink-2: color-mix(in srgb, var(--ink) 68%, var(--paper));
  --ink-3: color-mix(in srgb, var(--ink) 48%, var(--paper));
  --rule: color-mix(in srgb, var(--ink) 22%, transparent);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --panel: 400px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 12px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

#sheet {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 1px dashed var(--ink);
  outline-offset: 2px;
}

/* legenda da figura */
.caption {
  position: fixed;
  top: 20px;
  left: 24px;
  right: calc(var(--panel) + 24px);
  display: flex;
  gap: 16px;
  color: var(--ink-2);
  font-size: 11px;
  pointer-events: none;
  text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper);
}

.caption > span:first-child {
  color: var(--ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* dica sob o cursor */
.tip {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 5px 8px;
  max-width: 260px;
  background: var(--paper);
  border: 1px solid var(--ink);
  font-size: 11px;
  pointer-events: none;
  z-index: 3;
}

.tip span { color: var(--ink-2); font-size: 10px; }

/* legenda discreta sobre a imagem (sem caixa) */
.title-block {
  position: fixed;
  right: 24px;
  bottom: 20px;
  font-size: 10px;
  color: var(--ink-3);
  z-index: 2;
  text-align: right;
  text-shadow: 0 0 3px var(--paper), 0 0 6px var(--paper), 0 0 10px var(--paper);
}

.title-block__row { padding: 0; }

.title-block__name {
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.18em;
}

.title-block__grid {
  display: grid;
  grid-template-columns: auto auto auto auto;
  justify-content: end;
  column-gap: 8px;
  margin: 6px 0 4px;
}

.title-block__grid dt,
.title-block__grid dd {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title-block__grid dt { color: var(--ink-3); opacity: 0.7; }
.title-block__grid dd { color: var(--ink-2); text-align: left; max-width: 140px; }

.title-block__controls {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
}

.title-block__controls button { color: var(--ink-3); }
.title-block__controls button:hover { color: var(--ink); }
.title-block__controls button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* caderno: contexto do nó selecionado */
.notebook {
  position: fixed;
  top: 24px;
  right: 24px;
  width: calc(var(--panel) - 48px);
  max-height: calc(100vh - 24px - 200px);
  overflow-y: auto;
  padding: 12px 14px 14px;
  background: var(--paper);
  border: 1px solid var(--ink);
  z-index: 2;
  scrollbar-width: thin;
}

.nb-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--ink-3);
  font-size: 10px;
}

.nb-close { font-size: 14px; line-height: 1; padding: 0 2px; color: var(--ink-2); }
.nb-close:hover { color: var(--ink); }

.nb-title {
  margin: 6px 0 2px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  word-break: break-word;
}

.nb-meta { margin: 0 0 12px; color: var(--ink-2); font-size: 11px; }

.nb-section {
  margin: 14px 0 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--rule);
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nb-relations { list-style: none; margin: 0; padding: 0; }

.nb-link {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 6px;
  width: 100%;
  padding: 3px 0;
  text-align: left;
  border-bottom: 1px dotted var(--rule);
}

.nb-link:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nb-dir { color: var(--ink-3); }
.nb-sentence em { font-style: normal; color: var(--ink-2); }
.nb-sentence strong { font-weight: 600; }
.nb-self { color: var(--ink-3); }
.nb-weight { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.nb-depth, .nb-empty { margin: 10px 0 0; color: var(--ink-2); font-size: 11px; }

.nb-chain { margin: 2px 0 0; line-height: 1.8; color: var(--ink-3); }

.nb-inline {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.nb-inline:hover { text-decoration-color: var(--ink); }

/* índice textual: acessível a leitores de tela e visível sem JavaScript */
.index {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.failure {
  position: fixed;
  left: 24px;
  bottom: 24px;
  max-width: 480px;
  padding: 8px 10px;
  border: 1px solid var(--ink);
  background: var(--paper);
}

@media (max-width: 979px) {
  :root { --panel: 100vw; }

  .caption { left: 16px; right: 16px; top: 16px; flex-direction: column; gap: 0; }

  .title-block { left: 16px; right: 16px; bottom: 10px; width: auto; }
  .title-block__grid, .title-block__row:not(.title-block__name) { display: none; }
  .title-block__name { font-size: 11px; }

  .notebook {
    top: auto;
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
    max-height: 58vh;
    z-index: 3;
  }
}
