.ip-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 12px;
  height: calc(100dvh - 120px);
  min-height: 0;
}

.ip-sidebar {
  display: grid;
  grid-template-rows: 1fr 180px;
  gap: 12px;
  min-height: 0;
  min-width: 0;
  max-height: calc(100dvh - 120px);
}

.ip-pane {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.ip-pane-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 650;
  background: var(--surface-2);
}

.ip-toolbar {
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.ip-grid3 {
  grid-template-columns: 1fr auto;
}

.ip-grid3 > * {
  min-width: 0;
}

.ip-toolbar input {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-toolbar button {
  width: auto;
  min-width: 86px;
}

.ip-status {
  margin: 8px 10px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}

.ip-tree {
  margin: 0 10px 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.ip-tree .tree-node {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-tree .tree-node.selected {
  border-color: #a8b2c3;
  background: #eef2f7;
}

.ip-layer-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
}

.ip-layer-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}

.ip-layer-list input {
  width: auto;
  margin: 0;
}

.ip-meta {
  margin: 0 10px 10px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 1;
}

.ip-viewer {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  min-width: 0;
}

.ip-viewer-head {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  background: var(--surface-2);
  display: block;
}

.ip-viewer-head strong {
  display: block;
  font-size: 13px;
}

.ip-viewer-head span {
  font-size: 12px;
  color: var(--muted);
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-viewer-body {
  position: relative;
  display: grid;
  grid-template-rows: 1fr;
  padding: 10px;
  min-height: 0;
  height: 100%;
}

.ip-canvas {
  position: relative;
  background: #0b1220;
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

.ip-canvas-main {
  border: 1px solid var(--border);
}

.ip-canvas img,
.ip-canvas svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ip-canvas img {
  object-fit: contain;
  display: block;
}

.ip-canvas svg {
  pointer-events: none;
}

#svgGt polygon {
  fill: rgba(239, 68, 68, 0.20);
  stroke: #ef4444;
  stroke-width: 0.0025;
}

#svgPred polygon {
  fill: rgba(14, 165, 233, 0.20);
  stroke: #0ea5e9;
  stroke-width: 0.0025;
}

.ip-viewer-empty {
  position: absolute;
  inset: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  background: #f8fafc;
  z-index: 2;
}

@media (max-width: 1080px) {
  .ip-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .ip-sidebar {
    grid-template-rows: auto auto;
    max-height: none;
  }

  .ip-canvas-main {
    min-height: 420px;
  }

  .ip-layer-list {
    grid-template-columns: 1fr;
  }
}
