html,
body {
  height: 100%;
  margin: 0;
  background: #eef2f6;
}

body {
  color: #1f2937;
  font-family: Arial, sans-serif;
}

button,
a,
output {
  font: inherit;
}

.structure-viewer {
  display: flex;
  min-height: 420px;
  height: 100vh;
  background: #fff;
  color: #1f2937;
  flex-direction: column;
}

.viewer-toolbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #d7dde6;
  background: #f8fafc;
}

.viewer-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #172033;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewer-button,
.viewer-meter {
  box-sizing: border-box;
  height: 38px;
  border: 1px solid #c8d1dd;
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
}

.viewer-button {
  display: inline-flex;
  width: 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.viewer-button-wide {
  width: 46px;
  font-size: 13px;
}

.viewer-button:hover {
  border-color: #7a8ba2;
  background: #edf3f8;
}

.viewer-button:focus-visible,
.viewer-viewport:focus-visible {
  outline: 3px solid #8ac5ff;
  outline-offset: 2px;
}

.viewer-meter {
  display: inline-flex;
  min-width: 58px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.viewer-viewport {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  background: #eef2f6;
  cursor: grab;
  overscroll-behavior: contain;
  touch-action: none;
}

.viewer-viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.viewer-stage {
  box-sizing: border-box;
  display: flex;
  min-width: 900px;
  min-height: 100%;
  align-items: flex-start;
  justify-content: center;
  padding: 18px;
}

.viewer-image {
  display: block;
  width: 100%;
  max-width: 1600px;
  height: auto;
  border: 1px solid #d7dde6;
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
  user-select: none;
}

.viewer-ready .viewer-stage {
  min-width: max-content;
}

.viewer-ready .viewer-image {
  max-width: none;
}

@media (max-width: 640px) {
  .viewer-toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  .viewer-controls {
    justify-content: space-between;
  }

  .viewer-button {
    flex: 0 0 38px;
  }

  .viewer-button-wide {
    flex-basis: 46px;
  }

  .viewer-meter {
    flex: 1 1 58px;
    min-width: 50px;
  }

  .viewer-stage {
    padding: 10px;
  }
}
