* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: #111;
  background: #fff;
}

.toolbar {
  border-bottom: 1px solid #ddd;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafafa;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
}

.toolbar select,
.toolbar input[type="text"],
.toolbar input[type="number"] {
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
}

.toolbar input[type="text"] {
  min-width: 240px;
}

.toolbar button {
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.toolbar button:hover {
  background: #f0f0f0;
}

main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 24px;
  align-items: start;
}

.wheel-wrap {
  display: flex;
  justify-content: center;
}

#wheel {
  width: 100%;
  max-width: 700px;
  height: auto;
  user-select: none;
}

.sector {
  fill: #fff;
  stroke: #222;
  stroke-width: 1;
  cursor: pointer;
  transition: fill 0.1s ease;
}

.sector:hover {
  fill: #f5f5f5;
}

.sector.has-association {
  fill: #f0f7ff;
}

.sector.has-association:hover {
  fill: #e3effb;
}

.symbol-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  fill: #111;
  pointer-events: none;
  user-select: none;
}

.assoc-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  text-anchor: middle;
  dominant-baseline: middle;
  fill: #555;
  pointer-events: none;
  user-select: none;
}

.ring {
  cursor: grab;
}

.ring.dragging {
  cursor: grabbing;
}

#pointer polygon {
  fill: #d33;
  stroke: #800;
  stroke-width: 1;
}

#pointer line {
  stroke: #d33;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.4;
}

.ring-label {
  font-size: 10px;
  fill: #888;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
  font-style: italic;
}

.readout {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  background: #fafafa;
  position: sticky;
  top: 24px;
}

.readout h2 {
  font-size: 14px;
  margin: 0 0 12px 0;
  color: #555;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#alignment-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#alignment-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

#alignment-list li:last-child {
  border-bottom: none;
}

.alignment-ring-name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.alignment-symbol {
  font-size: 22px;
  font-weight: 600;
  color: #111;
  display: inline-block;
  min-width: 24px;
  margin-right: 8px;
}

.alignment-text {
  font-size: 14px;
  color: #333;
}

.alignment-text.empty {
  color: #bbb;
  font-style: italic;
}

.editor-input-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-input {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 11px;
  padding: 4px 6px;
  border: 1.5px solid #2a78d8;
  border-radius: 3px;
  background: #fff;
  width: calc(100% - 4px);
  outline: none;
}

dialog {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 20px 24px;
  min-width: 360px;
  font-family: inherit;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

dialog h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
}

dialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #555;
}

dialog input,
dialog select {
  font: inherit;
  font-size: 14px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

#nc-ring-names {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid #eee;
  border-radius: 4px;
  background: #fafafa;
}

#nc-ring-names label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

#nc-ring-names input {
  flex: 1;
  font-size: 13px;
  padding: 4px 6px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.dialog-actions button {
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.dialog-actions button[type="submit"] {
  background: #111;
  color: #fff;
  border-color: #111;
}

.suggestions {
  position: absolute;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  font-size: 12px;
}

.suggestions div {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.suggestions div:hover {
  background: #f0f7ff;
}

.suggestions div:last-child {
  border-bottom: none;
}

.suggestions .category-header {
  background: #f5f5f5;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  cursor: default;
  padding: 4px 10px;
}

.suggestions .category-header:hover {
  background: #f5f5f5;
}

@media print {
  .toolbar,
  .readout,
  dialog {
    display: none !important;
  }
  main {
    display: block;
    padding: 0;
  }
  #wheel {
    max-width: 100%;
  }
  .sector {
    stroke: #000;
  }
}
