:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #2a2e38;
  --text: #e8eaed;
  --muted: #9aa0ab;
  --accent: #4f8cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  position: relative;
}

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #232734;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  display: inline-block;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.export-dropdown {
  position: relative;
}

.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 20;
  min-width: 240px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.export-menu button:hover {
  background: var(--accent);
  color: white;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 1px;
  background: var(--border);
}

.sidebar,
.side-panel {
  background: var(--bg);
  padding: 14px;
  overflow-y: auto;
  max-height: calc(100vh - 130px);
}

.sidebar h2,
.side-panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 10px;
}

.count {
  color: var(--muted);
  font-weight: 400;
}

.image-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid transparent;
}

.image-item:hover {
  background: var(--card);
}

.image-item.active {
  border-color: var(--accent);
  background: #1c2333;
}

.image-item img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.image-item .image-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.image-item .image-item-count {
  color: var(--muted);
  font-size: 11px;
}

.image-item .delete-image {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
}

.image-item .delete-image:hover {
  color: #ff6b6b;
}

.canvas-area {
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.image-name {
  font-size: 13px;
  color: var(--muted);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  min-height: 300px;
}

#canvas {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  cursor: crosshair;
  background: #05060a;
  border-radius: 8px;
}

#canvas.hidden {
  display: none;
}

.empty-hint {
  color: var(--muted);
  font-size: 14px;
}

.panel-block {
  margin-bottom: 22px;
}

.class-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.class-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}

.class-item:hover {
  background: var(--card);
}

.class-item.active {
  border-color: var(--accent);
  background: #1c2333;
}

.class-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.class-item .class-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.class-item .delete-class {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.class-item .delete-class:hover {
  color: #ff6b6b;
}

.class-form {
  display: flex;
  gap: 6px;
}

.class-form input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #10131a;
  color: var(--text);
  font-size: 13px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.selected-box-panel {
  font-size: 13px;
}

.selected-box-panel select {
  width: 100%;
  padding: 7px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #10131a;
  color: var(--text);
  margin-bottom: 8px;
}

.selected-box-panel .btn {
  width: 100%;
  text-align: center;
}

.annotation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.annotation-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.annotation-item:hover,
.annotation-item.selected {
  background: var(--card);
  border-color: var(--accent);
}

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
  .sidebar,
  .side-panel {
    max-height: 240px;
  }
}
