html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 12px;
  background: #fff;
  color: #111;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
}

/* renderer_svg.html に倣う: 左上固定の縦ツールバー */
.toolbar {
  position: fixed;
  top: 12px;
  left: 12px;
  padding: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
}

.toolbar button {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 8px;
  cursor: pointer;
}
.toolbar button:hover {
  background: #f2f2f2;
}

.app {
  width: 100%;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
}

.message {
  margin: 0 0 12px 0;
  padding: 10px 12px;
  border: 1px solid #f3d1d1;
  background: #fff5f5;
  color: #7a1f1f;
  border-radius: 10px;
}

.scroll {
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 12px;
  background: #fcfcfc;
}

.canvas-wrapper {
  width: max-content;
  margin: 0 auto;
}

.canvas-wrapper svg {
  display: block;
  background: #fff;
  max-width: 100%;
  height: auto;
  shape-rendering: crispEdges;
}

#field-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.field-item {
  position: absolute;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.2;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  overflow: hidden;
  cursor: move;
}

.field-item.is-selected {
  outline: 2px dashed rgba(25, 118, 210, 0.65);
  outline-offset: 0;
  border-color: rgba(25, 118, 210, 0.35);
}

.field-item.is-active {
  outline: 2px solid #1976d2;
  outline-offset: 0;
  border-color: rgba(25, 118, 210, 0.6);
}

.field-visual {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  box-sizing: border-box;
  color: #111;
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-visual textarea {
  white-space: normal;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
}
.modal[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.modal-panel {
  position: relative;
  width: min(560px, calc(100vw - 24px));
  margin: 60px auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e5e5;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
  padding: 14px;
}
.modal-title {
  font-weight: 700;
  margin-bottom: 10px;
}
.modal-body {
  display: grid;
  gap: 8px;
}
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.text-input {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
}
.hint {
  color: #666;
  font-size: 12px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.modal-actions button {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: #fafafa;
  border-radius: 10px;
  cursor: pointer;
}
.modal-actions button.primary {
  border-color: #1976d2;
  background: #1976d2;
  color: #fff;
}
