*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Notion-inspired light theme (warm neutrals + blue accent) */
:root {
  --bg: #ffffff;
  --bg-secondary: #f7f6f3;
  --bg-tertiary: #f1f1ef;

  --text: #37352f;
  --text-secondary: #787774;
  --text-tertiary: #9b9a97;

  --border: rgba(55, 53, 47, 0.09);
  --border-strong: rgba(55, 53, 47, 0.16);

  --accent: #2383e2;
  --accent-hover: #1a7bc7;
  --accent-bg: rgba(35, 131, 226, 0.14);
  --accent-bg-hover: rgba(35, 131, 226, 0.08);

  --success: #0f7b6c;
  --success-bg: rgba(15, 123, 108, 0.09);

  --danger: #eb5757;
  --danger-hover: #e03e3e;
  --danger-bg: rgba(235, 87, 87, 0.08);
  --danger-border: rgba(235, 87, 87, 0.35);

  --shadow-sm: rgba(15, 15, 15, 0.03) 0px 0px 0px 1px, rgba(15, 15, 15, 0.03) 0px 2px 4px;
  --shadow-float: rgba(15, 15, 15, 0.05) 0px 4px 12px;

  --radius: 4px;
  --radius-sm: 3px;
  --radius-pill: 999px;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Helvetica,
    'Apple Color Emoji',
    Arial,
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr 292px;
  height: 100vh;
  min-height: 0;
}

.sidebar {
  background: var(--bg-secondary);
  color: var(--text);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-title {
  margin: 0;
  padding: 14px 14px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.image-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 16px;
  overflow-y: auto;
  flex: 1;
}

.image-list::-webkit-scrollbar {
  width: 10px;
}

.image-list::-webkit-scrollbar-thumb {
  background: rgba(55, 53, 47, 0.16);
  border-radius: var(--radius-pill);
  border: 3px solid var(--bg-secondary);
}

.image-card {
  display: block;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 2px;
  text-align: left;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s ease;
}

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

.image-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.image-card.active {
  background: var(--accent-bg);
  color: var(--text);
  font-weight: 500;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.main-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.btn {
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background 0.1s ease,
    border-color 0.1s ease,
    color 0.1s ease;
}

.btn:focus-visible {
  outline: 2px solid rgba(35, 131, 226, 0.55);
  outline-offset: 1px;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--bg);
  color: var(--danger);
  border-color: var(--danger-border);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.main-scroll {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.image-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border);
}

#main-image {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
  cursor: crosshair;
  user-select: none;
  border-radius: var(--radius);
}

.labels-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  border-radius: var(--radius);
}

.label.label-pin {
  position: absolute;
  pointer-events: auto;
  cursor: grab;
  left: 0;
  top: 0;
  /* Tip of the pin (bottom point) sits on the exact (x%, y%) click position */
  transform: translate(-50%, -100%);
  z-index: 3;
}

.label.label-pin:active {
  cursor: grabbing;
}

.label-pin-svg {
  display: block;
  width: 38px;
  height: 48px;
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(55, 53, 47, 0.2));
}

.image-hint {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-secondary);
  max-width: 42rem;
  padding: 10px 12px;
  background: var(--accent-bg);
  border-radius: var(--radius);
  border: 1px solid rgba(35, 131, 226, 0.22);
}

.image-hint.image-hint-neutral {
  background: var(--bg-secondary);
  border-color: var(--border);
  color: var(--text);
}

.panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-title {
  margin: 0;
  padding: 14px 14px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.muscle-list {
  list-style: none;
  margin: 0;
  padding: 4px 10px 16px;
  overflow-y: auto;
  flex: 1;
}

.muscle-list::-webkit-scrollbar {
  width: 10px;
}

.muscle-list::-webkit-scrollbar-thumb {
  background: rgba(55, 53, 47, 0.16);
  border-radius: var(--radius-pill);
  border: 3px solid var(--bg-secondary);
}

.muscle-item {
  padding: 8px 10px;
  margin-bottom: 4px;
  margin-left: 0;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition:
    background 0.1s ease,
    border-color 0.1s ease;
}

.muscle-item.placed {
  border-color: rgba(15, 123, 108, 0.2);
  background: var(--success-bg);
}

.muscle-item.active {
  border-color: rgba(35, 131, 226, 0.35);
  background: var(--accent-bg);
  box-shadow: none;
}

.muscle-item .muscle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.muscle-num {
  font-weight: 600;
  min-width: 1.5em;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.muscle-item.active .muscle-num {
  color: var(--accent);
}

.muscle-name-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.muscle-name {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
}

.muscle-copy-btn {
  flex-shrink: 0;
  padding: 2px 7px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background 0.1s ease,
    color 0.1s ease,
    border-color 0.1s ease;
}

.muscle-copy-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}

.muscle-copy-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.muscle-status {
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-tertiary);
}

.muscle-item.placed .muscle-status {
  color: var(--success);
}

.muscle-item.active .muscle-status {
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .sidebar .image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .image-card {
    width: auto;
    flex: 1 1 140px;
  }
}
